summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-11-11 17:07:00 -0800
committerGitHub <noreply@github.com>2016-11-11 17:07:00 -0800
commit4f18246f37becf6aae00bd8863401ec44462a08c (patch)
tree80594a7a8f334a608d97544471a12e5b45e967b4
parent485b1dca62848be92f9fcce4a70a5c63eb5015ee (diff)
downloadbinaryen-4f18246f37becf6aae00bd8863401ec44462a08c.tar.gz
binaryen-4f18246f37becf6aae00bd8863401ec44462a08c.tar.bz2
binaryen-4f18246f37becf6aae00bd8863401ec44462a08c.zip
add --mem-max option to set the maximum size of memory, overriding the default (which is the normal size of memory if no growth, or infinity if growth) (#837)
-rw-r--r--src/tools/asm2wasm.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/tools/asm2wasm.cpp b/src/tools/asm2wasm.cpp
index c5590c5eb..db6d723db 100644
--- a/src/tools/asm2wasm.cpp
+++ b/src/tools/asm2wasm.cpp
@@ -55,6 +55,10 @@ int main(int argc, const char *argv[]) {
[](Options *o, const std::string &argument) {
o->extra["mem base"] = argument;
})
+ .add("--mem-max", "-mm", "Set the maximum size of memory in the wasm module (in bytes). Without this, TOTAL_MEMORY is used (as it is used for the initial value), or if memory growth is enabled, no limit is set. This overrides both of those.", Options::Arguments::One,
+ [](Options *o, const std::string &argument) {
+ o->extra["mem max"] = argument;
+ })
.add("--total-memory", "-m", "Total memory size", Options::Arguments::One,
[](Options *o, const std::string &argument) {
o->extra["total memory"] = argument;
@@ -123,6 +127,12 @@ int main(int argc, const char *argv[]) {
}
}
+ // Set the max memory size, if requested
+ const auto &memMax = options.extra.find("mem max");
+ if (memMax != options.extra.end()) {
+ wasm.memory.max = atoi(memMax->second.c_str()) / Memory::kPageSize;
+ }
+
if (options.debug) std::cerr << "printing..." << std::endl;
Output output(options.extra["output"], Flags::Text, options.debug ? Flags::Debug : Flags::Release);
WasmPrinter::printModule(&wasm, output.getStream());