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:
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user