Skip to content

Commit 44dee18

Browse files
st0012k0kubun
authored andcommitted
ZJIT: Annotate Kernel#class
1 parent 3c1ca50 commit 44dee18

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

zjit/src/cruby_methods.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ pub fn init() -> Annotations {
165165

166166
annotate_builtin!(rb_mKernel, "Float", types::Flonum);
167167
annotate_builtin!(rb_mKernel, "Integer", types::Integer);
168+
annotate_builtin!(rb_mKernel, "class", types::Class, leaf);
168169

169170
Annotations {
170171
cfuncs: std::mem::take(cfuncs),

zjit/src/hir.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5011,6 +5011,18 @@ mod tests {
50115011
"#]]);
50125012
}
50135013

5014+
#[test]
5015+
fn test_invokebuiltin_cexpr_annotated() {
5016+
assert_method_hir_with_opcode("class", YARVINSN_opt_invokebuiltin_delegate_leave, expect![[r#"
5017+
fn class@<internal:kernel>:20:
5018+
bb0(v0:BasicObject):
5019+
v3:Class = InvokeBuiltin _bi20, v0
5020+
Jump bb1(v0, v3)
5021+
bb1(v5:BasicObject, v6:Class):
5022+
Return v6
5023+
"#]]);
5024+
}
5025+
50145026
#[test]
50155027
fn test_invokebuiltin_delegate_with_args() {
50165028
// Using an unannotated builtin to test InvokeBuiltin generation
@@ -5028,10 +5040,13 @@ mod tests {
50285040

50295041
#[test]
50305042
fn test_invokebuiltin_delegate_without_args() {
5031-
assert_method_hir_with_opcode("class", YARVINSN_opt_invokebuiltin_delegate_leave, expect![[r#"
5032-
fn class@<internal:kernel>:20:
5043+
let iseq = crate::cruby::with_rubyvm(|| get_method_iseq("GC", "enable"));
5044+
assert!(iseq_contains_opcode(iseq, YARVINSN_opt_invokebuiltin_delegate_leave), "iseq GC.enable does not contain invokebuiltin");
5045+
let function = iseq_to_hir(iseq).unwrap();
5046+
assert_function_hir(function, expect![[r#"
5047+
fn enable@<internal:gc>:55:
50335048
bb0(v0:BasicObject):
5034-
v3:BasicObject = InvokeBuiltin _bi20, v0
5049+
v3:BasicObject = InvokeBuiltin gc_enable, v0
50355050
Jump bb1(v0, v3)
50365051
bb1(v5:BasicObject, v6:BasicObject):
50375052
Return v6

0 commit comments

Comments
 (0)