[wasm] Pass translation state along for before/after_translate_operator callbacks (#879)

This commit is contained in:
Andy Wortman
2019-07-30 07:32:50 -07:00
committed by Benjamin Bouvier
parent 5ca13a70a5
commit b5cb8556f6
3 changed files with 6 additions and 2 deletions

View File

@@ -6,6 +6,7 @@
//!
//! [Wasmtime]: https://github.com/CraneStation/wasmtime
use crate::state::TranslationState;
use crate::translation_utils::{
FuncIndex, Global, GlobalIndex, Memory, MemoryIndex, SignatureIndex, Table, TableIndex,
};
@@ -262,6 +263,7 @@ pub trait FuncEnvironment {
&mut self,
_op: &Operator,
_builder: &mut FunctionBuilder,
_state: &mut TranslationState,
) -> WasmResult<()> {
Ok(())
}
@@ -272,6 +274,7 @@ pub trait FuncEnvironment {
&mut self,
_op: &Operator,
_builder: &mut FunctionBuilder,
_state: &mut TranslationState,
) -> WasmResult<()> {
Ok(())
}

View File

@@ -207,9 +207,9 @@ fn parse_function_body<FE: FuncEnvironment + ?Sized>(
while !state.control_stack.is_empty() {
builder.set_srcloc(cur_srcloc(&reader));
let op = reader.read_operator()?;
environ.before_translate_operator(&op, builder)?;
environ.before_translate_operator(&op, builder, state)?;
translate_operator(&op, builder, state, environ)?;
environ.after_translate_operator(&op, builder)?;
environ.after_translate_operator(&op, builder, state)?;
}
// The final `End` operator left us in the exit block where we need to manually add a return

View File

@@ -63,6 +63,7 @@ pub use crate::environ::{
};
pub use crate::func_translator::FuncTranslator;
pub use crate::module_translator::translate_module;
pub use crate::state::TranslationState;
pub use crate::translation_utils::{
get_vmctx_value_label, DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex,
DefinedTableIndex, FuncIndex, Global, GlobalIndex, GlobalInit, Memory, MemoryIndex,