Skip to content

Commit e5e32ac

Browse files
committed
ZJIT: Annotate Kernel#frozen? as returning BoolExact
1 parent c3c2544 commit e5e32ac

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

zjit/src/cruby_methods.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ pub fn init() -> Annotations {
225225
annotate_builtin!(rb_mKernel, "Float", types::Float);
226226
annotate_builtin!(rb_mKernel, "Integer", types::Integer);
227227
annotate_builtin!(rb_mKernel, "class", types::Class, leaf);
228+
annotate_builtin!(rb_mKernel, "frozen?", types::BoolExact);
228229
annotate_builtin!(rb_cSymbol, "name", types::StringExact);
229230
annotate_builtin!(rb_cSymbol, "to_s", types::StringExact);
230231

zjit/src/hir.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15346,6 +15346,32 @@ mod opt_tests {
1534615346
");
1534715347
}
1534815348

15349+
#[test]
15350+
fn test_inline_kernel_frozen_p() {
15351+
eval(r#"
15352+
def test(o) = o.frozen?
15353+
test :foo
15354+
"#);
15355+
assert_snapshot!(hir_string("test"), @r"
15356+
fn test@<compiled>:2:
15357+
bb0():
15358+
EntryPoint interpreter
15359+
v1:BasicObject = LoadSelf
15360+
v2:BasicObject = GetLocal l0, SP@4
15361+
Jump bb2(v1, v2)
15362+
bb1(v5:BasicObject, v6:BasicObject):
15363+
EntryPoint JIT(0)
15364+
Jump bb2(v5, v6)
15365+
bb2(v8:BasicObject, v9:BasicObject):
15366+
PatchPoint MethodRedefined(Symbol@0x1000, frozen?@0x1008, cme:0x1010)
15367+
v21:StaticSymbol = GuardType v9, StaticSymbol
15368+
IncrCounter inline_iseq_optimized_send_count
15369+
v24:BoolExact = InvokeBuiltin leaf _bi69, v21
15370+
CheckInterrupts
15371+
Return v24
15372+
");
15373+
}
15374+
1534915375
#[test]
1535015376
fn test_inline_integer_to_i() {
1535115377
eval(r#"

0 commit comments

Comments
 (0)