cranelift: add a new resumable_trapnz instruction;
This is useful to have to allow resumable_trap to happen in loop headers, for instance. This is the correct way to implement interrupt checks in Spidermonkey, which are effectively resumable traps. Previous implementation was using traps, which is wrong, since traps semantically can't be resumed after.
This commit is contained in:
@@ -340,7 +340,21 @@ fn define_control_flow(
|
||||
r#"
|
||||
Trap when non-zero.
|
||||
|
||||
if ``c`` is zero, execution continues at the following instruction.
|
||||
If ``c`` is zero, execution continues at the following instruction.
|
||||
"#,
|
||||
&formats.cond_trap,
|
||||
)
|
||||
.operands_in(vec![c, code])
|
||||
.can_trap(true),
|
||||
);
|
||||
|
||||
ig.push(
|
||||
Inst::new(
|
||||
"resumable_trapnz",
|
||||
r#"
|
||||
A resumable trap to be called when the passed condition is non-zero.
|
||||
|
||||
If ``c`` is zero, execution continues at the following instruction.
|
||||
"#,
|
||||
&formats.cond_trap,
|
||||
)
|
||||
|
||||
@@ -99,6 +99,7 @@ pub(crate) fn define(insts: &InstructionGroup, imm: &Immediates) -> TransformGro
|
||||
let jump = insts.by_name("jump");
|
||||
let load = insts.by_name("load");
|
||||
let popcnt = insts.by_name("popcnt");
|
||||
let resumable_trapnz = insts.by_name("resumable_trapnz");
|
||||
let rotl = insts.by_name("rotl");
|
||||
let rotl_imm = insts.by_name("rotl_imm");
|
||||
let rotr = insts.by_name("rotr");
|
||||
@@ -138,6 +139,7 @@ pub(crate) fn define(insts: &InstructionGroup, imm: &Immediates) -> TransformGro
|
||||
// TODO: Add sufficient XForm syntax that we don't need to hand-code these.
|
||||
expand.custom_legalize(trapz, "expand_cond_trap");
|
||||
expand.custom_legalize(trapnz, "expand_cond_trap");
|
||||
expand.custom_legalize(resumable_trapnz, "expand_cond_trap");
|
||||
expand.custom_legalize(br_table, "expand_br_table");
|
||||
expand.custom_legalize(select, "expand_select");
|
||||
widen.custom_legalize(select, "expand_select"); // small ints
|
||||
|
||||
Reference in New Issue
Block a user