From 1b45938aadd6e03e9210d88436be9c393623fb42 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Fri, 4 Mar 2016 17:09:47 -0800 Subject: 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. --- src/asm2wasm-main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/asm2wasm-main.cpp') 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); -- cgit v1.2.3