Skip to content

Commit 17588b7

Browse files
committed
Add cached_insns invalidation test
1 parent 6dd3d50 commit 17588b7

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

‎zjit/src/hir/opt_tests.rs‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25698,4 +25698,72 @@ mod hir_opt_tests {
2569825698
"
2569925699
);
2570025700
}
25701+
25702+
#[test]
25703+
fn test_global_load_cached_insns_invalidated() {
25704+
set_call_threshold(3);
25705+
eval(r#"
25706+
class TestObj
25707+
def initialize(value)
25708+
@value = value
25709+
end
25710+
25711+
def foo(modify)
25712+
before = @value
25713+
if modify
25714+
@value = 5
25715+
end
25716+
25717+
before + @value
25718+
end
25719+
end
25720+
25721+
obj = TestObj.new(3)
25722+
obj.foo(false)
25723+
obj.foo(true)
25724+
"#);
25725+
25726+
assert_snapshot!(
25727+
hir_string_proc("TestObj.instance_method(:foo)"),
25728+
@"
25729+
fn foo@<compiled>:8:
25730+
bb1():
25731+
EntryPoint interpreter
25732+
v1:BasicObject = LoadSelf
25733+
v2:CPtr = LoadSP
25734+
v3:BasicObject = LoadField v2, :modify@0x1000
25735+
Jump bb3(v1, v3)
25736+
bb2():
25737+
EntryPoint JIT(0)
25738+
v7:BasicObject = LoadArg :self@0
25739+
v8:BasicObject = LoadArg :modify@1
25740+
Jump bb3(v7, v8)
25741+
bb3(v11:BasicObject, v12:BasicObject):
25742+
v66:NilClass = Const Value(nil)
25743+
v17:HeapBasicObject = GuardType v11, HeapBasicObject
25744+
v18:CShape = LoadField v17, :shape_id@0x1001
25745+
v19:CShape[0x1002] = GuardBitEquals v18, CShape(0x1002) recompile
25746+
v20:BasicObject = LoadField v17, :@value@0x1003
25747+
PatchPoint NoEPEscape(foo)
25748+
v27:CBool = Test v12
25749+
v28:Falsy = RefineType v12, Falsy
25750+
CondBranch v27, bb5(), bb4(v17, v28)
25751+
bb5():
25752+
v30:Truthy = RefineType v12, Truthy
25753+
v33:Fixnum[5] = Const Value(5)
25754+
StoreField v17, :@value@0x1003, v33
25755+
Jump bb4(v17, v30)
25756+
bb4(v42:HeapBasicObject, v43:BasicObject):
25757+
v50:CShape = LoadField v42, :shape_id@0x1001
25758+
v51:CShape[0x1002] = GuardBitEquals v50, CShape(0x1002) recompile
25759+
v52:BasicObject = LoadField v42, :@value@0x1003
25760+
PatchPoint MethodRedefined(Integer@0x1008, +@0x1010, cme:0x1018)
25761+
v63:Fixnum = GuardType v20, Fixnum recompile
25762+
v64:Fixnum = GuardType v52, Fixnum
25763+
v65:Fixnum = FixnumAdd v63, v64
25764+
CheckInterrupts
25765+
Return v65
25766+
"
25767+
);
25768+
}
2570125769
}

0 commit comments

Comments
 (0)