Browse Source

Init frame->sp and frame->ip at entry of call func in interpreter (#2636)

Xu Jun 2 years ago
parent
commit
995817e463

+ 4 - 0
core/iwasm/interpreter/wasm_interp_classic.c

@@ -5060,6 +5060,10 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
                 frame->csp_bottom + cur_wasm_func->max_block_num;
                 frame->csp_bottom + cur_wasm_func->max_block_num;
 
 
 #if WASM_ENABLE_GC != 0
 #if WASM_ENABLE_GC != 0
+            /* frame->sp and frame->ip are used during GC root set enumeration,
+             * so we must initialized these fields here */
+            frame->sp = frame_sp;
+            frame->ip = frame_ip;
             frame_ref = (uint8 *)frame->csp_boundary;
             frame_ref = (uint8 *)frame->csp_boundary;
             init_frame_refs(frame_ref, (uint32)cell_num_of_local_stack,
             init_frame_refs(frame_ref, (uint32)cell_num_of_local_stack,
                             cur_func);
                             cur_func);

+ 3 - 0
core/iwasm/interpreter/wasm_interp_fast.c

@@ -5105,6 +5105,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
                    (uint32)(cur_func->local_cell_num * 4));
                    (uint32)(cur_func->local_cell_num * 4));
 
 
 #if WASM_ENABLE_GC != 0
 #if WASM_ENABLE_GC != 0
+            /* frame->ip is used during GC root set enumeration, so we must
+             * initialized this field here */
+            frame->ip = frame_ip;
             frame_ref = frame->frame_ref =
             frame_ref = frame->frame_ref =
                 (uint8 *)(frame->lp + (uint32)cell_num_of_local_stack);
                 (uint8 *)(frame->lp + (uint32)cell_num_of_local_stack);
             init_frame_refs(frame_ref, (uint32)cell_num_of_local_stack,
             init_frame_refs(frame_ref, (uint32)cell_num_of_local_stack,