mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-16 17:18:57 +00:00
Renamed Module to ModuleInfo
This commit is contained in:
@@ -10,7 +10,7 @@ use wasmer_compiler::CompileError;
|
||||
#[cfg(feature = "wat")]
|
||||
use wasmer_compiler::WasmError;
|
||||
use wasmer_engine::{CompiledModule, DeserializeError, Resolver, SerializeError};
|
||||
use wasmer_runtime::{ExportsIterator, ImportsIterator, InstanceHandle, Module as ModuleInfo};
|
||||
use wasmer_runtime::{ExportsIterator, ImportsIterator, InstanceHandle, ModuleInfo};
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum IoCompileError {
|
||||
|
||||
@@ -25,7 +25,7 @@ use wasmer_compiler::{
|
||||
FunctionBodyData,
|
||||
};
|
||||
use wasmer_compiler::{CompilerConfig, ModuleTranslationState, Target};
|
||||
use wasmer_runtime::{MemoryPlan, Module, TablePlan};
|
||||
use wasmer_runtime::{MemoryPlan, ModuleInfo, TablePlan};
|
||||
|
||||
/// A compiler that compiles a WebAssembly module with Cranelift, translating the Wasm to Cranelift IR,
|
||||
/// optimizing it and then translating to assembly.
|
||||
@@ -70,7 +70,7 @@ impl Compiler for CraneliftCompiler {
|
||||
/// associated relocations.
|
||||
fn compile_module(
|
||||
&self,
|
||||
module: &Module,
|
||||
module: &ModuleInfo,
|
||||
module_translation: &ModuleTranslationState,
|
||||
function_body_inputs: PrimaryMap<LocalFunctionIndex, FunctionBodyData<'_>>,
|
||||
memory_plans: PrimaryMap<MemoryIndex, MemoryPlan>,
|
||||
@@ -172,7 +172,7 @@ impl Compiler for CraneliftCompiler {
|
||||
|
||||
fn compile_dynamic_function_trampolines(
|
||||
&self,
|
||||
module: &Module,
|
||||
module: &ModuleInfo,
|
||||
) -> Result<PrimaryMap<FunctionIndex, FunctionBody>, CompileError> {
|
||||
use wasmer_runtime::VMOffsets;
|
||||
let isa = self.isa();
|
||||
|
||||
@@ -13,7 +13,7 @@ pub type StackSlots = PrimaryMap<LocalFunctionIndex, ir::StackSlots>;
|
||||
|
||||
/// Memory definition offset in the VMContext structure.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ModuleMemoryOffset {
|
||||
pub enum ModuleInfoMemoryOffset {
|
||||
/// Not available.
|
||||
None,
|
||||
/// Offset to the defined memory.
|
||||
@@ -22,11 +22,11 @@ pub enum ModuleMemoryOffset {
|
||||
Imported(u32),
|
||||
}
|
||||
|
||||
/// Module `vmctx` related info.
|
||||
/// ModuleInfo `vmctx` related info.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ModuleVmctxInfo {
|
||||
pub struct ModuleInfoVmctxInfo {
|
||||
/// The memory definition offset in the VMContext structure.
|
||||
pub memory_offset: ModuleMemoryOffset,
|
||||
pub memory_offset: ModuleInfoMemoryOffset,
|
||||
|
||||
/// The functions stack slots.
|
||||
pub stack_slots: StackSlots,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
mod address_map;
|
||||
mod frame_layout;
|
||||
|
||||
pub use self::address_map::{ModuleMemoryOffset, ModuleVmctxInfo, ValueLabelsRanges};
|
||||
pub use self::address_map::{ModuleInfoMemoryOffset, ModuleInfoVmctxInfo, ValueLabelsRanges};
|
||||
pub use self::frame_layout::{FrameLayout, FrameLayoutChange, FrameLayouts};
|
||||
|
||||
@@ -15,7 +15,7 @@ use wasm_common::{FunctionIndex, GlobalIndex, MemoryIndex, SignatureIndex, Table
|
||||
use wasmer_compiler::{WasmError, WasmResult};
|
||||
use wasmer_runtime::VMBuiltinFunctionIndex;
|
||||
use wasmer_runtime::VMOffsets;
|
||||
use wasmer_runtime::{MemoryPlan, MemoryStyle, Module, TablePlan, TableStyle};
|
||||
use wasmer_runtime::{MemoryPlan, MemoryStyle, ModuleInfo, TablePlan, TableStyle};
|
||||
|
||||
/// Compute an `ir::ExternalName` for a given wasm function index.
|
||||
pub fn get_func_name(func_index: FunctionIndex) -> ir::ExternalName {
|
||||
@@ -32,13 +32,13 @@ pub fn type_of_vmtable_definition_current_elements(vmoffsets: &VMOffsets) -> ir:
|
||||
ir::Type::int(u16::from(vmoffsets.size_of_vmtable_definition_current_elements()) * 8).unwrap()
|
||||
}
|
||||
|
||||
/// The `FuncEnvironment` implementation for use by the `ModuleEnvironment`.
|
||||
/// The `FuncEnvironment` implementation for use by the `ModuleInfoEnvironment`.
|
||||
pub struct FuncEnvironment<'module_environment> {
|
||||
/// Target-specified configuration.
|
||||
target_config: TargetFrontendConfig,
|
||||
|
||||
/// The module-level environment which this function-level environment belongs to.
|
||||
module: &'module_environment Module,
|
||||
module: &'module_environment ModuleInfo,
|
||||
|
||||
/// The module function signatures
|
||||
signatures: &'module_environment PrimaryMap<SignatureIndex, ir::Signature>,
|
||||
@@ -91,7 +91,7 @@ pub struct FuncEnvironment<'module_environment> {
|
||||
impl<'module_environment> FuncEnvironment<'module_environment> {
|
||||
pub fn new(
|
||||
target_config: TargetFrontendConfig,
|
||||
module: &'module_environment Module,
|
||||
module: &'module_environment ModuleInfo,
|
||||
signatures: &'module_environment PrimaryMap<SignatureIndex, ir::Signature>,
|
||||
memory_plans: &'module_environment PrimaryMap<MemoryIndex, MemoryPlan>,
|
||||
table_plans: &'module_environment PrimaryMap<TableIndex, TablePlan>,
|
||||
|
||||
@@ -57,7 +57,7 @@ mod translator;
|
||||
pub use crate::compiler::CraneliftCompiler;
|
||||
pub use crate::config::CraneliftConfig;
|
||||
pub use crate::debug::{FrameLayout, FrameLayoutChange, FrameLayouts};
|
||||
pub use crate::debug::{ModuleMemoryOffset, ModuleVmctxInfo, ValueLabelsRanges};
|
||||
pub use crate::debug::{ModuleInfoMemoryOffset, ModuleInfoVmctxInfo, ValueLabelsRanges};
|
||||
pub use crate::trampoline::make_trampoline_function_call;
|
||||
|
||||
/// Version number of this crate.
|
||||
|
||||
@@ -6,11 +6,11 @@ use cranelift_codegen::ir::{self, ExternalName};
|
||||
use wasm_common::entity::EntityRef;
|
||||
use wasm_common::{FunctionIndex, LocalFunctionIndex};
|
||||
use wasmer_compiler::{JumpTable, Relocation, RelocationTarget, SourceLoc, TrapInformation};
|
||||
use wasmer_runtime::{Module, TrapCode};
|
||||
use wasmer_runtime::{ModuleInfo, TrapCode};
|
||||
|
||||
/// Implementation of a relocation sink that just saves all the information for later
|
||||
pub(crate) struct RelocSink<'a> {
|
||||
module: &'a Module,
|
||||
module: &'a ModuleInfo,
|
||||
|
||||
/// Current function index.
|
||||
local_func_index: LocalFunctionIndex,
|
||||
@@ -81,7 +81,7 @@ impl<'a> binemit::RelocSink for RelocSink<'a> {
|
||||
|
||||
impl<'a> RelocSink<'a> {
|
||||
/// Return a new `RelocSink` instance.
|
||||
pub fn new(module: &'a Module, func_index: FunctionIndex) -> Self {
|
||||
pub fn new(module: &'a ModuleInfo, func_index: FunctionIndex) -> Self {
|
||||
let local_func_index = module
|
||||
.local_func_index(func_index)
|
||||
.expect("The provided function should be local");
|
||||
|
||||
@@ -16,12 +16,12 @@ use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
|
||||
use wasm_common::entity::EntityRef;
|
||||
use wasm_common::SignatureIndex;
|
||||
use wasmer_compiler::{CompileError, FunctionBody};
|
||||
use wasmer_runtime::{Module, VMOffsets};
|
||||
use wasmer_runtime::{ModuleInfo, VMOffsets};
|
||||
|
||||
/// Create a trampoline for invoking a WebAssembly function.
|
||||
pub fn make_trampoline_dynamic_function(
|
||||
isa: &dyn TargetIsa,
|
||||
module: &Module,
|
||||
module: &ModuleInfo,
|
||||
offsets: &VMOffsets,
|
||||
fn_builder_ctx: &mut FunctionBuilderContext,
|
||||
sig_index: &SignatureIndex,
|
||||
|
||||
@@ -14,7 +14,7 @@ use wasmer_compiler::{
|
||||
CustomSectionProtection, FunctionBody, FunctionBodyData, ModuleTranslationState, Relocation,
|
||||
RelocationTarget, SectionBody, SectionIndex, Target, TrapInformation,
|
||||
};
|
||||
use wasmer_runtime::{MemoryPlan, Module, TablePlan, TrapCode};
|
||||
use wasmer_runtime::{MemoryPlan, ModuleInfo, TablePlan, TrapCode};
|
||||
|
||||
use inkwell::targets::{InitializationConfig, Target as InkwellTarget};
|
||||
|
||||
@@ -56,7 +56,7 @@ impl Compiler for LLVMCompiler {
|
||||
/// associated relocations.
|
||||
fn compile_module<'data, 'module>(
|
||||
&self,
|
||||
module: &'module Module,
|
||||
module: &'module ModuleInfo,
|
||||
_module_translation: &ModuleTranslationState,
|
||||
function_body_inputs: PrimaryMap<LocalFunctionIndex, FunctionBodyData<'data>>,
|
||||
memory_plans: PrimaryMap<MemoryIndex, MemoryPlan>,
|
||||
@@ -142,7 +142,7 @@ impl Compiler for LLVMCompiler {
|
||||
|
||||
fn compile_dynamic_function_trampolines(
|
||||
&self,
|
||||
module: &Module,
|
||||
module: &ModuleInfo,
|
||||
) -> Result<PrimaryMap<FunctionIndex, FunctionBody>, CompileError> {
|
||||
Ok(PrimaryMap::new())
|
||||
// unimplemented!("Dynamic function trampolines not yet implemented");
|
||||
|
||||
@@ -10,7 +10,7 @@ use itertools::Itertools;
|
||||
use target_lexicon::Architecture;
|
||||
use wasmer_compiler::{Compiler, CompilerConfig, CpuFeature, Features, Target, Triple};
|
||||
|
||||
/// The InkWell Module type
|
||||
/// The InkWell ModuleInfo type
|
||||
pub type InkwellModule<'ctx> = inkwell::module::Module<'ctx>;
|
||||
|
||||
/// The InkWell MemoryBuffer type
|
||||
|
||||
@@ -47,8 +47,9 @@ use wasmer_compiler::{
|
||||
RelocationKind, RelocationTarget, SectionBody, SectionIndex, SourceLoc, WasmResult,
|
||||
};
|
||||
use wasmer_runtime::libcalls::LibCall;
|
||||
use wasmer_runtime::Module as WasmerCompilerModule;
|
||||
use wasmer_runtime::{MemoryPlan, MemoryStyle, TablePlan, VMBuiltinFunctionIndex, VMOffsets};
|
||||
use wasmer_runtime::{
|
||||
MemoryPlan, MemoryStyle, ModuleInfo, TablePlan, VMBuiltinFunctionIndex, VMOffsets,
|
||||
};
|
||||
|
||||
// TODO: debugging
|
||||
use std::fs;
|
||||
@@ -119,7 +120,7 @@ impl FuncTranslator {
|
||||
|
||||
pub fn translate(
|
||||
&mut self,
|
||||
wasm_module: &WasmerCompilerModule,
|
||||
wasm_module: &ModuleInfo,
|
||||
local_func_index: &LocalFunctionIndex,
|
||||
function_body: &FunctionBodyData,
|
||||
config: &LLVMConfig,
|
||||
@@ -1434,7 +1435,7 @@ pub struct LLVMFunctionCodeGenerator<'ctx, 'a> {
|
||||
*/
|
||||
module: &'a Module<'ctx>,
|
||||
vmoffsets: VMOffsets,
|
||||
wasm_module: &'a WasmerCompilerModule,
|
||||
wasm_module: &'a ModuleInfo,
|
||||
func_names: &'a SecondaryMap<FunctionIndex, String>,
|
||||
}
|
||||
|
||||
@@ -1442,7 +1443,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
|
||||
fn translate_operator(
|
||||
&mut self,
|
||||
op: Operator,
|
||||
module: &WasmerCompilerModule,
|
||||
module: &ModuleInfo,
|
||||
_source_loc: u32,
|
||||
) -> Result<(), CompileError> {
|
||||
// TODO: remove this vmctx by moving everything into CtxType. Values
|
||||
|
||||
@@ -25,7 +25,7 @@ use wasm_common::{
|
||||
FunctionIndex, FunctionType as FuncType, GlobalIndex, MemoryIndex, Mutability, Pages,
|
||||
SignatureIndex, TableIndex, Type,
|
||||
};
|
||||
use wasmer_runtime::Module as WasmerCompilerModule;
|
||||
use wasmer_runtime::ModuleInfo as WasmerCompilerModule;
|
||||
use wasmer_runtime::{MemoryPlan, MemoryStyle, TrapCode, VMOffsets};
|
||||
|
||||
pub fn type_to_llvm_ptr<'ctx>(intrinsics: &Intrinsics<'ctx>, ty: Type) -> PointerType<'ctx> {
|
||||
|
||||
@@ -4,7 +4,7 @@ use byteorder::{LittleEndian, ReadBytesExt};
|
||||
use std::io::{self, Cursor};
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use wasmer_runtime_core::{
|
||||
module::ModuleInfo,
|
||||
module::Module,
|
||||
structures::TypedIndex,
|
||||
types::{GlobalIndex, LocalOrImport, TableIndex},
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
This crate is the base for Compiler implementations.
|
||||
|
||||
It performs the translation from a Wasm module into a basic Module,
|
||||
It performs the translation from a Wasm module into a basic ModuleInfo,
|
||||
but leaves the Wasm function bytecode translation to the compiler implementor.
|
||||
|
||||
### Acknowledgments
|
||||
|
||||
@@ -12,7 +12,7 @@ use wasm_common::entity::PrimaryMap;
|
||||
use wasm_common::{
|
||||
Features, FunctionIndex, FunctionType, LocalFunctionIndex, MemoryIndex, TableIndex,
|
||||
};
|
||||
use wasmer_runtime::Module;
|
||||
use wasmer_runtime::ModuleInfo;
|
||||
use wasmer_runtime::{MemoryPlan, TablePlan};
|
||||
use wasmparser::{validate, OperatorValidatorConfig, ValidatingParserConfig};
|
||||
|
||||
@@ -70,7 +70,7 @@ pub trait Compiler {
|
||||
/// or a `CompileError`.
|
||||
fn compile_module<'data, 'module>(
|
||||
&self,
|
||||
module: &'module Module,
|
||||
module: &'module ModuleInfo,
|
||||
module_translation: &ModuleTranslationState,
|
||||
// The list of function bodies
|
||||
function_body_inputs: PrimaryMap<LocalFunctionIndex, FunctionBodyData<'data>>,
|
||||
@@ -113,6 +113,6 @@ pub trait Compiler {
|
||||
/// ```
|
||||
fn compile_dynamic_function_trampolines(
|
||||
&self,
|
||||
module: &Module,
|
||||
module: &ModuleInfo,
|
||||
) -> Result<PrimaryMap<FunctionIndex, FunctionBody>, CompileError>;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ pub use crate::target::{
|
||||
};
|
||||
#[cfg(feature = "translator")]
|
||||
pub use crate::translator::{
|
||||
to_wasm_error, translate_module, FunctionBodyData, ModuleEnvironment, ModuleTranslation,
|
||||
to_wasm_error, translate_module, FunctionBodyData, ModuleEnvironment, ModuleInfoTranslation,
|
||||
ModuleTranslationState,
|
||||
};
|
||||
pub use crate::trap::TrapInformation;
|
||||
|
||||
@@ -23,7 +23,7 @@ pub enum CustomSectionProtection {
|
||||
/// A custom section with read permissions,
|
||||
Read,
|
||||
// We don't include `ReadWrite` here because it would complicate freeze
|
||||
// and resumption of executing Modules.
|
||||
// and resumption of executing ModuleInfos.
|
||||
// TODO: add `ReadExecute`.
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ impl CpuFeature {
|
||||
}
|
||||
|
||||
/// This is the target that we will use for compiling
|
||||
/// the WebAssembly Module, and then run it.
|
||||
/// the WebAssembly ModuleInfo, and then run it.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct Target {
|
||||
triple: Triple,
|
||||
|
||||
@@ -13,7 +13,7 @@ use wasm_common::{
|
||||
GlobalIndex, GlobalInit, GlobalType, ImportIndex, LocalFunctionIndex, MemoryIndex, MemoryType,
|
||||
SignatureIndex, TableIndex, TableType,
|
||||
};
|
||||
use wasmer_runtime::{Module, TableElements};
|
||||
use wasmer_runtime::{ModuleInfo, TableElements};
|
||||
|
||||
/// Contains function data: bytecode and its offset in the module.
|
||||
#[derive(Hash)]
|
||||
@@ -29,9 +29,9 @@ pub struct FunctionBodyData<'a> {
|
||||
/// yet translated, and data initializers have not yet been copied out of the
|
||||
/// original buffer.
|
||||
/// The function bodies will be translated by a specific compiler backend.
|
||||
pub struct ModuleTranslation<'data> {
|
||||
/// Module information.
|
||||
pub module: Module,
|
||||
pub struct ModuleInfoTranslation<'data> {
|
||||
/// ModuleInfo information.
|
||||
pub module: ModuleInfo,
|
||||
|
||||
/// References to the function bodies.
|
||||
pub function_body_inputs: PrimaryMap<LocalFunctionIndex, FunctionBodyData<'data>>,
|
||||
@@ -46,7 +46,7 @@ pub struct ModuleTranslation<'data> {
|
||||
/// Object containing the standalone environment information.
|
||||
pub struct ModuleEnvironment<'data> {
|
||||
/// The result to be filled in.
|
||||
pub result: ModuleTranslation<'data>,
|
||||
pub result: ModuleInfoTranslation<'data>,
|
||||
imports: u32,
|
||||
}
|
||||
|
||||
@@ -54,8 +54,8 @@ impl<'data> ModuleEnvironment<'data> {
|
||||
/// Allocates the environment data structures.
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
result: ModuleTranslation {
|
||||
module: Module::new(),
|
||||
result: ModuleInfoTranslation {
|
||||
module: ModuleInfo::new(),
|
||||
function_body_inputs: PrimaryMap::new(),
|
||||
data_initializers: Vec::new(),
|
||||
module_translation: None,
|
||||
@@ -65,8 +65,8 @@ impl<'data> ModuleEnvironment<'data> {
|
||||
}
|
||||
|
||||
/// Translate a wasm module using this environment. This consumes the
|
||||
/// `ModuleEnvironment` and produces a `ModuleTranslation`.
|
||||
pub fn translate(mut self, data: &'data [u8]) -> WasmResult<ModuleTranslation<'data>> {
|
||||
/// `ModuleEnvironment` and produces a `ModuleInfoTranslation`.
|
||||
pub fn translate(mut self, data: &'data [u8]) -> WasmResult<ModuleInfoTranslation<'data>> {
|
||||
assert!(self.result.module_translation.is_none());
|
||||
let module_translation = translate_module(data, &mut self)?;
|
||||
self.result.module_translation = Some(module_translation);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! This module defines the parser and translator from wasmparser
|
||||
//! to a common structure `Module`.
|
||||
//! to a common structure `ModuleInfo`.
|
||||
//!
|
||||
//! It's derived from [cranelift-wasm] but architected for multiple
|
||||
//! compilers rather than just Cranelift.
|
||||
@@ -12,7 +12,7 @@ mod state;
|
||||
mod error;
|
||||
mod sections;
|
||||
|
||||
pub use self::environ::{FunctionBodyData, ModuleEnvironment, ModuleTranslation};
|
||||
pub use self::environ::{FunctionBodyData, ModuleEnvironment, ModuleInfoTranslation};
|
||||
pub use self::error::to_wasm_error;
|
||||
pub use self::module::translate_module;
|
||||
pub use self::state::ModuleTranslationState;
|
||||
|
||||
@@ -12,7 +12,7 @@ use crate::WasmResult;
|
||||
use wasmparser::{CustomSectionContent, ModuleReader, SectionContent};
|
||||
|
||||
/// Translate a sequence of bytes forming a valid Wasm binary into a
|
||||
/// parsed Module `ModuleTranslationState`.
|
||||
/// parsed ModuleInfo `ModuleTranslationState`.
|
||||
pub fn translate_module<'data>(
|
||||
data: &'data [u8],
|
||||
environ: &mut ModuleEnvironment<'data>,
|
||||
|
||||
@@ -13,7 +13,8 @@ use wasmer_engine::{
|
||||
SerializeError, Tunables,
|
||||
};
|
||||
use wasmer_runtime::{
|
||||
InstanceHandle, Module, SignatureRegistry, VMFunctionBody, VMSharedSignatureIndex, VMTrampoline,
|
||||
InstanceHandle, ModuleInfo, SignatureRegistry, VMFunctionBody, VMSharedSignatureIndex,
|
||||
VMTrampoline,
|
||||
};
|
||||
|
||||
/// A WebAssembly `JIT` Engine.
|
||||
@@ -212,7 +213,7 @@ impl JITEngineInner {
|
||||
/// Compile the given function bodies.
|
||||
pub(crate) fn allocate(
|
||||
&mut self,
|
||||
module: &Module,
|
||||
module: &ModuleInfo,
|
||||
functions: &PrimaryMap<LocalFunctionIndex, FunctionBody>,
|
||||
function_call_trampolines: &PrimaryMap<SignatureIndex, FunctionBody>,
|
||||
dynamic_function_trampolines: &PrimaryMap<FunctionIndex, FunctionBody>,
|
||||
|
||||
@@ -7,7 +7,7 @@ use wasmer_compiler::{
|
||||
JumpTable, JumpTableOffsets, Relocation, RelocationKind, RelocationTarget, Relocations,
|
||||
SectionBody, SectionIndex,
|
||||
};
|
||||
use wasmer_runtime::Module;
|
||||
use wasmer_runtime::ModuleInfo;
|
||||
use wasmer_runtime::VMFunctionBody;
|
||||
|
||||
fn apply_relocation(
|
||||
@@ -63,7 +63,7 @@ fn apply_relocation(
|
||||
/// Links a module, patching the allocated functions with the
|
||||
/// required relocations and jump tables.
|
||||
pub fn link_module(
|
||||
_module: &Module,
|
||||
_module: &ModuleInfo,
|
||||
allocated_functions: &PrimaryMap<LocalFunctionIndex, *mut [VMFunctionBody]>,
|
||||
jt_offsets: &PrimaryMap<LocalFunctionIndex, JumpTableOffsets>,
|
||||
function_relocations: Relocations,
|
||||
|
||||
@@ -20,7 +20,7 @@ use wasmer_engine::{
|
||||
SerializableFunctionFrameInfo, SerializeError,
|
||||
};
|
||||
use wasmer_runtime::{
|
||||
InstanceHandle, Module, SignatureRegistry, VMFunctionBody, VMSharedSignatureIndex,
|
||||
InstanceHandle, ModuleInfo, SignatureRegistry, VMFunctionBody, VMSharedSignatureIndex,
|
||||
};
|
||||
|
||||
use wasmer_runtime::{MemoryPlan, TablePlan};
|
||||
@@ -297,11 +297,11 @@ impl CompiledModule {
|
||||
}
|
||||
|
||||
impl BaseCompiledModule for CompiledModule {
|
||||
fn module(&self) -> &Module {
|
||||
fn module(&self) -> &ModuleInfo {
|
||||
&self.serializable.module
|
||||
}
|
||||
|
||||
fn module_mut(&mut self) -> &mut Module {
|
||||
fn module_mut(&mut self) -> &mut ModuleInfo {
|
||||
Arc::get_mut(&mut self.serializable.module).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use wasm_common::{
|
||||
};
|
||||
use wasmer_compiler::{FunctionBody, JumpTableOffsets, Relocation, SectionBody, SectionIndex};
|
||||
use wasmer_engine::SerializableFunctionFrameInfo;
|
||||
use wasmer_runtime::Module;
|
||||
use wasmer_runtime::ModuleInfo;
|
||||
use wasmer_runtime::{MemoryPlan, TablePlan};
|
||||
|
||||
/// The compilation related data for a serialized modules
|
||||
@@ -27,12 +27,12 @@ pub struct SerializableCompilation {
|
||||
}
|
||||
|
||||
/// Serializable struct that is able to serialize from and to
|
||||
/// a `CompiledModule`.
|
||||
/// a `CompiledModuleInfo`.
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct SerializableModule {
|
||||
pub compilation: SerializableCompilation,
|
||||
pub features: Features,
|
||||
pub module: Arc<Module>,
|
||||
pub module: Arc<ModuleInfo>,
|
||||
pub data_initializers: Box<[OwnedDataInitializer]>,
|
||||
// Plans for that module
|
||||
pub memory_plans: PrimaryMap<MemoryIndex, MemoryPlan>,
|
||||
|
||||
@@ -25,7 +25,8 @@ use wasmer_engine::{
|
||||
RuntimeError, SerializeError,
|
||||
};
|
||||
use wasmer_runtime::{
|
||||
InstanceHandle, Module, SignatureRegistry, VMFunctionBody, VMSharedSignatureIndex, VMTrampoline,
|
||||
InstanceHandle, ModuleInfo, SignatureRegistry, VMFunctionBody, VMSharedSignatureIndex,
|
||||
VMTrampoline,
|
||||
};
|
||||
use wasmer_runtime::{MemoryPlan, TablePlan};
|
||||
|
||||
@@ -511,11 +512,11 @@ impl NativeModule {
|
||||
}
|
||||
|
||||
impl CompiledModule for NativeModule {
|
||||
fn module(&self) -> &Module {
|
||||
fn module(&self) -> &ModuleInfo {
|
||||
&self.metadata.module
|
||||
}
|
||||
|
||||
fn module_mut(&mut self) -> &mut Module {
|
||||
fn module_mut(&mut self) -> &mut ModuleInfo {
|
||||
Arc::get_mut(&mut self.metadata.module).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@ use serde::{Deserialize, Serialize};
|
||||
use std::sync::Arc;
|
||||
use wasm_common::entity::PrimaryMap;
|
||||
use wasm_common::{Features, LocalFunctionIndex, MemoryIndex, OwnedDataInitializer, TableIndex};
|
||||
use wasmer_runtime::Module;
|
||||
use wasmer_runtime::ModuleInfo;
|
||||
use wasmer_runtime::{MemoryPlan, TablePlan};
|
||||
|
||||
/// Serializable struct that represents the compiled metadata.
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ModuleMetadata {
|
||||
pub features: Features,
|
||||
pub module: Arc<Module>,
|
||||
pub module: Arc<ModuleInfo>,
|
||||
pub prefix: String,
|
||||
pub data_initializers: Box<[OwnedDataInitializer]>,
|
||||
// The function body lengths (used for reverse-locate traps in the function)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use wasmer_runtime::Module;
|
||||
use wasmer_runtime::ModuleInfo;
|
||||
|
||||
use downcast_rs::{impl_downcast, Downcast};
|
||||
|
||||
@@ -6,10 +6,10 @@ use downcast_rs::{impl_downcast, Downcast};
|
||||
/// as a JIT or Native execution.
|
||||
pub trait CompiledModule: Downcast {
|
||||
/// Return a pointer to a module.
|
||||
fn module(&self) -> &Module;
|
||||
fn module(&self) -> &ModuleInfo;
|
||||
|
||||
/// Return a mutable pointer to a module.
|
||||
fn module_mut(&mut self) -> &mut Module;
|
||||
fn module_mut(&mut self) -> &mut ModuleInfo;
|
||||
}
|
||||
|
||||
impl_downcast!(CompiledModule);
|
||||
|
||||
@@ -11,7 +11,7 @@ use wasmer_runtime::{
|
||||
};
|
||||
|
||||
use wasmer_runtime::{MemoryPlan, TablePlan};
|
||||
use wasmer_runtime::{MemoryStyle, Module};
|
||||
use wasmer_runtime::{MemoryStyle, ModuleInfo};
|
||||
|
||||
/// Import resolver connects imports with available exported values.
|
||||
pub trait Resolver {
|
||||
@@ -36,7 +36,7 @@ impl Resolver for NullResolver {
|
||||
}
|
||||
|
||||
/// Get an `ExternType` given a import index.
|
||||
fn get_extern_from_import(module: &Module, import_index: &ImportIndex) -> ExternType {
|
||||
fn get_extern_from_import(module: &ModuleInfo, import_index: &ImportIndex) -> ExternType {
|
||||
match import_index {
|
||||
ImportIndex::Function(index) => {
|
||||
let func = module.signatures[module.functions[*index]].clone();
|
||||
@@ -59,7 +59,7 @@ fn get_extern_from_import(module: &Module, import_index: &ImportIndex) -> Extern
|
||||
|
||||
/// Get an `ExternType` given an export (and signatures in case is a function).
|
||||
fn get_extern_from_export(
|
||||
_module: &Module,
|
||||
_module: &ModuleInfo,
|
||||
signatures: &SignatureRegistry,
|
||||
export: &Export,
|
||||
) -> ExternType {
|
||||
@@ -83,12 +83,12 @@ fn get_extern_from_export(
|
||||
}
|
||||
}
|
||||
|
||||
/// This function allows to match all imports of a `Module` with concrete definitions provided by
|
||||
/// This function allows to match all imports of a `ModuleInfo` with concrete definitions provided by
|
||||
/// a `Resolver`.
|
||||
///
|
||||
/// If all imports are satisfied returns an `Imports` instance required for a module instantiation.
|
||||
pub fn resolve_imports(
|
||||
module: &Module,
|
||||
module: &ModuleInfo,
|
||||
signatures: &SignatureRegistry,
|
||||
resolver: &dyn Resolver,
|
||||
finished_dynamic_function_trampolines: &BoxedSlice<FunctionIndex, *const VMFunctionBody>,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
//! This module is used for having backtraces in the Wasm runtime.
|
||||
//! Once the Compiler has compiled the Module, and we have a set of
|
||||
//! Once the Compiler has compiled the ModuleInfo, and we have a set of
|
||||
//! compiled functions (addresses and function index) and a module,
|
||||
//! then we can use this to set a backtrace for that module.
|
||||
//!
|
||||
//! # Example
|
||||
//! ```ignore
|
||||
//! use wasmer_runtime::{Module, FRAME_INFO};
|
||||
//! use wasmer_runtime::{ModuleInfo, FRAME_INFO};
|
||||
//!
|
||||
//! let module: Module = ...;
|
||||
//! let module: ModuleInfo = ...;
|
||||
//! FRAME_INFO.register(module, compiled_functions);
|
||||
//! ```
|
||||
use crate::serialize::SerializableFunctionFrameInfo;
|
||||
@@ -17,7 +17,7 @@ use std::sync::{Arc, RwLock};
|
||||
use wasm_common::entity::{BoxedSlice, EntityRef, PrimaryMap};
|
||||
use wasm_common::LocalFunctionIndex;
|
||||
use wasmer_compiler::{CompiledFunctionFrameInfo, SourceLoc, TrapInformation};
|
||||
use wasmer_runtime::{Module, VMFunctionBody};
|
||||
use wasmer_runtime::{ModuleInfo, VMFunctionBody};
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
/// This is a global cache of backtrace frame information for all active
|
||||
@@ -39,7 +39,7 @@ pub struct GlobalFrameInfo {
|
||||
///
|
||||
/// The key of this map is the highest address in the module and the value
|
||||
/// is the module's information, which also contains the start address.
|
||||
ranges: BTreeMap<usize, ModuleFrameInfo>,
|
||||
ranges: BTreeMap<usize, ModuleInfoFrameInfo>,
|
||||
}
|
||||
|
||||
/// An RAII structure used to unregister a module's frame information when the
|
||||
@@ -50,14 +50,14 @@ pub struct GlobalFrameInfoRegistration {
|
||||
key: usize,
|
||||
}
|
||||
|
||||
struct ModuleFrameInfo {
|
||||
struct ModuleInfoFrameInfo {
|
||||
start: usize,
|
||||
functions: BTreeMap<usize, FunctionInfo>,
|
||||
module: Arc<Module>,
|
||||
module: Arc<ModuleInfo>,
|
||||
frame_infos: PrimaryMap<LocalFunctionIndex, SerializableFunctionFrameInfo>,
|
||||
}
|
||||
|
||||
impl ModuleFrameInfo {
|
||||
impl ModuleInfoFrameInfo {
|
||||
fn function_debug_info(
|
||||
&self,
|
||||
local_index: LocalFunctionIndex,
|
||||
@@ -193,7 +193,7 @@ impl GlobalFrameInfo {
|
||||
}
|
||||
|
||||
/// Gets a module given a pc
|
||||
fn module_info(&self, pc: usize) -> Option<&ModuleFrameInfo> {
|
||||
fn module_info(&self, pc: usize) -> Option<&ModuleInfoFrameInfo> {
|
||||
let (end, module_info) = self.ranges.range(pc..).next()?;
|
||||
if pc < module_info.start || *end < pc {
|
||||
return None;
|
||||
@@ -202,7 +202,7 @@ impl GlobalFrameInfo {
|
||||
}
|
||||
|
||||
/// Gets a module given a pc
|
||||
fn module_info_mut(&mut self, pc: usize) -> Option<&mut ModuleFrameInfo> {
|
||||
fn module_info_mut(&mut self, pc: usize) -> Option<&mut ModuleInfoFrameInfo> {
|
||||
let (end, module_info) = self.ranges.range_mut(pc..).next()?;
|
||||
if pc < module_info.start || *end < pc {
|
||||
return None;
|
||||
@@ -226,7 +226,7 @@ impl Drop for GlobalFrameInfoRegistration {
|
||||
/// then `None` will be returned. Otherwise the returned object, when
|
||||
/// dropped, will be used to unregister all name information from this map.
|
||||
pub fn register(
|
||||
module: Arc<Module>,
|
||||
module: Arc<ModuleInfo>,
|
||||
finished_functions: &BoxedSlice<LocalFunctionIndex, *mut [VMFunctionBody]>,
|
||||
frame_infos: PrimaryMap<LocalFunctionIndex, SerializableFunctionFrameInfo>,
|
||||
) -> Option<GlobalFrameInfoRegistration> {
|
||||
@@ -264,7 +264,7 @@ pub fn register(
|
||||
// ... then insert our range and assert nothing was there previously
|
||||
let prev = info.ranges.insert(
|
||||
max,
|
||||
ModuleFrameInfo {
|
||||
ModuleInfoFrameInfo {
|
||||
start: min,
|
||||
functions,
|
||||
module,
|
||||
@@ -302,9 +302,9 @@ impl FrameInfo {
|
||||
|
||||
/// Returns the identifer of the module that this frame is for.
|
||||
///
|
||||
/// Module identifiers are present in the `name` section of a WebAssembly
|
||||
/// ModuleInfo identifiers are present in the `name` section of a WebAssembly
|
||||
/// binary, but this may not return the exact item in the `name` section.
|
||||
/// Module names can be overwritten at construction time or perhaps inferred
|
||||
/// ModuleInfo names can be overwritten at construction time or perhaps inferred
|
||||
/// from file names. The primary purpose of this function is to assist in
|
||||
/// debugging and therefore may be tweaked over time.
|
||||
///
|
||||
|
||||
@@ -5,7 +5,7 @@ use wasm_common::{
|
||||
TableType,
|
||||
};
|
||||
use wasmer_runtime::MemoryError;
|
||||
use wasmer_runtime::{LinearMemory, Module, Table, VMGlobalDefinition};
|
||||
use wasmer_runtime::{LinearMemory, ModuleInfo, Table, VMGlobalDefinition};
|
||||
use wasmer_runtime::{MemoryPlan, TablePlan};
|
||||
|
||||
/// Tunables for an engine
|
||||
@@ -25,7 +25,7 @@ pub trait Tunables {
|
||||
/// Allocate memory for just the memories of the current module.
|
||||
fn create_memories(
|
||||
&self,
|
||||
module: &Module,
|
||||
module: &ModuleInfo,
|
||||
memory_plans: &PrimaryMap<MemoryIndex, MemoryPlan>,
|
||||
) -> Result<PrimaryMap<LocalMemoryIndex, LinearMemory>, LinkError> {
|
||||
let num_imports = module.num_imported_memories;
|
||||
@@ -44,7 +44,7 @@ pub trait Tunables {
|
||||
/// Allocate memory for just the tables of the current module.
|
||||
fn create_tables(
|
||||
&self,
|
||||
module: &Module,
|
||||
module: &ModuleInfo,
|
||||
table_plans: &PrimaryMap<TableIndex, TablePlan>,
|
||||
) -> Result<PrimaryMap<LocalTableIndex, Table>, LinkError> {
|
||||
let num_imports = module.num_imported_tables;
|
||||
@@ -61,7 +61,7 @@ pub trait Tunables {
|
||||
/// with initializers applied.
|
||||
fn create_globals(
|
||||
&self,
|
||||
module: &Module,
|
||||
module: &ModuleInfo,
|
||||
) -> Result<PrimaryMap<LocalGlobalIndex, VMGlobalDefinition>, LinkError> {
|
||||
let num_imports = module.num_imported_globals;
|
||||
let mut vmctx_globals = PrimaryMap::with_capacity(module.globals.len() - num_imports);
|
||||
|
||||
@@ -12,7 +12,7 @@ use crate::vmcontext::{
|
||||
VMSharedSignatureIndex, VMTableDefinition, VMTableImport,
|
||||
};
|
||||
use crate::{ExportFunction, ExportGlobal, ExportMemory, ExportTable};
|
||||
use crate::{Module, TableElements, VMOffsets};
|
||||
use crate::{ModuleInfo, TableElements, VMOffsets};
|
||||
use memoffset::offset_of;
|
||||
use more_asserts::assert_lt;
|
||||
use std::alloc::{self, Layout};
|
||||
@@ -62,8 +62,8 @@ cfg_if::cfg_if! {
|
||||
/// This is repr(C) to ensure that the vmctx field is last.
|
||||
#[repr(C)]
|
||||
pub(crate) struct Instance {
|
||||
/// The `Module` this `Instance` was instantiated from.
|
||||
module: Arc<Module>,
|
||||
/// The `ModuleInfo` this `Instance` was instantiated from.
|
||||
module: Arc<ModuleInfo>,
|
||||
|
||||
/// Offsets in the `vmctx` region.
|
||||
offsets: VMOffsets,
|
||||
@@ -114,11 +114,11 @@ impl Instance {
|
||||
unsafe { *self.signature_ids_ptr().add(index) }
|
||||
}
|
||||
|
||||
pub(crate) fn module(&self) -> &Arc<Module> {
|
||||
pub(crate) fn module(&self) -> &Arc<ModuleInfo> {
|
||||
&self.module
|
||||
}
|
||||
|
||||
pub(crate) fn module_ref(&self) -> &Module {
|
||||
pub(crate) fn module_ref(&self) -> &ModuleInfo {
|
||||
&*self.module
|
||||
}
|
||||
|
||||
@@ -779,7 +779,7 @@ impl InstanceHandle {
|
||||
/// the `wasmer` crate API rather than this type since that is vetted for
|
||||
/// safety.
|
||||
pub unsafe fn new(
|
||||
module: Arc<Module>,
|
||||
module: Arc<ModuleInfo>,
|
||||
finished_functions: BoxedSlice<LocalFunctionIndex, *mut [VMFunctionBody]>,
|
||||
finished_memories: BoxedSlice<LocalMemoryIndex, LinearMemory>,
|
||||
finished_tables: BoxedSlice<LocalTableIndex, Table>,
|
||||
@@ -939,12 +939,12 @@ impl InstanceHandle {
|
||||
}
|
||||
|
||||
/// Return a reference-counting pointer to a module.
|
||||
pub fn module(&self) -> &Arc<Module> {
|
||||
pub fn module(&self) -> &Arc<ModuleInfo> {
|
||||
self.instance().module()
|
||||
}
|
||||
|
||||
/// Return a reference to a module.
|
||||
pub fn module_ref(&self) -> &Module {
|
||||
pub fn module_ref(&self) -> &ModuleInfo {
|
||||
self.instance().module_ref()
|
||||
}
|
||||
|
||||
@@ -1180,7 +1180,7 @@ fn initialize_tables(instance: &Instance) -> Result<(), Trap> {
|
||||
}
|
||||
|
||||
/// Initialize the `Instance::passive_elements` map by resolving the
|
||||
/// `Module::passive_elements`'s `FunctionIndex`s into `VMCallerCheckedAnyfunc`s for
|
||||
/// `ModuleInfo::passive_elements`'s `FunctionIndex`s into `VMCallerCheckedAnyfunc`s for
|
||||
/// this instance.
|
||||
fn initialize_passive_elements(instance: &Instance) {
|
||||
let mut passive_elements = instance.passive_elements.borrow_mut();
|
||||
|
||||
@@ -42,8 +42,8 @@ pub use crate::instance::InstanceHandle;
|
||||
pub use crate::memory::{LinearMemory, MemoryError};
|
||||
pub use crate::mmap::Mmap;
|
||||
pub use crate::module::{
|
||||
ExportsIterator, ImportsIterator, MemoryPlan, MemoryStyle, Module, TableElements, TablePlan,
|
||||
TableStyle,
|
||||
ExportsIterator, ImportsIterator, MemoryPlan, MemoryStyle, ModuleInfo, TableElements,
|
||||
TablePlan, TableStyle,
|
||||
};
|
||||
pub use crate::probestack::PROBESTACK;
|
||||
pub use crate::sig_registry::SignatureRegistry;
|
||||
|
||||
@@ -93,7 +93,7 @@ impl Default for ModuleId {
|
||||
/// A translated WebAssembly module, excluding the function bodies and
|
||||
/// memory initializers.
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Module {
|
||||
pub struct ModuleInfo {
|
||||
/// A unique identifier (within this process) for this module.
|
||||
///
|
||||
/// We skip serialization/deserialization of this field, as it
|
||||
@@ -160,7 +160,7 @@ pub struct Module {
|
||||
pub num_imported_globals: usize,
|
||||
}
|
||||
|
||||
impl Module {
|
||||
impl ModuleInfo {
|
||||
/// Allocates the module data structures.
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
@@ -353,7 +353,7 @@ impl Module {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Module {
|
||||
impl fmt::Display for ModuleInfo {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self.name())
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@ pub struct VMFunctionImport {
|
||||
#[cfg(test)]
|
||||
mod test_vmfunction_import {
|
||||
use super::VMFunctionImport;
|
||||
use crate::{Module, VMOffsets};
|
||||
use crate::{ModuleInfo, VMOffsets};
|
||||
use memoffset::offset_of;
|
||||
use std::mem::size_of;
|
||||
|
||||
#[test]
|
||||
fn check_vmfunction_import_offsets() {
|
||||
let module = Module::new();
|
||||
let module = ModuleInfo::new();
|
||||
let offsets = VMOffsets::new(size_of::<*mut u8>() as u8, &module);
|
||||
assert_eq!(
|
||||
size_of::<VMFunctionImport>(),
|
||||
@@ -69,13 +69,13 @@ pub struct VMDynamicFunctionImportContext<T: Sized> {
|
||||
#[cfg(test)]
|
||||
mod test_vmdynamicfunction_import_context {
|
||||
use super::VMDynamicFunctionImportContext;
|
||||
use crate::{Module, VMOffsets};
|
||||
use crate::{ModuleInfo, VMOffsets};
|
||||
use memoffset::offset_of;
|
||||
use std::mem::size_of;
|
||||
|
||||
#[test]
|
||||
fn check_vmdynamicfunction_import_context_offsets() {
|
||||
let module = Module::new();
|
||||
let module = ModuleInfo::new();
|
||||
let offsets = VMOffsets::new(size_of::<*mut u8>() as u8, &module);
|
||||
assert_eq!(
|
||||
size_of::<VMDynamicFunctionImportContext<usize>>(),
|
||||
@@ -145,13 +145,13 @@ pub struct VMTableImport {
|
||||
#[cfg(test)]
|
||||
mod test_vmtable_import {
|
||||
use super::VMTableImport;
|
||||
use crate::{Module, VMOffsets};
|
||||
use crate::{ModuleInfo, VMOffsets};
|
||||
use memoffset::offset_of;
|
||||
use std::mem::size_of;
|
||||
|
||||
#[test]
|
||||
fn check_vmtable_import_offsets() {
|
||||
let module = Module::new();
|
||||
let module = ModuleInfo::new();
|
||||
let offsets = VMOffsets::new(size_of::<*mut u8>() as u8, &module);
|
||||
assert_eq!(
|
||||
size_of::<VMTableImport>(),
|
||||
@@ -183,13 +183,13 @@ pub struct VMMemoryImport {
|
||||
#[cfg(test)]
|
||||
mod test_vmmemory_import {
|
||||
use super::VMMemoryImport;
|
||||
use crate::{Module, VMOffsets};
|
||||
use crate::{ModuleInfo, VMOffsets};
|
||||
use memoffset::offset_of;
|
||||
use std::mem::size_of;
|
||||
|
||||
#[test]
|
||||
fn check_vmmemory_import_offsets() {
|
||||
let module = Module::new();
|
||||
let module = ModuleInfo::new();
|
||||
let offsets = VMOffsets::new(size_of::<*mut u8>() as u8, &module);
|
||||
assert_eq!(
|
||||
size_of::<VMMemoryImport>(),
|
||||
@@ -218,13 +218,13 @@ pub struct VMGlobalImport {
|
||||
#[cfg(test)]
|
||||
mod test_vmglobal_import {
|
||||
use super::VMGlobalImport;
|
||||
use crate::{Module, VMOffsets};
|
||||
use crate::{ModuleInfo, VMOffsets};
|
||||
use memoffset::offset_of;
|
||||
use std::mem::size_of;
|
||||
|
||||
#[test]
|
||||
fn check_vmglobal_import_offsets() {
|
||||
let module = Module::new();
|
||||
let module = ModuleInfo::new();
|
||||
let offsets = VMOffsets::new(size_of::<*mut u8>() as u8, &module);
|
||||
assert_eq!(
|
||||
size_of::<VMGlobalImport>(),
|
||||
@@ -313,13 +313,13 @@ impl VMMemoryDefinition {
|
||||
#[cfg(test)]
|
||||
mod test_vmmemory_definition {
|
||||
use super::VMMemoryDefinition;
|
||||
use crate::{Module, VMOffsets};
|
||||
use crate::{ModuleInfo, VMOffsets};
|
||||
use memoffset::offset_of;
|
||||
use std::mem::size_of;
|
||||
|
||||
#[test]
|
||||
fn check_vmmemory_definition_offsets() {
|
||||
let module = Module::new();
|
||||
let module = ModuleInfo::new();
|
||||
let offsets = VMOffsets::new(size_of::<*mut u8>() as u8, &module);
|
||||
assert_eq!(
|
||||
size_of::<VMMemoryDefinition>(),
|
||||
@@ -357,13 +357,13 @@ pub struct VMTableDefinition {
|
||||
#[cfg(test)]
|
||||
mod test_vmtable_definition {
|
||||
use super::VMTableDefinition;
|
||||
use crate::{Module, VMOffsets};
|
||||
use crate::{ModuleInfo, VMOffsets};
|
||||
use memoffset::offset_of;
|
||||
use std::mem::size_of;
|
||||
|
||||
#[test]
|
||||
fn check_vmtable_definition_offsets() {
|
||||
let module = Module::new();
|
||||
let module = ModuleInfo::new();
|
||||
let offsets = VMOffsets::new(size_of::<*mut u8>() as u8, &module);
|
||||
assert_eq!(
|
||||
size_of::<VMTableDefinition>(),
|
||||
@@ -395,7 +395,7 @@ pub struct VMGlobalDefinition {
|
||||
#[cfg(test)]
|
||||
mod test_vmglobal_definition {
|
||||
use super::VMGlobalDefinition;
|
||||
use crate::{Module, VMOffsets};
|
||||
use crate::{ModuleInfo, VMOffsets};
|
||||
use more_asserts::assert_ge;
|
||||
use std::mem::{align_of, size_of};
|
||||
|
||||
@@ -410,7 +410,7 @@ mod test_vmglobal_definition {
|
||||
|
||||
#[test]
|
||||
fn check_vmglobal_definition_offsets() {
|
||||
let module = Module::new();
|
||||
let module = ModuleInfo::new();
|
||||
let offsets = VMOffsets::new(size_of::<*mut u8>() as u8, &module);
|
||||
assert_eq!(
|
||||
size_of::<VMGlobalDefinition>(),
|
||||
@@ -420,7 +420,7 @@ mod test_vmglobal_definition {
|
||||
|
||||
#[test]
|
||||
fn check_vmglobal_begins_aligned() {
|
||||
let module = Module::new();
|
||||
let module = ModuleInfo::new();
|
||||
let offsets = VMOffsets::new(size_of::<*mut u8>() as u8, &module);
|
||||
assert_eq!(offsets.vmctx_globals_begin() % 16, 0);
|
||||
}
|
||||
@@ -562,13 +562,13 @@ pub struct VMSharedSignatureIndex(u32);
|
||||
#[cfg(test)]
|
||||
mod test_vmshared_signature_index {
|
||||
use super::VMSharedSignatureIndex;
|
||||
use crate::module::Module;
|
||||
use crate::module::ModuleInfo;
|
||||
use crate::vmoffsets::{TargetSharedSignatureIndex, VMOffsets};
|
||||
use std::mem::size_of;
|
||||
|
||||
#[test]
|
||||
fn check_vmshared_signature_index() {
|
||||
let module = Module::new();
|
||||
let module = ModuleInfo::new();
|
||||
let offsets = VMOffsets::new(size_of::<*mut u8>() as u8, &module);
|
||||
assert_eq!(
|
||||
size_of::<VMSharedSignatureIndex>(),
|
||||
@@ -616,13 +616,13 @@ pub struct VMCallerCheckedAnyfunc {
|
||||
#[cfg(test)]
|
||||
mod test_vmcaller_checked_anyfunc {
|
||||
use super::VMCallerCheckedAnyfunc;
|
||||
use crate::{Module, VMOffsets};
|
||||
use crate::{ModuleInfo, VMOffsets};
|
||||
use memoffset::offset_of;
|
||||
use std::mem::size_of;
|
||||
|
||||
#[test]
|
||||
fn check_vmcaller_checked_anyfunc_offsets() {
|
||||
let module = Module::new();
|
||||
let module = ModuleInfo::new();
|
||||
let offsets = VMOffsets::new(size_of::<*mut u8>() as u8, &module);
|
||||
assert_eq!(
|
||||
size_of::<VMCallerCheckedAnyfunc>(),
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#![deny(intra_doc_link_resolution_failure)]
|
||||
|
||||
use crate::module::Module;
|
||||
use crate::module::ModuleInfo;
|
||||
use crate::VMBuiltinFunctionIndex;
|
||||
use more_asserts::assert_lt;
|
||||
use std::convert::TryFrom;
|
||||
@@ -53,7 +53,7 @@ pub struct VMOffsets {
|
||||
|
||||
impl VMOffsets {
|
||||
/// Return a new `VMOffsets` instance, for a given pointer size.
|
||||
pub fn new(pointer_size: u8, module: &Module) -> Self {
|
||||
pub fn new(pointer_size: u8, module: &ModuleInfo) -> Self {
|
||||
Self {
|
||||
pointer_size,
|
||||
num_signature_ids: cast_to_u32(module.signatures.len()),
|
||||
|
||||
Reference in New Issue
Block a user