Skip to content

Commit c6ec5e2

Browse files
committed
Utilize Binaryen's -O4
When specifying -O3 or -Oz, asc now automatically increases the optimize level to 4, then including costly non-LLVM optimizations for blocky code, in turn achieving similar results as an LLVM-based generator.
1 parent e9094bb commit c6ec5e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+12219
-14202
lines changed

cli/asc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,10 @@ exports.main = function main(argv, options, callback) {
491491
shrinkLevel = 2;
492492
}
493493

494+
// Implicitly run costly non-LLVM optimizations on -O3 or -Oz
495+
// see: https://github.com/WebAssembly/binaryen/pull/1596
496+
if (optimizeLevel >= 3 || shrinkLevel >= 2) optimizeLevel = 4;
497+
494498
module.setOptimizeLevel(optimizeLevel > 0 ? optimizeLevel : 0);
495499
module.setShrinkLevel(shrinkLevel);
496500
module.setDebugInfo(debugInfo);

dist/asc.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/asc.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@protobufjs/utf8": "^1.1.0",
15-
"binaryen": "48.0.0-nightly.20180605",
15+
"binaryen": "48.0.0-nightly.20180609",
1616
"glob": "^7.1.2",
1717
"long": "^4.0.0",
1818
"minimist": "^1.2.0",

tests/compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ tests.forEach(filename => {
123123
filename,
124124
"--baseDir", basedir,
125125
"--validate",
126-
"--optimize",
126+
"-O3",
127127
"--measure",
128128
"--binaryFile" // -> stdout
129129
];

tests/compiler/abi.optimized.wat

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,46 +31,12 @@
3131
)
3232
)
3333
(func $start (; 5 ;) (type $v)
34-
(local $0 i32)
3534
(drop
3635
(call $abi/internal)
3736
)
3837
(set_global $abi/condition
3938
(i32.const 1)
4039
)
41-
(set_local $0
42-
(i32.const 256)
43-
)
44-
(if
45-
(tee_local $0
46-
(select
47-
(i32.shr_s
48-
(i32.shr_s
49-
(i32.shl
50-
(get_local $0)
51-
(i32.const 24)
52-
)
53-
(i32.const 24)
54-
)
55-
(i32.const 24)
56-
)
57-
(i32.and
58-
(get_local $0)
59-
(i32.const 127)
60-
)
61-
(get_global $abi/condition)
62-
)
63-
)
64-
(block
65-
(call $~lib/env/abort
66-
(i32.const 0)
67-
(i32.const 8)
68-
(i32.const 58)
69-
(i32.const 2)
70-
)
71-
(unreachable)
72-
)
73-
)
7440
(set_global $abi/y
7541
(i32.const 0)
7642
)

tests/compiler/assert.optimized.wat

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,6 @@
11
(module
2-
(type $iiiiv (func (param i32 i32 i32 i32)))
3-
(type $v (func))
4-
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
52
(memory $0 1)
63
(data (i32.const 8) "\t\00\00\00a\00s\00s\00e\00r\00t\00.\00t\00s")
74
(data (i32.const 32) "\0c\00\00\00m\00u\00s\00t\00 \00b\00e\00 \00t\00r\00u\00e")
85
(export "memory" (memory $0))
9-
(start $start)
10-
(func $start (; 1 ;) (type $v)
11-
(local $0 i32)
12-
(if
13-
(i32.eqz
14-
(if (result i32)
15-
(tee_local $0
16-
(i32.const 1)
17-
)
18-
(get_local $0)
19-
(block
20-
(call $~lib/env/abort
21-
(i32.const 32)
22-
(i32.const 8)
23-
(i32.const 10)
24-
(i32.const 5)
25-
)
26-
(unreachable)
27-
)
28-
)
29-
)
30-
(unreachable)
31-
)
32-
)
336
)

0 commit comments

Comments
 (0)