ZJIT: Get ZJIT allocation fastpath to run in debug/dev builds - #18033
Conversation
210d5f2 to
b4fa098
Compare
|
Getting this to work required fixing a couple of bugs with the way the ZJIT alloc fastpath worked. There was an issue with |
b4fa098 to
0e3992f
Compare
0e3992f to
5d6c58e
Compare
7e0792f to
34b6ec6
Compare
|
@k0kubun I've addressed your comments. Waiting for final review/approval 👍 |
| size_t | ||
| rb_zjit_offset_ractor_pub_id(void) | ||
| { | ||
| return offsetof(rb_ractor_t, pub) + offsetof(struct rb_ractor_pub, id); |
There was a problem hiding this comment.
Can we add these offsets (and maybe for rb_zjit_offset_ractor_newobj_cache as well) as part enum zjit_struct_offsets instead? We shouldn't need to make C function calls for them.
There was a problem hiding this comment.
I'm going to wait until ractor-local GC lands to make these changes because it removes the newobj cache.
66b6517 to
07bc3e3
Compare
| } | ||
|
|
||
| size_t | ||
| rb_zjit_offset_ractor_pub_id(void) |
There was a problem hiding this comment.
Can you use #18256 for offsetof(rb_ractor_t, pub) and offsetof(struct rb_ractor_pub, id) instead?
There was a problem hiding this comment.
RLGC got rid of this. We now track if an object belongs to the current ractor by GET_HEAP_PAGE(obj)->objspace == rb_ec_ractor_ptr(ec)->objspace. This is still only done in debug builds. It used to be that there was only 1 object space so we had to add space at the end of the object for its ractor_id.
This also enables the alloc fastpath where it previously wasn't enabled when `-DRUBY_DEBUG` is set in cflags during compilation. This will allow us to test the ZJIT alloc fastpath in CI and when running ZJIT tests locally in dev (--enable-zjit=dev) or debug mode (cflags="-DRUBY_DEBUG=1").
The allocation fastpath just advances the cursor and we don't want to emit code that checks for this rare case. Emit a patchpoint instead and invalidate the allocation fastpath code when NEWOBJ hooks are enabled for the first time.
1) Remove copied code in gc_fastpath.rs 2) RbGcZjitDefaultNewObjFastpath and RbGcZjitMmtkNewObjFastpath structs were copied from the cruby_bindings file. 3) Get MMTK to use the newobj hook patchpoint for ZJIT's alloc fastpath. Previously only the default GC used this patchpoint. MMTK had to check if newobj hooks were enabled in its fastpath, which it no longer does. 4) ractor_belonging_id has been removed
07bc3e3 to
18ac3f2
Compare
This allows us to run the allocation fastpath code in CI and during
make zjit-testwhen configured with--enable-zjit=dev.