home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sun-barr!rutgers!cbmvax!jesup
- From: jesup@cbmvax.commodore.com (Randell Jesup)
- Newsgroups: comp.arch
- Subject: Re: Threaded Code
- Message-ID: <34301@cbmvax.commodore.com>
- Date: 16 Aug 92 21:20:42 GMT
- References: <55535@mentor.cc.purdue.edu> <13910@goanna.cs.rmit.oz.au> <GLEW.92Aug7185506@pdx007.intel.com> <1992Aug10.141731.10007@email.tuwien.ac.at> <martin.713808550@bert>
- Reply-To: jesup@cbmvax.commodore.com (Randell Jesup)
- Organization: Commodore, West Chester, PA
- Lines: 37
-
- martin@math.rwth-aachen.de ( Martin Schoenert) writes:
- >Subroutine threading (sub.c):
- > For each instruction there is a (C) function which implements this
- > instruction. The instructions are encoded with the addresses of
- > those functions. Each function returns after it has done its work,
- > and there is a central dispatcher in 'main', which looks as follows
- > 'while (1) (**pc++)();'
-
- This is not what I would call "subroutine threading". Subroutine
- threading (at least from my perspective of having written a subroutine-
- threaded forth) means that you do not have an array of function addresses,
- you have an array of "jsr <address>". On top of that, the code that
- generates the instructions can inline when appropriate (a big win in forth
- on modern processors, since many simple operations are smaller than an
- instruction or even an address).
-
- I'm not sure what I'd call your method. It's big problem is that
- it requires an explicit "interpret" instruction to call an instruction
- written from instructions instead of as a pre-existing C routine. If I had
- to name it I would call it an "explicit-threaded interpreter", since the
- thing that compiles the code must know to generate "interpret" instructions
- to execute words that need interpretation, while all standard methods of
- threading do not need to know.
-
- The various forms of threading have been heavily explored in Forth
- literature and implementations over the years. If you're really interested
- in efficient interpretation, I advise reading some of the Forth literature
- (FORML proceedings, Rochester forth proceedings, even old Byte and Dr. Dobbs
- issues, etc).
-
- --
- "Rev on the redline, you're on your own; seems like a lifetime, but soon it's
- gone..." Foreigner
- -
- Randell Jesup, Jack-of-quite-a-few-trades, Commodore Engineering.
- {uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.cbm.commodore.com BIX: rjesup
- Disclaimer: Nothing I say is anything other than my personal opinion.
-