Skip to content

Commit ce73b6c

Browse files
committed
ZJIT: Pass the result of GuardNotFrozen to StoreField and WriteBarrier
1 parent 7963343 commit ce73b6c

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

zjit/src/hir.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2503,6 +2503,10 @@ impl Function {
25032503
// true of the converse.
25042504
//
25052505
// No need for a GuardShape.
2506+
if let OptimizedMethodType::StructAset = opt_type {
2507+
recv = self.push_insn(block, Insn::GuardNotFrozen { recv, state });
2508+
}
2509+
25062510
let (target, offset) = if is_embedded {
25072511
let offset = RUBY_OFFSET_RSTRUCT_AS_ARY + (SIZEOF_VALUE_I32 * index);
25082512
(recv, offset)
@@ -2513,7 +2517,6 @@ impl Function {
25132517
};
25142518

25152519
let replacement = if let (OptimizedMethodType::StructAset, &[val]) = (opt_type, args.as_slice()) {
2516-
self.push_insn(block, Insn::GuardNotFrozen { recv, state });
25172520
self.push_insn(block, Insn::StoreField { recv: target, id: mid, offset, val });
25182521
self.push_insn(block, Insn::WriteBarrier { recv, val });
25192522
val

zjit/src/hir/opt_tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5360,8 +5360,8 @@ mod hir_opt_tests {
53605360
PatchPoint NoSingletonClass(C@0x1000)
53615361
v29:HeapObject[class_exact:C] = GuardType v11, HeapObject[class_exact:C]
53625362
v30:HeapObject[class_exact:C] = GuardNotFrozen v29
5363-
StoreField v29, :foo=@0x1038, v12
5364-
WriteBarrier v29, v12
5363+
StoreField v30, :foo=@0x1038, v12
5364+
WriteBarrier v30, v12
53655365
CheckInterrupts
53665366
Return v12
53675367
");
@@ -5391,10 +5391,10 @@ mod hir_opt_tests {
53915391
PatchPoint MethodRedefined(C@0x1000, foo=@0x1008, cme:0x1010)
53925392
PatchPoint NoSingletonClass(C@0x1000)
53935393
v29:HeapObject[class_exact:C] = GuardType v11, HeapObject[class_exact:C]
5394-
v30:CPtr = LoadField v29, :_as_heap@0x1038
5395-
v31:HeapObject[class_exact:C] = GuardNotFrozen v29
5396-
StoreField v30, :foo=@0x1039, v12
5397-
WriteBarrier v29, v12
5394+
v30:HeapObject[class_exact:C] = GuardNotFrozen v29
5395+
v31:CPtr = LoadField v30, :_as_heap@0x1038
5396+
StoreField v31, :foo=@0x1039, v12
5397+
WriteBarrier v30, v12
53985398
CheckInterrupts
53995399
Return v12
54005400
");

0 commit comments

Comments
 (0)