ref-types: Correct default value for function local variables (#3397)
In classic interpreter, fast interpreter and fast-jit running modes, set the local variables' default value to NULL_REF (0xFFFFFFFF) rather than 0 if they are type of externref or funcref. The issue was reported in #3390 and #3391.
This commit is contained in:
@ -1243,6 +1243,21 @@ init_func_translation(JitCompContext *cc)
|
||||
NEW_CONST(I32, local_off));
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0 && WASM_ENABLE_GC == 0
|
||||
/* externref/funcref should be NULL_REF rather than 0 */
|
||||
local_off = (uint32)offsetof(WASMInterpFrame, lp)
|
||||
+ cur_wasm_func->param_cell_num * 4;
|
||||
for (i = 0; i < cur_wasm_func->local_count; i++) {
|
||||
if (cur_wasm_func->local_types[i] == VALUE_TYPE_EXTERNREF
|
||||
|| cur_wasm_func->local_types[i] == VALUE_TYPE_FUNCREF) {
|
||||
GEN_INSN(STI32, NEW_CONST(I32, NULL_REF), cc->fp_reg,
|
||||
NEW_CONST(I32, local_off));
|
||||
}
|
||||
local_off +=
|
||||
4 * wasm_value_type_cell_num(cur_wasm_func->local_types[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
return jit_frame;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user