Skip to content

Commit f4909ab

Browse files
committed
ZJIT: Add reason to GuardGreaterEq
1 parent 21862be commit f4909ab

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

zjit/src/codegen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio
539539
&Insn::GuardAnyBitSet { val, mask, reason, state, .. } => gen_guard_any_bit_set(jit, asm, opnd!(val), mask, reason, &function.frame_state(state)),
540540
&Insn::GuardNoBitsSet { val, mask, reason, state, .. } => gen_guard_no_bits_set(jit, asm, opnd!(val), mask, reason, &function.frame_state(state)),
541541
&Insn::GuardLess { left, right, state } => gen_guard_less(jit, asm, opnd!(left), opnd!(right), &function.frame_state(state)),
542-
&Insn::GuardGreaterEq { left, right, state } => gen_guard_greater_eq(jit, asm, opnd!(left), opnd!(right), &function.frame_state(state)),
542+
&Insn::GuardGreaterEq { left, right, state, .. } => gen_guard_greater_eq(jit, asm, opnd!(left), opnd!(right), &function.frame_state(state)),
543543
Insn::PatchPoint { invariant, state } => no_output!(gen_patch_point(jit, asm, invariant, &function.frame_state(*state))),
544544
Insn::CCall { cfunc, recv, args, name, return_type: _, elidable: _ } => gen_ccall(asm, *cfunc, *name, opnd!(recv), opnds!(args)),
545545
// Give up CCallWithFrame for 7+ args since asm.ccall() supports at most 6 args (recv + args).

zjit/src/cruby_methods.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ fn inline_array_aref(fun: &mut hir::Function, block: hir::BlockId, recv: hir::In
336336
let length = fun.push_insn(block, hir::Insn::ArrayLength { array: recv });
337337
let index = fun.push_insn(block, hir::Insn::GuardLess { left: index, right: length, state });
338338
let zero = fun.push_insn(block, hir::Insn::Const { val: hir::Const::CInt64(0) });
339-
let index = fun.push_insn(block, hir::Insn::GuardGreaterEq { left: index, right: zero, state });
339+
use crate::hir::SideExitReason;
340+
let index = fun.push_insn(block, hir::Insn::GuardGreaterEq { left: index, right: zero, reason: SideExitReason::GuardGreaterEq, state });
340341
let result = fun.push_insn(block, hir::Insn::ArrayAref { array: recv, index });
341342
return Some(result);
342343
}
@@ -359,7 +360,8 @@ fn inline_array_aset(fun: &mut hir::Function, block: hir::BlockId, recv: hir::In
359360
let length = fun.push_insn(block, hir::Insn::ArrayLength { array: recv });
360361
let index = fun.push_insn(block, hir::Insn::GuardLess { left: index, right: length, state });
361362
let zero = fun.push_insn(block, hir::Insn::Const { val: hir::Const::CInt64(0) });
362-
let index = fun.push_insn(block, hir::Insn::GuardGreaterEq { left: index, right: zero, state });
363+
use crate::hir::SideExitReason;
364+
let index = fun.push_insn(block, hir::Insn::GuardGreaterEq { left: index, right: zero, reason: SideExitReason::GuardGreaterEq, state });
363365

364366
let _ = fun.push_insn(block, hir::Insn::ArrayAset { array: recv, index, val });
365367
fun.push_insn(block, hir::Insn::WriteBarrier { recv, val });
@@ -451,7 +453,8 @@ fn inline_string_getbyte(fun: &mut hir::Function, block: hir::BlockId, recv: hir
451453
// This is unlike most other guards.
452454
let unboxed_index = fun.push_insn(block, hir::Insn::GuardLess { left: unboxed_index, right: len, state });
453455
let zero = fun.push_insn(block, hir::Insn::Const { val: hir::Const::CInt64(0) });
454-
let _ = fun.push_insn(block, hir::Insn::GuardGreaterEq { left: unboxed_index, right: zero, state });
456+
use crate::hir::SideExitReason;
457+
let _ = fun.push_insn(block, hir::Insn::GuardGreaterEq { left: unboxed_index, right: zero, reason: SideExitReason::GuardGreaterEq, state });
455458
let result = fun.push_insn(block, hir::Insn::StringGetbyte { string: recv, index: unboxed_index });
456459
return Some(result);
457460
}
@@ -473,7 +476,8 @@ fn inline_string_setbyte(fun: &mut hir::Function, block: hir::BlockId, recv: hir
473476
});
474477
let unboxed_index = fun.push_insn(block, hir::Insn::GuardLess { left: unboxed_index, right: len, state });
475478
let zero = fun.push_insn(block, hir::Insn::Const { val: hir::Const::CInt64(0) });
476-
let _ = fun.push_insn(block, hir::Insn::GuardGreaterEq { left: unboxed_index, right: zero, state });
479+
use crate::hir::SideExitReason;
480+
let _ = fun.push_insn(block, hir::Insn::GuardGreaterEq { left: unboxed_index, right: zero, reason: SideExitReason::GuardGreaterEq, state });
477481
// We know that all String are HeapObject, so no need to insert a GuardType(HeapObject).
478482
fun.guard_not_frozen(block, recv, state);
479483
let _ = fun.push_insn(block, hir::Insn::StringSetbyteFixnum { string: recv, index, value });

zjit/src/hir.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ pub enum Insn {
10311031
/// Side-exit if (val & mask) != 0
10321032
GuardNoBitsSet { val: InsnId, mask: Const, mask_name: Option<ID>, reason: SideExitReason, state: InsnId },
10331033
/// Side-exit if left is not greater than or equal to right (both operands are C long).
1034-
GuardGreaterEq { left: InsnId, right: InsnId, state: InsnId },
1034+
GuardGreaterEq { left: InsnId, right: InsnId, reason: SideExitReason, state: InsnId },
10351035
/// Side-exit if left is not less than right (both operands are C long).
10361036
GuardLess { left: InsnId, right: InsnId, state: InsnId },
10371037

@@ -2240,7 +2240,7 @@ impl Function {
22402240
&GuardBitEquals { val, expected, reason, state } => GuardBitEquals { val: find!(val), expected, reason, state },
22412241
&GuardAnyBitSet { val, mask, mask_name, reason, state } => GuardAnyBitSet { val: find!(val), mask, mask_name, reason, state },
22422242
&GuardNoBitsSet { val, mask, mask_name, reason, state } => GuardNoBitsSet { val: find!(val), mask, mask_name, reason, state },
2243-
&GuardGreaterEq { left, right, state } => GuardGreaterEq { left: find!(left), right: find!(right), state },
2243+
&GuardGreaterEq { left, right, reason, state } => GuardGreaterEq { left: find!(left), right: find!(right), reason, state },
22442244
&GuardLess { left, right, state } => GuardLess { left: find!(left), right: find!(right), state },
22452245
&IsBlockGiven { lep } => IsBlockGiven { lep: find!(lep) },
22462246
&GetBlockParam { level, ep_offset, state } => GetBlockParam { level, ep_offset, state: find!(state) },
@@ -4775,7 +4775,7 @@ impl Function {
47754775
worklist.push_back(val);
47764776
worklist.push_back(state);
47774777
}
4778-
&Insn::GuardGreaterEq { left, right, state } => {
4778+
&Insn::GuardGreaterEq { left, right, state, .. } => {
47794779
worklist.push_back(left);
47804780
worklist.push_back(right);
47814781
worklist.push_back(state);

0 commit comments

Comments
 (0)