mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-26 15:32:16 +00:00
Minor improvements to help asc -h
This commit is contained in:
parent
fc40ed80f7
commit
27a66c1a7a
29
bin/asc.js
29
bin/asc.js
@ -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()));
|
||||
|
32
bin/asc.json
32
bin/asc.json
@ -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"
|
||||
|
@ -88,12 +88,12 @@ class BlockHeader {
|
||||
}
|
||||
|
||||
/** Tags this block as 'free'. Careful: Does not update adjacent blocks. */
|
||||
tagFree(): void {
|
||||
tagAsFree(): void {
|
||||
this.tagged_size |= BlockHeader.FREE_BIT;
|
||||
}
|
||||
|
||||
/** Tags this block as 'used'. Careful: Does not update adjacent blocks. */
|
||||
tagUsed(): void {
|
||||
tagAsUsed(): void {
|
||||
this.tagged_size &= ~BlockHeader.FREE_BIT;
|
||||
}
|
||||
|
||||
@ -103,12 +103,12 @@ class BlockHeader {
|
||||
}
|
||||
|
||||
/** Tags this block as 'prev is free'. Does not update adjacent blocks. */
|
||||
tagPrevFree(): void {
|
||||
tagAsPrevFree(): void {
|
||||
this.tagged_size |= BlockHeader.PREV_FREE_BIT;
|
||||
}
|
||||
|
||||
/** Tags this block as 'prev is used'. Does not update adjacent blocks. */
|
||||
tagPrevUsed(): void {
|
||||
tagAsPrevUsed(): void {
|
||||
this.tagged_size &= ~BlockHeader.PREV_FREE_BIT;
|
||||
}
|
||||
|
||||
@ -158,15 +158,15 @@ class BlockHeader {
|
||||
/** Marks this block as being 'free'. */
|
||||
markAsFree(): void {
|
||||
var next = this.linkNext(); // Link the block to the next block, first.
|
||||
next.tagPrevFree();
|
||||
this.tagFree();
|
||||
next.tagAsPrevFree();
|
||||
this.tagAsFree();
|
||||
}
|
||||
|
||||
/** Marks this block as being 'used'. */
|
||||
markAsUsed(): void {
|
||||
var next = this.next;
|
||||
next.tagPrevUsed();
|
||||
this.tagUsed();
|
||||
next.tagAsPrevUsed();
|
||||
this.tagAsUsed();
|
||||
}
|
||||
|
||||
/** Tests if this block can be splitted. */
|
||||
@ -377,7 +377,7 @@ class Control extends BlockHeader { // Empty lists point here, indicating free
|
||||
if (block.canSplit(size)) {
|
||||
var remaining_block = block.split(size);
|
||||
block.linkNext();
|
||||
remaining_block.tagPrevFree();
|
||||
remaining_block.tagAsPrevFree();
|
||||
this.insertBlock(remaining_block);
|
||||
}
|
||||
}
|
||||
@ -393,7 +393,7 @@ class Control extends BlockHeader { // Empty lists point here, indicating free
|
||||
if (block.canSplit(size)) {
|
||||
// If the next block is free, we must coalesce.
|
||||
var remaining_block = block.split(size);
|
||||
remaining_block.tagPrevUsed();
|
||||
remaining_block.tagAsPrevUsed();
|
||||
remaining_block = this.mergeNextBlock(remaining_block);
|
||||
this.insertBlock(remaining_block);
|
||||
}
|
||||
@ -403,7 +403,7 @@ class Control extends BlockHeader { // Empty lists point here, indicating free
|
||||
var remaining_block = block;
|
||||
if (block.canSplit(size)) {
|
||||
remaining_block = block.split(size - BlockHeader.OVERHEAD);
|
||||
remaining_block.tagPrevFree();
|
||||
remaining_block.tagAsPrevFree();
|
||||
block.linkNext();
|
||||
this.insertBlock(block);
|
||||
}
|
||||
@ -481,15 +481,15 @@ class Control extends BlockHeader { // Empty lists point here, indicating free
|
||||
// it will never be used.
|
||||
var block = BlockHeader.fromOffset(mem, -BlockHeader.OVERHEAD);
|
||||
block.size = pool_bytes;
|
||||
block.tagFree();
|
||||
block.tagPrevUsed();
|
||||
block.tagAsFree();
|
||||
block.tagAsPrevUsed();
|
||||
this.insertBlock(block);
|
||||
|
||||
// Split the block to create a zero-size sentinel block.
|
||||
var next = block.linkNext();
|
||||
next.size = 0;
|
||||
next.tagUsed();
|
||||
next.tagPrevFree();
|
||||
next.tagAsUsed();
|
||||
next.tagAsPrevFree();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,11 @@ class Control {
|
||||
/** Tests whether the collector is currently paused. */
|
||||
get paused(): bool { return (this.state & Control.PAUSED_BIT) != 0; }
|
||||
/** Sets whether the collector is currently paused. */
|
||||
set paused(paused: bool) { this.state = paused ? this.state |= Control.PAUSED_BIT : this.state &= ~Control.PAUSED_BIT; }
|
||||
set paused(paused: bool) {
|
||||
this.state = paused
|
||||
? this.state |= Control.PAUSED_BIT
|
||||
: this.state &= ~Control.PAUSED_BIT;
|
||||
}
|
||||
|
||||
///////////////////////////////// Methods ///////////////////////////////////
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user