This is what I would call ‘token threaded code’. The code consists of tokens equal to 0,1,2,3,...

If you left out the dispatch table you would have ‘indirect threaded code’, such as is traditional in Forth. The code consists of a sequence of machine addresses, which can change from compilation to compilation. This is how I am likely to do a backend for hiha that has proper tail calls. We shall see.

The interpreter must ‘circulate’ within one function.

#programming #threadedCode #gcc

Google Pattern Matcher has told me GCC computed gotos are good for direct threading. However, if you go to the GCC manual, it tells you computed gotos are good for INDIRECT threading.

So I have thought this over, and cannot see how computed gotos help with direct threading. And, in any case, I do not see how computed gotos help except in a whole program compiler.

#FORTH #ThreadedCode #GCC

Implementing Fast Interpreters

Many modern virtual machines include either a fast interpreter or a fast baseline compiler. A baseline compiler needs extra memory and is li...