Skip to content

Commit 4f43a09

Browse files
XrXrk0kubun
authored andcommitted
Use GuardType output variable
Helps with readability and threads type info that's there around for longer. Amend test so `GuardType` doesn't DCE'ed.
1 parent 164bd8e commit 4f43a09

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

zjit/src/hir.rs

Lines changed: 7 additions & 7 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.unspecialized(), state });
1039+
let self_val = 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);
@@ -3305,16 +3305,16 @@ mod opt_tests {
33053305
#[test]
33063306
fn kernel_itself_simple() {
33073307
eval("
3308-
def test = 1.itself
3309-
test
3310-
test
3308+
def test(x) = x.itself
3309+
test(0) # profile
3310+
test(1)
33113311
");
33123312
assert_optimized_method_hir("test", expect![[r#"
33133313
fn test:
3314-
bb0():
3315-
v1:Fixnum[1] = Const Value(1)
3314+
bb0(v0:BasicObject):
33163315
PatchPoint MethodRedefined(Integer@0x1000, itself@0x1008)
3317-
v8:BasicObject = CCall itself@0x1010, v1
3316+
v7:Fixnum = GuardType v0, Fixnum
3317+
v8:BasicObject = CCall itself@0x1010, v7
33183318
PatchPoint CalleeModifiedLocals(v8)
33193319
Return v8
33203320
"#]]);

0 commit comments

Comments
 (0)