mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
ZJIT: Annotate Kernel#class
This commit is contained in:
parent
3c1ca509b8
commit
44dee185aa
2 changed files with 19 additions and 3 deletions
|
@ -165,6 +165,7 @@ pub fn init() -> Annotations {
|
|||
|
||||
annotate_builtin!(rb_mKernel, "Float", types::Flonum);
|
||||
annotate_builtin!(rb_mKernel, "Integer", types::Integer);
|
||||
annotate_builtin!(rb_mKernel, "class", types::Class, leaf);
|
||||
|
||||
Annotations {
|
||||
cfuncs: std::mem::take(cfuncs),
|
||||
|
|
|
@ -5011,6 +5011,18 @@ mod tests {
|
|||
"#]]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invokebuiltin_cexpr_annotated() {
|
||||
assert_method_hir_with_opcode("class", YARVINSN_opt_invokebuiltin_delegate_leave, expect![[r#"
|
||||
fn class@<internal:kernel>:20:
|
||||
bb0(v0:BasicObject):
|
||||
v3:Class = InvokeBuiltin _bi20, v0
|
||||
Jump bb1(v0, v3)
|
||||
bb1(v5:BasicObject, v6:Class):
|
||||
Return v6
|
||||
"#]]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invokebuiltin_delegate_with_args() {
|
||||
// Using an unannotated builtin to test InvokeBuiltin generation
|
||||
|
@ -5028,10 +5040,13 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_invokebuiltin_delegate_without_args() {
|
||||
assert_method_hir_with_opcode("class", YARVINSN_opt_invokebuiltin_delegate_leave, expect![[r#"
|
||||
fn class@<internal:kernel>:20:
|
||||
let iseq = crate::cruby::with_rubyvm(|| get_method_iseq("GC", "enable"));
|
||||
assert!(iseq_contains_opcode(iseq, YARVINSN_opt_invokebuiltin_delegate_leave), "iseq GC.enable does not contain invokebuiltin");
|
||||
let function = iseq_to_hir(iseq).unwrap();
|
||||
assert_function_hir(function, expect![[r#"
|
||||
fn enable@<internal:gc>:55:
|
||||
bb0(v0:BasicObject):
|
||||
v3:BasicObject = InvokeBuiltin _bi20, v0
|
||||
v3:BasicObject = InvokeBuiltin gc_enable, v0
|
||||
Jump bb1(v0, v3)
|
||||
bb1(v5:BasicObject, v6:BasicObject):
|
||||
Return v6
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue