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