Update to Rust 2018 Edition.
This commit is contained in:
@@ -7,6 +7,7 @@ license = "Apache-2.0 WITH LLVM-exception"
|
|||||||
documentation = "https://cranelift.readthedocs.io/"
|
documentation = "https://cranelift.readthedocs.io/"
|
||||||
categories = ["wasm"]
|
categories = ["wasm"]
|
||||||
repository = "https://github.com/CraneStation/wasmtime"
|
repository = "https://github.com/CraneStation/wasmtime"
|
||||||
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
name = "wasmtime-fuzz"
|
name = "wasmtime-fuzz"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
authors = ["The Wasmtime Project Developers"]
|
authors = ["The Wasmtime Project Developers"]
|
||||||
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[package.metadata]
|
[package.metadata]
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ documentation = "https://docs.rs/wasmtime-environ/"
|
|||||||
categories = ["wasm"]
|
categories = ["wasm"]
|
||||||
license = "Apache-2.0 WITH LLVM-exception"
|
license = "Apache-2.0 WITH LLVM-exception"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cranelift-codegen = "0.26.0"
|
cranelift-codegen = "0.26.0"
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
//! Support for compiling with Cranelift.
|
//! Support for compiling with Cranelift.
|
||||||
|
|
||||||
use compilation::{Compilation, CompileError, Relocation, RelocationTarget, Relocations};
|
use crate::compilation::{Compilation, CompileError, Relocation, RelocationTarget, Relocations};
|
||||||
|
use crate::func_environ::{
|
||||||
|
get_func_name, get_imported_memory32_grow_name, get_imported_memory32_size_name,
|
||||||
|
get_memory32_grow_name, get_memory32_size_name, FuncEnvironment,
|
||||||
|
};
|
||||||
|
use crate::module::Module;
|
||||||
use cranelift_codegen::binemit;
|
use cranelift_codegen::binemit;
|
||||||
use cranelift_codegen::ir;
|
use cranelift_codegen::ir;
|
||||||
use cranelift_codegen::ir::ExternalName;
|
use cranelift_codegen::ir::ExternalName;
|
||||||
@@ -8,11 +13,6 @@ use cranelift_codegen::isa;
|
|||||||
use cranelift_codegen::Context;
|
use cranelift_codegen::Context;
|
||||||
use cranelift_entity::PrimaryMap;
|
use cranelift_entity::PrimaryMap;
|
||||||
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, FuncTranslator};
|
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, FuncTranslator};
|
||||||
use func_environ::{
|
|
||||||
get_func_name, get_imported_memory32_grow_name, get_imported_memory32_size_name,
|
|
||||||
get_memory32_grow_name, get_memory32_size_name, FuncEnvironment,
|
|
||||||
};
|
|
||||||
use module::Module;
|
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
|
|
||||||
/// Implementation of a relocation sink that just saves all the information for later
|
/// Implementation of a relocation sink that just saves all the information for later
|
||||||
@@ -85,7 +85,7 @@ impl RelocSink {
|
|||||||
pub fn compile_module<'data, 'module>(
|
pub fn compile_module<'data, 'module>(
|
||||||
module: &'module Module,
|
module: &'module Module,
|
||||||
function_body_inputs: PrimaryMap<DefinedFuncIndex, &'data [u8]>,
|
function_body_inputs: PrimaryMap<DefinedFuncIndex, &'data [u8]>,
|
||||||
isa: &isa::TargetIsa,
|
isa: &dyn isa::TargetIsa,
|
||||||
) -> Result<(Compilation, Relocations), CompileError> {
|
) -> Result<(Compilation, Relocations), CompileError> {
|
||||||
let mut functions = PrimaryMap::new();
|
let mut functions = PrimaryMap::new();
|
||||||
let mut relocations = PrimaryMap::new();
|
let mut relocations = PrimaryMap::new();
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
use crate::module::{MemoryPlan, MemoryStyle, Module, TableStyle};
|
||||||
|
use crate::vmoffsets::VMOffsets;
|
||||||
|
use crate::WASM_PAGE_SIZE;
|
||||||
use cast;
|
use cast;
|
||||||
use cranelift_codegen::cursor::FuncCursor;
|
use cranelift_codegen::cursor::FuncCursor;
|
||||||
use cranelift_codegen::ir;
|
use cranelift_codegen::ir;
|
||||||
@@ -13,11 +16,8 @@ use cranelift_wasm::{
|
|||||||
self, FuncIndex, GlobalIndex, GlobalVariable, MemoryIndex, SignatureIndex, TableIndex,
|
self, FuncIndex, GlobalIndex, GlobalVariable, MemoryIndex, SignatureIndex, TableIndex,
|
||||||
WasmResult,
|
WasmResult,
|
||||||
};
|
};
|
||||||
use module::{MemoryPlan, MemoryStyle, Module, TableStyle};
|
|
||||||
use std::clone::Clone;
|
use std::clone::Clone;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
use vmoffsets::VMOffsets;
|
|
||||||
use WASM_PAGE_SIZE;
|
|
||||||
|
|
||||||
/// Compute an `ir::ExternalName` for a given wasm function index.
|
/// Compute an `ir::ExternalName` for a given wasm function index.
|
||||||
pub fn get_func_name(func_index: FuncIndex) -> ir::ExternalName {
|
pub fn get_func_name(func_index: FuncIndex) -> ir::ExternalName {
|
||||||
@@ -394,7 +394,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
|
|||||||
|
|
||||||
fn translate_call_indirect(
|
fn translate_call_indirect(
|
||||||
&mut self,
|
&mut self,
|
||||||
mut pos: FuncCursor,
|
mut pos: FuncCursor<'_>,
|
||||||
table_index: TableIndex,
|
table_index: TableIndex,
|
||||||
table: ir::Table,
|
table: ir::Table,
|
||||||
sig_index: SignatureIndex,
|
sig_index: SignatureIndex,
|
||||||
@@ -462,7 +462,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
|
|||||||
|
|
||||||
fn translate_call(
|
fn translate_call(
|
||||||
&mut self,
|
&mut self,
|
||||||
mut pos: FuncCursor,
|
mut pos: FuncCursor<'_>,
|
||||||
callee_index: FuncIndex,
|
callee_index: FuncIndex,
|
||||||
callee: ir::FuncRef,
|
callee: ir::FuncRef,
|
||||||
call_args: &[ir::Value],
|
call_args: &[ir::Value],
|
||||||
@@ -501,7 +501,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
|
|||||||
|
|
||||||
fn translate_memory_grow(
|
fn translate_memory_grow(
|
||||||
&mut self,
|
&mut self,
|
||||||
mut pos: FuncCursor,
|
mut pos: FuncCursor<'_>,
|
||||||
index: MemoryIndex,
|
index: MemoryIndex,
|
||||||
_heap: ir::Heap,
|
_heap: ir::Heap,
|
||||||
val: ir::Value,
|
val: ir::Value,
|
||||||
@@ -517,7 +517,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
|
|||||||
|
|
||||||
fn translate_memory_size(
|
fn translate_memory_size(
|
||||||
&mut self,
|
&mut self,
|
||||||
mut pos: FuncCursor,
|
mut pos: FuncCursor<'_>,
|
||||||
index: MemoryIndex,
|
index: MemoryIndex,
|
||||||
_heap: ir::Heap,
|
_heap: ir::Heap,
|
||||||
) -> WasmResult<ir::Value> {
|
) -> WasmResult<ir::Value> {
|
||||||
|
|||||||
@@ -27,14 +27,12 @@
|
|||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
||||||
|
|
||||||
extern crate cranelift_codegen;
|
use cranelift_wasm;
|
||||||
extern crate cranelift_entity;
|
|
||||||
extern crate cranelift_wasm;
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
extern crate cast;
|
use cast;
|
||||||
extern crate failure;
|
use failure;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate failure_derive;
|
extern crate failure_derive;
|
||||||
|
|
||||||
@@ -47,14 +45,18 @@ mod vmoffsets;
|
|||||||
|
|
||||||
pub mod cranelift;
|
pub mod cranelift;
|
||||||
|
|
||||||
pub use compilation::{Compilation, CompileError, Relocation, RelocationTarget, Relocations};
|
pub use crate::compilation::{
|
||||||
pub use module::{Export, MemoryPlan, MemoryStyle, Module, TableElements, TablePlan, TableStyle};
|
Compilation, CompileError, Relocation, RelocationTarget, Relocations,
|
||||||
pub use module_environ::{
|
};
|
||||||
|
pub use crate::module::{
|
||||||
|
Export, MemoryPlan, MemoryStyle, Module, TableElements, TablePlan, TableStyle,
|
||||||
|
};
|
||||||
|
pub use crate::module_environ::{
|
||||||
translate_signature, DataInitializer, DataInitializerLocation, ModuleEnvironment,
|
translate_signature, DataInitializer, DataInitializerLocation, ModuleEnvironment,
|
||||||
ModuleTranslation,
|
ModuleTranslation,
|
||||||
};
|
};
|
||||||
pub use tunables::Tunables;
|
pub use crate::tunables::Tunables;
|
||||||
pub use vmoffsets::VMOffsets;
|
pub use crate::vmoffsets::VMOffsets;
|
||||||
|
|
||||||
/// WebAssembly page sizes are defined to be 64KiB.
|
/// WebAssembly page sizes are defined to be 64KiB.
|
||||||
pub const WASM_PAGE_SIZE: u32 = 0x10000;
|
pub const WASM_PAGE_SIZE: u32 = 0x10000;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
//! Data structures for representing decoded wasm modules.
|
//! Data structures for representing decoded wasm modules.
|
||||||
|
|
||||||
|
use crate::tunables::Tunables;
|
||||||
use cranelift_codegen::ir;
|
use cranelift_codegen::ir;
|
||||||
use cranelift_entity::{EntityRef, PrimaryMap};
|
use cranelift_entity::{EntityRef, PrimaryMap};
|
||||||
use cranelift_wasm::{
|
use cranelift_wasm::{
|
||||||
@@ -9,7 +10,6 @@ use cranelift_wasm::{
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
use tunables::Tunables;
|
|
||||||
|
|
||||||
/// A WebAssembly table initializer.
|
/// A WebAssembly table initializer.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
use crate::func_environ::FuncEnvironment;
|
||||||
|
use crate::module::{Export, MemoryPlan, Module, TableElements, TablePlan};
|
||||||
|
use crate::tunables::Tunables;
|
||||||
use cranelift_codegen::ir;
|
use cranelift_codegen::ir;
|
||||||
use cranelift_codegen::ir::{AbiParam, ArgumentPurpose};
|
use cranelift_codegen::ir::{AbiParam, ArgumentPurpose};
|
||||||
use cranelift_codegen::isa::TargetFrontendConfig;
|
use cranelift_codegen::isa::TargetFrontendConfig;
|
||||||
@@ -6,12 +9,9 @@ use cranelift_wasm::{
|
|||||||
self, translate_module, DefinedFuncIndex, FuncIndex, Global, GlobalIndex, Memory, MemoryIndex,
|
self, translate_module, DefinedFuncIndex, FuncIndex, Global, GlobalIndex, Memory, MemoryIndex,
|
||||||
SignatureIndex, Table, TableIndex, WasmResult,
|
SignatureIndex, Table, TableIndex, WasmResult,
|
||||||
};
|
};
|
||||||
use func_environ::FuncEnvironment;
|
|
||||||
use module::{Export, MemoryPlan, Module, TableElements, TablePlan};
|
|
||||||
use std::clone::Clone;
|
use std::clone::Clone;
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
use tunables::Tunables;
|
|
||||||
|
|
||||||
/// The result of translating via `ModuleEnvironment`. Function bodies are not
|
/// The result of translating via `ModuleEnvironment`. Function bodies are not
|
||||||
/// yet translated, and data initializers have not yet been copied out of the
|
/// yet translated, and data initializers have not yet been copied out of the
|
||||||
@@ -35,7 +35,7 @@ pub struct ModuleTranslation<'data> {
|
|||||||
|
|
||||||
impl<'data> ModuleTranslation<'data> {
|
impl<'data> ModuleTranslation<'data> {
|
||||||
/// Return a new `FuncEnvironment` for translating a function.
|
/// Return a new `FuncEnvironment` for translating a function.
|
||||||
pub fn func_env(&self) -> FuncEnvironment {
|
pub fn func_env(&self) -> FuncEnvironment<'_> {
|
||||||
FuncEnvironment::new(self.target_config, &self.module)
|
FuncEnvironment::new(self.target_config, &self.module)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
//! Offsets and sizes of various structs in wasmtime-runtime's vmcontext
|
//! Offsets and sizes of various structs in wasmtime-runtime's vmcontext
|
||||||
//! module.
|
//! module.
|
||||||
|
|
||||||
|
use crate::module::Module;
|
||||||
use cranelift_codegen::ir;
|
use cranelift_codegen::ir;
|
||||||
use cranelift_wasm::{
|
use cranelift_wasm::{
|
||||||
DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex, FuncIndex, GlobalIndex, MemoryIndex,
|
DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex, FuncIndex, GlobalIndex, MemoryIndex,
|
||||||
SignatureIndex, TableIndex,
|
SignatureIndex, TableIndex,
|
||||||
};
|
};
|
||||||
use module::Module;
|
|
||||||
|
|
||||||
/// This class computes offsets to fields within `VMContext` and other
|
/// This class computes offsets to fields within `VMContext` and other
|
||||||
/// related structs that JIT code accesses directly.
|
/// related structs that JIT code accesses directly.
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ categories = ["wasm"]
|
|||||||
repository = "https://github.com/CraneStation/wasmtime"
|
repository = "https://github.com/CraneStation/wasmtime"
|
||||||
license = "Apache-2.0 WITH LLVM-exception"
|
license = "Apache-2.0 WITH LLVM-exception"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cranelift-codegen = "0.26.0"
|
cranelift-codegen = "0.26.0"
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
//! Support for performing actions with a wasm module from the outside.
|
//! Support for performing actions with a wasm module from the outside.
|
||||||
|
|
||||||
use compiler::Compiler;
|
use crate::compiler::Compiler;
|
||||||
|
use crate::instantiate::SetupError;
|
||||||
use cranelift_codegen::ir;
|
use cranelift_codegen::ir;
|
||||||
use instantiate::SetupError;
|
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
@@ -77,7 +77,7 @@ impl RuntimeValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for RuntimeValue {
|
impl fmt::Display for RuntimeValue {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
RuntimeValue::I32(x) => write!(f, "{}: i32", x),
|
RuntimeValue::I32(x) => write!(f, "{}: i32", x),
|
||||||
RuntimeValue::I64(x) => write!(f, "{}: i64", x),
|
RuntimeValue::I64(x) => write!(f, "{}: i64", x),
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
//! JIT compilation.
|
//! JIT compilation.
|
||||||
|
|
||||||
use code_memory::CodeMemory;
|
use crate::code_memory::CodeMemory;
|
||||||
|
use crate::instantiate::SetupError;
|
||||||
|
use crate::target_tunables::target_tunables;
|
||||||
use cranelift_codegen::ir::InstBuilder;
|
use cranelift_codegen::ir::InstBuilder;
|
||||||
use cranelift_codegen::isa::{TargetFrontendConfig, TargetIsa};
|
use cranelift_codegen::isa::{TargetFrontendConfig, TargetIsa};
|
||||||
use cranelift_codegen::Context;
|
use cranelift_codegen::Context;
|
||||||
@@ -8,12 +10,10 @@ use cranelift_codegen::{binemit, ir};
|
|||||||
use cranelift_entity::PrimaryMap;
|
use cranelift_entity::PrimaryMap;
|
||||||
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
|
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
|
||||||
use cranelift_wasm::DefinedFuncIndex;
|
use cranelift_wasm::DefinedFuncIndex;
|
||||||
use instantiate::SetupError;
|
|
||||||
use std::boxed::Box;
|
use std::boxed::Box;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
use target_tunables::target_tunables;
|
|
||||||
use wasmtime_environ::cranelift;
|
use wasmtime_environ::cranelift;
|
||||||
use wasmtime_environ::{Compilation, CompileError, Module, Relocations, Tunables};
|
use wasmtime_environ::{Compilation, CompileError, Module, Relocations, Tunables};
|
||||||
use wasmtime_runtime::{InstantiationError, SignatureRegistry, VMFunctionBody};
|
use wasmtime_runtime::{InstantiationError, SignatureRegistry, VMFunctionBody};
|
||||||
@@ -27,7 +27,7 @@ use wasmtime_runtime::{InstantiationError, SignatureRegistry, VMFunctionBody};
|
|||||||
///
|
///
|
||||||
/// TODO: Consider using cranelift-module.
|
/// TODO: Consider using cranelift-module.
|
||||||
pub struct Compiler {
|
pub struct Compiler {
|
||||||
isa: Box<TargetIsa>,
|
isa: Box<dyn TargetIsa>,
|
||||||
|
|
||||||
code_memory: CodeMemory,
|
code_memory: CodeMemory,
|
||||||
trampoline_park: HashMap<*const VMFunctionBody, *const VMFunctionBody>,
|
trampoline_park: HashMap<*const VMFunctionBody, *const VMFunctionBody>,
|
||||||
@@ -39,7 +39,7 @@ pub struct Compiler {
|
|||||||
|
|
||||||
impl Compiler {
|
impl Compiler {
|
||||||
/// Construct a new `Compiler`.
|
/// Construct a new `Compiler`.
|
||||||
pub fn new(isa: Box<TargetIsa>) -> Self {
|
pub fn new(isa: Box<dyn TargetIsa>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
isa,
|
isa,
|
||||||
code_memory: CodeMemory::new(),
|
code_memory: CodeMemory::new(),
|
||||||
@@ -125,7 +125,7 @@ impl Compiler {
|
|||||||
|
|
||||||
/// Create a trampoline for invoking a function.
|
/// Create a trampoline for invoking a function.
|
||||||
fn make_trampoline(
|
fn make_trampoline(
|
||||||
isa: &TargetIsa,
|
isa: &dyn TargetIsa,
|
||||||
code_memory: &mut CodeMemory,
|
code_memory: &mut CodeMemory,
|
||||||
fn_builder_ctx: &mut FunctionBuilderContext,
|
fn_builder_ctx: &mut FunctionBuilderContext,
|
||||||
callee_address: *const VMFunctionBody,
|
callee_address: *const VMFunctionBody,
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
//! `CompiledModule` to allow compiling and instantiating to be done as separate
|
//! `CompiledModule` to allow compiling and instantiating to be done as separate
|
||||||
//! steps.
|
//! steps.
|
||||||
|
|
||||||
use compiler::Compiler;
|
use crate::compiler::Compiler;
|
||||||
|
use crate::link::link_module;
|
||||||
|
use crate::resolver::Resolver;
|
||||||
use cranelift_entity::{BoxedSlice, PrimaryMap};
|
use cranelift_entity::{BoxedSlice, PrimaryMap};
|
||||||
use cranelift_wasm::{DefinedFuncIndex, SignatureIndex};
|
use cranelift_wasm::{DefinedFuncIndex, SignatureIndex};
|
||||||
use link::link_module;
|
|
||||||
use resolver::Resolver;
|
|
||||||
use std::boxed::Box;
|
use std::boxed::Box;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
@@ -52,7 +52,7 @@ impl<'data> RawCompiledModule<'data> {
|
|||||||
fn new(
|
fn new(
|
||||||
compiler: &mut Compiler,
|
compiler: &mut Compiler,
|
||||||
data: &'data [u8],
|
data: &'data [u8],
|
||||||
resolver: &mut Resolver,
|
resolver: &mut dyn Resolver,
|
||||||
) -> Result<Self, SetupError> {
|
) -> Result<Self, SetupError> {
|
||||||
let environ = ModuleEnvironment::new(compiler.frontend_config(), compiler.tunables());
|
let environ = ModuleEnvironment::new(compiler.frontend_config(), compiler.tunables());
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ impl CompiledModule {
|
|||||||
pub fn new<'data>(
|
pub fn new<'data>(
|
||||||
compiler: &mut Compiler,
|
compiler: &mut Compiler,
|
||||||
data: &'data [u8],
|
data: &'data [u8],
|
||||||
resolver: &mut Resolver,
|
resolver: &mut dyn Resolver,
|
||||||
) -> Result<Self, SetupError> {
|
) -> Result<Self, SetupError> {
|
||||||
let raw = RawCompiledModule::<'data>::new(compiler, data, resolver)?;
|
let raw = RawCompiledModule::<'data>::new(compiler, data, resolver)?;
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ pub struct OwnedDataInitializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl OwnedDataInitializer {
|
impl OwnedDataInitializer {
|
||||||
fn new(borrowed: &DataInitializer) -> Self {
|
fn new(borrowed: &DataInitializer<'_>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
location: borrowed.location.clone(),
|
location: borrowed.location.clone(),
|
||||||
data: borrowed.data.to_vec().into_boxed_slice(),
|
data: borrowed.data.to_vec().into_boxed_slice(),
|
||||||
@@ -204,7 +204,7 @@ impl OwnedDataInitializer {
|
|||||||
pub fn instantiate(
|
pub fn instantiate(
|
||||||
compiler: &mut Compiler,
|
compiler: &mut Compiler,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
resolver: &mut Resolver,
|
resolver: &mut dyn Resolver,
|
||||||
) -> Result<Instance, SetupError> {
|
) -> Result<Instance, SetupError> {
|
||||||
let raw = RawCompiledModule::new(compiler, data, resolver)?;
|
let raw = RawCompiledModule::new(compiler, data, resolver)?;
|
||||||
|
|
||||||
|
|||||||
@@ -24,19 +24,16 @@
|
|||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
||||||
|
|
||||||
extern crate cranelift_codegen;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate cranelift_entity;
|
extern crate cranelift_entity;
|
||||||
extern crate cranelift_frontend;
|
|
||||||
extern crate cranelift_wasm;
|
use region;
|
||||||
extern crate region;
|
|
||||||
extern crate wasmtime_environ;
|
|
||||||
extern crate wasmtime_runtime;
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
extern crate failure;
|
use failure;
|
||||||
extern crate target_lexicon;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate failure_derive;
|
extern crate failure_derive;
|
||||||
|
|
||||||
@@ -49,13 +46,13 @@ mod namespace;
|
|||||||
mod resolver;
|
mod resolver;
|
||||||
mod target_tunables;
|
mod target_tunables;
|
||||||
|
|
||||||
pub use action::{ActionError, ActionOutcome, RuntimeValue};
|
pub use crate::action::{ActionError, ActionOutcome, RuntimeValue};
|
||||||
pub use compiler::Compiler;
|
pub use crate::compiler::Compiler;
|
||||||
pub use instantiate::{instantiate, CompiledModule, SetupError};
|
pub use crate::instantiate::{instantiate, CompiledModule, SetupError};
|
||||||
pub use link::link_module;
|
pub use crate::link::link_module;
|
||||||
pub use namespace::{InstanceIndex, Namespace};
|
pub use crate::namespace::{InstanceIndex, Namespace};
|
||||||
pub use resolver::{NullResolver, Resolver};
|
pub use crate::resolver::{NullResolver, Resolver};
|
||||||
pub use target_tunables::target_tunables;
|
pub use crate::target_tunables::target_tunables;
|
||||||
|
|
||||||
// Re-export `Instance` so that users won't need to separately depend on
|
// Re-export `Instance` so that users won't need to separately depend on
|
||||||
// wasmtime-runtime in common cases.
|
// wasmtime-runtime in common cases.
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
//! Linking for JIT-compiled code.
|
//! Linking for JIT-compiled code.
|
||||||
|
|
||||||
|
use crate::resolver::Resolver;
|
||||||
use cranelift_codegen::binemit::Reloc;
|
use cranelift_codegen::binemit::Reloc;
|
||||||
use cranelift_entity::PrimaryMap;
|
use cranelift_entity::PrimaryMap;
|
||||||
use cranelift_wasm::{DefinedFuncIndex, Global, GlobalInit, Memory, Table, TableElementType};
|
use cranelift_wasm::{DefinedFuncIndex, Global, GlobalInit, Memory, Table, TableElementType};
|
||||||
use resolver::Resolver;
|
|
||||||
use std::ptr::write_unaligned;
|
use std::ptr::write_unaligned;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
use wasmtime_environ::{
|
use wasmtime_environ::{
|
||||||
@@ -20,7 +20,7 @@ pub fn link_module(
|
|||||||
module: &Module,
|
module: &Module,
|
||||||
allocated_functions: &PrimaryMap<DefinedFuncIndex, *mut [VMFunctionBody]>,
|
allocated_functions: &PrimaryMap<DefinedFuncIndex, *mut [VMFunctionBody]>,
|
||||||
relocations: Relocations,
|
relocations: Relocations,
|
||||||
resolver: &mut Resolver,
|
resolver: &mut dyn Resolver,
|
||||||
) -> Result<Imports, LinkError> {
|
) -> Result<Imports, LinkError> {
|
||||||
let mut function_imports = PrimaryMap::with_capacity(module.imported_funcs.len());
|
let mut function_imports = PrimaryMap::with_capacity(module.imported_funcs.len());
|
||||||
for (index, (ref module_name, ref field)) in module.imported_funcs.iter() {
|
for (index, (ref module_name, ref field)) in module.imported_funcs.iter() {
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
//! to exports. This file provides one possible way to manage multiple instances
|
//! to exports. This file provides one possible way to manage multiple instances
|
||||||
//! and resolve imports to exports among them.
|
//! and resolve imports to exports among them.
|
||||||
|
|
||||||
use action::{get, inspect_memory, invoke};
|
use crate::action::{get, inspect_memory, invoke};
|
||||||
use action::{ActionError, ActionOutcome, RuntimeValue};
|
use crate::action::{ActionError, ActionOutcome, RuntimeValue};
|
||||||
use compiler::Compiler;
|
use crate::compiler::Compiler;
|
||||||
|
use crate::resolver::Resolver;
|
||||||
use cranelift_entity::PrimaryMap;
|
use cranelift_entity::PrimaryMap;
|
||||||
use resolver::Resolver;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
use wasmtime_runtime::{Export, Instance};
|
use wasmtime_runtime::{Export, Instance};
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ repository = "https://github.com/CraneStation/wasmtime"
|
|||||||
categories = ["wasm"]
|
categories = ["wasm"]
|
||||||
license = "Apache-2.0 WITH LLVM-exception"
|
license = "Apache-2.0 WITH LLVM-exception"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cranelift-codegen = "0.26.0"
|
cranelift-codegen = "0.26.0"
|
||||||
|
|||||||
@@ -26,11 +26,6 @@
|
|||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
|
|
||||||
extern crate cranelift_codegen;
|
|
||||||
extern crate cranelift_entity;
|
|
||||||
extern crate faerie;
|
|
||||||
extern crate wasmtime_environ;
|
|
||||||
|
|
||||||
mod emit_module;
|
mod emit_module;
|
||||||
|
|
||||||
pub use emit_module::emit_module;
|
pub use crate::emit_module::emit_module;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ categories = ["wasm"]
|
|||||||
repository = "https://github.com/CraneStation/wasmtime"
|
repository = "https://github.com/CraneStation/wasmtime"
|
||||||
license = "Apache-2.0 WITH LLVM-exception"
|
license = "Apache-2.0 WITH LLVM-exception"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cranelift-codegen = "0.26.0"
|
cranelift-codegen = "0.26.0"
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use cranelift_codegen::ir;
|
use crate::vmcontext::{
|
||||||
use cranelift_wasm::Global;
|
|
||||||
use vmcontext::{
|
|
||||||
VMContext, VMFunctionBody, VMGlobalDefinition, VMMemoryDefinition, VMTableDefinition,
|
VMContext, VMFunctionBody, VMGlobalDefinition, VMMemoryDefinition, VMTableDefinition,
|
||||||
};
|
};
|
||||||
|
use cranelift_codegen::ir;
|
||||||
|
use cranelift_wasm::Global;
|
||||||
use wasmtime_environ::{MemoryPlan, TablePlan};
|
use wasmtime_environ::{MemoryPlan, TablePlan};
|
||||||
|
|
||||||
/// The value of an export passed from one instance to another.
|
/// The value of an export passed from one instance to another.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
use crate::vmcontext::{VMFunctionImport, VMGlobalImport, VMMemoryImport, VMTableImport};
|
||||||
use cranelift_entity::{BoxedSlice, PrimaryMap};
|
use cranelift_entity::{BoxedSlice, PrimaryMap};
|
||||||
use cranelift_wasm::{FuncIndex, GlobalIndex, MemoryIndex, TableIndex};
|
use cranelift_wasm::{FuncIndex, GlobalIndex, MemoryIndex, TableIndex};
|
||||||
use vmcontext::{VMFunctionImport, VMGlobalImport, VMMemoryImport, VMTableImport};
|
|
||||||
|
|
||||||
/// Resolved import pointers.
|
/// Resolved import pointers.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
//! An `Instance` contains all the runtime state used by execution of a wasm
|
//! An `Instance` contains all the runtime state used by execution of a wasm
|
||||||
//! module.
|
//! module.
|
||||||
|
|
||||||
|
use crate::export::Export;
|
||||||
|
use crate::imports::Imports;
|
||||||
|
use crate::memory::LinearMemory;
|
||||||
|
use crate::mmap::Mmap;
|
||||||
|
use crate::signalhandlers::{wasmtime_init_eager, wasmtime_init_finish};
|
||||||
|
use crate::table::Table;
|
||||||
|
use crate::traphandlers::wasmtime_call;
|
||||||
|
use crate::vmcontext::{
|
||||||
|
VMCallerCheckedAnyfunc, VMContext, VMFunctionBody, VMFunctionImport, VMGlobalDefinition,
|
||||||
|
VMGlobalImport, VMMemoryDefinition, VMMemoryImport, VMSharedSignatureIndex, VMTableDefinition,
|
||||||
|
VMTableImport,
|
||||||
|
};
|
||||||
use cranelift_entity::EntityRef;
|
use cranelift_entity::EntityRef;
|
||||||
use cranelift_entity::{BoxedSlice, PrimaryMap};
|
use cranelift_entity::{BoxedSlice, PrimaryMap};
|
||||||
use cranelift_wasm::{
|
use cranelift_wasm::{
|
||||||
DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex, FuncIndex,
|
DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex, FuncIndex,
|
||||||
GlobalIndex, GlobalInit, MemoryIndex, SignatureIndex, TableIndex,
|
GlobalIndex, GlobalInit, MemoryIndex, SignatureIndex, TableIndex,
|
||||||
};
|
};
|
||||||
use export::Export;
|
|
||||||
use imports::Imports;
|
|
||||||
use memory::LinearMemory;
|
|
||||||
use mmap::Mmap;
|
|
||||||
use signalhandlers::{wasmtime_init_eager, wasmtime_init_finish};
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
use std::{mem, ptr};
|
use std::{mem, ptr};
|
||||||
use table::Table;
|
|
||||||
use traphandlers::wasmtime_call;
|
|
||||||
use vmcontext::{
|
|
||||||
VMCallerCheckedAnyfunc, VMContext, VMFunctionBody, VMFunctionImport, VMGlobalDefinition,
|
|
||||||
VMGlobalImport, VMMemoryDefinition, VMMemoryImport, VMSharedSignatureIndex, VMTableDefinition,
|
|
||||||
VMTableImport,
|
|
||||||
};
|
|
||||||
use wasmtime_environ::{DataInitializer, Module, TableElements, VMOffsets};
|
use wasmtime_environ::{DataInitializer, Module, TableElements, VMOffsets};
|
||||||
|
|
||||||
fn signature_id(
|
fn signature_id(
|
||||||
@@ -450,7 +450,7 @@ impl Instance {
|
|||||||
module: Rc<Module>,
|
module: Rc<Module>,
|
||||||
finished_functions: BoxedSlice<DefinedFuncIndex, *const VMFunctionBody>,
|
finished_functions: BoxedSlice<DefinedFuncIndex, *const VMFunctionBody>,
|
||||||
imports: Imports,
|
imports: Imports,
|
||||||
data_initializers: &[DataInitializer],
|
data_initializers: &[DataInitializer<'_>],
|
||||||
vmshared_signatures: BoxedSlice<SignatureIndex, VMSharedSignatureIndex>,
|
vmshared_signatures: BoxedSlice<SignatureIndex, VMSharedSignatureIndex>,
|
||||||
) -> Result<Self, InstantiationError> {
|
) -> Result<Self, InstantiationError> {
|
||||||
let mut tables = create_tables(&module);
|
let mut tables = create_tables(&module);
|
||||||
@@ -705,7 +705,7 @@ fn check_table_init_bounds(
|
|||||||
|
|
||||||
/// Compute the offset for a memory data initializer.
|
/// Compute the offset for a memory data initializer.
|
||||||
fn get_memory_init_start(
|
fn get_memory_init_start(
|
||||||
init: &DataInitializer,
|
init: &DataInitializer<'_>,
|
||||||
module: &Module,
|
module: &Module,
|
||||||
contents: &mut InstanceContents,
|
contents: &mut InstanceContents,
|
||||||
) -> usize {
|
) -> usize {
|
||||||
@@ -725,7 +725,7 @@ fn get_memory_init_start(
|
|||||||
|
|
||||||
/// Return a byte-slice view of a memory's data.
|
/// Return a byte-slice view of a memory's data.
|
||||||
fn get_memory_slice<'contents>(
|
fn get_memory_slice<'contents>(
|
||||||
init: &DataInitializer,
|
init: &DataInitializer<'_>,
|
||||||
module: &Module,
|
module: &Module,
|
||||||
contents: &'contents mut InstanceContents,
|
contents: &'contents mut InstanceContents,
|
||||||
) -> &'contents mut [u8] {
|
) -> &'contents mut [u8] {
|
||||||
@@ -746,7 +746,7 @@ fn get_memory_slice<'contents>(
|
|||||||
fn check_memory_init_bounds(
|
fn check_memory_init_bounds(
|
||||||
module: &Module,
|
module: &Module,
|
||||||
contents: &mut InstanceContents,
|
contents: &mut InstanceContents,
|
||||||
data_initializers: &[DataInitializer],
|
data_initializers: &[DataInitializer<'_>],
|
||||||
) -> Result<(), InstantiationError> {
|
) -> Result<(), InstantiationError> {
|
||||||
for init in data_initializers {
|
for init in data_initializers {
|
||||||
let start = get_memory_init_start(init, module, contents);
|
let start = get_memory_init_start(init, module, contents);
|
||||||
@@ -868,7 +868,7 @@ fn create_memories(
|
|||||||
fn initialize_memories(
|
fn initialize_memories(
|
||||||
module: &Module,
|
module: &Module,
|
||||||
contents: &mut InstanceContents,
|
contents: &mut InstanceContents,
|
||||||
data_initializers: &[DataInitializer],
|
data_initializers: &[DataInitializer<'_>],
|
||||||
) -> Result<(), InstantiationError> {
|
) -> Result<(), InstantiationError> {
|
||||||
for init in data_initializers {
|
for init in data_initializers {
|
||||||
let start = get_memory_init_start(init, module, contents);
|
let start = get_memory_init_start(init, module, contents);
|
||||||
|
|||||||
@@ -24,22 +24,19 @@
|
|||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
||||||
|
|
||||||
extern crate cranelift_codegen;
|
use errno;
|
||||||
extern crate cranelift_entity;
|
use region;
|
||||||
extern crate cranelift_wasm;
|
|
||||||
extern crate errno;
|
|
||||||
extern crate region;
|
|
||||||
extern crate wasmtime_environ;
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
extern crate libc;
|
use libc;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate memoffset;
|
extern crate memoffset;
|
||||||
extern crate cast;
|
use cast;
|
||||||
extern crate failure;
|
use failure;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate failure_derive;
|
extern crate failure_derive;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
@@ -58,14 +55,14 @@ mod vmcontext;
|
|||||||
|
|
||||||
pub mod libcalls;
|
pub mod libcalls;
|
||||||
|
|
||||||
pub use export::Export;
|
pub use crate::export::Export;
|
||||||
pub use imports::Imports;
|
pub use crate::imports::Imports;
|
||||||
pub use instance::{Instance, InstantiationError, LinkError};
|
pub use crate::instance::{Instance, InstantiationError, LinkError};
|
||||||
pub use mmap::Mmap;
|
pub use crate::mmap::Mmap;
|
||||||
pub use sig_registry::SignatureRegistry;
|
pub use crate::sig_registry::SignatureRegistry;
|
||||||
pub use signalhandlers::{wasmtime_init_eager, wasmtime_init_finish};
|
pub use crate::signalhandlers::{wasmtime_init_eager, wasmtime_init_finish};
|
||||||
pub use traphandlers::{wasmtime_call, wasmtime_call_trampoline};
|
pub use crate::traphandlers::{wasmtime_call, wasmtime_call_trampoline};
|
||||||
pub use vmcontext::{
|
pub use crate::vmcontext::{
|
||||||
VMContext, VMFunctionBody, VMFunctionImport, VMGlobalDefinition, VMGlobalImport,
|
VMContext, VMFunctionBody, VMFunctionImport, VMGlobalDefinition, VMGlobalImport,
|
||||||
VMMemoryDefinition, VMMemoryImport, VMSharedSignatureIndex, VMTableDefinition, VMTableImport,
|
VMMemoryDefinition, VMMemoryImport, VMSharedSignatureIndex, VMTableDefinition, VMTableImport,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
//! inline rather than calling them, particularly when CPUs have special
|
//! inline rather than calling them, particularly when CPUs have special
|
||||||
//! instructions which compute them directly.
|
//! instructions which compute them directly.
|
||||||
|
|
||||||
|
use crate::vmcontext::VMContext;
|
||||||
use cranelift_wasm::{DefinedMemoryIndex, MemoryIndex};
|
use cranelift_wasm::{DefinedMemoryIndex, MemoryIndex};
|
||||||
use vmcontext::VMContext;
|
|
||||||
|
|
||||||
/// Implementation of f32.ceil
|
/// Implementation of f32.ceil
|
||||||
pub extern "C" fn wasmtime_f32_ceil(x: f32) -> f32 {
|
pub extern "C" fn wasmtime_f32_ceil(x: f32) -> f32 {
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
//!
|
//!
|
||||||
//! `LinearMemory` is to WebAssembly linear memories what `Table` is to WebAssembly tables.
|
//! `LinearMemory` is to WebAssembly linear memories what `Table` is to WebAssembly tables.
|
||||||
|
|
||||||
use mmap::Mmap;
|
use crate::mmap::Mmap;
|
||||||
|
use crate::vmcontext::VMMemoryDefinition;
|
||||||
use region;
|
use region;
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
use vmcontext::VMMemoryDefinition;
|
|
||||||
use wasmtime_environ::{MemoryPlan, MemoryStyle, WASM_MAX_PAGES, WASM_PAGE_SIZE};
|
use wasmtime_environ::{MemoryPlan, MemoryStyle, WASM_MAX_PAGES, WASM_PAGE_SIZE};
|
||||||
|
|
||||||
/// A linear memory instance.
|
/// A linear memory instance.
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
//! Implement a registry of function signatures, for fast indirect call
|
//! Implement a registry of function signatures, for fast indirect call
|
||||||
//! signature checking.
|
//! signature checking.
|
||||||
|
|
||||||
|
use crate::vmcontext::VMSharedSignatureIndex;
|
||||||
use cast;
|
use cast;
|
||||||
use cranelift_codegen::ir;
|
use cranelift_codegen::ir;
|
||||||
use std::collections::{hash_map, HashMap};
|
use std::collections::{hash_map, HashMap};
|
||||||
use vmcontext::VMSharedSignatureIndex;
|
|
||||||
|
|
||||||
/// WebAssembly requires that the caller and callee signatures in an indirect
|
/// WebAssembly requires that the caller and callee signatures in an indirect
|
||||||
/// call must match. To implement this efficiently, keep a registry of all
|
/// call must match. To implement this efficiently, keep a registry of all
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
|
use crate::vmcontext::VMContext;
|
||||||
use std::borrow::{Borrow, BorrowMut};
|
use std::borrow::{Borrow, BorrowMut};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
use vmcontext::VMContext;
|
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/signalhandlers.rs"));
|
include!(concat!(env!("OUT_DIR"), "/signalhandlers.rs"));
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
//!
|
//!
|
||||||
//! `Table` is to WebAssembly tables what `LinearMemory` is to WebAssembly linear memories.
|
//! `Table` is to WebAssembly tables what `LinearMemory` is to WebAssembly linear memories.
|
||||||
|
|
||||||
|
use crate::vmcontext::{VMCallerCheckedAnyfunc, VMTableDefinition};
|
||||||
use cranelift_wasm::TableElementType;
|
use cranelift_wasm::TableElementType;
|
||||||
use vmcontext::{VMCallerCheckedAnyfunc, VMTableDefinition};
|
|
||||||
use wasmtime_environ::{TablePlan, TableStyle};
|
use wasmtime_environ::{TablePlan, TableStyle};
|
||||||
|
|
||||||
/// A table instance.
|
/// A table instance.
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
//! WebAssembly trap handling, which is built on top of the lower-level
|
//! WebAssembly trap handling, which is built on top of the lower-level
|
||||||
//! signalhandling mechanisms.
|
//! signalhandling mechanisms.
|
||||||
|
|
||||||
|
use crate::signalhandlers::jmp_buf;
|
||||||
|
use crate::vmcontext::{VMContext, VMFunctionBody};
|
||||||
use libc::c_int;
|
use libc::c_int;
|
||||||
use signalhandlers::jmp_buf;
|
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
use vmcontext::{VMContext, VMFunctionBody};
|
|
||||||
|
|
||||||
// Currently we uset setjmp/longjmp to unwind out of a signal handler
|
// Currently we uset setjmp/longjmp to unwind out of a signal handler
|
||||||
// and back to the point where WebAssembly was called (via `call_wasm`).
|
// and back to the point where WebAssembly was called (via `call_wasm`).
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//! This file declares `VMContext` and several related structs which contain
|
//! This file declares `VMContext` and several related structs which contain
|
||||||
//! fields that compiled wasm code accesses directly.
|
//! fields that compiled wasm code accesses directly.
|
||||||
|
|
||||||
use instance::InstanceContents;
|
use crate::instance::InstanceContents;
|
||||||
use std::{ptr, u32};
|
use std::{ptr, u32};
|
||||||
|
|
||||||
/// An imported function.
|
/// An imported function.
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ categories = ["wasm"]
|
|||||||
repository = "https://github.com/CraneStation/wasmtime"
|
repository = "https://github.com/CraneStation/wasmtime"
|
||||||
license = "Apache-2.0 WITH LLVM-exception"
|
license = "Apache-2.0 WITH LLVM-exception"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cranelift-codegen = "0.26.0"
|
cranelift-codegen = "0.26.0"
|
||||||
|
|||||||
@@ -22,21 +22,12 @@
|
|||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
|
|
||||||
extern crate cranelift_codegen;
|
use failure;
|
||||||
extern crate cranelift_entity;
|
|
||||||
extern crate cranelift_wasm;
|
|
||||||
extern crate failure;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate failure_derive;
|
extern crate failure_derive;
|
||||||
extern crate target_lexicon;
|
|
||||||
extern crate wabt;
|
|
||||||
extern crate wasmparser;
|
|
||||||
extern crate wasmtime_environ;
|
|
||||||
extern crate wasmtime_jit;
|
|
||||||
extern crate wasmtime_runtime;
|
|
||||||
|
|
||||||
mod spectest;
|
mod spectest;
|
||||||
mod wast;
|
mod wast;
|
||||||
|
|
||||||
pub use spectest::instantiate_spectest;
|
pub use crate::spectest::instantiate_spectest;
|
||||||
pub use wast::{WastContext, WastError};
|
pub use crate::wast::{WastContext, WastError};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use spectest::instantiate_spectest;
|
use crate::spectest::instantiate_spectest;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::{fmt, fs, io, str};
|
use std::{fmt, fs, io, str};
|
||||||
@@ -26,7 +26,7 @@ pub struct UnknownInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for UnknownInstance {
|
impl fmt::Display for UnknownInstance {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self.instance {
|
match self.instance {
|
||||||
None => write!(f, "no default instance present"),
|
None => write!(f, "no default instance present"),
|
||||||
Some(ref name) => write!(f, "no instance {} present", name),
|
Some(ref name) => write!(f, "no instance {} present", name),
|
||||||
@@ -52,7 +52,7 @@ pub enum WastError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for WastError {
|
impl fmt::Display for WastError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
WastError::Assert(ref message) => write!(f, "Assert command failed: {}", message),
|
WastError::Assert(ref message) => write!(f, "Assert command failed: {}", message),
|
||||||
WastError::Instance(ref error) => error.fmt(f),
|
WastError::Instance(ref error) => error.fmt(f),
|
||||||
|
|||||||
@@ -29,18 +29,12 @@
|
|||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
|
|
||||||
extern crate cranelift_codegen;
|
|
||||||
extern crate cranelift_native;
|
|
||||||
extern crate docopt;
|
|
||||||
extern crate wasmtime_environ;
|
|
||||||
extern crate wasmtime_obj;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
extern crate faerie;
|
|
||||||
extern crate target_lexicon;
|
|
||||||
|
|
||||||
use cranelift_codegen::isa;
|
use cranelift_codegen::isa;
|
||||||
use cranelift_codegen::settings;
|
use cranelift_codegen::settings;
|
||||||
|
use cranelift_native;
|
||||||
use docopt::Docopt;
|
use docopt::Docopt;
|
||||||
use faerie::Artifact;
|
use faerie::Artifact;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|||||||
@@ -30,20 +30,15 @@
|
|||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
|
|
||||||
extern crate cranelift_codegen;
|
|
||||||
extern crate cranelift_native;
|
|
||||||
extern crate docopt;
|
|
||||||
extern crate wasmtime_jit;
|
|
||||||
extern crate wasmtime_wast;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
extern crate file_per_thread_logger;
|
|
||||||
extern crate pretty_env_logger;
|
|
||||||
extern crate wabt;
|
|
||||||
|
|
||||||
use cranelift_codegen::settings;
|
use cranelift_codegen::settings;
|
||||||
use cranelift_codegen::settings::Configurable;
|
use cranelift_codegen::settings::Configurable;
|
||||||
|
use cranelift_native;
|
||||||
use docopt::Docopt;
|
use docopt::Docopt;
|
||||||
|
use file_per_thread_logger;
|
||||||
|
use pretty_env_logger;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
@@ -51,6 +46,7 @@ use std::io::prelude::*;
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
use wabt;
|
||||||
use wasmtime_jit::{instantiate, ActionOutcome, Compiler, Namespace};
|
use wasmtime_jit::{instantiate, ActionOutcome, Compiler, Namespace};
|
||||||
use wasmtime_wast::instantiate_spectest;
|
use wasmtime_wast::instantiate_spectest;
|
||||||
|
|
||||||
|
|||||||
10
src/wast.rs
10
src/wast.rs
@@ -25,19 +25,15 @@
|
|||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
|
|
||||||
extern crate cranelift_codegen;
|
|
||||||
extern crate cranelift_native;
|
|
||||||
extern crate docopt;
|
|
||||||
extern crate wasmtime_jit;
|
|
||||||
extern crate wasmtime_wast;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
extern crate file_per_thread_logger;
|
|
||||||
extern crate pretty_env_logger;
|
|
||||||
|
|
||||||
use cranelift_codegen::settings;
|
use cranelift_codegen::settings;
|
||||||
use cranelift_codegen::settings::Configurable;
|
use cranelift_codegen::settings::Configurable;
|
||||||
|
use cranelift_native;
|
||||||
use docopt::Docopt;
|
use docopt::Docopt;
|
||||||
|
use file_per_thread_logger;
|
||||||
|
use pretty_env_logger;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use wasmtime_jit::Compiler;
|
use wasmtime_jit::Compiler;
|
||||||
use wasmtime_wast::WastContext;
|
use wasmtime_wast::WastContext;
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
extern crate cranelift_codegen;
|
use cranelift_native;
|
||||||
extern crate cranelift_native;
|
|
||||||
extern crate wasmtime_jit;
|
|
||||||
extern crate wasmtime_wast;
|
|
||||||
|
|
||||||
use cranelift_codegen::isa;
|
use cranelift_codegen::isa;
|
||||||
use cranelift_codegen::settings;
|
use cranelift_codegen::settings;
|
||||||
@@ -13,7 +10,7 @@ use wasmtime_wast::WastContext;
|
|||||||
include!(concat!(env!("OUT_DIR"), "/wast_testsuite_tests.rs"));
|
include!(concat!(env!("OUT_DIR"), "/wast_testsuite_tests.rs"));
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn native_isa() -> Box<isa::TargetIsa> {
|
fn native_isa() -> Box<dyn isa::TargetIsa> {
|
||||||
let mut flag_builder = settings::builder();
|
let mut flag_builder = settings::builder();
|
||||||
flag_builder.enable("enable_verifier").unwrap();
|
flag_builder.enable("enable_verifier").unwrap();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user