diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-01-05 10:59:30 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-05 10:59:30 -0800 |
commit | 4935b96a60fc2d45dd5229acb9c784f278c37b78 (patch) | |
tree | 8fe88ae21114b68c120f97eb231b3c63355ffa7c /src | |
parent | e1371b9c6ae1ad9a7e758f43af4d56def1f331d3 (diff) | |
parent | 967c1e4181702f6058b7bfbad1d6ed54887813b7 (diff) | |
download | binaryen-4935b96a60fc2d45dd5229acb9c784f278c37b78.tar.gz binaryen-4935b96a60fc2d45dd5229acb9c784f278c37b78.tar.bz2 binaryen-4935b96a60fc2d45dd5229acb9c784f278c37b78.zip |
Merge pull request #871 from WebAssembly/fix-c-api-unused-mem
Mark memory as existing when it is created in the C API
Diffstat (limited to 'src')
-rw-r--r-- | src/binaryen-c.cpp | 1 | ||||
-rw-r--r-- | src/wasm-binary.h | 1 | ||||
-rw-r--r-- | src/wasm/wasm-binary.cpp | 9 |
3 files changed, 7 insertions, 4 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index dc68d8439..c618f9d14 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -808,6 +808,7 @@ void BinaryenSetMemory(BinaryenModuleRef module, BinaryenIndex initial, Binaryen auto* wasm = (Module*)module; wasm->memory.initial = initial; wasm->memory.max = maximum; + wasm->memory.exists = true; if (exportName) { auto memoryExport = make_unique<Export>(); memoryExport->name = exportName; diff --git a/src/wasm-binary.h b/src/wasm-binary.h index bc4a225df..e681f30e8 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -690,6 +690,7 @@ public: void readFunctions(); std::map<Export*, Index> exportIndexes; + std::vector<Export*> exportOrder; void readExports(); Expression* readExpression(); diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 55f85b4b5..e6b33dbb0 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1271,6 +1271,7 @@ void WasmBinaryBuilder::readExports() { curr->kind = (ExternalKind)getU32LEB(); auto index = getU32LEB(); exportIndexes[curr] = index; + exportOrder.push_back(curr); } } @@ -1372,16 +1373,16 @@ void WasmBinaryBuilder::processFunctions() { wasm.start = getFunctionIndexName(startIndex); } - for (auto& iter : exportIndexes) { - Export* curr = iter.first; + for (auto* curr : exportOrder) { + auto index = exportIndexes[curr]; switch (curr->kind) { case ExternalKind::Function: { - curr->value = getFunctionIndexName(iter.second); + curr->value = getFunctionIndexName(index); break; } case ExternalKind::Table: curr->value = Name::fromInt(0); break; case ExternalKind::Memory: curr->value = Name::fromInt(0); break; - case ExternalKind::Global: curr->value = getGlobalName(iter.second); break; + case ExternalKind::Global: curr->value = getGlobalName(index); break; default: WASM_UNREACHABLE(); } wasm.addExport(curr); |