fast-interp: Fix GC opcode ref.as_non_null (#3156)

The issue was found in https://github.com/bytecodealliance/wasm-micro-runtime/issues/3151.
This commit is contained in:
Wenyong Huang 2024-02-17 11:54:49 +08:00 committed by GitHub
parent b0c54c8a86
commit 3a0e86454e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 7 deletions

View File

@ -686,10 +686,12 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module,
bh_assert(func_index < comp_ctx->func_ctx_count);
bh_assert(LLVMGetReturnType(func_type) == ret_type);
const char *prefix = AOT_FUNC_PREFIX;
const bool need_precheck =
comp_ctx->enable_stack_bound_check || comp_ctx->enable_stack_estimation;
LLVMValueRef precheck_func;
LLVMValueRef precheck_func = NULL;
if (need_precheck) {
precheck_func = aot_add_llvm_func1(comp_ctx, module, func_index,
aot_func_type->param_count,

View File

@ -2437,11 +2437,12 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
HANDLE_OP(WASM_OP_REF_AS_NON_NULL)
{
gc_obj = GET_REF_FROM_ADDR(frame_sp - REF_CELL_NUM);
gc_obj = POP_REF();
if (gc_obj == NULL_REF) {
wasm_set_exception(module, "null reference");
goto got_exception;
}
PUSH_REF(gc_obj);
HANDLE_OP_END();
}

View File

@ -1967,12 +1967,12 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
}
HANDLE_OP(WASM_OP_REF_AS_NON_NULL)
{
opnd_off = GET_OFFSET();
gc_obj = GET_REF_FROM_ADDR(frame_lp + opnd_off);
gc_obj = POP_REF();
if (gc_obj == NULL_REF) {
wasm_set_exception(module, "null reference");
goto got_exception;
}
PUSH_REF(gc_obj);
HANDLE_OP_END();
}
HANDLE_OP(WASM_OP_REF_EQ)

View File

@ -12253,11 +12253,10 @@ re_scan:
error_buf, error_buf_size))) {
goto fail;
}
}
#if WASM_ENABLE_FAST_INTERP != 0
disable_emit = true;
disable_emit = true;
#endif
}
/* PUSH the converted (ref ht) */
if (type != VALUE_TYPE_ANY) {