Remove dependency on TargetIsa from Wasmtime crates (#3178)
This commit started off by deleting the `cranelift_codegen::settings` reexport in the `wasmtime-environ` crate and then basically played whack-a-mole until everything compiled again. The main result of this is that the `wasmtime-*` family of crates have generally less of a dependency on the `TargetIsa` trait and type from Cranelift. While the dependency isn't entirely severed yet this is at least a significant start. This commit is intended to be largely refactorings, no functional changes are intended here. The refactorings are: * A `CompilerBuilder` trait has been added to `wasmtime_environ` which server as an abstraction used to create compilers and configure them in a uniform fashion. The `wasmtime::Config` type now uses this instead of cranelift-specific settings. The `wasmtime-jit` crate exports the ability to create a compiler builder from a `CompilationStrategy`, which only works for Cranelift right now. In a cranelift-less build of Wasmtime this is expected to return a trait object that fails all requests to compile. * The `Compiler` trait in the `wasmtime_environ` crate has been souped up with a number of methods that Wasmtime and other crates needed. * The `wasmtime-debug` crate is now moved entirely behind the `wasmtime-cranelift` crate. * The `wasmtime-cranelift` crate is now only depended on by the `wasmtime-jit` crate. * Wasm types in `cranelift-wasm` no longer contain their IR type, instead they only contain the `WasmType`. This is required to get everything to align correctly but will also be required in a future refactoring where the types used by `cranelift-wasm` will be extracted to a separate crate. * I moved around a fair bit of code in `wasmtime-cranelift`. * Some gdb-specific jit-specific code has moved from `wasmtime-debug` to `wasmtime-jit`.
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
//! Module for System V ABI unwind registry.
|
||||
|
||||
use crate::Compiler;
|
||||
use anyhow::{bail, Result};
|
||||
use gimli::{
|
||||
write::{Address, EhFrame, EndianVec, FrameTable, Writer},
|
||||
RunTimeEndian,
|
||||
};
|
||||
use wasmtime_environ::isa::{unwind::UnwindInfo, TargetIsa};
|
||||
use wasmtime_environ::isa::unwind::UnwindInfo;
|
||||
|
||||
/// Represents a registry of function unwind information for System V ABI.
|
||||
pub struct UnwindRegistry {
|
||||
@@ -53,7 +54,7 @@ impl UnwindRegistry {
|
||||
}
|
||||
|
||||
/// Publishes all registered functions.
|
||||
pub fn publish(&mut self, isa: &dyn TargetIsa) -> Result<()> {
|
||||
pub fn publish(&mut self, compiler: &Compiler) -> Result<()> {
|
||||
if self.published {
|
||||
bail!("unwind registry has already been published");
|
||||
}
|
||||
@@ -63,7 +64,7 @@ impl UnwindRegistry {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
self.set_frame_table(isa)?;
|
||||
self.set_frame_table(compiler)?;
|
||||
|
||||
unsafe {
|
||||
self.register_frames();
|
||||
@@ -74,9 +75,9 @@ impl UnwindRegistry {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_frame_table(&mut self, isa: &dyn TargetIsa) -> Result<()> {
|
||||
fn set_frame_table(&mut self, compiler: &Compiler) -> Result<()> {
|
||||
let mut table = FrameTable::default();
|
||||
let cie_id = table.add_cie(match isa.create_systemv_cie() {
|
||||
let cie_id = table.add_cie(match compiler.compiler().create_systemv_cie() {
|
||||
Some(cie) => cie,
|
||||
None => bail!("ISA does not support System V unwind information"),
|
||||
});
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
//! Module for Windows x64 ABI unwind registry.
|
||||
|
||||
use crate::Compiler;
|
||||
use anyhow::{bail, Result};
|
||||
use wasmtime_environ::isa::{unwind::UnwindInfo, TargetIsa};
|
||||
use wasmtime_environ::isa::unwind::UnwindInfo;
|
||||
use winapi::um::winnt;
|
||||
|
||||
/// Represents a registry of function unwind information for Windows x64 ABI.
|
||||
@@ -49,7 +50,7 @@ impl UnwindRegistry {
|
||||
}
|
||||
|
||||
/// Publishes all registered functions.
|
||||
pub fn publish(&mut self, _isa: &dyn TargetIsa) -> Result<()> {
|
||||
pub fn publish(&mut self, _compiler: &Compiler) -> Result<()> {
|
||||
if self.published {
|
||||
bail!("unwind registry has already been published");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user