Update to Rust 2018 Edition.
This commit is contained in:
@@ -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};
|
||||
|
||||
Reference in New Issue
Block a user