How to JIT – An Introduction
eli.thegreenplace.net
eli.thegreenplace.net
If you don't handle this correctly, then you'll have a Very Fun time [2].
What's especially Fun is that if you halt your program in a debugger and read back the contents of the JIT buffer, it will look perfectly correct – because those reads are coming through RAM / DCache, not ICache!
[1] https://developer.apple.com/library/archive/documentation/Sy... [2] https://twitter.com/impraxical/status/1579586601117548544
E: see the intel SDM, vol 3, sec 8.1.3.
I question this. We used this term regularly in the Smalltalk community at or before 1992.
But whatever. As Jan Steinman so aptly put it so many years ago:
"Java: All the speed of Smalltalk written in all the elegance of C"
In Self 1 and 2 we also used dynamic compilation and we got adaptive compilation in Self 3. This moved from Sun to Animorphic for the Strongtalk project and got bought by Sun to become the Java HotSpot technology.
JIT was very popular among Japanese car manufacturers and the term was borrowed for Java. Note that Java only had simple interpreters in its first few years so we are talking the late 1990s here.
By this definition, the Emacs native compiler would be a jit, even though it is considered an AoT compiler.
I think there needs to be another caveat, where a jit uses some run time information to generate the machine code.
It makes me wonder if there are any JIT compilers that generate code based on runtime data, but not at runtime? Similar to profile guided optimizations in static languages. Basically collect your traces and runtime info, then generate the code offline. This would let you take more time to optimize, and you could save the new code to disk and reuse it.
In practice, the JIT/AOT distinction boils down to whether compilation time counts as part of execution time, or not. If cycles you spend optimizing your code are cycles you don't spend running it, you make different design decisions.
(Note also that the Emacs native compiler is built using libgccjit.)
https://keleshev.com/abstract-syntax-tree-an-example-in-c/
I am working on codegen for my imaginary assembler and I'm trying to work out how to set compound expressions such as
struct[key][key2]["balance"] += 100
In assembly.* do not read the Dragon Book, there’s better ones out there
Those were the days before wasm and I didn’t really have any concrete plans (some cockamamie blender related idea I’m sure) so never did anything with it. Probably be fairly trivial to make a wasm front end for it though.
Worth noting that the 2-phase split isn’t really there in JITs that have been optimized to the limit because they tend to do some amount of self-modifying code and to make that great, they interleave the compiler IR with runtime data structures. Not saying it has to be that way, only that it often is, for good reasons.