mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-08 05:38:19 +00:00
Emit dynamic trampoline for each function index, not just each signature.
Emit names for trampolines when building through that experimental native pipeline.
This commit is contained in:
@@ -122,7 +122,7 @@ impl LLVMCompiler {
|
||||
compile_info
|
||||
.module
|
||||
.signatures
|
||||
.values()
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>()
|
||||
.par_iter()
|
||||
.map_init(
|
||||
@@ -130,8 +130,9 @@ impl LLVMCompiler {
|
||||
let target_machine = self.config().target_machine(target);
|
||||
FuncTrampoline::new(target_machine)
|
||||
},
|
||||
|func_trampoline, sig| {
|
||||
let module = func_trampoline.trampoline_to_module(sig, self.config())?;
|
||||
|func_trampoline, (i, sig)| {
|
||||
let name = symbol_registry.symbol_to_name(Symbol::FunctionCallTrampoline(*i));
|
||||
let module = func_trampoline.trampoline_to_module(sig, self.config(), &name)?;
|
||||
Ok(module.write_bitcode_to_memory().as_slice().to_vec())
|
||||
},
|
||||
)
|
||||
@@ -145,18 +146,24 @@ impl LLVMCompiler {
|
||||
|
||||
compile_info
|
||||
.module
|
||||
.signatures
|
||||
.values()
|
||||
.functions
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>()
|
||||
.par_iter()
|
||||
.map_init(
|
||||
|| {
|
||||
let target_machine = self.config().target_machine(target);
|
||||
FuncTrampoline::new(target_machine)
|
||||
(
|
||||
FuncTrampoline::new(target_machine),
|
||||
&compile_info.module.signatures,
|
||||
)
|
||||
},
|
||||
|func_trampoline, sig| {
|
||||
|(func_trampoline, signatures), (i, sig)| {
|
||||
let sig = &signatures[**sig];
|
||||
let name =
|
||||
symbol_registry.symbol_to_name(Symbol::DynamicFunctionTrampoline(*i));
|
||||
let module =
|
||||
func_trampoline.dynamic_trampoline_to_module(sig, self.config())?;
|
||||
func_trampoline.dynamic_trampoline_to_module(sig, self.config(), &name)?;
|
||||
Ok(module.write_bitcode_to_memory().as_slice().to_vec())
|
||||
},
|
||||
)
|
||||
@@ -337,7 +344,7 @@ impl Compiler for LLVMCompiler {
|
||||
let target_machine = self.config().target_machine(target);
|
||||
FuncTrampoline::new(target_machine)
|
||||
},
|
||||
|func_trampoline, sig| func_trampoline.trampoline(sig, self.config()),
|
||||
|func_trampoline, sig| func_trampoline.trampoline(sig, self.config(), ""),
|
||||
)
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
@@ -353,7 +360,7 @@ impl Compiler for LLVMCompiler {
|
||||
FuncTrampoline::new(target_machine)
|
||||
},
|
||||
|func_trampoline, func_type| {
|
||||
func_trampoline.dynamic_trampoline(&func_type, self.config())
|
||||
func_trampoline.dynamic_trampoline(&func_type, self.config(), "")
|
||||
},
|
||||
)
|
||||
.collect::<Result<Vec<_>, CompileError>>()?
|
||||
|
||||
@@ -39,6 +39,7 @@ impl FuncTrampoline {
|
||||
&self,
|
||||
ty: &FunctionType,
|
||||
config: &LLVM,
|
||||
name: &str,
|
||||
) -> Result<Module, CompileError> {
|
||||
// The function type, used for the callbacks.
|
||||
let function = CompiledFunctionKind::FunctionCallTrampoline(ty.clone());
|
||||
@@ -61,7 +62,7 @@ impl FuncTrampoline {
|
||||
false,
|
||||
);
|
||||
|
||||
let trampoline_func = module.add_function("", trampoline_ty, Some(Linkage::External));
|
||||
let trampoline_func = module.add_function(name, trampoline_ty, Some(Linkage::External));
|
||||
trampoline_func
|
||||
.as_global_value()
|
||||
.set_section(FUNCTION_SECTION);
|
||||
@@ -92,8 +93,9 @@ impl FuncTrampoline {
|
||||
&self,
|
||||
ty: &FunctionType,
|
||||
config: &LLVM,
|
||||
name: &str,
|
||||
) -> Result<FunctionBody, CompileError> {
|
||||
let module = self.trampoline_to_module(ty, config)?;
|
||||
let module = self.trampoline_to_module(ty, config, name)?;
|
||||
let function = CompiledFunctionKind::FunctionCallTrampoline(ty.clone());
|
||||
let target_machine = &self.target_machine;
|
||||
|
||||
@@ -161,6 +163,7 @@ impl FuncTrampoline {
|
||||
&self,
|
||||
ty: &FunctionType,
|
||||
config: &LLVM,
|
||||
name: &str,
|
||||
) -> Result<Module, CompileError> {
|
||||
// The function type, used for the callbacks
|
||||
let function = CompiledFunctionKind::DynamicFunctionTrampoline(ty.clone());
|
||||
@@ -172,7 +175,7 @@ impl FuncTrampoline {
|
||||
let intrinsics = Intrinsics::declare(&module, &self.ctx);
|
||||
|
||||
let (trampoline_ty, trampoline_attrs) = func_type_to_llvm(&self.ctx, &intrinsics, ty)?;
|
||||
let trampoline_func = module.add_function("", trampoline_ty, Some(Linkage::External));
|
||||
let trampoline_func = module.add_function(name, trampoline_ty, Some(Linkage::External));
|
||||
for (attr, attr_loc) in trampoline_attrs {
|
||||
trampoline_func.add_attribute(attr_loc, attr);
|
||||
}
|
||||
@@ -205,11 +208,12 @@ impl FuncTrampoline {
|
||||
&self,
|
||||
ty: &FunctionType,
|
||||
config: &LLVM,
|
||||
name: &str,
|
||||
) -> Result<FunctionBody, CompileError> {
|
||||
let function = CompiledFunctionKind::DynamicFunctionTrampoline(ty.clone());
|
||||
let target_machine = &self.target_machine;
|
||||
|
||||
let module = self.dynamic_trampoline_to_module(ty, config)?;
|
||||
let module = self.dynamic_trampoline_to_module(ty, config, name)?;
|
||||
|
||||
let memory_buffer = target_machine
|
||||
.write_to_memory_buffer(&module, FileType::Object)
|
||||
|
||||
Reference in New Issue
Block a user