diff options
-rw-r--r-- | src/wasm/wasm-emscripten.cpp | 8 | ||||
-rw-r--r-- | test/lld/reserved_func_ptr.wast.jscall.out | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp index 58ef41c9b..3b658c3ff 100644 --- a/src/wasm/wasm-emscripten.cpp +++ b/src/wasm/wasm-emscripten.cpp @@ -207,16 +207,16 @@ struct JSCallWalker : public PostWalker<JSCallWalker> { } const auto& tableSegmentData = wasm.table.segments[0].data; + jsCallStartIndex = + wasm.table.segments[0].offset->cast<Const>()->value.getInteger(); // Check if jsCalls have already been created for (Index i = 0; i < tableSegmentData.size(); ++i) { if (tableSegmentData[i].startsWith("jsCall_")) { - jsCallStartIndex = i; + jsCallStartIndex += i; return; } } - jsCallStartIndex = - wasm.table.segments[0].offset->cast<Const>()->value.getInteger() + - tableSegmentData.size(); + jsCallStartIndex += tableSegmentData.size(); } // Gather all function signatures used in call_indirect, because any of them diff --git a/test/lld/reserved_func_ptr.wast.jscall.out b/test/lld/reserved_func_ptr.wast.jscall.out index c688e69f2..44f2e888f 100644 --- a/test/lld/reserved_func_ptr.wast.jscall.out +++ b/test/lld/reserved_func_ptr.wast.jscall.out @@ -294,4 +294,4 @@ ) ) ) -;; METADATA: { "asmConsts": {},"staticBump": 0, "initializers": ["__wasm_call_ctors"], "jsCallStartIndex": 2, "jsCallFuncType": ["ddi","fffi","iii","v","vi","viii"], "declares": ["_Z4atoiPKc"], "externs": [], "implementedFunctions": ["___wasm_call_ctors","_main","_stackSave","_stackAlloc","_stackRestore","___growWasmMemory","_dynCall_viii"], "exports": ["memory","__wasm_call_ctors","main","__heap_base","__data_end","stackSave","stackAlloc","stackRestore","__growWasmMemory","dynCall_viii"], "invokeFuncs": [] } +;; METADATA: { "asmConsts": {},"staticBump": 0, "initializers": ["__wasm_call_ctors"], "jsCallStartIndex": 3, "jsCallFuncType": ["ddi","fffi","iii","v","vi","viii"], "declares": ["_Z4atoiPKc"], "externs": [], "implementedFunctions": ["___wasm_call_ctors","_main","_stackSave","_stackAlloc","_stackRestore","___growWasmMemory","_dynCall_viii"], "exports": ["memory","__wasm_call_ctors","main","__heap_base","__data_end","stackSave","stackAlloc","stackRestore","__growWasmMemory","dynCall_viii"], "invokeFuncs": [] } |