From 97c2f0eb7cf57cab242b2707c3514bf0d2d7d13e Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 14 Dec 2018 10:11:47 -0800 Subject: wasm-emscripten-finalize: Don't add a table max if none is present in the input (#1825) --- src/wasm/wasm-emscripten.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp index 3c78ce866..953a2edc3 100644 --- a/src/wasm/wasm-emscripten.cpp +++ b/src/wasm/wasm-emscripten.cpp @@ -331,6 +331,7 @@ void EmscriptenGlueGenerator::generateJSCallThunks( JSCallWalker walker = getJSCallWalker(wasm); auto& tableSegmentData = wasm.table.segments[0].data; + unsigned numEntriesAdded = 0; for (std::string sig : walker.indirectlyCallableSigs) { // Add imports for jsCall_sig (e.g. jsCall_vi). // Imported jsCall_sig functions have their first parameter as an index to @@ -371,11 +372,13 @@ void EmscriptenGlueGenerator::generateJSCallThunks( f->body = call; wasm.addFunction(f); tableSegmentData.push_back(f->name); + numEntriesAdded++; } } - wasm.table.initial = wasm.table.max = - wasm.table.segments[0].offset->cast()->value.getInteger() + - tableSegmentData.size(); + wasm.table.initial.addr += numEntriesAdded; + if (wasm.table.max != Table::kUnlimitedSize) { + wasm.table.max.addr += numEntriesAdded; + } } std::vector
getSegmentOffsets(Module& wasm) { -- cgit v1.2.3