From 84df04cb612a266ad4e6c72e242f66b7275a0270 Mon Sep 17 00:00:00 2001 From: Luke Gruber Date: Thu, 22 Oct 2026 17:36:26 -0400 Subject: [PATCH 1/2] Sync gc impl API with ruby PR 19470 rb_gc_impl_heap_page_count -> rb_gc_impl_zombie_heap_page_count This API function may go away soon (it's unused except for default GC) but for now it has changed names. --- gc/gc_impl.h | 2 +- gc/mmtk/mmtk.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gc/gc_impl.h b/gc/gc_impl.h index 80da58d..81fb63a 100644 --- a/gc/gc_impl.h +++ b/gc/gc_impl.h @@ -152,7 +152,7 @@ GC_IMPL_FN bool rb_gc_impl_during_postmortem_p(void *objspace_ptr); * objspace impl. */ GC_IMPL_FN bool rb_gc_impl_obj_foreign_p(void *objspace_ptr, VALUE obj); GC_IMPL_FN bool rb_gc_impl_shref_marked_p(void *objspace_ptr, VALUE obj); -GC_IMPL_FN size_t rb_gc_impl_heap_page_count(void *objspace_ptr); +GC_IMPL_FN size_t rb_gc_impl_zombie_heap_page_count(void *objspace_ptr); GC_IMPL_FN void rb_gc_impl_objspace_absorb(void *dst_ptr, void *src_ptr); GC_IMPL_FN void rb_gc_impl_each_object(void *objspace_ptr, void (*func)(VALUE obj, void *data), void *data); // Finalizers diff --git a/gc/mmtk/mmtk.c b/gc/mmtk/mmtk.c index cf80d98..e65172f 100644 --- a/gc/mmtk/mmtk.c +++ b/gc/mmtk/mmtk.c @@ -1859,7 +1859,7 @@ rb_gc_impl_shref_marked_p(void *objspace_ptr, VALUE obj) } size_t -rb_gc_impl_heap_page_count(void *objspace_ptr) +rb_gc_impl_zombie_heap_page_count(void *objspace_ptr) { /* With a single objspace zombie_objspaces is always empty. */ return 0; From 623a607447d6c45981fdd161fa1086e188ae6724 Mon Sep 17 00:00:00 2001 From: Luke Gruber Date: Thu, 22 Oct 2026 17:48:44 -0400 Subject: [PATCH 2/2] Run bundle exec rake vendor_ruby_headers --- gc/gc_impl.h | 15 ++++++++------- gc/mmtk/mmtk.c | 6 +++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/gc/gc_impl.h b/gc/gc_impl.h index 81fb63a..1bcb744 100644 --- a/gc/gc_impl.h +++ b/gc/gc_impl.h @@ -89,14 +89,15 @@ GC_IMPL_FN VALUE rb_gc_impl_new_obj(void *objspace_ptr, void *cache_ptr, VALUE k * generated instruction sequence; see zjit/src/gc_fastpath.rs. */ GC_IMPL_FN bool rb_gc_impl_zjit_new_obj_fastpath(void *objspace_ptr, size_t alloc_size, VALUE flags, VALUE klass, struct rb_gc_zjit_fastpath *fastpath); -/* Returns a pointer to a word that is nonzero while incremental marking is in - * progress, or NULL if the implementation does not support ZJIT's inline write - * barrier fast path. ZJIT-generated code skips the call to rb_gc_writebarrier() - * when the receiver has neither RUBY_FL_PROMOTED nor RUBY_FL_SHAREABLE set and - * this word is zero, so only implementations whose write barrier is a no-op - * under exactly those conditions may return non-NULL. +/* Returns the offset of a word inside the objspace that is nonzero while that + * objspace is incremental-marking, or -1 if the implementation does not support + * ZJIT's inline write barrier fast path. ZJIT-generated code skips the call to + * rb_gc_writebarrier() when the receiver has neither RUBY_FL_PROMOTED nor + * RUBY_FL_SHAREABLE set and the word of the current Ractor's objspace is zero, + * so only implementations whose write barrier is a no-op under exactly those + * conditions may return a nonnegative offset. */ -GC_IMPL_FN const uintptr_t *rb_gc_impl_zjit_writebarrier_required_p_ptr(void *objspace_ptr); +GC_IMPL_FN int32_t rb_gc_impl_zjit_writebarrier_required_offset(void); GC_IMPL_FN size_t rb_gc_impl_obj_slot_size(VALUE obj); GC_IMPL_FN size_t rb_gc_impl_size_slot_size(void *objspace_ptr, size_t size); GC_IMPL_FN bool rb_gc_impl_size_allocatable_p(size_t size); diff --git a/gc/mmtk/mmtk.c b/gc/mmtk/mmtk.c index e65172f..c379354 100644 --- a/gc/mmtk/mmtk.c +++ b/gc/mmtk/mmtk.c @@ -742,12 +742,12 @@ rb_gc_impl_zjit_new_obj_fastpath(void *objspace_ptr, size_t alloc_size, VALUE fl #endif } -const uintptr_t * -rb_gc_impl_zjit_writebarrier_required_p_ptr(void *objspace_ptr) +int32_t +rb_gc_impl_zjit_writebarrier_required_offset(void) { /* MMTk's write barrier is not a no-op for young, unshareable receivers, * so ZJIT must always call rb_gc_writebarrier(). */ - return NULL; + return -1; } void