bfjit icon indicating copy to clipboard operation
bfjit copied to clipboard

Auto resize/expand JIT memory buffer

Open Jaycadox opened this issue 2 years ago • 0 comments

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.

Jaycadox avatar Jan 19 '24 03:01 Jaycadox