Add support for panicking/returning err back to llvm

This commit is contained in:
Lachlan Sneff
2019-04-10 14:17:10 -07:00
parent 6848e81a77
commit 1cb3fbea0a
3 changed files with 19 additions and 9 deletions

View File

@ -75,7 +75,11 @@ extern "C" {
fn module_delete(module: *mut LLVMModule);
fn get_func_symbol(module: *mut LLVMModule, name: *const c_char) -> *const vm::Func;
fn throw_trap(ty: i32);
fn throw_trap(ty: i32) -> !;
/// This should be the same as spliting up the fat pointer into two arguments,
/// but this is cleaner, I think?
fn throw_any(data: *mut dyn Any) -> !;
#[allow(improper_ctypes)]
fn invoke_trampoline(
@ -433,8 +437,8 @@ impl ProtectedCaller for LLVMProtectedCaller {
}
impl UserTrapper for Placeholder {
unsafe fn do_early_trap(&self, _data: Box<dyn Any>) -> ! {
unimplemented!("do early trap")
unsafe fn do_early_trap(&self, data: Box<dyn Any>) -> ! {
throw_any(Box::leak(data))
}
}