bfjit
bfjit copied to clipboard
Auto resize/expand JIT memory buffer
The generated JIT code now keeps track of a JitMemoryInfo object, which is just a dynamically sized array, and a function pointer which potentially resizes/reallocates the memory under the hood once called.
After every OP_RIGHT opcode, the resize function is called via call qword [rsi] (as the resize function pointer is at *(rsi+0x0)), with RDI being the head ptr, and RSI being the JitMemoryInfo*, the function returns the new (or unchanged) head ptr, which is then used.
This could potentially be improved by housing the entire resize logic in emitted assembly, but I felt existing Nob functions could be easily used without changing the structure of the codebase that much.