Add FuncEnvironment trait.

This trait is used to provide the environment necessary to translate a
single WebAssembly function without having other global data structures
for the WebAssembly module.

The WasmRuntime trait extends the FuncEnvironment trait for those uses
that want to parse a whole WebAssembly module.

- Change the handling of WebAssembly globals to use the FuncEnvironment
  trait as well as the new GlobalVar infrastructure in Cretonne. The
  runtime is not consulted on the translation of each
  get_global/get_global instruction. Instead it gets to create the
  GlobalVar declaration in the function preamble the first time the
  global is used.

- Change the handling of heap load/store instructions to use the new
  Heap infrastructure in Cretonne. The runtime is called to create the
  Heap declaration in the preamble. It is not involved in individual
  load/store instructions.
This commit is contained in:
Jakob Stoklund Olesen
2017-09-05 13:11:35 -07:00
parent 19c8ba5021
commit 0ac1d0dd94
6 changed files with 240 additions and 190 deletions

View File

@@ -26,7 +26,10 @@ pub struct FunctionBuilder<'a, Variable: 'a>
where
Variable: EntityRef + Hash + Default,
{
func: &'a mut Function,
/// The function currently being built.
/// This field is public so the function can be re-borrowed.
pub func: &'a mut Function,
builder: &'a mut ILBuilder<Variable>,
position: Position,
pristine: bool,