mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-25 22:51:32 +00:00
feat(runtime-core,clif-backend,llvm-backend) Rename an ImportFunc
offset.
`ImportedFunc::offset_vmctx` becomes `ImportedFunc::offset_func_ctx`.
This commit is contained in:
@ -763,20 +763,22 @@ impl FuncEnvironment for FunctionEnvironment {
|
|||||||
readonly: true,
|
readonly: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
let imported_vmctx_addr = pos.func.create_global_value(ir::GlobalValueData::Load {
|
let imported_func_ctx_addr =
|
||||||
|
pos.func.create_global_value(ir::GlobalValueData::Load {
|
||||||
base: imported_func_struct_addr,
|
base: imported_func_struct_addr,
|
||||||
offset: (vm::ImportedFunc::offset_vmctx() as i32).into(),
|
offset: (vm::ImportedFunc::offset_func_ctx() as i32).into(),
|
||||||
global_type: ptr_type,
|
global_type: ptr_type,
|
||||||
readonly: true,
|
readonly: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
let imported_func_addr = pos.ins().global_value(ptr_type, imported_func_addr);
|
let imported_func_addr = pos.ins().global_value(ptr_type, imported_func_addr);
|
||||||
let imported_vmctx_addr = pos.ins().global_value(ptr_type, imported_vmctx_addr);
|
let imported_func_ctx_addr =
|
||||||
|
pos.ins().global_value(ptr_type, imported_func_ctx_addr);
|
||||||
|
|
||||||
let sig_ref = pos.func.dfg.ext_funcs[callee].signature;
|
let sig_ref = pos.func.dfg.ext_funcs[callee].signature;
|
||||||
|
|
||||||
let mut args = Vec::with_capacity(call_args.len() + 1);
|
let mut args = Vec::with_capacity(call_args.len() + 1);
|
||||||
args.push(imported_vmctx_addr);
|
args.push(imported_func_ctx_addr);
|
||||||
args.extend(call_args.iter().cloned());
|
args.extend(call_args.iter().cloned());
|
||||||
|
|
||||||
Ok(pos
|
Ok(pos
|
||||||
|
@ -161,7 +161,7 @@ impl StackmapEntry {
|
|||||||
ValueSemantic::ImportedFuncCtx(idx) => MachineValue::VmctxDeref(vec![
|
ValueSemantic::ImportedFuncCtx(idx) => MachineValue::VmctxDeref(vec![
|
||||||
Ctx::offset_imported_funcs() as usize,
|
Ctx::offset_imported_funcs() as usize,
|
||||||
vm::ImportedFunc::size() as usize * idx
|
vm::ImportedFunc::size() as usize * idx
|
||||||
+ vm::ImportedFunc::offset_vmctx() as usize,
|
+ vm::ImportedFunc::offset_func_ctx() as usize,
|
||||||
0,
|
0,
|
||||||
]),
|
]),
|
||||||
ValueSemantic::DynamicSigindice(idx) => {
|
ValueSemantic::DynamicSigindice(idx) => {
|
||||||
|
@ -524,7 +524,9 @@ pub struct ImportedFunc {
|
|||||||
pub func_ctx: NonNull<FuncCtx>,
|
pub func_ctx: NonNull<FuncCtx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// manually implemented because ImportedFunc contains raw pointers directly; `Func` is marked Send (But `Ctx` actually isn't! (TODO: review this, shouldn't `Ctx` be Send?))
|
// manually implemented because ImportedFunc contains raw pointers
|
||||||
|
// directly; `Func` is marked Send (But `Ctx` actually isn't! (TODO:
|
||||||
|
// review this, shouldn't `Ctx` be Send?))
|
||||||
unsafe impl Send for ImportedFunc {}
|
unsafe impl Send for ImportedFunc {}
|
||||||
|
|
||||||
impl ImportedFunc {
|
impl ImportedFunc {
|
||||||
@ -533,7 +535,7 @@ impl ImportedFunc {
|
|||||||
0 * (mem::size_of::<usize>() as u8)
|
0 * (mem::size_of::<usize>() as u8)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn offset_vmctx() -> u8 {
|
pub fn offset_func_ctx() -> u8 {
|
||||||
1 * (mem::size_of::<usize>() as u8)
|
1 * (mem::size_of::<usize>() as u8)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -756,8 +758,8 @@ mod vm_offset_tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ImportedFunc::offset_vmctx() as usize,
|
ImportedFunc::offset_func_ctx() as usize,
|
||||||
offset_of!(ImportedFunc => vmctx).get_byte_offset(),
|
offset_of!(ImportedFunc => func_ctx).get_byte_offset(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user