mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-16 17:18:57 +00:00
Make compilers use FunctionBody for trampolines
This commit is contained in:
@@ -17,10 +17,9 @@ use wasm_common::{
|
|||||||
Features, FuncIndex, FuncType, LocalFuncIndex, MemoryIndex, SignatureIndex, TableIndex,
|
Features, FuncIndex, FuncType, LocalFuncIndex, MemoryIndex, SignatureIndex, TableIndex,
|
||||||
};
|
};
|
||||||
use wasmer_compiler::CompileError;
|
use wasmer_compiler::CompileError;
|
||||||
use wasmer_compiler::FunctionBodyData;
|
|
||||||
use wasmer_compiler::{
|
use wasmer_compiler::{
|
||||||
Compilation, CompiledFunction, CompiledFunctionFrameInfo, Compiler, FunctionBody, JumpTable,
|
Compilation, CompiledFunction, CompiledFunctionFrameInfo, Compiler, FunctionBody,
|
||||||
SourceLoc, TrapInformation,
|
FunctionBodyData, JumpTable, SourceLoc, TrapInformation,
|
||||||
};
|
};
|
||||||
use wasmer_compiler::{CompilerConfig, ModuleTranslationState, Target};
|
use wasmer_compiler::{CompilerConfig, ModuleTranslationState, Target};
|
||||||
use wasmer_compiler::{Relocation, RelocationTarget};
|
use wasmer_compiler::{Relocation, RelocationTarget};
|
||||||
@@ -277,7 +276,7 @@ impl Compiler for CraneliftCompiler {
|
|||||||
fn compile_wasm_trampolines(
|
fn compile_wasm_trampolines(
|
||||||
&self,
|
&self,
|
||||||
signatures: &[FuncType],
|
signatures: &[FuncType],
|
||||||
) -> Result<Vec<CompiledFunction>, CompileError> {
|
) -> Result<Vec<FunctionBody>, CompileError> {
|
||||||
signatures
|
signatures
|
||||||
.par_iter()
|
.par_iter()
|
||||||
.map_init(FunctionBuilderContext::new, |mut cx, sig| {
|
.map_init(FunctionBuilderContext::new, |mut cx, sig| {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ pub fn make_wasm_trampoline(
|
|||||||
fn_builder_ctx: &mut FunctionBuilderContext,
|
fn_builder_ctx: &mut FunctionBuilderContext,
|
||||||
func_type: &FuncType,
|
func_type: &FuncType,
|
||||||
value_size: usize,
|
value_size: usize,
|
||||||
) -> Result<CompiledFunction, CompileError> {
|
) -> Result<FunctionBody, CompileError> {
|
||||||
let pointer_type = isa.pointer_type();
|
let pointer_type = isa.pointer_type();
|
||||||
let frontend_config = isa.frontend_config();
|
let frontend_config = isa.frontend_config();
|
||||||
let signature = signature_to_cranelift_ir(func_type, &frontend_config);
|
let signature = signature_to_cranelift_ir(func_type, &frontend_config);
|
||||||
@@ -121,13 +121,9 @@ pub fn make_wasm_trampoline(
|
|||||||
|
|
||||||
let unwind_info = compiled_function_unwind_info(isa, &context);
|
let unwind_info = compiled_function_unwind_info(isa, &context);
|
||||||
|
|
||||||
Ok(CompiledFunction {
|
Ok(FunctionBody {
|
||||||
body: FunctionBody {
|
body: code_buf,
|
||||||
body: code_buf,
|
unwind_info,
|
||||||
unwind_info,
|
// jt_offsets: transform_jump_table(context.func.jt_offsets),
|
||||||
},
|
|
||||||
jt_offsets: transform_jump_table(context.func.jt_offsets),
|
|
||||||
relocations: vec![],
|
|
||||||
frame_info: CompiledFunctionFrameInfo::default(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
use crate::config::Target;
|
use crate::config::Target;
|
||||||
use crate::error::CompileError;
|
use crate::error::CompileError;
|
||||||
use crate::function::{Compilation, CompiledFunction};
|
use crate::function::{Compilation, FunctionBody};
|
||||||
use crate::std::vec::Vec;
|
use crate::std::vec::Vec;
|
||||||
use crate::FunctionBodyData;
|
use crate::FunctionBodyData;
|
||||||
use crate::ModuleTranslationState;
|
use crate::ModuleTranslationState;
|
||||||
@@ -66,5 +66,5 @@ pub trait Compiler {
|
|||||||
fn compile_wasm_trampolines(
|
fn compile_wasm_trampolines(
|
||||||
&self,
|
&self,
|
||||||
signatures: &[FuncType],
|
signatures: &[FuncType],
|
||||||
) -> Result<Vec<CompiledFunction>, CompileError>;
|
) -> Result<Vec<FunctionBody>, CompileError>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ use std::sync::Arc;
|
|||||||
use wasm_common::entity::PrimaryMap;
|
use wasm_common::entity::PrimaryMap;
|
||||||
use wasm_common::{FuncType, LocalFuncIndex, MemoryIndex, MemoryType, TableIndex, TableType};
|
use wasm_common::{FuncType, LocalFuncIndex, MemoryIndex, MemoryType, TableIndex, TableType};
|
||||||
use wasmer_compiler::{
|
use wasmer_compiler::{
|
||||||
Compilation, CompileError, Compiler as BaseCompiler, CompilerConfig,
|
Compilation, CompileError, Compiler as BaseCompiler, CompilerConfig, FunctionBody,
|
||||||
FunctionBody, FunctionBodyData, ModuleTranslationState,
|
FunctionBodyData, ModuleTranslationState,
|
||||||
};
|
};
|
||||||
use wasmer_runtime::{
|
use wasmer_runtime::{
|
||||||
InstanceHandle, LinearMemory, MemoryPlan, Module, SignatureRegistry, Table, TablePlan,
|
InstanceHandle, LinearMemory, MemoryPlan, Module, SignatureRegistry, Table, TablePlan,
|
||||||
@@ -208,7 +208,7 @@ impl JITEngineInner {
|
|||||||
{
|
{
|
||||||
let ptr = self
|
let ptr = self
|
||||||
.code_memory
|
.code_memory
|
||||||
.allocate_for_function(&compiled_function.body)
|
.allocate_for_function(&compiled_function)
|
||||||
.map_err(|message| CompileError::Resource(message))?
|
.map_err(|message| CompileError::Resource(message))?
|
||||||
.as_ptr();
|
.as_ptr();
|
||||||
let trampoline =
|
let trampoline =
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use crate::serialize::{SerializedCompilation, SerializedModule};
|
|||||||
use crate::trap::GlobalFrameInfoRegistration;
|
use crate::trap::GlobalFrameInfoRegistration;
|
||||||
use crate::trap::RuntimeError;
|
use crate::trap::RuntimeError;
|
||||||
use crate::trap::{register as register_frame_info, ExtraFunctionInfo};
|
use crate::trap::{register as register_frame_info, ExtraFunctionInfo};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use wasm_common::entity::{BoxedSlice, EntityRef, PrimaryMap};
|
use wasm_common::entity::{BoxedSlice, EntityRef, PrimaryMap};
|
||||||
@@ -20,9 +21,8 @@ use wasm_common::{
|
|||||||
DataInitializer, LocalFuncIndex, LocalGlobalIndex, LocalMemoryIndex, LocalTableIndex,
|
DataInitializer, LocalFuncIndex, LocalGlobalIndex, LocalMemoryIndex, LocalTableIndex,
|
||||||
MemoryIndex, SignatureIndex, TableIndex,
|
MemoryIndex, SignatureIndex, TableIndex,
|
||||||
};
|
};
|
||||||
use serde::{Serialize, Deserialize};
|
|
||||||
use wasmer_compiler::ModuleEnvironment;
|
|
||||||
use wasmer_compiler::CompileError;
|
use wasmer_compiler::CompileError;
|
||||||
|
use wasmer_compiler::ModuleEnvironment;
|
||||||
use wasmer_runtime::{
|
use wasmer_runtime::{
|
||||||
InstanceHandle, LinearMemory, Module, SignatureRegistry, Table, VMFunctionBody,
|
InstanceHandle, LinearMemory, Module, SignatureRegistry, Table, VMFunctionBody,
|
||||||
VMGlobalDefinition, VMSharedSignatureIndex,
|
VMGlobalDefinition, VMSharedSignatureIndex,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use std::path::PathBuf;
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use wasmer::*;
|
use wasmer::*;
|
||||||
#[cfg(feature = "cache")]
|
#[cfg(feature = "cache")]
|
||||||
use wasmer_cache::{Cache, FileSystemCache, WasmHash, IoDeserializeError};
|
use wasmer_cache::{Cache, FileSystemCache, IoDeserializeError, WasmHash};
|
||||||
|
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user