Add a hook to the wasm FuncEnvironment for emitting loop headers.
This will allow wasm implementations that wish to insert code into every loop, for example to insert an interrupt check or a safepoint. do so without relying on asynchronous signals.
This commit is contained in:
@@ -137,6 +137,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
||||
builder.ins().jump(loop_body, &[]);
|
||||
state.push_loop(loop_body, next, num_return_values(ty));
|
||||
builder.switch_to_block(loop_body);
|
||||
environ.translate_loop_header(builder.cursor());
|
||||
}
|
||||
Operator::If { ty } => {
|
||||
let val = state.pop1();
|
||||
|
||||
@@ -144,6 +144,14 @@ pub trait FuncEnvironment {
|
||||
index: MemoryIndex,
|
||||
heap: ir::Heap,
|
||||
) -> ir::Value;
|
||||
|
||||
/// Emit code at the beginning of every wasm loop.
|
||||
///
|
||||
/// This can be used to insert explicit interrupt or safepoint checking at
|
||||
/// the beginnings of loops.
|
||||
fn translate_loop_header(&mut self, _pos: FuncCursor) {
|
||||
// By default, don't emit anything.
|
||||
}
|
||||
}
|
||||
|
||||
/// An object satisfying the `ModuleEnvironment` trait can be passed as argument to the
|
||||
|
||||
Reference in New Issue
Block a user