diff options
author | Derek Schuff <dschuff@chromium.org> | 2016-03-04 17:09:47 -0800 |
---|---|---|
committer | Derek Schuff <dschuff@chromium.org> | 2016-03-09 13:04:18 -0800 |
commit | 1b45938aadd6e03e9210d88436be9c393623fb42 (patch) | |
tree | 24028248c7b9999a8d46bbab913fbe460d76bc46 /src/asm2wasm-main.cpp | |
parent | e9d98deed872a72a826f78c8525464c446c6f21b (diff) | |
download | binaryen-1b45938aadd6e03e9210d88436be9c393623fb42.tar.gz binaryen-1b45938aadd6e03e9210d88436be9c393623fb42.tar.bz2 binaryen-1b45938aadd6e03e9210d88436be9c393623fb42.zip |
Make initial and max memory sizes be in pages instead of bytes
The AST and everything that uses it treats the values as
pages. Javascript continues to use bytes.
This matches v8 and sexpr-wasm, and the consensus from live discussion
and PR209 in the spec.
Diffstat (limited to 'src/asm2wasm-main.cpp')
-rw-r--r-- | src/asm2wasm-main.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/asm2wasm-main.cpp b/src/asm2wasm-main.cpp index 5ab8bb0cf..73f6853d8 100644 --- a/src/asm2wasm-main.cpp +++ b/src/asm2wasm-main.cpp @@ -58,6 +58,11 @@ int main(int argc, const char *argv[]) { const auto &tm_it = options.extra.find("total memory"); size_t totalMemory = tm_it == options.extra.end() ? 16 * 1024 * 1024 : atoi(tm_it->second.c_str()); + if (totalMemory & ~Memory::kPageMask) { + std::cerr << "Error: total memory size " << totalMemory << + " is not a multiple of the 64k wasm page size\n"; + exit(EXIT_FAILURE); + } Asm2WasmPreProcessor pre; auto input( @@ -75,7 +80,7 @@ int main(int argc, const char *argv[]) { if (options.debug) std::cerr << "wasming..." << std::endl; AllocatingModule wasm; - wasm.memory.initial = wasm.memory.max = totalMemory; + wasm.memory.initial = wasm.memory.max = totalMemory / Memory::kPageSize; Asm2WasmBuilder asm2wasm(wasm, pre.memoryGrowth, options.debug); asm2wasm.processAsm(asmjs); |