cranelift: tweak condition in safepoint detection to check for resumable traps;

This commit is contained in:
Benjamin Bouvier
2020-06-12 19:22:06 +02:00
parent dad56a2488
commit 238ae3bf21
2 changed files with 10 additions and 6 deletions

View File

@@ -59,6 +59,14 @@ impl Opcode {
pub fn constraints(self) -> OpcodeConstraints { pub fn constraints(self) -> OpcodeConstraints {
OPCODE_CONSTRAINTS[self as usize - 1] OPCODE_CONSTRAINTS[self as usize - 1]
} }
/// Returns true if the instruction is a resumable trap.
pub fn is_resumable_trap(&self) -> bool {
match self {
Opcode::ResumableTrap | Opcode::ResumableTrapnz => true,
_ => false,
}
}
} }
// This trait really belongs in cranelift-reader where it is used by the `.clif` file parser, but since // This trait really belongs in cranelift-reader where it is used by the `.clif` file parser, but since

View File

@@ -1,6 +1,6 @@
use crate::cursor::{Cursor, FuncCursor}; use crate::cursor::{Cursor, FuncCursor};
use crate::dominator_tree::DominatorTree; use crate::dominator_tree::DominatorTree;
use crate::ir::{Function, InstBuilder, InstructionData, Opcode, TrapCode}; use crate::ir::{Function, InstBuilder, Opcode};
use crate::isa::TargetIsa; use crate::isa::TargetIsa;
use crate::regalloc::live_value_tracker::LiveValueTracker; use crate::regalloc::live_value_tracker::LiveValueTracker;
use crate::regalloc::liveness::Liveness; use crate::regalloc::liveness::Liveness;
@@ -51,11 +51,7 @@ pub fn emit_stackmaps(
pos.goto_top(block); pos.goto_top(block);
while let Some(inst) = pos.next_inst() { while let Some(inst) = pos.next_inst() {
if let InstructionData::Trap { if pos.func.dfg[inst].opcode().is_resumable_trap() {
code: TrapCode::Interrupt,
..
} = &pos.func.dfg[inst]
{
insert_and_encode_safepoint(&mut pos, tracker, isa); insert_and_encode_safepoint(&mut pos, tracker, isa);
} else if pos.func.dfg[inst].opcode().is_call() { } else if pos.func.dfg[inst].opcode().is_call() {
insert_and_encode_safepoint(&mut pos, tracker, isa); insert_and_encode_safepoint(&mut pos, tracker, isa);