mirror of
https://github.com/fluencelabs/wasmer
synced 2025-04-01 23:41:03 +00:00
Cherry-picked fix
This commit is contained in:
parent
59ce7ea54b
commit
65872a1be4
@ -92,8 +92,9 @@ impl Module {
|
|||||||
func_assoc.iter_mut().for_each(|(_, sig_index)| {
|
func_assoc.iter_mut().for_each(|(_, sig_index)| {
|
||||||
*sig_index = sig_registry.lookup_deduplicated_sigindex(*sig_index);
|
*sig_index = sig_registry.lookup_deduplicated_sigindex(*sig_index);
|
||||||
});
|
});
|
||||||
|
let imported_functions_len = self.module.imported_functions.len();
|
||||||
let (func_resolver_builder, handler_data) = FuncResolverBuilder::new(isa, functions)?;
|
let (func_resolver_builder, handler_data) =
|
||||||
|
FuncResolverBuilder::new(isa, functions, imported_functions_len)?;
|
||||||
self.module.func_resolver = Box::new(func_resolver_builder.finalize()?);
|
self.module.func_resolver = Box::new(func_resolver_builder.finalize()?);
|
||||||
|
|
||||||
let trampolines = Trampolines::new(isa, &self.module);
|
let trampolines = Trampolines::new(isa, &self.module);
|
||||||
|
@ -14,7 +14,7 @@ use wasmer_runtime_core::{
|
|||||||
sys::{Memory, Protect},
|
sys::{Memory, Protect},
|
||||||
},
|
},
|
||||||
error::{CompileError, CompileResult},
|
error::{CompileError, CompileResult},
|
||||||
structures::Map,
|
structures::{Map, TypedIndex},
|
||||||
types::LocalFuncIndex,
|
types::LocalFuncIndex,
|
||||||
vm, vmcalls,
|
vm, vmcalls,
|
||||||
};
|
};
|
||||||
@ -23,12 +23,14 @@ use wasmer_runtime_core::{
|
|||||||
pub struct FuncResolverBuilder {
|
pub struct FuncResolverBuilder {
|
||||||
resolver: FuncResolver,
|
resolver: FuncResolver,
|
||||||
relocations: Map<LocalFuncIndex, Vec<Relocation>>,
|
relocations: Map<LocalFuncIndex, Vec<Relocation>>,
|
||||||
|
import_len: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FuncResolverBuilder {
|
impl FuncResolverBuilder {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
isa: &isa::TargetIsa,
|
isa: &isa::TargetIsa,
|
||||||
function_bodies: Map<LocalFuncIndex, ir::Function>,
|
function_bodies: Map<LocalFuncIndex, ir::Function>,
|
||||||
|
import_len: usize,
|
||||||
) -> CompileResult<(Self, HandlerData)> {
|
) -> CompileResult<(Self, HandlerData)> {
|
||||||
let mut compiled_functions: Vec<Vec<u8>> = Vec::with_capacity(function_bodies.len());
|
let mut compiled_functions: Vec<Vec<u8>> = Vec::with_capacity(function_bodies.len());
|
||||||
let mut relocations = Map::with_capacity(function_bodies.len());
|
let mut relocations = Map::with_capacity(function_bodies.len());
|
||||||
@ -100,6 +102,7 @@ impl FuncResolverBuilder {
|
|||||||
Self {
|
Self {
|
||||||
resolver: FuncResolver { map, memory },
|
resolver: FuncResolver { map, memory },
|
||||||
relocations,
|
relocations,
|
||||||
|
import_len,
|
||||||
},
|
},
|
||||||
handler_data,
|
handler_data,
|
||||||
))
|
))
|
||||||
@ -113,6 +116,10 @@ impl FuncResolverBuilder {
|
|||||||
// This will always be an internal function
|
// This will always be an internal function
|
||||||
// because imported functions are not
|
// because imported functions are not
|
||||||
// called in this way.
|
// called in this way.
|
||||||
|
// Adjust from wasm-wide function index to index of locally-defined functions only.
|
||||||
|
let local_func_index =
|
||||||
|
LocalFuncIndex::new(local_func_index.index() - self.import_len);
|
||||||
|
|
||||||
self.resolver.lookup(local_func_index).unwrap().as_ptr() as isize
|
self.resolver.lookup(local_func_index).unwrap().as_ptr() as isize
|
||||||
}
|
}
|
||||||
RelocationType::LibCall(libcall) => match libcall {
|
RelocationType::LibCall(libcall) => match libcall {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user