mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-18 11:21:21 +00:00
Remove multiple throwing functions, just use one.
This commit is contained in:
@ -71,9 +71,9 @@ extern "C" {
|
||||
) -> LLVMResult;
|
||||
fn module_delete(module: *mut LLVMModule);
|
||||
fn get_func_symbol(module: *mut LLVMModule, name: *const c_char) -> *const vm::Func;
|
||||
fn throw_unreachable_exception();
|
||||
fn throw_incorrect_call_indirect_signature();
|
||||
// invoke_trampoline(trampoline_t trampoline, void* ctx, void* func, void* params, void* results)
|
||||
|
||||
fn throw_trap(ty: i32);
|
||||
|
||||
fn invoke_trampoline(
|
||||
trampoline: unsafe extern "C" fn(*mut vm::Ctx, *const vm::Func, *const u64, *mut u64),
|
||||
vmctx_ptr: *mut vm::Ctx,
|
||||
@ -173,10 +173,8 @@ fn get_callbacks() -> Callbacks {
|
||||
fn_name!("vm.memory.grow.static.local") => vmcalls::local_static_memory_grow as _,
|
||||
fn_name!("vm.memory.size.static.local") => vmcalls::local_static_memory_size as _,
|
||||
|
||||
fn_name!("vm.exception.throw.unreachable") => throw_unreachable_exception as _,
|
||||
fn_name!("vm.exception.throw.incorrect-call_indirect_signature") => {
|
||||
throw_incorrect_call_indirect_signature as _
|
||||
}
|
||||
fn_name!("vm.exception.trap") => throw_trap as _,
|
||||
|
||||
_ => ptr::null(),
|
||||
}
|
||||
}
|
||||
|
@ -540,9 +540,11 @@ fn parse_function(
|
||||
// If llvm cannot prove that this is never touched,
|
||||
// it will emit a `ud2` instruction on x86_64 arches.
|
||||
|
||||
builder.build_call(intrinsics.throw_unreachable, &[], "throw");
|
||||
|
||||
ctx.build_trap();
|
||||
builder.build_call(
|
||||
intrinsics.throw_trap,
|
||||
&[intrinsics.trap_unreachable],
|
||||
"throw",
|
||||
);
|
||||
builder.build_unreachable();
|
||||
|
||||
state.reachable = false;
|
||||
@ -767,8 +769,8 @@ fn parse_function(
|
||||
|
||||
builder.position_at_end(&sigindices_notequal_block);
|
||||
builder.build_call(
|
||||
intrinsics.throw_incorrect_call_indirect_signature,
|
||||
&[],
|
||||
intrinsics.throw_trap,
|
||||
&[intrinsics.trap_call_indirect_sig],
|
||||
"throw",
|
||||
);
|
||||
builder.build_unreachable();
|
||||
|
@ -90,6 +90,10 @@ pub struct Intrinsics {
|
||||
pub f32_zero: FloatValue,
|
||||
pub f64_zero: FloatValue,
|
||||
|
||||
pub trap_unreachable: BasicValueEnum,
|
||||
pub trap_call_indirect_sig: BasicValueEnum,
|
||||
pub trap_memory_oob: BasicValueEnum,
|
||||
|
||||
// VM intrinsics.
|
||||
pub memory_grow_dynamic_local: FunctionValue,
|
||||
pub memory_grow_static_local: FunctionValue,
|
||||
@ -105,8 +109,7 @@ pub struct Intrinsics {
|
||||
pub memory_size_static_import: FunctionValue,
|
||||
pub memory_size_shared_import: FunctionValue,
|
||||
|
||||
pub throw_unreachable: FunctionValue,
|
||||
pub throw_incorrect_call_indirect_signature: FunctionValue,
|
||||
pub throw_trap: FunctionValue,
|
||||
|
||||
ctx_ty: StructType,
|
||||
pub ctx_ptr_ty: PointerType,
|
||||
@ -285,6 +288,10 @@ impl Intrinsics {
|
||||
f32_zero,
|
||||
f64_zero,
|
||||
|
||||
trap_unreachable: i32_zero.as_basic_value_enum(),
|
||||
trap_call_indirect_sig: i32_ty.const_int(1, false).as_basic_value_enum(),
|
||||
trap_memory_oob: i32_ty.const_int(2, false).as_basic_value_enum(),
|
||||
|
||||
// VM intrinsics.
|
||||
memory_grow_dynamic_local: module.add_function(
|
||||
"vm.memory.grow.dynamic.local",
|
||||
@ -347,14 +354,9 @@ impl Intrinsics {
|
||||
ret_i32_take_ctx_i32,
|
||||
None,
|
||||
),
|
||||
throw_unreachable: module.add_function(
|
||||
"vm.exception.throw.unreachable",
|
||||
void_ty.fn_type(&[], false),
|
||||
None,
|
||||
),
|
||||
throw_incorrect_call_indirect_signature: module.add_function(
|
||||
"vm.exception.throw.incorrect-call_indirect_signature",
|
||||
void_ty.fn_type(&[], false),
|
||||
throw_trap: module.add_function(
|
||||
"vm.exception.trap",
|
||||
void_ty.fn_type(&[i32_ty_basic], false),
|
||||
None,
|
||||
),
|
||||
ctx_ty,
|
||||
|
Reference in New Issue
Block a user