Removes duplicate code in src/obj.rs, crates/obj and crates/jit/object.rs (#1993)

Changes:

 -  Moves object creation code from crates/jit/object.rs to the creates/obj (as ObjectBuilder)
 -   Removes legacy crates/obj/function.rs
 -  Removes write_debugsections
This commit is contained in:
Yury Delendik
2020-07-08 12:14:19 -05:00
committed by GitHub
parent 2a4f72aeb7
commit 091373f9b8
17 changed files with 621 additions and 594 deletions

View File

@@ -71,6 +71,14 @@ impl Compilation {
self.functions.is_empty()
}
/// Returns unwind info for all defined functions.
pub fn unwind_info(&self) -> PrimaryMap<DefinedFuncIndex, &Option<UnwindInfo>> {
self.functions
.iter()
.map(|(_, func)| &func.unwind_info)
.collect::<PrimaryMap<DefinedFuncIndex, _>>()
}
/// Gets functions jump table offsets.
pub fn get_jt_offsets(&self) -> PrimaryMap<DefinedFuncIndex, ir::JumpTableOffsets> {
self.functions

View File

@@ -1,10 +1,10 @@
#![doc(hidden)]
pub mod ir {
pub use cranelift_codegen::binemit::Stackmap;
pub use cranelift_codegen::binemit::{Reloc, Stackmap};
pub use cranelift_codegen::ir::{
types, AbiParam, ArgumentPurpose, Signature, SourceLoc, StackSlots, TrapCode, Type,
ValueLabel, ValueLoc,
types, AbiParam, ArgumentPurpose, JumpTableOffsets, LibCall, Signature, SourceLoc,
StackSlots, TrapCode, Type, ValueLabel, ValueLoc,
};
pub use cranelift_codegen::{ValueLabelsRanges, ValueLocRange};
}

View File

@@ -87,3 +87,28 @@ pub(crate) fn reference_type(
_ => panic!("unsupported Wasm reference type"),
}
}
/// Iterates through all `LibCall` members and all runtime exported functions.
#[macro_export]
macro_rules! for_each_libcall {
($op:ident) => {
$op![
(UdivI64, wasmtime_i64_udiv),
(UdivI64, wasmtime_i64_udiv),
(SdivI64, wasmtime_i64_sdiv),
(UremI64, wasmtime_i64_urem),
(SremI64, wasmtime_i64_srem),
(IshlI64, wasmtime_i64_ishl),
(UshrI64, wasmtime_i64_ushr),
(SshrI64, wasmtime_i64_sshr),
(CeilF32, wasmtime_f32_ceil),
(FloorF32, wasmtime_f32_floor),
(TruncF32, wasmtime_f32_trunc),
(NearestF32, wasmtime_f32_nearest),
(CeilF64, wasmtime_f64_ceil),
(FloorF64, wasmtime_f64_floor),
(TruncF64, wasmtime_f64_trunc),
(NearestF64, wasmtime_f64_nearest)
];
};
}