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