blob: 0638c77440f628536c61f43cddd8023ade47aec7 (
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
|
var wast = String.raw`
(module
(import "env" "memory" (memory $0 1))
(data (i32.const 1024) "\00\00\00\00")
(export "memory" (memory $0))
)
`;
console.log("=== input wast ===" + wast);
var module = binaryen.parseText(wast);
console.log("=== unoptimized ===");
assert(module.validate());
console.log(module.emitText());
console.log("=== optimized, zeroFilledMemory=" + binaryen.getZeroFilledMemory() + " ===");
module.optimize();
assert(module.validate());
console.log(module.emitText());
binaryen.setZeroFilledMemory(true);
assert(binaryen.getZeroFilledMemory());
console.log();
console.log("=== optimized, zeroFilledMemory=" + binaryen.getZeroFilledMemory() + " ===");
module.optimize();
assert(module.validate());
console.log(module.emitText());
module.dispose();
|