I'm working on a JIT and I'd like to be able to flush icache. I've tried writing a 0 to ICIALLU (at address 0xE000EF50) and I've also tried the STM32CubeF7 library's InvalidateICache(). However, all methods I've tried result in the device crashing. I'm not sure what to do at this point except to execute 4kb of nops.
Right, we don't provide direct access to system registers. I'll file a feature request for a cache-flushing function on the C API. My first though was nah, that's too niche, but now I really want to see what you can do with JIT code. ![]()
I'll try and get that into the 2.0.0 release!
Thank you so much! I hope not to disappoint ![]()
I believe that is right.
Please note, that because the Playdate operates exclusively in THUMB mode, pointers to instructions (i.e. function pointers) always have the lowest bit set. In other words, they point to one byte after the instructions begin; and if you jump to/call arbitrary code, you need the address (ptr|1) instead.
Took a while, but the icache flush feature came in useful. The code isn't JIT anymore (since that turns out to be pretty inefficient), but self-modifying code is still involved. 60 FPS gameboy emulation.