Update Lightbeam for various API changes.

This commit is contained in:
Dan Gohman
2019-10-02 10:10:32 -07:00
parent 9757f7194c
commit 8d52e389f8
3 changed files with 28 additions and 6 deletions

View File

@@ -22,7 +22,7 @@ failure_derive = "0.1.3"
cranelift-codegen = "0.44"
multi_mut = "0.1"
either = "1.5"
wabt = "0.7"
wabt = "0.9.2"
lazy_static = "1.2"
quickcheck = "0.7"
typemap = "0.3"

View File

@@ -153,6 +153,10 @@ pub enum CompileError {
/// A compilation error occured.
#[fail(display = "Compilation error: {}", _0)]
Codegen(CodegenError),
/// A compilation error occured.
#[fail(display = "Debug info is not supported with this configuration")]
DebugInfoNotSupported,
}
/// An implementation of a compiler from parsed WebAssembly module to native code.

View File

@@ -1,12 +1,13 @@
//! Support for compiling with Lightbeam.
use crate::compilation::{AddressTransforms, Compilation, CompileError, Relocations};
use crate::compilation::{Compilation, CompileError, Relocations, Traps};
use crate::func_environ::FuncEnvironment;
use crate::module::Module;
use crate::module_environ::FunctionBodyData;
// TODO: Put this in `compilation`
use crate::address_map::{ModuleAddressMap, ValueLabelsRanges};
use crate::cranelift::RelocSink;
use cranelift_codegen::isa;
use cranelift_codegen::{ir, isa};
use cranelift_entity::{PrimaryMap, SecondaryMap};
use cranelift_wasm::DefinedFuncIndex;
use lightbeam;
@@ -22,8 +23,22 @@ impl crate::compilation::Compiler for Lightbeam {
function_body_inputs: PrimaryMap<DefinedFuncIndex, FunctionBodyData<'data>>,
isa: &dyn isa::TargetIsa,
// TODO
_generate_debug_info: bool,
) -> Result<(Compilation, Relocations, AddressTransforms), CompileError> {
generate_debug_info: bool,
) -> Result<
(
Compilation,
Relocations,
ModuleAddressMap,
ValueLabelsRanges,
PrimaryMap<DefinedFuncIndex, ir::StackSlots>,
Traps,
),
CompileError,
> {
if generate_debug_info {
return Err(CompileError::DebugInfoNotSupported);
}
let env = FuncEnvironment::new(isa.frontend_config(), module);
let mut relocations = PrimaryMap::new();
let mut codegen_session: lightbeam::CodeGenSession<_> =
@@ -57,7 +72,10 @@ impl crate::compilation::Compiler for Lightbeam {
Ok((
Compilation::from_buffer(code_section.buffer().to_vec(), code_section_ranges_and_jt),
relocations,
AddressTransforms::new(),
ModuleAddressMap::new(),
ValueLabelsRanges::new(),
PrimaryMap::new(),
Traps::new(),
))
}
}