3 ms·
>Additionally, mike pall wrote a large chunk of luajit in assembly language and hand-optimized lots of things, which gives the code that dense demoscene feeling
by oddity 8y ago
>Additionally, mike pall wrote a large chunk of luajit in assembly language and hand-optimized lots of things, which gives the code that dense demoscene feeling that was mentioned before.
The use of assembly is actually very tame in luajit. I was actually referring more to things like the fact that it spits out native code by iterating backwards so it can do register allocation in reverse (simultaneously and with minimal memory footprint!). Because of a lot of neat details of how the SSA IR is laid out and stored and how tracing JITs work, this results in more optimal register allocation in a way that is actually very straightforward to implement.
It's very, very clever and overall very clean with minimal code, but understanding why things are done in a particular way requires a lot of experience. The demoscene is similar: very neat 'hacks' that combine low-level programming knowledge with very deep domain knowledge motivated by the need to write code that is both fast and small.