29 ms·
I knew someone else who made a jit C compiler similar to this, but for 68K (also where the entire environment is in a single memory map). Functions could be co
by jhallenworld 11y ago
I knew someone else who made a jit C compiler similar to this, but for 68K (also where the entire environment is in a single memory map). Functions could be compiled when called. The advantage is that the compiler could treat arguments as constants for further optimization.
It's impressive that he made his own optimizing compiler, even if it is not C standard. From the video it has at least constant folding, dead code elimination and jump optimization. It's interesting that the intermediate code is in the form of a double-linked list for easy editing.
I would suggest to try to make a compiler which uses SSA- it's pretty simple and allows more optimizations, particularly CSE. I worked with Bob Morgan at one point, and I suggest his book on compilers as an accessible resource. He would like your jump optimization outer loop: repeat while we're still making progress.
- blt 11y agoI've often thought about this idea. It could be as simple as `#pragma jit` before a function call. If you're about to call a function that chews on a big dataset for several seconds, it's probably worth the effort. In particular I'm thinking of hot loops with an `if` statement or function pointer / virtual call.