Skip to content

Commit 7039aa6

Browse files
committed
Add no-op rb_gc_impl_zjit_writebarrier_required_p_ptr
See ruby/ruby#18641
1 parent d38bba4 commit 7039aa6

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎gc/gc_impl.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ GC_IMPL_FN VALUE rb_gc_impl_new_obj(void *objspace_ptr, void *cache_ptr, VALUE k
8989
* generated instruction sequence; see zjit/src/gc_fastpath.rs.
9090
*/
9191
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);
92+
/* Returns a pointer to a word that is nonzero while incremental marking is in
93+
* progress, or NULL if the implementation does not support ZJIT's inline write
94+
* barrier fast path. ZJIT-generated code skips the call to rb_gc_writebarrier()
95+
* when the receiver has neither RUBY_FL_PROMOTED nor RUBY_FL_SHAREABLE set and
96+
* this word is zero, so only implementations whose write barrier is a no-op
97+
* under exactly those conditions may return non-NULL.
98+
*/
99+
GC_IMPL_FN const uintptr_t *rb_gc_impl_zjit_writebarrier_required_p_ptr(void *objspace_ptr);
92100
GC_IMPL_FN size_t rb_gc_impl_obj_slot_size(VALUE obj);
93101
GC_IMPL_FN size_t rb_gc_impl_size_slot_size(void *objspace_ptr, size_t size);
94102
GC_IMPL_FN bool rb_gc_impl_size_allocatable_p(size_t size);

‎gc/mmtk/mmtk.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,14 @@ rb_gc_impl_zjit_new_obj_fastpath(void *objspace_ptr, size_t alloc_size, VALUE fl
749749
#endif
750750
}
751751

752+
const uintptr_t *
753+
rb_gc_impl_zjit_writebarrier_required_p_ptr(void *objspace_ptr)
754+
{
755+
/* MMTk's write barrier is not a no-op for young, unshareable receivers,
756+
* so ZJIT must always call rb_gc_writebarrier(). */
757+
return NULL;
758+
}
759+
752760
void
753761
rb_gc_impl_init(void)
754762
{

0 commit comments

Comments
 (0)