Re: Threaded Interpreter (Anton Ertl)
21 Nov 2005 22:41:06 -0500

          From comp.compilers

Related articles
Threaded Interpreter (Avatar) (2005-11-19)
Re: Threaded Interpreter (2005-11-21)
Re: Threaded Interpreter (Etienne Gagnon) (2005-11-21)
Re: Threaded Interpreter (Jeff Kenton) (2005-11-21)
Re: Threaded Interpreter (chandramouli gowrikumar) (2005-11-21)
Re: Threaded Interpreter (Ian Rogers) (2005-11-21)
Re: Threaded Interpreter (2005-11-27)
| List of all articles for this month |

From: (Anton Ertl)
Newsgroups: comp.compilers
Date: 21 Nov 2005 22:41:06 -0500
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
References: 05-11-091
Keywords: interpreter
Posted-Date: 21 Nov 2005 22:41:06 EST

"Avatar" <> writes:
>I am searching for reference implementations of a threaded interpreter
>(as opposed to the traditional switch dispatch method).

For a trivial implementation, look at my interpreter dispatch

For something a little more substantial, you could look at the
examples provided with Vmgen
<>. Since Vmgen is
distributed with Gforth, you also get a full-size threaded-code
interpreter with additional optimizations.

Finally, you can look at full-size interpreters like Gforth, SableVM,
the Ocaml "bytecode" interpreter, YAP or Sicstus Prolog.

>There was a long thread in comp.compilers some years back about how you
>could write fairly machine independent threaded C code using some gross
>hacks. -John]

No gross hacks needed, just the labels-as-values feature supported by
gcc and a number of other C compilers.

Fortran also supports this feature (under the name "assigned goto"),
so writing a threaded-code interpreter in Fortran should be possible.

- anton
M. Anton Ertl

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.