feat: add new_with_capacity to Assembler#115
Conversation
|
Hi! Thank you for the contribution. I understand the need for such an API. However, I have some comments. First, this API would now take a certain amount of instructions as an argument. I would recommend just taking the size as bytes. You've now assumed an instruction size of 7 bytes, which could be correct for x64/x86, but would be wildly incorrect for the riscv/aarch64 backends. This is a detail is probably best exposed to the programmer to begin with, rather than assuming a certain average instruction size. Second, I would strongly recommend however that MemoryManager is always initialized with a multiple of the memory page size. Memory permissions can only be changed on a page size basis for most platforms, so reserving anything less than a full page doesn't actually save anything. |
|
Pushed a commit that should fix your concerns :) |
|
Thanks! I'll cut a release with this in a week or so. |
I think most use cases do have a lower bound on the number of emitted instructions, and using
VecAssemblerrequires extra steps to make the code executable.