Skip to content

Commit 72ab0c3

Browse files
committed
Add a test that we don't fold non-BasicObject
1 parent 3bc97b9 commit 72ab0c3

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

zjit/src/hir/opt_tests.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9905,4 +9905,34 @@ mod hir_opt_tests {
99059905
Return v52
99069906
");
99079907
}
9908+
9909+
#[test]
9910+
fn test_dont_fold_load_field_with_primitive_return_type() {
9911+
eval(r#"
9912+
S = "abc".freeze
9913+
def test = S.bytesize
9914+
test
9915+
"#);
9916+
assert_snapshot!(hir_string("test"), @r"
9917+
fn test@<compiled>:3:
9918+
bb0():
9919+
EntryPoint interpreter
9920+
v1:BasicObject = LoadSelf
9921+
Jump bb2(v1)
9922+
bb1(v4:BasicObject):
9923+
EntryPoint JIT(0)
9924+
Jump bb2(v4)
9925+
bb2(v6:BasicObject):
9926+
PatchPoint SingleRactorMode
9927+
PatchPoint StableConstantNames(0x1000, S)
9928+
v20:StringExact[VALUE(0x1008)] = Const Value(VALUE(0x1008))
9929+
PatchPoint MethodRedefined(String@0x1010, bytesize@0x1018, cme:0x1020)
9930+
PatchPoint NoSingletonClass(String@0x1010)
9931+
v24:CInt64 = LoadField v20, :len@0x1048
9932+
v25:Fixnum = BoxFixnum v24
9933+
IncrCounter inline_cfunc_optimized_send_count
9934+
CheckInterrupts
9935+
Return v25
9936+
");
9937+
}
99089938
}

0 commit comments

Comments
 (0)