diff options
| author | Max Bernstein <ruby@bernsteinbear.com> | 2025-10-24 16:12:24 -0700 |
|---|---|---|
| committer | Max Bernstein <tekknolagi@gmail.com> | 2025-10-27 18:57:08 -0400 |
| commit | e5e32acc7ec020e3fd7a7dff76e19a6f39ffb3ab (patch) | |
| tree | b1b6fab49311133634736f2f333558efdd981c3e | |
| parent | c3c254439f06073a9c7e167f89e1c1e97629d947 (diff) | |
ZJIT: Annotate Kernel#frozen? as returning BoolExact
| -rw-r--r-- | zjit/src/cruby_methods.rs | 1 | ||||
| -rw-r--r-- | zjit/src/hir.rs | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/zjit/src/cruby_methods.rs b/zjit/src/cruby_methods.rs index 6a16ae3e46..dd33bb206a 100644 --- a/zjit/src/cruby_methods.rs +++ b/zjit/src/cruby_methods.rs @@ -225,6 +225,7 @@ pub fn init() -> Annotations { annotate_builtin!(rb_mKernel, "Float", types::Float); annotate_builtin!(rb_mKernel, "Integer", types::Integer); annotate_builtin!(rb_mKernel, "class", types::Class, leaf); + annotate_builtin!(rb_mKernel, "frozen?", types::BoolExact); annotate_builtin!(rb_cSymbol, "name", types::StringExact); annotate_builtin!(rb_cSymbol, "to_s", types::StringExact); diff --git a/zjit/src/hir.rs b/zjit/src/hir.rs index 776b1582a7..e0e682ccb2 100644 --- a/zjit/src/hir.rs +++ b/zjit/src/hir.rs @@ -15347,6 +15347,32 @@ mod opt_tests { } #[test] + fn test_inline_kernel_frozen_p() { + eval(r#" + def test(o) = o.frozen? + test :foo + "#); + assert_snapshot!(hir_string("test"), @r" + fn test@<compiled>:2: + bb0(): + EntryPoint interpreter + v1:BasicObject = LoadSelf + v2:BasicObject = GetLocal l0, SP@4 + Jump bb2(v1, v2) + bb1(v5:BasicObject, v6:BasicObject): + EntryPoint JIT(0) + Jump bb2(v5, v6) + bb2(v8:BasicObject, v9:BasicObject): + PatchPoint MethodRedefined(Symbol@0x1000, frozen?@0x1008, cme:0x1010) + v21:StaticSymbol = GuardType v9, StaticSymbol + IncrCounter inline_iseq_optimized_send_count + v24:BoolExact = InvokeBuiltin leaf _bi69, v21 + CheckInterrupts + Return v24 + "); + } + + #[test] fn test_inline_integer_to_i() { eval(r#" def test(o) = o.to_i |
