From Newsgroup: comp.lang.forth
Paul Rubin <
no.email@nospam.invalid> writes:
anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
Now if you have a sequence of primitives to generate in your
heap-allocated threaded code, such as "+ C@",
I'm not versed enough in Gforth's implementation to completely
understand this post, but is there currently a way to generate threaded
code in the heap?
The stuff that is allocated HERE is (a variant of) direct threaded
code; with dynamic native-code generation, these cells point to
dynamically generated native code, without they point into the code
segment of the binary.
I had thought threaded code in Gforth was mostly for debugging and to
make certain legacy hacks work, but that it is mostly ok to use the
native code compiler.
There is gforth-itc (indirect threaded code), and the stepping
debugger works only with that, and maybe there is some legacy software
that works with it and not with the other engines. There is no
dynamic native code generation here, because that does not work with indirect-threaded code (well, I can think of a way, but we have not
implemented it).
The gforth and gforth-native engine are basically direct-threaded and,
in the usual case, the threaded code points to dynamically generated
native code. Read all about it in:
@InProceedings{ertl&paysan25ef,
author = {M. Anton Ertl and Bernd Paysan},
title = {Code-Copying Compilation in Production---An Experience Report},
crossref = {euroforth25},
pages = {29--45},
url = {
http://www.euroforth.org/ef25/papers/ertl.pdf},
url-slides = {
http://www.euroforth.org/ef25/papers/ertl-slides.pdf},
OPTvideo = {},
note = {Paper also presented and published at KPS'25},
abstract = {A code-copying compiler implements a programming
language by concatenating code snippets produced by
a different compiler. This technique has been used
in Gforth since 2003, with code snippets generated
by GCC. We have solved various challenges: in
particular, which code snippets can be copied and
what to do about the others; and challenges posed by
changes in compilers. The performance of Gforth is
similar to that of SwiftForth, a commercial system
with a conventional compiler; the implementation
effort is comparable to 1--2 targets for SwiftForth.}
}
@Proceedings{euroforth25,
editor = {M. Anton Ertl},
title = {41st EuroForth Conference},
booktitle = {41st EuroForth Conference},
year = {2025},
key = {EuroForth'25},
url-proceedings = {
http://www.euroforth.org/ef25/papers/proceedings.pdf}
}
- anton
--
M. Anton Ertl
http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs:
http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard:
https://forth-standard.org/
EuroForth 2026 CFP:
http://www.euroforth.org/ef26/cfp.html
--- Synchronet 3.22a-Linux NewsLink 1.2