cranelift-jit: add bump memory allocator, make configurable#10512
Conversation
This adds a new JIT memory allocator which operates on an address range that is reserved up-front. This is useful in order to side-step issues where allocation behavior affect relocations, i.e. on x86 where we run into issues when the system allocator returns memory that is more than 4 GiB apart. The main drawback of this allocator option is that the memory range has to be reserved up-front, so allocation will fail if this space is exhausted. This commit: - adds a 'JITMemoryProvider' trait - moves the previous on-demand allocator to this trait - adds a new 'Arena' allocator
f508348 to
0621d5b
Compare
abrown
left a comment
There was a problem hiding this comment.
I think this overall makes sense to me; I didn't look too, too closely at all the arithmetic so it would be useful to have some tests around this (if there aren't any already). Plus, @bjorn3 are you a +1 on this? I believe you may be the one most interested in this. (I checked and apparently there are some other dependents of this so it isn't just @bjorn3).
I've added some simple tests and have cleaned up the PR a bit. |
|
Whoops, sorry. Didn't realize that only a subset of the CI jobs runs on posted PRs ^^ |
* cranelift-jit: add bump memory allocator, make configurable This adds a new JIT memory allocator which operates on an address range that is reserved up-front. This is useful in order to side-step issues where allocation behavior affect relocations, i.e. on x86 where we run into issues when the system allocator returns memory that is more than 4 GiB apart. The main drawback of this allocator option is that the memory range has to be reserved up-front, so allocation will fail if this space is exhausted. This commit: - adds a 'JITMemoryProvider' trait - moves the previous on-demand allocator to this trait - adds a new 'Arena' allocator * ArenaMemoryProvider: add tests, simplify alignment logic * ArenaMemoryProvider: add asserts * Move pipeline flush back out of `set_readable_and_executable` * Fix aarch64 build
Send was implemented for JITModule in bytecodealliance#8718, but this was (likely intentionally) broken in bytecodealliance#10512. This commit implements Send again and adds a test to guard against any future regressions.
Send was implemented for JITModule in bytecodealliance#8718, but this was (likely intentionally) broken in bytecodealliance#10512. This commit implements Send again and adds a test to guard against any future regressions.
Hey,
this is a stab at #4000 (and #4986) to resolve an issue with x86 relocation range that comes up in multi-threaded JITs.
I've added an option to swap out the memory allocator in
cranelift-jitand have added an arena-based option that works with a pre-allocatedPROT_NONEregion.I've marked this as draft because I could also see updating the PR to either
Let me know if this seems reasonable. Thanks! 🙂