Minor improvements to help asc -h

This commit is contained in:
dcodeIO
2018-01-18 06:55:30 +01:00
parent fc40ed80f7
commit 27a66c1a7a
4 changed files with 54 additions and 43 deletions

View File

@ -164,18 +164,18 @@ else if (args.trapMode !== "allow") {
process.exit(1);
}
var optimizeLevel = 0;
var defaultOptimizeLevel = 2;
var defaultShrinkLevel = 1;
var optimizeLevel = -1;
var shrinkLevel = 0;
var debugInfo = !args.noDebug;
var runPasses = [];
if (args["O"]) {
if (typeof args["O"] === "number")
optimizeLevel = args["O"];
else if (args["O"] === true) {
optimizeLevel = 2;
shrinkLevel = 1;
} else if (args["0"])
if (args.optimize !== false) {
if (typeof args.optimize === "number")
optimizeLevel = args.optimize;
else if (args["0"])
optimizeLevel = 0;
else if (args["1"])
optimizeLevel = 1;
@ -183,8 +183,11 @@ if (args["O"]) {
optimizeLevel = 2;
else if (args["3"])
optimizeLevel = 3;
else
optimizeLevel = 2;
else if (args.optimize === true) {
optimizeLevel = defaultOptimizeLevel;
shrinkLevel = defaultShrinkLevel;
} else
optimizeLevel = 0;
}
if (args["s"])
shrinkLevel = 1;
@ -198,8 +201,8 @@ if (typeof args.shrinkLevel === "number")
shrinkLevel = args.shrinkLevel;
// Workaround for inlining not being performed (42.0.0)
if ((optimizeLevel >= 2 || shrinkLevel >= 2) && !debugInfo)
runPasses = [ "inlining", "inlining-optimizing" ];
// if ((optimizeLevel >= 2 || shrinkLevel >= 2) && !debugInfo)
// runPasses = [ "inlining", "inlining-optimizing" ];
// Check additional passes
if (args.runPasses) {
@ -216,7 +219,7 @@ module.setOptimizeLevel(optimizeLevel);
module.setShrinkLevel(shrinkLevel);
module.setDebugInfo(debugInfo);
if (optimizeLevel || shrinkLevel)
if (optimizeLevel >= 0)
module.optimize();
if (runPasses.length)
module.runPasses(runPasses.map(pass => pass.trim()));

View File

@ -12,23 +12,25 @@
"optimize": {
"desc": [
"Optimizes the module. Also accepts the optimize level:",
" -O Equivalent to -O2s",
" -O0 Runs no optimization passes",
" -O1 Runs fast optimization passes",
" -O2 Runs default optimization passes",
" -O3 Runs all optimization passes",
" -O2s Specifies optimize level 2 with shrink level 1",
" -O3z etc."
"",
" -O Defaults: Equivalent to -O2s",
" -O0 Equivalent to --optimizeLevel 0",
" -O1 Equivalent to --optimizeLevel 1",
" -O2 Equivalent to --optimizeLevel 2",
" -O2 Equivalent to --optimizeLevel 3",
" -Oz Equivalent to -O but with --shrinkLevel 2",
" -O3s Equivalent to -O3 with --shrinkLevel 1 etc.",
""
],
"type": "number",
"type": "boolean",
"aliases": [ "O" ]
},
"optimizeLevel": {
"desc": "How much to focus on optimizing code.",
"desc": "How much to focus on optimizing code. [0-3]",
"type": "number"
},
"shrinkLevel": {
"desc": "How much to focus on shrinking code size.",
"desc": "How much to focus on shrinking code size. [0-2]",
"type": "number"
},
"validate": {
@ -42,17 +44,17 @@
"aliases": [ "o" ]
},
"binaryFile": {
"desc": "Specifies the binary format output file (.wasm).",
"desc": "Specifies the binary output file (.wasm).",
"type": "string",
"aliases": [ "b" ]
},
"textFile": {
"desc": "Specifies the text format output file (.wast).",
"desc": "Specifies the text output file (.wast).",
"type": "string",
"aliases": [ "t" ]
},
"asmjsFile": {
"desc": "Specifies the asm.js format output file (.js).",
"desc": "Specifies the asm.js output file (.js).",
"type": "string",
"aliases": [ "a" ]
},
@ -79,9 +81,11 @@
"trapMode": {
"desc": [
"Sets the trap mode to use.",
"",
" allow Allow trapping operations. This is the default.",
" clamp Replace trapping operations with clamping semantics.",
" js Replace trapping operations with JS semantics."
" js Replace trapping operations with JS semantics.",
""
],
"type": "string",
"default": "allow"