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