There is a prior, very similar approach in GNU Jitter, but it uses only the compiler and some magic rather than the linker for marking spots to replace. I read about it by mention of moonchild in a thread[0] linked by foota here.
There is a prior, very similar approach in GNU Jitter, but it uses only the compiler and some magic rather than the linker for marking spots to replace. I read about it by mention of moonchild in a thread[0] linked by foota here.
I say possible in the sense that hardware supports it. The standard C language doesn't support this, but GCC's GNU C does support it as one of its extensions.
The GNU Jitter author wrote about this, see page 48, referred to as page '17', of this PDF: https://ageinghacker.net/talks/jitter-slides--saiu--ghm2017-...
See also Gforth writing about the same technique: https://gforth.org/manual/Threading.html
The term context threading refers to generation of native code that behaves much like conventional threaded-code interpretation, except specialised to the particular input code. [0][1]
See also dynamic superinstructions, a term used by gforth to refer to its runtime generation of native code for input Forth code. [2]
Disclaimer: I'm no Forth expert. I should give [1] a proper read, it looks interesting.
[0] https://webkit.org/blog/214/introducing-squirrelfish-extreme...
[1] (PDF) https://csng.cs.toronto.edu/publication_files/0000/0162/demk...
[2] https://www.complang.tuwien.ac.at/forth/gforth/Docs-html-his...
The creator of Jitter has read a lot about Gforth, as evidenced in [0][1].
You're not the only one to suspect there's some reinvention going on here somewhere though. [2] I'm not familiar enough with these topics (copy-and-patch and Jitter) to weigh in.
[0] (PDF) https://ageinghacker.net/talks/jitter-slides--saiu--ghm2017-...
[1] (PDF) https://ageinghacker.net/talks/jitter-slides--saiu--bts-2022...