diff options
Diffstat (limited to 'test/binaryen.js/low-memory-unused.js')
-rw-r--r-- | test/binaryen.js/low-memory-unused.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/binaryen.js/low-memory-unused.js b/test/binaryen.js/low-memory-unused.js new file mode 100644 index 000000000..37bdc2cb0 --- /dev/null +++ b/test/binaryen.js/low-memory-unused.js @@ -0,0 +1,40 @@ +var wast = ` +(module + (memory $0 1) + (export "test" (func $test)) + (func $test (param $0 i32) (result i32) + (i32.load + (i32.add + (local.get $0) + (i32.const 128) + ) + ) + ) +) +`; + +console.log("=== input wast ===" + wast); + +var module = binaryen.parseText(wast); + +console.log("=== unoptimized ==="); +assert(module.validate()); +console.log(module.emitText()); + +console.log("=== optimized, lowMemoryUnused=" + binaryen.getLowMemoryUnused() + " ==="); +module.optimize(); +assert(module.validate()); +console.log(module.emitText()); + +binaryen.setAPITracing(true); +binaryen.setLowMemoryUnused(true); +assert(binaryen.getLowMemoryUnused()); +binaryen.setAPITracing(false); +console.log(); + +console.log("=== optimized, lowMemoryUnused=" + binaryen.getLowMemoryUnused() + " ==="); +module.optimize(); +assert(module.validate()); +console.log(module.emitText()); + +module.dispose(); |