diff options
author | Derek Schuff <dschuff@chromium.org> | 2016-10-14 10:27:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-14 10:27:36 -0700 |
commit | 58f7d6cd477701d7fb4c87ffa9e795ddc6423abb (patch) | |
tree | 9bda4f141e0ffffea5e3556377ca6d463ea1834a /src/wasm-linker.h | |
parent | 87c3aab6500f2a3a3ca8cecfaf65cc14e407a0cd (diff) | |
download | binaryen-58f7d6cd477701d7fb4c87ffa9e795ddc6423abb.tar.gz binaryen-58f7d6cd477701d7fb4c87ffa9e795ddc6423abb.tar.bz2 binaryen-58f7d6cd477701d7fb4c87ffa9e795ddc6423abb.zip |
Import memory instead of defining/exporting it when using emscripten glue (#777)
The emscripten JS module code creates the memory using the native wasm
APIs, and imports that into the wasm module.
Diffstat (limited to 'src/wasm-linker.h')
-rw-r--r-- | src/wasm-linker.h | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/wasm-linker.h b/src/wasm-linker.h index 4a0e1e0b9..3660b3038 100644 --- a/src/wasm-linker.h +++ b/src/wasm-linker.h @@ -193,18 +193,18 @@ class LinkerObject { // applying the relocations, resulting in an executable wasm module. class Linker { public: - Linker(Address globalBase, Address stackAllocation, - Address userInitialMemory, Address userMaxMemory, - bool ignoreUnknownSymbols, Name startFunction, - bool debug) : - ignoreUnknownSymbols(ignoreUnknownSymbols), - startFunction(startFunction), - globalBase(globalBase), - nextStatic(globalBase), - userInitialMemory(userInitialMemory), - userMaxMemory(userMaxMemory), - stackAllocation(stackAllocation), - debug(debug) { + Linker(Address globalBase, Address stackAllocation, Address userInitialMemory, + Address userMaxMemory, bool importMemory, bool ignoreUnknownSymbols, + Name startFunction, bool debug) + : ignoreUnknownSymbols(ignoreUnknownSymbols), + startFunction(startFunction), + globalBase(globalBase), + nextStatic(globalBase), + userInitialMemory(userInitialMemory), + userMaxMemory(userMaxMemory), + importMemory(importMemory), + stackAllocation(stackAllocation), + debug(debug) { if (userMaxMemory && userMaxMemory < userInitialMemory) { Fatal() << "Specified max memory " << userMaxMemory << " is < specified initial memory " << userInitialMemory; @@ -217,6 +217,7 @@ class Linker { Fatal() << "Specified initial memory " << userInitialMemory << " is not a multiple of 64k"; } + // Don't allow anything to be allocated at address 0 if (globalBase == 0) nextStatic = 1; @@ -312,6 +313,8 @@ class Linker { Address userInitialMemory; // Initial memory size (in bytes) specified by the user. Address userMaxMemory; // Max memory size (in bytes) specified by the user. //(after linking, this is rounded and set on the wasm object in pages) + bool importMemory; // Whether the memory should be imported instead of + // defined. Address stackAllocation; bool debug; |