mirror of
https://github.com/fluencelabs/wasmer
synced 2025-05-09 01:02:17 +00:00
Moved ctx to first argument in Cranelift backend
This commit is contained in:
parent
6c7fd55b87
commit
227d5e24cf
@ -460,7 +460,7 @@ impl<'env, 'module, 'isa> FuncEnvironment for FuncEnv<'env, 'module, 'isa> {
|
||||
// and the vmctx parameter.
|
||||
let mut args = Vec::with_capacity(call_args.len() + 1);
|
||||
args.extend(call_args.iter().cloned());
|
||||
args.push(vmctx_ptr);
|
||||
args.insert(0, vmctx_ptr);
|
||||
|
||||
Ok(pos.ins().call_indirect(sig_ref, func_ptr, &args))
|
||||
}
|
||||
@ -486,7 +486,7 @@ impl<'env, 'module, 'isa> FuncEnvironment for FuncEnv<'env, 'module, 'isa> {
|
||||
|
||||
let mut args = Vec::with_capacity(call_args.len() + 1);
|
||||
args.extend(call_args.iter().cloned());
|
||||
args.push(vmctx);
|
||||
args.insert(0, vmctx);
|
||||
|
||||
Ok(pos.ins().call(callee, &args))
|
||||
}
|
||||
@ -533,7 +533,7 @@ impl<'env, 'module, 'isa> FuncEnvironment for FuncEnv<'env, 'module, 'isa> {
|
||||
|
||||
let mut args = Vec::with_capacity(call_args.len() + 1);
|
||||
args.extend(call_args.iter().cloned());
|
||||
args.push(imported_vmctx_addr);
|
||||
args.insert(0, imported_vmctx_addr);
|
||||
|
||||
Ok(pos
|
||||
.ins()
|
||||
@ -604,7 +604,7 @@ impl<'env, 'module, 'isa> FuncEnvironment for FuncEnv<'env, 'module, 'isa> {
|
||||
|
||||
let call_inst = pos
|
||||
.ins()
|
||||
.call(mem_grow_func, &[const_mem_index, by_value, vmctx]);
|
||||
.call(mem_grow_func, &[vmctx, const_mem_index, by_value]);
|
||||
|
||||
Ok(*pos.func.dfg.inst_results(call_inst).first().unwrap())
|
||||
}
|
||||
@ -664,7 +664,7 @@ impl<'env, 'module, 'isa> FuncEnvironment for FuncEnv<'env, 'module, 'isa> {
|
||||
.special_param(ir::ArgumentPurpose::VMContext)
|
||||
.expect("missing vmctx parameter");
|
||||
|
||||
let call_inst = pos.ins().call(mem_grow_func, &[const_mem_index, vmctx]);
|
||||
let call_inst = pos.ins().call(mem_grow_func, &[vmctx, const_mem_index]);
|
||||
|
||||
Ok(*pos.func.dfg.inst_results(call_inst).first().unwrap())
|
||||
}
|
||||
|
@ -536,14 +536,14 @@ impl<'module, 'isa, 'data> ModuleEnvironment<'data> for ModuleEnv<'module, 'isa>
|
||||
|
||||
let func_index = pos.ins().iconst(ir::types::I32, func_index.index() as i64);
|
||||
|
||||
pos.ins().call(start_debug, &[func_index, vmctx]);
|
||||
pos.ins().call(start_debug, &[vmctx, func_index]);
|
||||
|
||||
for param in new_ebb_params.iter().cloned() {
|
||||
match pos.func.dfg.value_type(param) {
|
||||
ir::types::I32 => pos.ins().call(i32_print, &[param, vmctx]),
|
||||
ir::types::I64 => pos.ins().call(i64_print, &[param, vmctx]),
|
||||
ir::types::F32 => pos.ins().call(f32_print, &[param, vmctx]),
|
||||
ir::types::F64 => pos.ins().call(f64_print, &[param, vmctx]),
|
||||
ir::types::I32 => pos.ins().call(i32_print, &[vmctx, param]),
|
||||
ir::types::I64 => pos.ins().call(i64_print, &[vmctx, param]),
|
||||
ir::types::F32 => pos.ins().call(f32_print, &[vmctx, param]),
|
||||
ir::types::F64 => pos.ins().call(f64_print, &[vmctx, param]),
|
||||
_ => unimplemented!(),
|
||||
};
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ use wasmer_runtime_core::{
|
||||
types::{FuncSig, LocalFuncIndex, SigIndex},
|
||||
vm, vmcalls,
|
||||
};
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
extern "C" {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
@ -350,21 +351,21 @@ fn round_up(n: usize, multiple: usize) -> usize {
|
||||
(n + multiple - 1) & !(multiple - 1)
|
||||
}
|
||||
|
||||
extern "C" fn i32_print(n: i32) {
|
||||
extern "C" fn i32_print(_ctx: &mut Ctx, n: i32) {
|
||||
print!(" i32: {},", n);
|
||||
}
|
||||
extern "C" fn i64_print(n: i64) {
|
||||
extern "C" fn i64_print(_ctx: &mut Ctx, n: i64) {
|
||||
print!(" i64: {},", n);
|
||||
}
|
||||
extern "C" fn f32_print(n: f32) {
|
||||
extern "C" fn f32_print(_ctx: &mut Ctx, n: f32) {
|
||||
print!(" f32: {},", n);
|
||||
}
|
||||
extern "C" fn f64_print(n: f64) {
|
||||
extern "C" fn f64_print(_ctx: &mut Ctx, n: f64) {
|
||||
print!(" f64: {},", n);
|
||||
}
|
||||
extern "C" fn start_debug(func_index: u32) {
|
||||
extern "C" fn start_debug(_ctx: &mut Ctx, func_index: u32) {
|
||||
print!("func ({}), args: [", func_index);
|
||||
}
|
||||
extern "C" fn end_debug() {
|
||||
extern "C" fn end_debug(_ctx: &mut Ctx) {
|
||||
println!(" ]");
|
||||
}
|
||||
|
@ -169,6 +169,7 @@ fn generate_func(func_sig: &FuncSig) -> ir::Function {
|
||||
let mut pos = FuncCursor::new(&mut func).at_first_insertion_point(entry_ebb);
|
||||
|
||||
let mut args_vec = Vec::with_capacity(func_sig.params().len() + 1);
|
||||
args_vec.push(vmctx_ptr);
|
||||
for (index, wasm_ty) in func_sig.params().iter().enumerate() {
|
||||
let mem_flags = ir::MemFlags::trusted();
|
||||
|
||||
@ -180,7 +181,6 @@ fn generate_func(func_sig: &FuncSig) -> ir::Function {
|
||||
);
|
||||
args_vec.push(val);
|
||||
}
|
||||
args_vec.push(vmctx_ptr);
|
||||
|
||||
let call_inst = pos.ins().call_indirect(export_sig_ref, func_ptr, &args_vec);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user