Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/ruby/test_zjit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,13 @@ def entry = test(a: 1, b: 2)
}
end

def test_send_ccall_variadic_with_different_receiver_classes
assert_compiles '[true, true]', %q{
def test(obj) = obj.start_with?("a")
[test("abc"), test(:abc)]
}, call_threshold: 2
end

def test_forwardable_iseq
assert_compiles '1', %q{
def test(...) = 1
Expand Down
13 changes: 10 additions & 3 deletions zjit/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2169,6 +2169,11 @@ impl Function {
state
});

if let Some(profiled_type) = profiled_type {
// Guard receiver class
recv = fun.push_insn(block, Insn::GuardType { val: recv, guard_type: Type::from_profiled_type(profiled_type), state });
}

let cfun = unsafe { get_mct_func(cfunc) }.cast();
let ccall = fun.push_insn(block, Insn::CCallVariadic {
cfun,
Expand Down Expand Up @@ -7131,9 +7136,10 @@ mod opt_tests {
v4:StringExact[VALUE(0x1000)] = Const Value(VALUE(0x1000))
v6:StringExact = StringCopy v4
PatchPoint MethodRedefined(Object@0x1008, puts@0x1010, cme:0x1018)
v16:BasicObject = CCallVariadic puts@0x1040, v0, v6
v16:HeapObject[class_exact*:Object@VALUE(0x1008)] = GuardType v0, HeapObject[class_exact*:Object@VALUE(0x1008)]
v17:BasicObject = CCallVariadic puts@0x1040, v16, v6
CheckInterrupts
Return v16
Return v17
");
}

Expand Down Expand Up @@ -8515,7 +8521,8 @@ mod opt_tests {
PatchPoint MethodRedefined(Set@0x1008, new@0x1010, cme:0x1018)
v10:HeapObject = ObjectAlloc v34
PatchPoint MethodRedefined(Set@0x1008, initialize@0x1040, cme:0x1048)
v39:BasicObject = CCallVariadic initialize@0x1070, v10
v39:HeapObject[class_exact:Set] = GuardType v10, HeapObject[class_exact:Set]
v40:BasicObject = CCallVariadic initialize@0x1070, v39
CheckInterrupts
CheckInterrupts
Return v10
Expand Down
Loading