@@ -4870,6 +4870,16 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
48704870 }
48714871
48724872#if WASM_ENABLE_FAST_INTERP != 0
4873+ /* For the first traverse, the initial value of preserved_local_offset has
4874+ * not been determined, we use the INT16_MAX to represent that a slot has
4875+ * been copied to preserve space. For second traverse, this field will be
4876+ * set to the appropriate value in wasm_loader_ctx_reinit.
4877+ * This is for Issue #1230,
4878+ * https://github.com/bytecodealliance/wasm-micro-runtime/issues/1230, the
4879+ * drop opcodes need to know which slots are preserved, so those slots will
4880+ * not be treated as dynamically allocated slots */
4881+ loader_ctx -> preserved_local_offset = INT16_MAX ;
4882+
48734883re_scan :
48744884 if (loader_ctx -> code_compiled_size > 0 ) {
48754885 if (!wasm_loader_ctx_reinit (loader_ctx )) {
@@ -5446,8 +5456,10 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
54465456#if WASM_ENABLE_FAST_INTERP != 0
54475457 skip_label ();
54485458 loader_ctx -> frame_offset -- ;
5449- if (* (loader_ctx -> frame_offset )
5450- > loader_ctx -> start_dynamic_offset )
5459+ if ((* (loader_ctx -> frame_offset )
5460+ > loader_ctx -> start_dynamic_offset )
5461+ && (* (loader_ctx -> frame_offset )
5462+ < loader_ctx -> max_dynamic_offset ))
54515463 loader_ctx -> dynamic_offset -- ;
54525464#endif
54535465 }
@@ -5460,9 +5472,11 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
54605472#if WASM_ENABLE_FAST_INTERP != 0
54615473 skip_label ();
54625474 loader_ctx -> frame_offset -= 2 ;
5463- if (* (loader_ctx -> frame_offset )
5464- > loader_ctx -> start_dynamic_offset )
5465- loader_ctx -> dynamic_offset -= 2 ;
5475+ if ((* (loader_ctx -> frame_offset )
5476+ > loader_ctx -> start_dynamic_offset )
5477+ && (* (loader_ctx -> frame_offset )
5478+ < loader_ctx -> max_dynamic_offset ))
5479+ loader_ctx -> dynamic_offset -- ;
54665480#endif
54675481 }
54685482 else {
0 commit comments