Move cranelift dependencies to wasmtime-environ (#669)
Groups all CL data structures into single dependency to be used accross wasmtime project.
This commit is contained in:
@@ -15,10 +15,6 @@ publish = false
|
||||
|
||||
[dependencies]
|
||||
# Enable all supported architectures by default.
|
||||
cranelift-codegen = { version = "0.50.0", features = ["enable-serde", "all-arch"] }
|
||||
cranelift-entity = { version = "0.50.0", features = ["enable-serde"] }
|
||||
cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] }
|
||||
cranelift-native = "0.50.0"
|
||||
wasmtime = { path = "crates/api" }
|
||||
wasmtime-debug = { path = "crates/debug" }
|
||||
wasmtime-environ = { path = "crates/environ" }
|
||||
|
||||
@@ -13,11 +13,6 @@ name = "wasmtime"
|
||||
crate-type = ["lib", "staticlib", "cdylib"]
|
||||
|
||||
[dependencies]
|
||||
cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] }
|
||||
cranelift-native = "0.50.0"
|
||||
cranelift-entity = { version = "0.50.0", features = ["enable-serde"] }
|
||||
cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] }
|
||||
cranelift-frontend = "0.50.0"
|
||||
wasmtime-runtime = { path = "../runtime" }
|
||||
wasmtime-environ = { path = "../environ" }
|
||||
wasmtime-jit = { path = "../jit" }
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use crate::data_structures::ir;
|
||||
use crate::r#ref::HostRef;
|
||||
use crate::runtime::Store;
|
||||
use crate::trampoline::{generate_func_export, take_api_trap};
|
||||
@@ -6,6 +5,7 @@ use crate::trap::Trap;
|
||||
use crate::types::FuncType;
|
||||
use crate::values::Val;
|
||||
use std::rc::Rc;
|
||||
use wasmtime_environ::ir;
|
||||
use wasmtime_jit::InstanceHandle;
|
||||
use wasmtime_runtime::Export;
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use crate::data_structures::native_isa_builder;
|
||||
use crate::Config;
|
||||
use std::cell::{RefCell, RefMut};
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::rc::Rc;
|
||||
use wasmtime_jit::{Compiler, Features};
|
||||
use wasmtime_jit::{native, Compiler, Features};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Context {
|
||||
@@ -14,8 +13,7 @@ pub struct Context {
|
||||
|
||||
impl Context {
|
||||
pub fn new(config: &Config) -> Context {
|
||||
let isa_builder = native_isa_builder();
|
||||
let isa = isa_builder.finish(config.flags.clone());
|
||||
let isa = native::builder().finish(config.flags.clone());
|
||||
Context::new_with_compiler(config, Compiler::new(isa, config.strategy))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
pub(crate) mod ir {
|
||||
pub(crate) use cranelift_codegen::ir::{types, AbiParam, ArgumentPurpose, Signature, Type};
|
||||
}
|
||||
|
||||
pub(crate) mod settings {
|
||||
pub(crate) use cranelift_codegen::settings::{builder, Flags};
|
||||
}
|
||||
|
||||
pub(crate) use cranelift_codegen::isa::CallConv;
|
||||
pub(crate) use cranelift_entity::{EntityRef, PrimaryMap};
|
||||
|
||||
pub(crate) mod wasm {
|
||||
pub(crate) use cranelift_wasm::{
|
||||
DefinedFuncIndex, DefinedTableIndex, FuncIndex, Global, GlobalInit, Memory, Table,
|
||||
TableElementType,
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) fn native_isa_builder() -> cranelift_codegen::isa::Builder {
|
||||
cranelift_native::builder().expect("host machine is not a supported target")
|
||||
}
|
||||
|
||||
pub(crate) fn native_isa_call_conv() -> CallConv {
|
||||
use target_lexicon::HOST;
|
||||
CallConv::triple_default(&HOST)
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
use crate::callable::{Callable, NativeCallable, WasmtimeFn, WrappedCallable};
|
||||
use crate::data_structures::wasm;
|
||||
use crate::r#ref::{AnyRef, HostRef};
|
||||
use crate::runtime::Store;
|
||||
use crate::trampoline::{generate_global_export, generate_memory_export, generate_table_export};
|
||||
@@ -9,6 +8,7 @@ use crate::values::{from_checked_anyfunc, into_checked_anyfunc, Val};
|
||||
use std::fmt;
|
||||
use std::rc::Rc;
|
||||
use std::slice;
|
||||
use wasmtime_environ::wasm;
|
||||
use wasmtime_runtime::InstanceHandle;
|
||||
|
||||
// Externals
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
mod callable;
|
||||
mod context;
|
||||
mod data_structures;
|
||||
mod externals;
|
||||
mod instance;
|
||||
mod module;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use crate::context::Context;
|
||||
use crate::data_structures::{ir, settings};
|
||||
use crate::r#ref::HostRef;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
use wasmtime_environ::{ir, settings};
|
||||
use wasmtime_jit::{CompilationStrategy, Features};
|
||||
|
||||
// Runtime Environment
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
//! Support for a calling of an imported function.
|
||||
|
||||
use crate::data_structures::wasm::DefinedFuncIndex;
|
||||
use crate::data_structures::PrimaryMap;
|
||||
use crate::runtime::Store;
|
||||
use anyhow::Result;
|
||||
use std::any::Any;
|
||||
use std::cell::{RefCell, RefMut};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::rc::Rc;
|
||||
use wasmtime_environ::entity::PrimaryMap;
|
||||
use wasmtime_environ::wasm::DefinedFuncIndex;
|
||||
use wasmtime_environ::Module;
|
||||
use wasmtime_runtime::{Imports, InstanceHandle, VMFunctionBody};
|
||||
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
//! Support for a calling of an imported function.
|
||||
|
||||
use super::create_handle::create_handle;
|
||||
use super::ir::{ExternalName, Function, InstBuilder, MemFlags, StackSlotData, StackSlotKind};
|
||||
use super::trap::{record_api_trap, TrapSink, API_TRAP_CODE};
|
||||
use super::{binemit, pretty_error, TargetIsa};
|
||||
use super::{Context, FunctionBuilder, FunctionBuilderContext};
|
||||
use crate::data_structures::ir::{self, types};
|
||||
use crate::data_structures::wasm::{DefinedFuncIndex, FuncIndex};
|
||||
use crate::data_structures::{native_isa_builder, settings, EntityRef, PrimaryMap};
|
||||
use crate::r#ref::HostRef;
|
||||
use crate::{Callable, FuncType, Store, Val};
|
||||
use anyhow::Result;
|
||||
use std::cmp;
|
||||
use std::convert::TryFrom;
|
||||
use std::rc::Rc;
|
||||
use wasmtime_environ::{CompiledFunction, Export, Module, TrapInformation};
|
||||
use wasmtime_jit::CodeMemory;
|
||||
use wasmtime_environ::entity::{EntityRef, PrimaryMap};
|
||||
use wasmtime_environ::ir::types;
|
||||
use wasmtime_environ::isa::TargetIsa;
|
||||
use wasmtime_environ::wasm::{DefinedFuncIndex, FuncIndex};
|
||||
use wasmtime_environ::{ir, settings, CompiledFunction, Export, Module, TrapInformation};
|
||||
use wasmtime_jit::trampoline::ir::{
|
||||
ExternalName, Function, InstBuilder, MemFlags, StackSlotData, StackSlotKind,
|
||||
};
|
||||
use wasmtime_jit::trampoline::{
|
||||
binemit, pretty_error, Context, FunctionBuilder, FunctionBuilderContext,
|
||||
};
|
||||
use wasmtime_jit::{native, CodeMemory};
|
||||
use wasmtime_runtime::{
|
||||
get_mut_trap_registry, InstanceHandle, TrapRegistrationGuard, VMContext, VMFunctionBody,
|
||||
};
|
||||
@@ -232,7 +236,7 @@ pub fn create_handle_with_function(
|
||||
let sig = ft.get_wasmtime_signature().clone();
|
||||
|
||||
let isa = {
|
||||
let isa_builder = native_isa_builder();
|
||||
let isa_builder = native::builder();
|
||||
let flag_builder = settings::builder();
|
||||
isa_builder.finish(settings::Flags::new(flag_builder))
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use super::create_handle::create_handle;
|
||||
use crate::data_structures::{wasm, PrimaryMap};
|
||||
use crate::{GlobalType, Mutability, Val};
|
||||
use anyhow::Result;
|
||||
use wasmtime_environ::Module;
|
||||
use wasmtime_environ::entity::PrimaryMap;
|
||||
use wasmtime_environ::{wasm, Module};
|
||||
use wasmtime_runtime::{InstanceHandle, VMGlobalDefinition};
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use super::create_handle::create_handle;
|
||||
use crate::data_structures::{wasm, PrimaryMap};
|
||||
use crate::MemoryType;
|
||||
use anyhow::Result;
|
||||
use wasmtime_environ::Module;
|
||||
use wasmtime_environ::entity::PrimaryMap;
|
||||
use wasmtime_environ::{wasm, Module};
|
||||
use wasmtime_runtime::InstanceHandle;
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
||||
@@ -51,61 +51,3 @@ pub fn generate_table_export(
|
||||
let export = instance.lookup("table").expect("table export");
|
||||
Ok((instance, export))
|
||||
}
|
||||
|
||||
pub(crate) use cranelift_codegen::print_errors::pretty_error;
|
||||
|
||||
pub(crate) mod binemit {
|
||||
pub(crate) use cranelift_codegen::binemit::{CodeOffset, NullStackmapSink, TrapSink};
|
||||
|
||||
pub use cranelift_codegen::{binemit, ir};
|
||||
|
||||
/// We don't expect trampoline compilation to produce any relocations, so
|
||||
/// this `RelocSink` just asserts that it doesn't recieve any.
|
||||
pub(crate) struct TrampolineRelocSink {}
|
||||
|
||||
impl binemit::RelocSink for TrampolineRelocSink {
|
||||
fn reloc_ebb(
|
||||
&mut self,
|
||||
_offset: binemit::CodeOffset,
|
||||
_reloc: binemit::Reloc,
|
||||
_ebb_offset: binemit::CodeOffset,
|
||||
) {
|
||||
panic!("trampoline compilation should not produce ebb relocs");
|
||||
}
|
||||
fn reloc_external(
|
||||
&mut self,
|
||||
_offset: binemit::CodeOffset,
|
||||
_reloc: binemit::Reloc,
|
||||
_name: &ir::ExternalName,
|
||||
_addend: binemit::Addend,
|
||||
) {
|
||||
panic!("trampoline compilation should not produce external symbol relocs");
|
||||
}
|
||||
fn reloc_constant(
|
||||
&mut self,
|
||||
_code_offset: binemit::CodeOffset,
|
||||
_reloc: binemit::Reloc,
|
||||
_constant_offset: ir::ConstantOffset,
|
||||
) {
|
||||
panic!("trampoline compilation should not produce constant relocs");
|
||||
}
|
||||
fn reloc_jt(
|
||||
&mut self,
|
||||
_offset: binemit::CodeOffset,
|
||||
_reloc: binemit::Reloc,
|
||||
_jt: ir::JumpTable,
|
||||
) {
|
||||
panic!("trampoline compilation should not produce jump table relocs");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) mod ir {
|
||||
pub(crate) use cranelift_codegen::ir::{
|
||||
ExternalName, Function, InstBuilder, MemFlags, SourceLoc, StackSlotData, StackSlotKind,
|
||||
TrapCode,
|
||||
};
|
||||
}
|
||||
pub(crate) use cranelift_codegen::isa::TargetIsa;
|
||||
pub(crate) use cranelift_codegen::Context;
|
||||
pub(crate) use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use super::create_handle::create_handle;
|
||||
use crate::data_structures::{wasm, PrimaryMap};
|
||||
use crate::{TableType, ValType};
|
||||
use anyhow::Result;
|
||||
use wasmtime_environ::Module;
|
||||
use wasmtime_environ::entity::PrimaryMap;
|
||||
use wasmtime_environ::{wasm, Module};
|
||||
use wasmtime_runtime::InstanceHandle;
|
||||
|
||||
pub fn create_handle_with_table(table: &TableType) -> Result<InstanceHandle> {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use std::cell::Cell;
|
||||
|
||||
use super::binemit;
|
||||
use super::ir::{SourceLoc, TrapCode};
|
||||
use crate::r#ref::HostRef;
|
||||
use crate::Trap;
|
||||
use wasmtime_environ::ir::{SourceLoc, TrapCode};
|
||||
use wasmtime_environ::TrapInformation;
|
||||
use wasmtime_jit::trampoline::binemit;
|
||||
|
||||
// Randomly selected user TrapCode magic number 13.
|
||||
pub const API_TRAP_CODE: TrapCode = TrapCode::User(13);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::data_structures::{ir, wasm};
|
||||
use wasmtime_environ::{ir, wasm};
|
||||
|
||||
// Type Representations
|
||||
|
||||
@@ -156,9 +156,9 @@ pub struct FuncType {
|
||||
|
||||
impl FuncType {
|
||||
pub fn new(params: Box<[ValType]>, results: Box<[ValType]>) -> FuncType {
|
||||
use crate::data_structures::ir::{types, AbiParam, ArgumentPurpose, Signature};
|
||||
use crate::data_structures::native_isa_call_conv;
|
||||
let call_conv = native_isa_call_conv();
|
||||
use wasmtime_environ::ir::{types, AbiParam, ArgumentPurpose, Signature};
|
||||
use wasmtime_jit::native;
|
||||
let call_conv = native::call_conv();
|
||||
let signature: Signature = {
|
||||
let mut params = params
|
||||
.iter()
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use crate::data_structures::ir;
|
||||
use crate::externals::Func;
|
||||
use crate::r#ref::{AnyRef, HostRef};
|
||||
use crate::runtime::Store;
|
||||
use crate::types::ValType;
|
||||
use std::ptr;
|
||||
use wasmtime_environ::ir;
|
||||
use wasmtime_jit::RuntimeValue;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@@ -14,9 +14,6 @@ edition = "2018"
|
||||
[dependencies]
|
||||
gimli = "0.19.0"
|
||||
wasmparser = "0.44.0"
|
||||
cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] }
|
||||
cranelift-entity = { version = "0.50.0", features = ["enable-serde"] }
|
||||
cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] }
|
||||
faerie = "0.13.0"
|
||||
wasmtime-environ = { path = "../environ" }
|
||||
target-lexicon = { version = "0.9.0", default-features = false }
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
#![allow(clippy::cast_ptr_alignment)]
|
||||
|
||||
use anyhow::Error;
|
||||
use cranelift_codegen::isa::TargetFrontendConfig;
|
||||
use faerie::{Artifact, Decl};
|
||||
use more_asserts::assert_gt;
|
||||
use target_lexicon::{BinaryFormat, Triple};
|
||||
use wasmtime_environ::isa::TargetFrontendConfig;
|
||||
use wasmtime_environ::{ModuleAddressMap, ModuleVmctxInfo, ValueLabelsRanges};
|
||||
|
||||
pub use crate::read_debuginfo::{read_debuginfo, DebugInfoData, WasmFileInfo};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use crate::WasmFileInfo;
|
||||
use cranelift_codegen::ir::SourceLoc;
|
||||
use cranelift_entity::{EntityRef, PrimaryMap};
|
||||
use cranelift_wasm::DefinedFuncIndex;
|
||||
use gimli::write;
|
||||
use more_asserts::assert_le;
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
use std::iter::FromIterator;
|
||||
use wasmtime_environ::entity::{EntityRef, PrimaryMap};
|
||||
use wasmtime_environ::ir::SourceLoc;
|
||||
use wasmtime_environ::wasm::DefinedFuncIndex;
|
||||
use wasmtime_environ::{FunctionAddressMap, ModuleAddressMap};
|
||||
|
||||
pub type GeneratedAddress = usize;
|
||||
@@ -492,10 +492,10 @@ impl AddressTransform {
|
||||
mod tests {
|
||||
use super::{build_function_lookup, get_wasm_code_offset, AddressTransform};
|
||||
use crate::read_debuginfo::WasmFileInfo;
|
||||
use cranelift_codegen::ir::SourceLoc;
|
||||
use cranelift_entity::PrimaryMap;
|
||||
use gimli::write::Address;
|
||||
use std::iter::FromIterator;
|
||||
use wasmtime_environ::entity::PrimaryMap;
|
||||
use wasmtime_environ::ir::SourceLoc;
|
||||
use wasmtime_environ::{FunctionAddressMap, InstructionAddressMap, ModuleAddressMap};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
use super::address_transform::AddressTransform;
|
||||
use anyhow::Error;
|
||||
use cranelift_codegen::ir::{StackSlots, ValueLabel, ValueLoc};
|
||||
use cranelift_codegen::isa::RegUnit;
|
||||
use cranelift_codegen::ValueLabelsRanges;
|
||||
use cranelift_entity::EntityRef;
|
||||
use cranelift_wasm::{get_vmctx_value_label, DefinedFuncIndex};
|
||||
use gimli::{self, write, Expression, Operation, Reader, ReaderOffset, Register, X86_64};
|
||||
use more_asserts::{assert_le, assert_lt};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use wasmtime_environ::entity::EntityRef;
|
||||
use wasmtime_environ::ir::{StackSlots, ValueLabel, ValueLabelsRanges, ValueLoc};
|
||||
use wasmtime_environ::isa::RegUnit;
|
||||
use wasmtime_environ::wasm::{get_vmctx_value_label, DefinedFuncIndex};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FunctionFrameInfo<'a> {
|
||||
|
||||
@@ -2,13 +2,13 @@ use super::address_transform::AddressTransform;
|
||||
use super::attr::clone_attr_string;
|
||||
use super::{Reader, TransformError};
|
||||
use anyhow::Error;
|
||||
use cranelift_entity::EntityRef;
|
||||
use gimli::{
|
||||
write, DebugLine, DebugLineOffset, DebugStr, DebuggingInformationEntry, LineEncoding, Unit,
|
||||
};
|
||||
use more_asserts::assert_le;
|
||||
use std::collections::BTreeMap;
|
||||
use std::iter::FromIterator;
|
||||
use wasmtime_environ::entity::EntityRef;
|
||||
|
||||
#[derive(Debug)]
|
||||
enum SavedLineProgramRow {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use crate::gc::build_dependencies;
|
||||
use crate::DebugInfoData;
|
||||
use anyhow::Error;
|
||||
use cranelift_codegen::isa::TargetFrontendConfig;
|
||||
use gimli::{
|
||||
write, DebugAddr, DebugAddrBase, DebugLine, DebugStr, LocationLists, RangeLists,
|
||||
UnitSectionOffset,
|
||||
@@ -10,6 +9,7 @@ use simulate::generate_simulated_dwarf;
|
||||
use std::collections::HashSet;
|
||||
use thiserror::Error;
|
||||
use unit::clone_unit;
|
||||
use wasmtime_environ::isa::TargetFrontendConfig;
|
||||
use wasmtime_environ::{ModuleAddressMap, ModuleVmctxInfo, ValueLabelsRanges};
|
||||
|
||||
pub use address_transform::AddressTransform;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use super::address_transform::AddressTransform;
|
||||
use super::{DebugInputContext, Reader};
|
||||
use anyhow::Error;
|
||||
use cranelift_entity::EntityRef;
|
||||
use cranelift_wasm::DefinedFuncIndex;
|
||||
use gimli::{write, AttributeValue, DebuggingInformationEntry, RangeListsOffset};
|
||||
use more_asserts::assert_lt;
|
||||
use wasmtime_environ::entity::EntityRef;
|
||||
use wasmtime_environ::wasm::DefinedFuncIndex;
|
||||
|
||||
pub(crate) enum RangeInfoBuilder {
|
||||
Undefined,
|
||||
|
||||
@@ -3,12 +3,12 @@ use super::utils::{add_internal_types, append_vmctx_info, get_function_frame_inf
|
||||
use super::AddressTransform;
|
||||
use crate::read_debuginfo::WasmFileInfo;
|
||||
use anyhow::Error;
|
||||
use cranelift_entity::EntityRef;
|
||||
use cranelift_wasm::get_vmctx_value_label;
|
||||
use gimli::write;
|
||||
use gimli::{self, LineEncoding};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::path::PathBuf;
|
||||
use wasmtime_environ::entity::EntityRef;
|
||||
use wasmtime_environ::wasm::get_vmctx_value_label;
|
||||
use wasmtime_environ::{ModuleVmctxInfo, ValueLabelsRanges};
|
||||
|
||||
pub use crate::read_debuginfo::{DebugInfoData, FunctionMetadata, WasmType};
|
||||
|
||||
@@ -6,10 +6,10 @@ use super::range_info_builder::RangeInfoBuilder;
|
||||
use super::utils::{add_internal_types, append_vmctx_info, get_function_frame_info};
|
||||
use super::{DebugInputContext, Reader, TransformError};
|
||||
use anyhow::Error;
|
||||
use cranelift_entity::EntityRef;
|
||||
use gimli::write;
|
||||
use gimli::{AttributeValue, DebuggingInformationEntry, Unit, UnitOffset};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use wasmtime_environ::entity::EntityRef;
|
||||
use wasmtime_environ::{ModuleVmctxInfo, ValueLabelsRanges};
|
||||
|
||||
pub(crate) type PendingDieRef = (write::UnitEntryId, gimli::DwAt, UnitOffset);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use super::address_transform::AddressTransform;
|
||||
use super::expression::{CompiledExpression, FunctionFrameInfo};
|
||||
use anyhow::Error;
|
||||
use cranelift_wasm::DefinedFuncIndex;
|
||||
use gimli::write;
|
||||
use wasmtime_environ::wasm::DefinedFuncIndex;
|
||||
use wasmtime_environ::{ModuleVmctxInfo, ValueLabelsRanges};
|
||||
|
||||
pub(crate) fn add_internal_types(
|
||||
|
||||
29
crates/environ/src/data_structures.rs
Normal file
29
crates/environ/src/data_structures.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
#![doc(hidden)]
|
||||
|
||||
pub mod ir {
|
||||
pub use cranelift_codegen::ir::{
|
||||
types, AbiParam, ArgumentPurpose, Signature, SourceLoc, StackSlots, TrapCode, Type,
|
||||
ValueLabel, ValueLoc,
|
||||
};
|
||||
pub use cranelift_codegen::ValueLabelsRanges;
|
||||
}
|
||||
|
||||
pub mod settings {
|
||||
pub use cranelift_codegen::settings::{builder, Configurable, Flags};
|
||||
}
|
||||
|
||||
pub mod isa {
|
||||
pub use cranelift_codegen::isa::{CallConv, RegUnit, TargetFrontendConfig, TargetIsa};
|
||||
}
|
||||
|
||||
pub mod entity {
|
||||
pub use cranelift_entity::{BoxedSlice, EntityRef, PrimaryMap};
|
||||
}
|
||||
|
||||
pub mod wasm {
|
||||
pub use cranelift_wasm::{
|
||||
get_vmctx_value_label, DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex,
|
||||
DefinedTableIndex, FuncIndex, Global, GlobalIndex, GlobalInit, Memory, MemoryIndex,
|
||||
SignatureIndex, Table, TableElementType, TableIndex,
|
||||
};
|
||||
}
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
mod address_map;
|
||||
mod compilation;
|
||||
mod data_structures;
|
||||
mod func_environ;
|
||||
mod module;
|
||||
mod module_environ;
|
||||
@@ -47,6 +48,7 @@ pub use crate::compilation::{
|
||||
Relocations, TrapInformation, Traps,
|
||||
};
|
||||
pub use crate::cranelift::Cranelift;
|
||||
pub use crate::data_structures::*;
|
||||
pub use crate::func_environ::BuiltinFunctionIndex;
|
||||
#[cfg(feature = "lightbeam")]
|
||||
pub use crate::lightbeam::Lightbeam;
|
||||
|
||||
@@ -12,13 +12,12 @@ version = "0.1.0"
|
||||
anyhow = "1.0.22"
|
||||
arbitrary = "0.2.0"
|
||||
binaryen = "0.8.2"
|
||||
cranelift-codegen = "0.50.0"
|
||||
cranelift-native = "0.50.0"
|
||||
env_logger = { version = "0.7.1", optional = true }
|
||||
log = "0.4.8"
|
||||
wasmparser = "0.44.0"
|
||||
wasmprinter = "0.2.0"
|
||||
wasmtime = { path = "../api" }
|
||||
wasmtime-environ = { path = "../environ" }
|
||||
wasmtime-jit = { path = "../jit" }
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
@@ -12,17 +12,17 @@
|
||||
|
||||
pub mod dummy;
|
||||
|
||||
use cranelift_codegen::settings;
|
||||
use dummy::dummy_imports;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
use wasmtime::{Config, Engine, HostRef, Instance, Module, Store};
|
||||
use wasmtime_jit::{CompilationStrategy, CompiledModule, Compiler, NullResolver};
|
||||
use wasmtime_environ::{isa, settings};
|
||||
use wasmtime_jit::{native, CompilationStrategy, CompiledModule, Compiler, NullResolver};
|
||||
|
||||
fn host_isa() -> Box<dyn cranelift_codegen::isa::TargetIsa> {
|
||||
fn host_isa() -> Box<dyn isa::TargetIsa> {
|
||||
let flag_builder = settings::builder();
|
||||
let isa_builder = cranelift_native::builder().expect("host machine is not a supported target");
|
||||
let isa_builder = native::builder();
|
||||
isa_builder.finish(settings::Flags::new(flag_builder))
|
||||
}
|
||||
|
||||
|
||||
@@ -12,12 +12,12 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.19"
|
||||
cranelift-codegen = { version = "0.50.0", default-features = false }
|
||||
walrus = "0.13"
|
||||
wasmparser = { version = "0.44.0", default-features = false }
|
||||
wasm-webidl-bindings = "0.6"
|
||||
wasmtime = { path = '../api' }
|
||||
wasmtime-jit = { path = '../jit' }
|
||||
wasmtime-environ = { path = '../environ' }
|
||||
wasmtime-runtime = { path = '../runtime' }
|
||||
wasmtime-wasi = { path = '../wasi' }
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
#![deny(missing_docs)]
|
||||
|
||||
use anyhow::{bail, format_err, Result};
|
||||
use cranelift_codegen::ir;
|
||||
use std::convert::TryFrom;
|
||||
use std::str;
|
||||
use wasm_webidl_bindings::ast;
|
||||
use wasmtime_environ::ir;
|
||||
use wasmtime_jit::RuntimeValue;
|
||||
use wasmtime_runtime::{Export, InstanceHandle};
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ edition = "2018"
|
||||
cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] }
|
||||
cranelift-entity = { version = "0.50.0", features = ["enable-serde"] }
|
||||
cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] }
|
||||
cranelift-native = "0.50.0"
|
||||
cranelift-frontend = "0.50.0"
|
||||
wasmtime-environ = { path = "../environ" }
|
||||
wasmtime-runtime = { path = "../runtime" }
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
use crate::compiler::Compiler;
|
||||
use crate::instantiate::SetupError;
|
||||
use cranelift_codegen::ir;
|
||||
use std::cmp::max;
|
||||
use std::{fmt, mem, ptr, slice};
|
||||
use thiserror::Error;
|
||||
use wasmtime_environ::ir;
|
||||
use wasmtime_runtime::{wasmtime_call_trampoline, Export, InstanceHandle, VMInvokeArgument};
|
||||
|
||||
/// A runtime value.
|
||||
|
||||
@@ -4,16 +4,17 @@ 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::print_errors::pretty_error;
|
||||
use cranelift_codegen::Context;
|
||||
use cranelift_codegen::{binemit, ir};
|
||||
use cranelift_entity::{EntityRef, PrimaryMap};
|
||||
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
|
||||
use cranelift_wasm::{DefinedFuncIndex, DefinedMemoryIndex, ModuleTranslationState};
|
||||
use cranelift_wasm::ModuleTranslationState;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryFrom;
|
||||
use wasmtime_debug::{emit_debugsections_image, DebugInfoData};
|
||||
use wasmtime_environ::entity::{EntityRef, PrimaryMap};
|
||||
use wasmtime_environ::isa::{TargetFrontendConfig, TargetIsa};
|
||||
use wasmtime_environ::wasm::{DefinedFuncIndex, DefinedMemoryIndex};
|
||||
use wasmtime_environ::{
|
||||
Compilation, CompileError, CompiledFunction, Compiler as _C, FunctionBodyData, Module,
|
||||
ModuleVmctxInfo, Relocations, Traps, Tunables, VMOffsets,
|
||||
|
||||
@@ -3,12 +3,12 @@ use crate::{
|
||||
instantiate, ActionError, ActionOutcome, CompilationStrategy, CompiledModule, Compiler,
|
||||
InstanceHandle, Namespace, RuntimeValue, SetupError,
|
||||
};
|
||||
use cranelift_codegen::isa::TargetIsa;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use wasmparser::{validate, OperatorValidatorConfig, ValidatingParserConfig};
|
||||
use wasmtime_environ::isa::TargetIsa;
|
||||
|
||||
/// Indicates an unknown instance was specified.
|
||||
#[derive(Error, Debug)]
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
use crate::compiler::Compiler;
|
||||
use crate::link::link_module;
|
||||
use crate::resolver::Resolver;
|
||||
use cranelift_entity::{BoxedSlice, PrimaryMap};
|
||||
use cranelift_wasm::{DefinedFuncIndex, SignatureIndex};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::io::Write;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use wasmtime_debug::read_debuginfo;
|
||||
use wasmtime_environ::entity::{BoxedSlice, PrimaryMap};
|
||||
use wasmtime_environ::wasm::{DefinedFuncIndex, SignatureIndex};
|
||||
use wasmtime_environ::{
|
||||
CompileError, DataInitializer, DataInitializerLocation, Module, ModuleEnvironment,
|
||||
};
|
||||
|
||||
@@ -32,6 +32,9 @@ mod namespace;
|
||||
mod resolver;
|
||||
mod target_tunables;
|
||||
|
||||
pub mod native;
|
||||
pub mod trampoline;
|
||||
|
||||
pub use crate::action::{ActionError, ActionOutcome, RuntimeValue};
|
||||
pub use crate::code_memory::CodeMemory;
|
||||
pub use crate::compiler::{CompilationStrategy, Compiler};
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
use crate::resolver::Resolver;
|
||||
use cranelift_codegen::binemit::Reloc;
|
||||
use cranelift_codegen::ir::JumpTableOffsets;
|
||||
use cranelift_entity::PrimaryMap;
|
||||
use cranelift_wasm::{DefinedFuncIndex, Global, GlobalInit, Memory, Table, TableElementType};
|
||||
use more_asserts::assert_ge;
|
||||
use std::collections::HashSet;
|
||||
use std::ptr::write_unaligned;
|
||||
use wasmtime_environ::entity::PrimaryMap;
|
||||
use wasmtime_environ::wasm::{
|
||||
DefinedFuncIndex, Global, GlobalInit, Memory, Table, TableElementType,
|
||||
};
|
||||
use wasmtime_environ::{
|
||||
MemoryPlan, MemoryStyle, Module, Relocation, RelocationTarget, Relocations, TablePlan,
|
||||
};
|
||||
|
||||
14
crates/jit/src/native.rs
Normal file
14
crates/jit/src/native.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use cranelift_codegen;
|
||||
|
||||
pub fn builder() -> cranelift_codegen::isa::Builder {
|
||||
cranelift_native::builder().expect("host machine is not a supported target")
|
||||
}
|
||||
|
||||
pub fn call_conv() -> cranelift_codegen::isa::CallConv {
|
||||
use target_lexicon::HOST;
|
||||
cranelift_codegen::isa::CallConv::triple_default(&HOST)
|
||||
}
|
||||
|
||||
pub use cranelift_codegen::isa::lookup;
|
||||
56
crates/jit/src/trampoline.rs
Normal file
56
crates/jit/src/trampoline.rs
Normal file
@@ -0,0 +1,56 @@
|
||||
#![allow(missing_docs)]
|
||||
|
||||
pub mod ir {
|
||||
pub use cranelift_codegen::ir::{
|
||||
ExternalName, Function, InstBuilder, MemFlags, StackSlotData, StackSlotKind,
|
||||
};
|
||||
}
|
||||
pub use cranelift_codegen::print_errors::pretty_error;
|
||||
pub use cranelift_codegen::Context;
|
||||
pub use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
|
||||
|
||||
pub mod binemit {
|
||||
pub use cranelift_codegen::binemit::{CodeOffset, NullStackmapSink, TrapSink};
|
||||
|
||||
use cranelift_codegen::{binemit, ir};
|
||||
|
||||
/// We don't expect trampoline compilation to produce any relocations, so
|
||||
/// this `RelocSink` just asserts that it doesn't recieve any.
|
||||
pub struct TrampolineRelocSink {}
|
||||
|
||||
impl binemit::RelocSink for TrampolineRelocSink {
|
||||
fn reloc_ebb(
|
||||
&mut self,
|
||||
_offset: binemit::CodeOffset,
|
||||
_reloc: binemit::Reloc,
|
||||
_ebb_offset: binemit::CodeOffset,
|
||||
) {
|
||||
panic!("trampoline compilation should not produce ebb relocs");
|
||||
}
|
||||
fn reloc_external(
|
||||
&mut self,
|
||||
_offset: binemit::CodeOffset,
|
||||
_reloc: binemit::Reloc,
|
||||
_name: &ir::ExternalName,
|
||||
_addend: binemit::Addend,
|
||||
) {
|
||||
panic!("trampoline compilation should not produce external symbol relocs");
|
||||
}
|
||||
fn reloc_constant(
|
||||
&mut self,
|
||||
_code_offset: binemit::CodeOffset,
|
||||
_reloc: binemit::Reloc,
|
||||
_constant_offset: ir::ConstantOffset,
|
||||
) {
|
||||
panic!("trampoline compilation should not produce constant relocs");
|
||||
}
|
||||
fn reloc_jt(
|
||||
&mut self,
|
||||
_offset: binemit::CodeOffset,
|
||||
_reloc: binemit::Reloc,
|
||||
_jt: ir::JumpTable,
|
||||
) {
|
||||
panic!("trampoline compilation should not produce jump table relocs");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,6 @@ name = "_wasmtime"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
cranelift-codegen = "0.50.0"
|
||||
cranelift-native = "0.50.0"
|
||||
cranelift-entity = "0.50.0"
|
||||
cranelift-wasm = "0.50.0"
|
||||
cranelift-frontend = "0.50.0"
|
||||
wasmtime = { path = "../../api" }
|
||||
wasmtime-environ = { path = "../../environ" }
|
||||
wasmtime-interface-types = { path = "../../interface-types" }
|
||||
|
||||
@@ -11,9 +11,6 @@ readme = "README.md"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] }
|
||||
cranelift-entity = { version = "0.50.0", features = ["enable-serde"] }
|
||||
cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] }
|
||||
wasmtime-environ = { path = "../environ" }
|
||||
faerie = "0.13.0"
|
||||
more-asserts = "0.2.1"
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#![allow(clippy::cast_ptr_alignment)]
|
||||
|
||||
use cranelift_codegen::isa::TargetFrontendConfig;
|
||||
use cranelift_entity::EntityRef;
|
||||
use cranelift_wasm::GlobalInit;
|
||||
use more_asserts::assert_le;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::collections::HashMap;
|
||||
use std::ptr;
|
||||
use wasmtime_environ::entity::EntityRef;
|
||||
use wasmtime_environ::isa::TargetFrontendConfig;
|
||||
use wasmtime_environ::wasm::GlobalInit;
|
||||
use wasmtime_environ::{Module, TargetSharedSignatureIndex, VMOffsets};
|
||||
|
||||
pub struct TableRelocation {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use cranelift_codegen::settings;
|
||||
use cranelift_codegen::settings::Configurable;
|
||||
use cranelift_entity::EntityRef;
|
||||
use faerie::{Artifact, Decl, Link};
|
||||
use wasmtime_environ::entity::EntityRef;
|
||||
use wasmtime_environ::settings;
|
||||
use wasmtime_environ::settings::Configurable;
|
||||
use wasmtime_environ::{Compilation, Module, RelocationTarget, Relocations};
|
||||
|
||||
fn get_reloc_target_special_import_name(target: RelocationTarget) -> Option<&'static str> {
|
||||
|
||||
@@ -2,8 +2,8 @@ use crate::context::layout_vmcontext;
|
||||
use crate::data_segment::{declare_data_segment, emit_data_segment};
|
||||
use crate::function::{declare_functions, emit_functions};
|
||||
use crate::table::{declare_table, emit_table};
|
||||
use cranelift_codegen::isa::TargetFrontendConfig;
|
||||
use faerie::{Artifact, Decl, Link};
|
||||
use wasmtime_environ::isa::TargetFrontendConfig;
|
||||
use wasmtime_environ::{Compilation, DataInitializer, Module, Relocations};
|
||||
|
||||
fn emit_vmcontext_init(
|
||||
|
||||
@@ -11,9 +11,6 @@ readme = "README.md"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] }
|
||||
cranelift-entity = { version = "0.50.0", features = ["enable-serde"] }
|
||||
cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] }
|
||||
wasmtime-environ = { path = "../environ" }
|
||||
region = "2.0.0"
|
||||
lazy_static = "1.2.0"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::vmcontext::{
|
||||
VMContext, VMFunctionBody, VMGlobalDefinition, VMMemoryDefinition, VMTableDefinition,
|
||||
};
|
||||
use cranelift_codegen::ir;
|
||||
use cranelift_wasm::Global;
|
||||
use wasmtime_environ::ir;
|
||||
use wasmtime_environ::wasm::Global;
|
||||
use wasmtime_environ::{MemoryPlan, TablePlan};
|
||||
|
||||
/// The value of an export passed from one instance to another.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::instance::InstanceHandle;
|
||||
use crate::vmcontext::{VMFunctionImport, VMGlobalImport, VMMemoryImport, VMTableImport};
|
||||
use cranelift_entity::{BoxedSlice, PrimaryMap};
|
||||
use cranelift_wasm::{FuncIndex, GlobalIndex, MemoryIndex, TableIndex};
|
||||
use std::collections::HashSet;
|
||||
use wasmtime_environ::entity::{BoxedSlice, PrimaryMap};
|
||||
use wasmtime_environ::wasm::{FuncIndex, GlobalIndex, MemoryIndex, TableIndex};
|
||||
|
||||
/// Resolved import pointers.
|
||||
#[derive(Clone)]
|
||||
|
||||
@@ -15,11 +15,6 @@ use crate::vmcontext::{
|
||||
VMGlobalDefinition, VMGlobalImport, VMMemoryDefinition, VMMemoryImport, VMSharedSignatureIndex,
|
||||
VMTableDefinition, VMTableImport,
|
||||
};
|
||||
use cranelift_entity::{BoxedSlice, EntityRef, PrimaryMap};
|
||||
use cranelift_wasm::{
|
||||
DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex, FuncIndex,
|
||||
GlobalIndex, GlobalInit, MemoryIndex, SignatureIndex, TableIndex,
|
||||
};
|
||||
use memoffset::offset_of;
|
||||
use more_asserts::assert_lt;
|
||||
use std::any::Any;
|
||||
@@ -30,6 +25,11 @@ use std::convert::TryFrom;
|
||||
use std::rc::Rc;
|
||||
use std::{mem, ptr, slice};
|
||||
use thiserror::Error;
|
||||
use wasmtime_environ::entity::{BoxedSlice, EntityRef, PrimaryMap};
|
||||
use wasmtime_environ::wasm::{
|
||||
DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex, FuncIndex,
|
||||
GlobalIndex, GlobalInit, MemoryIndex, SignatureIndex, TableIndex,
|
||||
};
|
||||
use wasmtime_environ::{DataInitializer, Module, TableElements, VMOffsets};
|
||||
|
||||
fn signature_id(
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! instructions which compute them directly.
|
||||
|
||||
use crate::vmcontext::VMContext;
|
||||
use cranelift_wasm::{DefinedMemoryIndex, MemoryIndex};
|
||||
use wasmtime_environ::wasm::{DefinedMemoryIndex, MemoryIndex};
|
||||
|
||||
/// Implementation of f32.ceil
|
||||
pub extern "C" fn wasmtime_f32_ceil(x: f32) -> f32 {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
//! signature checking.
|
||||
|
||||
use crate::vmcontext::VMSharedSignatureIndex;
|
||||
use cranelift_codegen::ir;
|
||||
use more_asserts::{assert_lt, debug_assert_lt};
|
||||
use std::collections::{hash_map, HashMap};
|
||||
use std::convert::TryFrom;
|
||||
use wasmtime_environ::ir;
|
||||
|
||||
/// WebAssembly requires that the caller and callee signatures in an indirect
|
||||
/// call must match. To implement this efficiently, keep a registry of all
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
//! `Table` is to WebAssembly tables what `LinearMemory` is to WebAssembly linear memories.
|
||||
|
||||
use crate::vmcontext::{VMCallerCheckedAnyfunc, VMTableDefinition};
|
||||
use cranelift_wasm::TableElementType;
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use wasmtime_environ::wasm::TableElementType;
|
||||
use wasmtime_environ::{TablePlan, TableStyle};
|
||||
|
||||
/// A table instance.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use cranelift_codegen::ir;
|
||||
use lazy_static::lazy_static;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||
use wasmtime_environ::ir;
|
||||
|
||||
lazy_static! {
|
||||
static ref REGISTRY: RwLock<TrapRegistry> = RwLock::new(TrapRegistry::default());
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
use crate::trap_registry::get_trap_registry;
|
||||
use crate::trap_registry::TrapDescription;
|
||||
use crate::vmcontext::{VMContext, VMFunctionBody};
|
||||
use cranelift_codegen::ir;
|
||||
use std::cell::Cell;
|
||||
use std::ptr;
|
||||
use wasmtime_environ::ir;
|
||||
|
||||
extern "C" {
|
||||
fn WasmtimeCallTrampoline(
|
||||
|
||||
@@ -16,7 +16,6 @@ wasmtime-environ = { path = "../environ" }
|
||||
wasmtime-jit = { path = "../jit" }
|
||||
wasmtime-wasi = { path = "../wasi" }
|
||||
wasmtime = { path = "../api" }
|
||||
cranelift-codegen = "0.50.0"
|
||||
target-lexicon = "0.9.0"
|
||||
pretty_env_logger = "0.3.0"
|
||||
tempfile = "3.1.0"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use anyhow::{bail, Context};
|
||||
use cranelift_codegen::settings::{self, Configurable};
|
||||
use std::fs::File;
|
||||
use std::{collections::HashMap, path::Path};
|
||||
use wasmtime::{Config, Engine, HostRef, Instance, Module, Store};
|
||||
use wasmtime_environ::settings::{self, Configurable};
|
||||
|
||||
pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> anyhow::Result<()> {
|
||||
// Prepare runtime
|
||||
|
||||
@@ -11,9 +11,6 @@ readme = "README.md"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] }
|
||||
cranelift-entity = { version = "0.50.0", features = ["enable-serde"] }
|
||||
cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] }
|
||||
wasmtime-jit = { path = "../jit" }
|
||||
wasmtime-runtime = { path = "../runtime" }
|
||||
wasmtime-environ = { path = "../environ" }
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
use cranelift_codegen::ir::types;
|
||||
use cranelift_codegen::{ir, isa};
|
||||
use cranelift_entity::PrimaryMap;
|
||||
use cranelift_wasm::{DefinedFuncIndex, Global, GlobalInit, Memory, Table, TableElementType};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::hash_map::HashMap;
|
||||
use std::rc::Rc;
|
||||
use target_lexicon::HOST;
|
||||
use wasmtime_environ::entity::PrimaryMap;
|
||||
use wasmtime_environ::ir::types;
|
||||
use wasmtime_environ::wasm::{
|
||||
DefinedFuncIndex, Global, GlobalInit, Memory, Table, TableElementType,
|
||||
};
|
||||
use wasmtime_environ::{ir, isa};
|
||||
use wasmtime_environ::{translate_signature, Export, MemoryPlan, Module, TablePlan};
|
||||
use wasmtime_jit::target_tunables;
|
||||
use wasmtime_runtime::{Imports, InstanceHandle, InstantiationError, VMContext, VMFunctionBody};
|
||||
|
||||
@@ -29,10 +29,6 @@
|
||||
)
|
||||
)]
|
||||
|
||||
use cranelift_codegen::settings::Configurable;
|
||||
use cranelift_codegen::{isa, settings};
|
||||
use cranelift_entity::EntityRef;
|
||||
use cranelift_wasm::DefinedMemoryIndex;
|
||||
use docopt::Docopt;
|
||||
use faerie::Artifact;
|
||||
use serde::Deserialize;
|
||||
@@ -44,13 +40,17 @@ use std::{process, str};
|
||||
use target_lexicon::Triple;
|
||||
use wasmtime_cli::pick_compilation_strategy;
|
||||
use wasmtime_debug::{emit_debugsections, read_debuginfo};
|
||||
use wasmtime_environ::entity::EntityRef;
|
||||
use wasmtime_environ::settings;
|
||||
use wasmtime_environ::settings::Configurable;
|
||||
use wasmtime_environ::wasm::DefinedMemoryIndex;
|
||||
#[cfg(feature = "lightbeam")]
|
||||
use wasmtime_environ::Lightbeam;
|
||||
use wasmtime_environ::{
|
||||
cache_create_new_config, cache_init, Compiler, Cranelift, ModuleEnvironment, ModuleVmctxInfo,
|
||||
Tunables, VMOffsets,
|
||||
};
|
||||
use wasmtime_jit::CompilationStrategy;
|
||||
use wasmtime_jit::{native, CompilationStrategy};
|
||||
use wasmtime_obj::emit_module;
|
||||
|
||||
const USAGE: &str = "
|
||||
@@ -190,11 +190,9 @@ fn handle_module(
|
||||
let isa_builder = match *target {
|
||||
Some(ref target) => {
|
||||
let target = Triple::from_str(&target).map_err(|_| "could not parse --target")?;
|
||||
isa::lookup(target).map_err(|err| format!("{:?}", err))?
|
||||
native::lookup(target).map_err(|err| format!("{:?}", err))?
|
||||
}
|
||||
None => cranelift_native::builder().unwrap_or_else(|_| {
|
||||
panic!("host machine is not a supported target");
|
||||
}),
|
||||
None => native::builder(),
|
||||
};
|
||||
let mut flag_builder = settings::builder();
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
)]
|
||||
|
||||
use anyhow::{bail, Context as _, Result};
|
||||
use cranelift_codegen::{settings, settings::Configurable};
|
||||
use docopt::Docopt;
|
||||
use serde::Deserialize;
|
||||
use std::path::{Component, Path};
|
||||
@@ -40,6 +39,7 @@ use wasi_common::preopen_dir;
|
||||
use wasmtime::{Config, Engine, HostRef, Instance, Module, Store};
|
||||
use wasmtime_cli::pick_compilation_strategy;
|
||||
use wasmtime_environ::{cache_create_new_config, cache_init};
|
||||
use wasmtime_environ::{settings, settings::Configurable};
|
||||
use wasmtime_interface_types::ModuleData;
|
||||
use wasmtime_jit::Features;
|
||||
use wasmtime_wasi::create_wasi_instance;
|
||||
|
||||
@@ -25,16 +25,16 @@
|
||||
)
|
||||
)]
|
||||
|
||||
use cranelift_codegen::settings;
|
||||
use cranelift_codegen::settings::Configurable;
|
||||
use cranelift_native;
|
||||
use docopt::Docopt;
|
||||
use pretty_env_logger;
|
||||
use serde::Deserialize;
|
||||
use std::path::Path;
|
||||
use std::process;
|
||||
use wasmtime_cli::pick_compilation_strategy;
|
||||
use wasmtime_environ::settings;
|
||||
use wasmtime_environ::settings::Configurable;
|
||||
use wasmtime_environ::{cache_create_new_config, cache_init};
|
||||
use wasmtime_jit::native;
|
||||
use wasmtime_jit::{Compiler, Features};
|
||||
use wasmtime_wast::WastContext;
|
||||
|
||||
@@ -128,9 +128,7 @@ fn main() {
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
let isa_builder = cranelift_native::builder().unwrap_or_else(|_| {
|
||||
panic!("host machine is not a supported target");
|
||||
});
|
||||
let isa_builder = native::builder();
|
||||
let mut flag_builder = settings::builder();
|
||||
let mut features: Features = Default::default();
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use cranelift_codegen::settings;
|
||||
use cranelift_codegen::settings::Configurable;
|
||||
use more_asserts::assert_gt;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
use wasmtime_jit::{instantiate, CompilationStrategy, Compiler, NullResolver};
|
||||
use wasmtime_environ::settings;
|
||||
use wasmtime_environ::settings::Configurable;
|
||||
use wasmtime_jit::{instantiate, native, CompilationStrategy, Compiler, NullResolver};
|
||||
|
||||
const PATH_MODULE_RS2WASM_ADD_FUNC: &str = r"tests/wat/rs2wasm-add-func.wat";
|
||||
|
||||
@@ -19,9 +19,7 @@ fn test_environ_translate() {
|
||||
let mut flag_builder = settings::builder();
|
||||
flag_builder.enable("enable_verifier").unwrap();
|
||||
|
||||
let isa_builder = cranelift_native::builder().unwrap_or_else(|_| {
|
||||
panic!("host machine is not a supported target");
|
||||
});
|
||||
let isa_builder = native::builder();
|
||||
let isa = isa_builder.finish(settings::Flags::new(flag_builder));
|
||||
|
||||
let mut resolver = NullResolver {};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use cranelift_codegen::settings::Configurable;
|
||||
use cranelift_codegen::{isa, settings};
|
||||
use std::path::Path;
|
||||
use wasmtime_jit::{CompilationStrategy, Compiler, Features};
|
||||
use wasmtime_environ::settings::Configurable;
|
||||
use wasmtime_environ::{isa, settings};
|
||||
use wasmtime_jit::{native, CompilationStrategy, Compiler, Features};
|
||||
use wasmtime_wast::WastContext;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/wast_testsuite_tests.rs"));
|
||||
@@ -30,9 +30,7 @@ fn native_isa() -> Box<dyn isa::TargetIsa> {
|
||||
flag_builder.enable("avoid_div_traps").unwrap();
|
||||
flag_builder.enable("enable_simd").unwrap();
|
||||
|
||||
let isa_builder = cranelift_native::builder().unwrap_or_else(|_| {
|
||||
panic!("host machine is not a supported target");
|
||||
});
|
||||
let isa_builder = native::builder();
|
||||
|
||||
isa_builder.finish(settings::Flags::new(flag_builder))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user