mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Allow pass special constants to the write barrier
Some GC implementations want to always know when an object is written to, even if the written value is a special constant. Checking special constants in rb_obj_written was a micro-optimization that made assumptions about the GC implementation.
This commit is contained in:
parent
5f247416b6
commit
ea8b53a539
Notes:
git
2025-06-03 16:04:39 +00:00
4 changed files with 6 additions and 5 deletions
|
@ -6006,9 +6006,10 @@ rb_gc_impl_writebarrier(void *objspace_ptr, VALUE a, VALUE b)
|
|||
|
||||
if (RGENGC_CHECK_MODE) {
|
||||
if (SPECIAL_CONST_P(a)) rb_bug("rb_gc_writebarrier: a is special const: %"PRIxVALUE, a);
|
||||
if (SPECIAL_CONST_P(b)) rb_bug("rb_gc_writebarrier: b is special const: %"PRIxVALUE, b);
|
||||
}
|
||||
|
||||
if (SPECIAL_CONST_P(b)) return;
|
||||
|
||||
GC_ASSERT(RB_BUILTIN_TYPE(a) != T_NONE);
|
||||
GC_ASSERT(RB_BUILTIN_TYPE(a) != T_MOVED);
|
||||
GC_ASSERT(RB_BUILTIN_TYPE(a) != T_ZOMBIE);
|
||||
|
|
|
@ -750,6 +750,8 @@ rb_gc_impl_writebarrier(void *objspace_ptr, VALUE a, VALUE b)
|
|||
{
|
||||
struct MMTk_ractor_cache *cache = rb_gc_get_ractor_newobj_cache();
|
||||
|
||||
if (SPECIAL_CONST_P(b)) return;
|
||||
|
||||
mmtk_object_reference_write_post(cache->mutator, (MMTk_ObjectReference)a);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue