https://concatenative.org/wiki/view/Factor/Non-optimizing%20compiler

Apparently the JIT for the interactive non-optimizing compiler generates
subroutine threaded code with some inlining.

I wouldn't call it a compiler optimization; maybe an interpreter
optimization or a simple compiling technique. I think you hear about it a
lot with respect to Forth and its family because of the proportion of Forth
users who implemented the language or at least learned how it was
implemented, although often modern Forth implementations have optimizing
compilers. But the earliest academic reference I've seen for threaded code
was in reference to a Fortran compiler for the PDP-11:
http://home.claranet.nl/users/mhx/Forth_Bell.pdf

I'm pretty sure that 1971 article was more of a description of a technique
already widely in practice (i.e. a description of "folklore") rather than a
new invention, so it's definitely been around a whlie.

I wrote a simple threaded code interpreter in C as an exercise to
understand them better a while back; including some conditionally-compiled
debug code and a fairly small complement of core Forth words and an outer
interpreter loop, it's still well under 1k lines of source.

    --Levi

On Tue, Jan 31, 2017 at 3:23 PM, Björn Lindqvist <bjou...@gmail.com> wrote:

> Probably not! I've never heard of that technique. From skimming that
> Wikipedia article it seem to be a compiler optimization invented a
> long time ago. We have an instruction called ##dispatch, used for
> method dispatching, but it is not nearly as dynamic as the method
> described. Probably for the best because on modern processors jumping
> to addresses kept in memory or in registers is very bad for
> performance.
>
>
> 2017-01-31 21:11 GMT+01:00 Alexander Ilin <ajs...@yandex.ru>:
> > Hello!
> >
> >   Does Factor use threaded code in any way?
> >   https://en.wikipedia.org/wiki/Threaded_code
> >
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to