Skip to content

Commit 392c492

Browse files
tekknolagik0kubun
authored andcommitted
Remove any object specialization in CCall optimization
We don't want to only guard on the class
1 parent 5f69e35 commit 392c492

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

zjit/src/hir.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ impl Function {
10361036
// Commit to the replacement. Put PatchPoint.
10371037
fun.push_insn(block, Insn::PatchPoint(Invariant::MethodRedefined { klass: recv_class, method: method_id }));
10381038
// Guard receiver class
1039-
fun.push_insn(block, Insn::GuardType { val: self_val, guard_type: *recv_type, state });
1039+
fun.push_insn(block, Insn::GuardType { val: self_val, guard_type: recv_type.unspecialized(), state });
10401040
let cfun = unsafe { get_mct_func(cfunc) }.cast();
10411041
let mut cfunc_args = vec![self_val];
10421042
cfunc_args.append(&mut args);
@@ -3344,8 +3344,7 @@ mod opt_tests {
33443344
v1:StringExact[VALUE(0x1000)] = Const Value(VALUE(0x1000))
33453345
v2:StringExact = StringCopy v1
33463346
PatchPoint MethodRedefined(String@0x1008, bytesize@0x1010)
3347-
v8:StringExact[VALUE(0x1018)] = GuardType v2, StringExact[VALUE(0x1018)]
3348-
v9:Fixnum = CCall bytesize@0x1020, v2
3347+
v9:Fixnum = CCall bytesize@0x1018, v2
33493348
PatchPoint CalleeModifiedLocals(v9)
33503349
Return v9
33513350
"#]]);

zjit/src/hir_type/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ impl Type {
247247
}
248248
}
249249

250+
pub fn unspecialized(&self) -> Self {
251+
Type { spec: Specialization::Any, ..*self }
252+
}
253+
250254
pub fn fixnum_value(&self) -> Option<i64> {
251255
if self.is_subtype(types::Fixnum) {
252256
self.ruby_object().map(|val| val.as_fixnum())

0 commit comments

Comments
 (0)