Skip to content

Commit 4df85c5

Browse files
authored
Cranelift: Add an is_safepoint predicate to Opcode (bytecodealliance#9066)
1 parent 974c324 commit 4df85c5

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

cranelift/codegen/src/ir/dfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ impl DataFlowGraph {
587587
/// Panics if the given instruction is not a (non-tail) call instruction.
588588
pub fn append_user_stack_map_entry(&mut self, inst: Inst, entry: UserStackMapEntry) {
589589
let opcode = self.insts[inst].opcode();
590-
assert!(opcode.is_call() && !opcode.is_return());
590+
assert!(opcode.is_safepoint());
591591
self.user_stack_maps.entry(inst).or_default().push(entry);
592592
}
593593
}

cranelift/codegen/src/ir/instructions.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ impl Opcode {
193193
pub fn constraints(self) -> OpcodeConstraints {
194194
OPCODE_CONSTRAINTS[self as usize - 1]
195195
}
196+
197+
/// Is this instruction a GC safepoint?
198+
///
199+
/// Safepoints are all kinds of calls, except for tail calls.
200+
#[inline]
201+
pub fn is_safepoint(self) -> bool {
202+
self.is_call() && !self.is_return()
203+
}
196204
}
197205

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

0 commit comments

Comments
 (0)