Skip to content

Commit 238ae3b

Browse files
committed
cranelift: tweak condition in safepoint detection to check for resumable traps;
1 parent dad56a2 commit 238ae3b

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

cranelift/codegen/src/ir/instructions.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ impl Opcode {
5959
pub fn constraints(self) -> OpcodeConstraints {
6060
OPCODE_CONSTRAINTS[self as usize - 1]
6161
}
62+
63+
/// Returns true if the instruction is a resumable trap.
64+
pub fn is_resumable_trap(&self) -> bool {
65+
match self {
66+
Opcode::ResumableTrap | Opcode::ResumableTrapnz => true,
67+
_ => false,
68+
}
69+
}
6270
}
6371

6472
// This trait really belongs in cranelift-reader where it is used by the `.clif` file parser, but since

cranelift/codegen/src/regalloc/safepoint.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::cursor::{Cursor, FuncCursor};
22
use crate::dominator_tree::DominatorTree;
3-
use crate::ir::{Function, InstBuilder, InstructionData, Opcode, TrapCode};
3+
use crate::ir::{Function, InstBuilder, Opcode};
44
use crate::isa::TargetIsa;
55
use crate::regalloc::live_value_tracker::LiveValueTracker;
66
use crate::regalloc::liveness::Liveness;
@@ -51,11 +51,7 @@ pub fn emit_stackmaps(
5151
pos.goto_top(block);
5252

5353
while let Some(inst) = pos.next_inst() {
54-
if let InstructionData::Trap {
55-
code: TrapCode::Interrupt,
56-
..
57-
} = &pos.func.dfg[inst]
58-
{
54+
if pos.func.dfg[inst].opcode().is_resumable_trap() {
5955
insert_and_encode_safepoint(&mut pos, tracker, isa);
6056
} else if pos.func.dfg[inst].opcode().is_call() {
6157
insert_and_encode_safepoint(&mut pos, tracker, isa);

0 commit comments

Comments
 (0)