Skip to content

Commit 4f95dce

Browse files
committed
Do not emit debug info by default
This basically flips the --noDebug flag to become a --debug flag, so some optimizations, like inlining, aren't skipped by default, which might be unexpected.
1 parent d93ca84 commit 4f95dce

File tree

72 files changed

+6267
-6220
lines changed

Some content is hidden

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

72 files changed

+6267
-6220
lines changed

bin/asinit

+2-2
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ function ensureGitignore() {
206206
function ensurePackageJson() {
207207
console.log("- Making sure that 'package.json' contains the build commands...")
208208
const entryPath = path.relative(projectDir, entryFile).replace(/\\/g, "/");
209-
const buildUntouched = "asc " + entryPath + " -b build/untouched.wasm -t build/untouched.wat --sourceMap --validate";
210-
const buildOptimized = "asc " + entryPath + " -b build/optimized.wasm -t build/optimized.wat --sourceMap --validate --optimize --noDebug";
209+
const buildUntouched = "asc " + entryPath + " -b build/untouched.wasm -t build/untouched.wat --sourceMap --validate --debug";
210+
const buildOptimized = "asc " + entryPath + " -b build/optimized.wasm -t build/optimized.wat --sourceMap --validate --optimize";
211211
const buildAll = "npm run asbuild:untouched && npm run asbuild:optimized";
212212
if (!fs.existsSync(packageFile)) {
213213
fs.writeFileSync(packageFile, JSON.stringify({

cli/asc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ exports.main = function main(argv, options, callback) {
505505

506506
module.setOptimizeLevel(optimizeLevel);
507507
module.setShrinkLevel(shrinkLevel);
508-
module.setDebugInfo(!args.noDebug);
508+
module.setDebugInfo(args.debug);
509509

510510
var runPasses = [];
511511
if (args.runPasses) {

cli/asc.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@
8181
],
8282
"type": "s"
8383
},
84-
"noTreeShaking": {
85-
"description": "Disables compiler-level tree-shaking, compiling everything.",
84+
"debug": {
85+
"description": "Enables debug information in emitted binaries.",
8686
"type": "b",
8787
"default": false
8888
},
89-
"noDebug": {
90-
"description": "Disables maintaining of debug information in binaries.",
89+
"noTreeShaking": {
90+
"description": "Disables compiler-level tree-shaking, compiling everything.",
9191
"type": "b",
9292
"default": false
9393
},

dist/asc.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/asc.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/game-of-life/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"version": "1.0.0",
44
"private": true,
55
"scripts": {
6-
"asbuild:untouched": "asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --use Math=JSMath --importMemory --sourceMap --validate --measure",
7-
"asbuild:optimized": "asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat -d build/optimized.d.ts --use Math=JSMath -O3 --importMemory --sourceMap --validate --noDebug --measure",
6+
"asbuild:untouched": "asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --use Math=JSMath --importMemory --sourceMap --debug --validate --measure",
7+
"asbuild:optimized": "asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat -d build/optimized.d.ts --use Math=JSMath -O3 --importMemory --sourceMap --validate --measure",
88
"asbuild": "npm run asbuild:untouched && npm run asbuild:optimized",
99
"server": "http-server . -o -c-1"
1010
},

examples/i64-polyfill/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"scripts": {
1919
"asbuild": "npm run asbuild:untouched && npm run asbuild:optimized",
20-
"asbuild:untouched": "asc assembly/i64.ts -t build/untouched.wat -b build/untouched.wasm --validate --sourceMap --measure",
20+
"asbuild:untouched": "asc assembly/i64.ts -t build/untouched.wat -b build/untouched.wasm --validate --sourceMap --debug --measure",
2121
"asbuild:optimized": "asc -O assembly/i64.ts -b build/optimized.wasm -t build/optimized.wat -d build/optimized.d.ts --validate --sourceMap --measure",
2222
"test": "node tests"
2323
},

examples/mandelbrot/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"version": "1.0.0",
44
"private": true,
55
"scripts": {
6-
"asbuild:untouched": "asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --use Math=JSMath --importMemory --sourceMap --validate --measure",
7-
"asbuild:optimized": "asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat -d build/optimized.d.ts --use Math=JSMath -O3 --importMemory --sourceMap --validate --noDebug --measure",
6+
"asbuild:untouched": "asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --use Math=JSMath --importMemory --sourceMap --debug --validate --measure",
7+
"asbuild:optimized": "asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat -d build/optimized.d.ts --use Math=JSMath -O3 --importMemory --sourceMap --validate --measure",
88
"asbuild": "npm run asbuild:untouched && npm run asbuild:optimized",
99
"server": "http-server . -o -c-1"
1010
},

examples/n-body/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"version": "1.0.0",
44
"private": true,
55
"scripts": {
6-
"asbuild:untouched": "asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --sourceMap --validate --importMemory",
7-
"asbuild:optimized": "asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat -O3 --validate --noDebug --noAssert --importMemory",
8-
"asbuild:asmjs": "asc assembly/index.ts -a build/index.asm.js -O3 --validate --noDebug --noAssert",
6+
"asbuild:untouched": "asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --sourceMap --debug --validate --importMemory",
7+
"asbuild:optimized": "asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat -O3 --validate --noAssert --importMemory",
8+
"asbuild:asmjs": "asc assembly/index.ts -a build/index.asm.js -O3 --validate --noAssert",
99
"asbuild": "npm run asbuild:untouched && npm run asbuild:optimized && npm run asbuild:asmjs",
1010
"tsbuild": "tsc -p assembly -t ES2017 -m commonjs --outDir build",
1111
"build": "npm run asbuild && npm run tsbuild",

examples/pson/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"scripts": {
66
"asbuild": "npm run asbuild:untouched && npm run asbuild:optimized",
7-
"asbuild:untouched": "asc assembly/pson.ts -b build/untouched.wasm -t build/untouched.wat --validate --sourceMap --measure",
7+
"asbuild:untouched": "asc assembly/pson.ts -b build/untouched.wasm -t build/untouched.wat --validate --sourceMap --debug --measure",
88
"asbuild:optimized": "asc -O assembly/pson.ts -b build/optimized.wasm -t build/optimized.wat --validate --sourceMap --measure",
99
"test": "node tests"
1010
},

lib/parse/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"types": "index.d.ts",
77
"scripts": {
8-
"asbuild": "asc assembly/index.ts -O3 -b build/index.wasm -t build/index.wat --importMemory --noDebug --sourceMap --validate",
8+
"asbuild": "asc assembly/index.ts -O3 -b build/index.wasm -t build/index.wat --importMemory --sourceMap --validate",
99
"build": "npm run asbuild && webpack --mode production --display-modules",
1010
"test": "ts-node tests/"
1111
},

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@protobufjs/utf8": "^1.1.0",
15-
"binaryen": "52.0.0-nightly.20181104",
15+
"binaryen": "52.0.0-nightly.20181108",
1616
"glob": "^7.1.3",
1717
"long": "^4.0.0"
1818
},

tests/compiler.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ tests.forEach(filename => {
8686
"--baseDir", basedir,
8787
"--validate",
8888
"--measure",
89+
"--debug",
8990
"--textFile" // -> stdout
9091
], {
9192
stdout: stdout,
@@ -136,9 +137,9 @@ tests.forEach(filename => {
136137
filename,
137138
"--baseDir", basedir,
138139
"--validate",
139-
"-O3",
140140
"--measure",
141-
"--binaryFile" // -> stdout
141+
"--binaryFile", // -> stdout
142+
"-O3"
142143
];
143144
if (args.create) cmd.push(
144145
"--textFile", basename + ".optimized.wat"

tests/compiler/abi.optimized.wat

+4-19
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,13 @@
1212
(export "memory" (memory $0))
1313
(export "table" (table $0))
1414
(export "exported" (func $abi/exported))
15-
(export "exportedExported" (func $abi/exportedExported))
16-
(export "exportedInternal" (func $abi/exportedInternal))
15+
(export "exportedExported" (func $abi/exported))
16+
(export "exportedInternal" (func $abi/exported))
1717
(start $start)
1818
(func $abi/exported (; 1 ;) (type $i) (result i32)
1919
i32.const -128
2020
)
21-
(func $abi/exportedExported (; 2 ;) (type $i) (result i32)
22-
call $abi/exported
23-
)
24-
(func $abi/internal (; 3 ;) (type $i) (result i32)
25-
i32.const 128
26-
)
27-
(func $abi/exportedInternal (; 4 ;) (type $i) (result i32)
28-
call $abi/internal
29-
i32.const 24
30-
i32.shl
31-
i32.const 24
32-
i32.shr_s
33-
)
34-
(func $start (; 5 ;) (type $v)
35-
call $abi/internal
36-
drop
21+
(func $start (; 2 ;) (type $v)
3722
i32.const 1
3823
set_global $abi/condition
3924
i32.const 0
@@ -48,7 +33,7 @@
4833
unreachable
4934
end
5035
)
51-
(func $null (; 6 ;) (type $v)
36+
(func $null (; 3 ;) (type $v)
5237
nop
5338
)
5439
)

tests/compiler/binary.optimized.wat

+68-35
Original file line numberDiff line numberDiff line change
@@ -221,32 +221,7 @@
221221
get_local $0
222222
f32.mul
223223
)
224-
(func $~lib/math/NativeMathf.pow (; 2 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32)
225-
(local $1 i32)
226-
(local $2 i32)
227-
get_local $0
228-
i32.reinterpret/f32
229-
tee_local $2
230-
i32.const 2147483647
231-
i32.and
232-
i32.const 2139095040
233-
i32.gt_s
234-
tee_local $1
235-
i32.eqz
236-
if
237-
i32.const 0
238-
set_local $1
239-
end
240-
get_local $1
241-
if
242-
get_local $0
243-
f32.const 1
244-
f32.add
245-
return
246-
end
247-
get_local $0
248-
)
249-
(func $~lib/math/NativeMath.mod (; 3 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64)
224+
(func $~lib/math/NativeMath.mod (; 2 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64)
250225
(local $1 i64)
251226
(local $2 i64)
252227
(local $3 i64)
@@ -404,7 +379,9 @@
404379
get_local $0
405380
f64.mul
406381
)
407-
(func $start (; 4 ;) (type $v)
382+
(func $start (; 3 ;) (type $v)
383+
(local $0 f32)
384+
(local $1 i32)
408385
get_global $binary/i
409386
i32.const 1
410387
i32.rem_s
@@ -626,9 +603,23 @@
626603
get_global $binary/f
627604
call $~lib/math/NativeMathf.mod
628605
drop
629-
get_global $binary/f
630-
call $~lib/math/NativeMathf.pow
631-
drop
606+
block $__inlined_func$~lib/math/NativeMathf.pow
607+
get_global $binary/f
608+
tee_local $0
609+
i32.reinterpret/f32
610+
i32.const 2147483647
611+
i32.and
612+
i32.const 2139095040
613+
i32.gt_s
614+
tee_local $1
615+
i32.eqz
616+
if
617+
i32.const 0
618+
set_local $1
619+
end
620+
get_local $1
621+
br_if $__inlined_func$~lib/math/NativeMathf.pow
622+
end
632623
get_global $binary/f
633624
f32.const 1
634625
f32.lt
@@ -664,8 +655,29 @@
664655
get_global $binary/f
665656
call $~lib/math/NativeMathf.mod
666657
set_global $binary/f
667-
get_global $binary/f
668-
call $~lib/math/NativeMathf.pow
658+
block $__inlined_func$~lib/math/NativeMathf.pow0
659+
get_global $binary/f
660+
tee_local $0
661+
i32.reinterpret/f32
662+
i32.const 2147483647
663+
i32.and
664+
i32.const 2139095040
665+
i32.gt_s
666+
tee_local $1
667+
i32.eqz
668+
if
669+
i32.const 0
670+
set_local $1
671+
end
672+
get_local $1
673+
if
674+
get_local $0
675+
f32.const 1
676+
f32.add
677+
set_local $0
678+
end
679+
end
680+
get_local $0
669681
set_global $binary/f
670682
get_global $binary/f
671683
f32.const 1
@@ -678,8 +690,29 @@
678690
get_global $binary/f
679691
call $~lib/math/NativeMathf.mod
680692
set_global $binary/f
681-
get_global $binary/f
682-
call $~lib/math/NativeMathf.pow
693+
block $__inlined_func$~lib/math/NativeMathf.pow2
694+
get_global $binary/f
695+
tee_local $0
696+
i32.reinterpret/f32
697+
i32.const 2147483647
698+
i32.and
699+
i32.const 2139095040
700+
i32.gt_s
701+
tee_local $1
702+
i32.eqz
703+
if
704+
i32.const 0
705+
set_local $1
706+
end
707+
get_local $1
708+
if
709+
get_local $0
710+
f32.const 1
711+
f32.add
712+
set_local $0
713+
end
714+
end
715+
get_local $0
683716
set_global $binary/f
684717
get_global $binary/F
685718
call $~lib/math/NativeMath.mod
@@ -740,7 +773,7 @@
740773
call $~lib/math/NativeMath.pow
741774
set_global $binary/F
742775
)
743-
(func $null (; 5 ;) (type $v)
776+
(func $null (; 4 ;) (type $v)
744777
nop
745778
)
746779
)

0 commit comments

Comments
 (0)