Fix tests for the Cranelift backend

This commit is contained in:
Mark McCaskey
2020-04-24 14:30:14 -07:00
parent b9ec8f9845
commit 9723270f96
18 changed files with 69 additions and 46 deletions

View File

@ -56,7 +56,7 @@ extern "C" {
/// but this is cleaner, I think?
#[cfg_attr(nightly, unwind(allowed))]
#[allow(improper_ctypes)]
fn throw_runtime_error(data: RuntimeError) -> !;
fn throw_runtime_error(data: *mut Option<RuntimeError>) -> !;
#[allow(improper_ctypes)]
fn cxx_invoke_trampoline(
@ -475,8 +475,7 @@ impl RunnableModule for LLVMBackend {
}
unsafe fn do_early_trap(&self, data: RuntimeError) -> ! {
// maybe need to box leak it?
throw_runtime_error(data)
throw_runtime_error(Box::into_raw(Box::new(Some(data))))
}
}

View File

@ -35,6 +35,7 @@ use wasmer_runtime_core::{
backend::{CacheGen, CompilerConfig, Token},
cache::{Artifact, Error as CacheError},
codegen::*,
error::RuntimeError,
memory::MemoryType,
module::{ModuleInfo, ModuleInner},
parse::{wp_type_to_type, LoadError},
@ -940,12 +941,11 @@ pub struct CodegenError {
// prevents unused function elimination.
#[no_mangle]
pub unsafe extern "C" fn callback_trampoline(
b: *mut Option<Box<dyn std::any::Any>>,
b: *mut Option<RuntimeError>,
callback: *mut BreakpointHandler,
) {
let callback = Box::from_raw(callback);
let result: Result<(), Box<dyn std::any::Any + Send>> =
callback(BreakpointInfo { fault: None });
let result: Result<(), RuntimeError> = callback(BreakpointInfo { fault: None });
match result {
Ok(()) => *b = None,
Err(e) => *b = Some(e),