blob: 3413edb37d172e4fb7d5e27c2f6ad37354ca9f3b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
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.setLowMemoryUnused(true);
assert(binaryen.getLowMemoryUnused());
console.log();
console.log("=== optimized, lowMemoryUnused=" + binaryen.getLowMemoryUnused() + " ===");
module.optimize();
assert(module.validate());
console.log(module.emitText());
module.dispose();
|