Skip to content

Commit 49cecd3

Browse files
committed
ZJIT: Guard other calls to rb_gc_writebarrier() with a !special_const_p() check
1 parent 68174c3 commit 49cecd3

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

zjit/src/gc.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ pub fn append_gc_offsets(iseq: IseqPtr, mut version: IseqVersionRef, offsets: &V
183183
let value_ptr = value_ptr as *const VALUE;
184184
unsafe {
185185
let object = value_ptr.read_unaligned();
186-
rb_gc_writebarrier(iseq.into(), object);
186+
if !object.special_const_p() {
187+
rb_gc_writebarrier(iseq.into(), object);
188+
}
187189
}
188190
}
189191
}

zjit/src/profile.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ fn profile_operands(profiler: &mut Profiler, profile: &mut IseqProfile, n: usize
124124
// TODO(max): Handle GC-hidden classes like Array, Hash, etc and make them look normal or
125125
// drop them or something
126126
let ty = ProfiledType::new(obj);
127-
unsafe { rb_gc_writebarrier(profiler.iseq.into(), ty.class()) };
127+
if !ty.class().special_const_p() {
128+
unsafe { rb_gc_writebarrier(profiler.iseq.into(), ty.class()) };
129+
}
128130
profile_type.observe(ty);
129131
}
130132
}
@@ -138,7 +140,9 @@ fn profile_self(profiler: &mut Profiler, profile: &mut IseqProfile) {
138140
// TODO(max): Handle GC-hidden classes like Array, Hash, etc and make them look normal or
139141
// drop them or something
140142
let ty = ProfiledType::new(obj);
141-
unsafe { rb_gc_writebarrier(profiler.iseq.into(), ty.class()) };
143+
if !ty.class().special_const_p() {
144+
unsafe { rb_gc_writebarrier(profiler.iseq.into(), ty.class()) };
145+
}
142146
types[0].observe(ty);
143147
}
144148

@@ -149,7 +153,9 @@ fn profile_block_handler(profiler: &mut Profiler, profile: &mut IseqProfile) {
149153
}
150154
let obj = profiler.peek_at_block_handler();
151155
let ty = ProfiledType::object(obj);
152-
unsafe { rb_gc_writebarrier(profiler.iseq.into(), ty.class()) };
156+
if !ty.class().special_const_p() {
157+
unsafe { rb_gc_writebarrier(profiler.iseq.into(), ty.class()) };
158+
}
153159
types[0].observe(ty);
154160
}
155161

0 commit comments

Comments
 (0)