3 ms·
> Are there real uses for this kind of thing, on modern architectures? For me, I came up with an algorithm for doing error correction coding, however, good per
by Nyan 6y ago
> Are there real uses for this kind of thing, on modern architectures?
For me, I came up with an algorithm for doing error correction coding, however, good performance can only be achieved by JIT'ing code. Trying to implement the algorithm without JIT results in many if/switch statements and memory lookups, which makes it much slower.
Unfortunately, the JIT'd code can only be used once because a new function needs to be written every time the routine is called, which leads to a scenario like that in the article.
Otherwise, I do think this is somewhat niche, but there may be some interesting applications if the security of write+execute memory is not a concern.
- vardump 6y agoYeah, I was actually thinking about this particular case for code specialization. In code where the inner loop is very branchy, you can have considerable gains for being able to remove unnecessary branches (and code). This kind of technique was (is?) a fairly common in demoscene. Often just modifying constants in existing code but also specializing (AFAIK usually block concatenation) isn't unheard of. (By the way, at least on x86, it might pay off to watch out for things like inner loop(s) branch target 16-byte alignment to avoid penalties.)
- saagarjha 6y agoDemos are generally more focused on size savings than performance ;)
- vardump 6y agoOnly for size compos. Like 4 kB demos. Or 256 byte, the "new 4k". For retro systems (like C64, speccy, Amiga OCS) speed is generally the king. Of course there are still sizecoding compos for them as well. My oooold Amiga demo effects were full of code generation and SMC.
- Nyan 6y agoDidn't know the practicality of this in the demoscene - thanks for the info!