Skip to content

Commit e16b6e5

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 0bcc64c + 077e9f6 commit e16b6e5

File tree

279 files changed

+84860
-79522
lines changed

Some content is hidden

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

279 files changed

+84860
-79522
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
node_version: ["lts/*", "node"]
4343
steps:
4444
- uses: actions/[email protected]
45-
- uses: dcodeIO/setup-node-nvm@v1.0.0
45+
- uses: dcodeIO/setup-node-nvm@master
4646
with:
4747
node-version: ${{ matrix.node_version }}
4848
- name: Install dependencies
@@ -84,7 +84,7 @@ jobs:
8484
needs: check
8585
steps:
8686
- uses: actions/[email protected]
87-
- uses: dcodeIO/setup-node-nvm@v1.0.0
87+
- uses: dcodeIO/setup-node-nvm@master
8888
with:
8989
node-mirror: https://nodejs.org/download/v8-canary/
9090
# FIXME: newer node-v8 builds are currently broken
@@ -104,7 +104,7 @@ jobs:
104104
needs: check
105105
steps:
106106
- uses: actions/[email protected]
107-
- uses: dcodeIO/setup-node-nvm@v1.0.0
107+
- uses: dcodeIO/setup-node-nvm@master
108108
with:
109109
node-version: node
110110
- name: Install dependencies
@@ -129,7 +129,7 @@ jobs:
129129
needs: check
130130
steps:
131131
- uses: actions/[email protected]
132-
- uses: dcodeIO/setup-node-nvm@v1.0.0
132+
- uses: dcodeIO/setup-node-nvm@master
133133
with:
134134
node-version: node
135135
- name: Install dependencies
@@ -147,7 +147,7 @@ jobs:
147147
needs: check
148148
steps:
149149
- uses: actions/[email protected]
150-
- uses: dcodeIO/setup-node-nvm@v1.0.0
150+
- uses: dcodeIO/setup-node-nvm@master
151151
with:
152152
node-version: node
153153
- name: Install dependencies

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- uses: actions/checkout@v1
1111
with:
1212
ref: release
13-
- uses: dcodeIO/setup-node-nvm@v1.0.0
13+
- uses: dcodeIO/setup-node-nvm@master
1414
with:
1515
node-version: node
1616
- name: Merge master

cli/asc.js

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,7 @@ exports.main = function main(argv, options, callback) {
247247
assemblyscript.setSourceMap(compilerOptions, args.sourceMap != null);
248248
assemblyscript.setNoUnsafe(compilerOptions, args.noUnsafe);
249249
assemblyscript.setPedantic(compilerOptions, args.pedantic);
250-
251-
// Initialize default aliases
252-
assemblyscript.setGlobalAlias(compilerOptions, "Math", "NativeMath");
253-
assemblyscript.setGlobalAlias(compilerOptions, "Mathf", "NativeMathf");
254-
assemblyscript.setGlobalAlias(compilerOptions, "abort", "~lib/builtins/abort");
255-
assemblyscript.setGlobalAlias(compilerOptions, "trace", "~lib/builtins/trace");
250+
assemblyscript.setLowMemoryLimit(compilerOptions, args.lowMemoryLimit >>> 0);
256251

257252
// Add or override aliases if specified
258253
if (args.use) {
@@ -678,6 +673,20 @@ exports.main = function main(argv, options, callback) {
678673
const passes = [];
679674
function add(pass) { passes.push(pass); }
680675

676+
if (optimizeLevel >= 2 && shrinkLevel === 0) {
677+
// tweak inlining options when speed more preferable than size
678+
module.setAlwaysInlineMaxSize(12);
679+
module.setFlexibleInlineMaxSize(70);
680+
module.setOneCallerInlineMaxSize(200);
681+
} else {
682+
// tweak inlining options when size matters
683+
optimizeLevel === 0 && shrinkLevel >= 0
684+
? module.setAlwaysInlineMaxSize(2)
685+
: module.setAlwaysInlineMaxSize(4); // default: 2
686+
module.setFlexibleInlineMaxSize(65); // default: 20
687+
module.setOneCallerInlineMaxSize(80); // default: 15
688+
}
689+
681690
// Optimize the module if requested
682691
if (optimizeLevel > 0 || shrinkLevel > 0) {
683692
// Binaryen's default passes with Post-AssemblyScript passes added.
@@ -691,9 +700,15 @@ exports.main = function main(argv, options, callback) {
691700
add("ssa-nomerge");
692701
}
693702
if (optimizeLevel >= 3) {
703+
add("simplify-locals-nostructure"); // differs
704+
add("vacuum"); // differs
705+
add("reorder-locals"); // differs
694706
add("flatten");
695707
add("local-cse");
696708
}
709+
if (optimizeLevel >= 2 || shrinkLevel >= 1) { // differs
710+
add("rse");
711+
}
697712
if (hasARC) { // differs
698713
if (optimizeLevel < 3) {
699714
add("flatten");
@@ -703,33 +718,47 @@ exports.main = function main(argv, options, callback) {
703718
add("dce");
704719
add("remove-unused-brs");
705720
add("remove-unused-names");
706-
add("optimize-instructions");
721+
// add("optimize-instructions"); // differs move 2 lines above
707722
if (optimizeLevel >= 2 || shrinkLevel >= 1) {
708723
add("pick-load-signs");
709724
add("simplify-globals-optimizing"); // differs
710725
}
726+
add("optimize-instructions"); // differs
711727
if (optimizeLevel >= 3 || shrinkLevel >= 2) {
712728
add("precompute-propagate");
713729
} else {
714730
add("precompute");
715731
}
732+
if (module.getLowMemoryUnused()) {
733+
if (optimizeLevel >= 3 || shrinkLevel >= 1) {
734+
add("optimize-added-constants-propagate");
735+
} else {
736+
add("optimize-added-constants");
737+
}
738+
}
716739
// this will be done later (1)
717740
// if (optimizeLevel >= 2 || shrinkLevel >= 2) {
718741
// add("code-pushing");
719742
// }
743+
if (optimizeLevel >= 3 && shrinkLevel <= 1) { // differs
744+
add("licm");
745+
}
720746
add("simplify-locals-nostructure");
721747
add("vacuum");
722748
add("reorder-locals");
723749
add("remove-unused-brs");
724-
if (optimizeLevel >= 3 || shrinkLevel >= 2) {
725-
add("merge-locals");
726-
}
750+
// if (optimizeLevel >= 3 || shrinkLevel >= 2) { // do it later
751+
// add("merge-locals");
752+
// }
727753
add("coalesce-locals");
728754
add("simplify-locals");
729755
add("vacuum");
730756
add("reorder-locals");
731757
add("coalesce-locals");
732758
add("reorder-locals");
759+
if (optimizeLevel >= 3 || shrinkLevel >= 1) { // differs
760+
add("merge-locals");
761+
}
733762
add("vacuum");
734763
if (optimizeLevel >= 3 || shrinkLevel >= 1) {
735764
add("code-folding");
@@ -789,29 +818,26 @@ exports.main = function main(argv, options, callback) {
789818
add("remove-unused-brs");
790819
add("vacuum");
791820

792-
// replace indirect calls with direct and inline if possible again.
793-
add("directize");
794-
add("inlining-optimizing");
795821
// move some code after early return which potentially could reduce computations
796822
// do this after CFG cleanup (originally it was done before)
797823
// moved from (1)
798824
add("code-pushing");
799-
800-
// this quite expensive so do this only for highest opt level
801-
add("simplify-globals-optimizing");
802825
if (optimizeLevel >= 3) {
803-
add("simplify-locals-nostructure");
804-
add("vacuum");
805-
826+
// this quite expensive so do this only for highest opt level
827+
add("simplify-globals");
828+
// replace indirect calls with direct and inline if possible again.
829+
add("directize");
830+
add("dae-optimizing");
806831
add("precompute-propagate");
832+
add("coalesce-locals");
833+
add("merge-locals");
807834
add("simplify-locals-nostructure");
808835
add("vacuum");
809-
810-
add("reorder-locals");
811-
} else {
812-
add("simplify-globals-optimizing");
836+
add("inlining-optimizing");
837+
add("precompute-propagate");
813838
}
814839
add("optimize-instructions");
840+
add("simplify-globals-optimizing");
815841
}
816842
// remove unused elements of table and pack / reduce memory
817843
add("duplicate-function-elimination"); // differs

cli/asc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@
192192
"type": "S",
193193
"alias": "u"
194194
},
195+
"lowMemoryLimit": {
196+
"category": "Features",
197+
"description": "Enforces very low (<64k) memory constraints.",
198+
"default": 0,
199+
"type": "i"
200+
},
195201

196202
"memoryBase": {
197203
"category": "Linking",

examples/game-of-life/build/optimized.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ declare module ASModule {
22
type i8 = number;
33
type i16 = number;
44
type i32 = number;
5+
type i64 = BigInt;
6+
type isize = number;
57
type u8 = number;
68
type u16 = number;
79
type u32 = number;
10+
type u64 = BigInt;
11+
type usize = number;
812
type f32 = number;
913
type f64 = number;
1014
type bool = any;
-5 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)