Remove FunctionBuilderContext from API, and change FunctionBuilder API
This commit is contained in:
@@ -81,7 +81,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
||||
* `get_global` and `set_global` are handled by the environment.
|
||||
***********************************************************************************/
|
||||
Operator::GetGlobal { global_index } => {
|
||||
let val = match state.get_global(builder.func, *global_index, environ)? {
|
||||
let val = match state.get_global(&mut builder.func, *global_index, environ)? {
|
||||
GlobalVariable::Const(val) => val,
|
||||
GlobalVariable::Memory { gv, offset, ty } => {
|
||||
let addr = builder.ins().global_value(environ.pointer_type(), gv);
|
||||
@@ -92,7 +92,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
||||
state.push1(val);
|
||||
}
|
||||
Operator::SetGlobal { global_index } => {
|
||||
match state.get_global(builder.func, *global_index, environ)? {
|
||||
match state.get_global(&mut builder.func, *global_index, environ)? {
|
||||
GlobalVariable::Const(_) => panic!("global #{} is a constant", *global_index),
|
||||
GlobalVariable::Memory { gv, offset, ty } => {
|
||||
let addr = builder.ins().global_value(environ.pointer_type(), gv);
|
||||
@@ -367,7 +367,8 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
||||
* argument referring to an index in the external functions table of the module.
|
||||
************************************************************************************/
|
||||
Operator::Call { function_index } => {
|
||||
let (fref, num_args) = state.get_direct_func(builder.func, *function_index, environ)?;
|
||||
let (fref, num_args) =
|
||||
state.get_direct_func(&mut builder.func, *function_index, environ)?;
|
||||
let call = environ.translate_call(
|
||||
builder.cursor(),
|
||||
FuncIndex::from_u32(*function_index),
|
||||
@@ -388,8 +389,8 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
||||
Operator::CallIndirect { index, table_index } => {
|
||||
// `index` is the index of the function's signature and `table_index` is the index of
|
||||
// the table to search the function in.
|
||||
let (sigref, num_args) = state.get_indirect_sig(builder.func, *index, environ)?;
|
||||
let table = state.get_table(builder.func, *table_index, environ)?;
|
||||
let (sigref, num_args) = state.get_indirect_sig(&mut builder.func, *index, environ)?;
|
||||
let table = state.get_table(&mut builder.func, *table_index, environ)?;
|
||||
let callee = state.pop1();
|
||||
let call = environ.translate_call_indirect(
|
||||
builder.cursor(),
|
||||
@@ -417,13 +418,13 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
||||
// The WebAssembly MVP only supports one linear memory, but we expect the reserved
|
||||
// argument to be a memory index.
|
||||
let heap_index = MemoryIndex::from_u32(*reserved);
|
||||
let heap = state.get_heap(builder.func, *reserved, environ)?;
|
||||
let heap = state.get_heap(&mut builder.func, *reserved, environ)?;
|
||||
let val = state.pop1();
|
||||
state.push1(environ.translate_memory_grow(builder.cursor(), heap_index, heap, val)?)
|
||||
}
|
||||
Operator::MemorySize { reserved } => {
|
||||
let heap_index = MemoryIndex::from_u32(*reserved);
|
||||
let heap = state.get_heap(builder.func, *reserved, environ)?;
|
||||
let heap = state.get_heap(&mut builder.func, *reserved, environ)?;
|
||||
state.push1(environ.translate_memory_size(builder.cursor(), heap_index, heap)?);
|
||||
}
|
||||
/******************************* Load instructions ***********************************
|
||||
@@ -1231,7 +1232,7 @@ fn translate_load<FE: FuncEnvironment + ?Sized>(
|
||||
) -> WasmResult<()> {
|
||||
let addr32 = state.pop1();
|
||||
// We don't yet support multiple linear memories.
|
||||
let heap = state.get_heap(builder.func, 0, environ)?;
|
||||
let heap = state.get_heap(&mut builder.func, 0, environ)?;
|
||||
let (base, offset) = get_heap_addr(heap, addr32, offset, environ.pointer_type(), builder);
|
||||
// Note that we don't set `is_aligned` here, even if the load instruction's
|
||||
// alignment immediate says it's aligned, because WebAssembly's immediate
|
||||
@@ -1256,7 +1257,7 @@ fn translate_store<FE: FuncEnvironment + ?Sized>(
|
||||
let val_ty = builder.func.dfg.value_type(val);
|
||||
|
||||
// We don't yet support multiple linear memories.
|
||||
let heap = state.get_heap(builder.func, 0, environ)?;
|
||||
let heap = state.get_heap(&mut builder.func, 0, environ)?;
|
||||
let (base, offset) = get_heap_addr(heap, addr32, offset, environ.pointer_type(), builder);
|
||||
// See the comments in `translate_load` about the flags.
|
||||
let flags = MemFlags::new();
|
||||
|
||||
Reference in New Issue
Block a user