mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-08 05:38:19 +00:00
Wire up llvm code generated traps to the new runtime trap handler function.
This commit is contained in:
@@ -213,6 +213,7 @@ impl FuncTranslator {
|
||||
|
||||
// TODO: use phf?
|
||||
let mut libcalls = HashMap::new();
|
||||
libcalls.insert("vm.exception.trap".to_string(), LibCall::RaiseTrap);
|
||||
libcalls.insert("truncf".to_string(), LibCall::TruncF32);
|
||||
libcalls.insert("trunc".to_string(), LibCall::TruncF64);
|
||||
libcalls.insert("ceilf".to_string(), LibCall::CeilF32);
|
||||
|
||||
@@ -38,7 +38,7 @@ use wasm_common::{
|
||||
SignatureIndex, TableIndex, Type,
|
||||
};
|
||||
use wasmer_runtime::Module as WasmerCompilerModule;
|
||||
use wasmer_runtime::{MemoryPlan, MemoryStyle, VMOffsets};
|
||||
use wasmer_runtime::{MemoryPlan, MemoryStyle, TrapCode, VMOffsets};
|
||||
|
||||
fn type_to_llvm_ptr<'ctx>(intrinsics: &Intrinsics<'ctx>, ty: Type) -> PointerType<'ctx> {
|
||||
match ty {
|
||||
@@ -462,12 +462,26 @@ impl<'ctx> Intrinsics<'ctx> {
|
||||
f32x4_zero,
|
||||
f64x2_zero,
|
||||
|
||||
trap_unreachable: i32_zero.as_basic_value_enum(),
|
||||
trap_call_indirect_sig: i32_ty.const_int(1, false).as_basic_value_enum(),
|
||||
trap_call_indirect_oob: i32_ty.const_int(3, false).as_basic_value_enum(),
|
||||
trap_memory_oob: i32_ty.const_int(2, false).as_basic_value_enum(),
|
||||
trap_illegal_arithmetic: i32_ty.const_int(4, false).as_basic_value_enum(),
|
||||
trap_misaligned_atomic: i32_ty.const_int(5, false).as_basic_value_enum(),
|
||||
trap_unreachable: i32_ty
|
||||
.const_int(TrapCode::UnreachableCodeReached as _, false)
|
||||
.as_basic_value_enum(),
|
||||
trap_call_indirect_sig: i32_ty
|
||||
.const_int(TrapCode::BadSignature as _, false)
|
||||
.as_basic_value_enum(),
|
||||
trap_call_indirect_oob: i32_ty
|
||||
.const_int(TrapCode::OutOfBounds as _, false)
|
||||
.as_basic_value_enum(),
|
||||
trap_memory_oob: i32_ty
|
||||
.const_int(TrapCode::OutOfBounds as _, false)
|
||||
.as_basic_value_enum(),
|
||||
// TODO: split out div-by-zero and float-to-int
|
||||
trap_illegal_arithmetic: i32_ty
|
||||
.const_int(TrapCode::IntegerOverflow as _, false)
|
||||
.as_basic_value_enum(),
|
||||
// TODO: add misaligned atomic traps to wasmer runtime
|
||||
trap_misaligned_atomic: i32_ty
|
||||
.const_int(TrapCode::Interrupt as _, false)
|
||||
.as_basic_value_enum(),
|
||||
|
||||
// VM intrinsics.
|
||||
memory_grow_dynamic_local: module.add_function(
|
||||
|
||||
Reference in New Issue
Block a user