Skip to content

Commit 0520fcb

Browse files
authored
Update binaryen & other deps (AssemblyScript#2057)
1 parent 87cf3e8 commit 0520fcb

File tree

107 files changed

+73797
-76253
lines changed

Some content is hidden

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

107 files changed

+73797
-76253
lines changed

package-lock.json

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

package.json

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,23 @@
2121
"url": "https://github.com/AssemblyScript/assemblyscript/issues"
2222
},
2323
"dependencies": {
24-
"binaryen": "101.0.0-nightly.20210904",
24+
"binaryen": "102.0.0-nightly.20211028",
2525
"long": "^4.0.0",
26-
"source-map-support": "^0.5.19",
26+
"source-map-support": "^0.5.20",
2727
"ts-node": "^6.2.0"
2828
},
2929
"devDependencies": {
30-
"@types/node": "^15.6.1",
31-
"@typescript-eslint/eslint-plugin": "^4.9.1",
32-
"@typescript-eslint/parser": "^4.9.1",
30+
"@types/node": "^16.11.4",
31+
"@typescript-eslint/eslint-plugin": "^4.33.0",
32+
"@typescript-eslint/parser": "^4.33.0",
3333
"diff": "^5.0.0",
34-
"eslint": "^7.15.0",
35-
"glob": "^7.1.6",
34+
"eslint": "^7.32.0",
35+
"glob": "^7.2.0",
3636
"physical-cpu-count": "^2.0.0",
37-
"source-map-support": "^0.5.19",
38-
"ts-loader": "^9.2.2",
37+
"ts-loader": "^9.2.6",
3938
"ts-node": "^6.2.0",
40-
"typescript": "~4.2.4",
41-
"webpack": "^5.59.1",
39+
"typescript": "^4.4.4",
40+
"webpack": "^5.61.0",
4241
"webpack-cli": "^4.9.1"
4342
},
4443
"type": "commonjs",

src/glue/binaryen.d.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,32 @@ export declare function _BinaryenRefEqSetLeft(expr: ExpressionRef, leftExpr: Exp
410410
export declare function _BinaryenRefEqGetRight(expr: ExpressionRef): ExpressionRef;
411411
export declare function _BinaryenRefEqSetRight(expr: ExpressionRef, rightExpr: ExpressionRef): void;
412412

413+
export declare function _BinaryenTableGet(module: ModuleRef, name: StringRef, index: ExpressionRef, type: TypeRef): ExpressionRef;
414+
export declare function _BinaryenTableGetGetTable(expr: ExpressionRef): StringRef;
415+
export declare function _BinaryenTableGetSetTable(expr: ExpressionRef, table: StringRef): void;
416+
export declare function _BinaryenTableGetGetIndex(expr: ExpressionRef): ExpressionRef;
417+
export declare function _BinaryenTableGetSetIndex(expr: ExpressionRef, index: ExpressionRef): void;
418+
419+
export declare function _BinaryenTableSet(module: ModuleRef, name: StringRef, index: ExpressionRef, value: ExpressionRef): ExpressionRef;
420+
export declare function _BinaryenTableSetGetTable(expr: ExpressionRef): StringRef;
421+
export declare function _BinaryenTableSetSetTable(expr: ExpressionRef, table: StringRef): void;
422+
export declare function _BinaryenTableSetGetIndex(expr: ExpressionRef): ExpressionRef;
423+
export declare function _BinaryenTableSetSetIndex(expr: ExpressionRef, index: ExpressionRef): void;
424+
export declare function _BinaryenTableSetGetValue(expr: ExpressionRef): ExpressionRef;
425+
export declare function _BinaryenTableSetSetValue(expr: ExpressionRef, value: ExpressionRef): void;
426+
427+
export declare function _BinaryenTableSize(module: ModuleRef, name: StringRef): ExpressionRef;
428+
export declare function _BinaryenTableSizeGetTable(expr: ExpressionRef): StringRef;
429+
export declare function _BinaryenTableSizeSetTable(expr: ExpressionRef, table: StringRef): void;
430+
431+
export declare function _BinaryenTableGrow(module: ModuleRef, name: StringRef, value: ExpressionRef, delta: ExpressionRef): ExpressionRef;
432+
export declare function _BinaryenTableGrowGetTable(expr: ExpressionRef): StringRef;
433+
export declare function _BinaryenTableGrowSetTable(expr: ExpressionRef, table: StringRef): void;
434+
export declare function _BinaryenTableGrowGetValue(expr: ExpressionRef): ExpressionRef;
435+
export declare function _BinaryenTableGrowSetValue(expr: ExpressionRef, value: ExpressionRef): void;
436+
export declare function _BinaryenTableGrowGetDelta(expr: ExpressionRef): ExpressionRef;
437+
export declare function _BinaryenTableGrowSetDelta(expr: ExpressionRef, delta: ExpressionRef): void;
438+
413439
export declare function _BinaryenTry(module: ModuleRef, name: StringRef, bodyExpr: ExpressionRef, catchTags: ArrayRef<StringRef>, numCatchTags: Index, catchBodies: ArrayRef<ExpressionRef>, numCatchBodies: Index, delegateTarget: StringRef): ExpressionRef;
414440
export declare function _BinaryenTryGetName(expr: ExpressionRef): StringRef;
415441
export declare function _BinaryenTrySetName(expr: ExpressionRef, name: StringRef): void;

src/module.ts

Lines changed: 81 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ export enum FeatureFlags {
7676
GC = 1024 /* _BinaryenFeatureGC */,
7777
Memory64 = 2048 /* _BinaryenFeatureMemory64 */,
7878
TypedFunctionReferences = 4096 /* _BinaryenFeatureTypedFunctionReferences */,
79-
All = 16383 /* _BinaryenFeatureAll */
79+
RelaxedSIMD = 16384 /* _BinaryenFeatureRelaxedSIMD */,
80+
All = 32767 /* _BinaryenFeatureAll */
8081
}
8182

8283
/** Binaryen expression id constants. */
@@ -126,28 +127,33 @@ export enum ExpressionId {
126127
RefIs = 42 /* _BinaryenRefIsId */,
127128
RefFunc = 43 /* _BinaryenRefFuncId */,
128129
RefEq = 44 /* _BinaryenRefEqId */,
129-
Try = 45 /* _BinaryenTryId */,
130-
Throw = 46 /* _BinaryenThrowId */,
131-
Rethrow = 47 /* _BinaryenRethrowId */,
132-
TupleMake = 48 /* _BinaryenTupleMakeId */,
133-
TupleExtract = 49 /* _BinaryenTupleExtractId */,
134-
I31New = 50 /* _BinaryenI31NewId */,
135-
I31Get = 51 /* _BinaryenI31GetId */,
136-
CallRef = 52 /* _BinaryenCallRefId */,
137-
RefTest = 53 /* _BinaryenRefTestId */,
138-
RefCast = 54 /* _BinaryenRefCastId */,
139-
BrOn = 55 /* _BinaryenBrOnId */,
140-
RttCanon = 56 /* _BinaryenRttCanonId */,
141-
RttSub = 57 /* _BinaryenRttSubId */,
142-
StructNew = 58 /* _BinaryenStructNewId */,
143-
StructGet = 59 /* _BinaryenStructGetId */,
144-
StructSet = 60 /* _BinaryenStructSetId */,
145-
ArrayNew = 61 /* _BinaryenArrayNewId */,
146-
ArrayGet = 62 /* _BinaryenArrayGetId */,
147-
ArraySet = 63 /* _BinaryenArraySetId */,
148-
ArrayLen = 64 /* _BinaryenArrayLenId */,
149-
ArrayCopy = 65 /* _BinaryenArrayCopyId */,
150-
RefAs = 66 /* _BinaryenRefAsId */
130+
TableGet = 45 /* _BinaryenTableGetId */,
131+
TableSet = 46 /* _BinaryenTableSetId */,
132+
TableSize = 47 /* _BinaryenTableSizeId */,
133+
TableGrow = 48 /* _BinaryenTableGrowId */,
134+
Try = 49 /* _BinaryenTryId */,
135+
Throw = 50 /* _BinaryenThrowId */,
136+
Rethrow = 51 /* _BinaryenRethrowId */,
137+
TupleMake = 52 /* _BinaryenTupleMakeId */,
138+
TupleExtract = 53 /* _BinaryenTupleExtractId */,
139+
I31New = 54 /* _BinaryenI31NewId */,
140+
I31Get = 55 /* _BinaryenI31GetId */,
141+
CallRef = 56 /* _BinaryenCallRefId */,
142+
RefTest = 57 /* _BinaryenRefTestId */,
143+
RefCast = 58 /* _BinaryenRefCastId */,
144+
BrOn = 59 /* _BinaryenBrOnId */,
145+
RttCanon = 60 /* _BinaryenRttCanonId */,
146+
RttSub = 61 /* _BinaryenRttSubId */,
147+
StructNew = 62 /* _BinaryenStructNewId */,
148+
StructGet = 63 /* _BinaryenStructGetId */,
149+
StructSet = 64 /* _BinaryenStructSetId */,
150+
ArrayNew = 65 /* _BinaryenArrayNewId */,
151+
ArrayInit = 66 /* _BinaryenArrayInitId */,
152+
ArrayGet = 67 /* _BinaryenArrayGetId */,
153+
ArraySet = 68 /* _BinaryenArraySetId */,
154+
ArrayLen = 69 /* _BinaryenArrayLenId */,
155+
ArrayCopy = 70 /* _BinaryenArrayCopyId */,
156+
RefAs = 71 /* _BinaryenRefAsId */
151157
}
152158

153159
/** Binaryen external kind constants. */
@@ -1239,6 +1245,16 @@ export class Module {
12391245
return binaryen._BinaryenMemoryGrow(this.ref, delta);
12401246
}
12411247

1248+
table_size(name: string): ExpressionRef {
1249+
var cStr = this.allocStringCached(name);
1250+
return binaryen._BinaryenTableSize(this.ref, cStr);
1251+
}
1252+
1253+
table_grow(name: string, delta: ExpressionRef, value: ExpressionRef = 0): ExpressionRef {
1254+
var cStr = this.allocStringCached(name);
1255+
return binaryen._BinaryenTableGrow(this.ref, cStr, value, delta);
1256+
}
1257+
12421258
local_get(
12431259
index: i32,
12441260
type: TypeRef
@@ -1276,6 +1292,15 @@ export class Module {
12761292
return binaryen._BinaryenGlobalGet(this.ref, cStr, type);
12771293
}
12781294

1295+
table_get(
1296+
name: string,
1297+
index: ExpressionRef,
1298+
type: TypeRef
1299+
): ExpressionRef {
1300+
var cStr = this.allocStringCached(name);
1301+
return binaryen._BinaryenTableGet(this.ref, cStr, index, type);
1302+
}
1303+
12791304
load(
12801305
bytes: Index,
12811306
signed: bool,
@@ -1380,6 +1405,15 @@ export class Module {
13801405
return binaryen._BinaryenGlobalSet(this.ref, cStr, value);
13811406
}
13821407

1408+
table_set(
1409+
name: string,
1410+
index: ExpressionRef,
1411+
value: ExpressionRef
1412+
): ExpressionRef {
1413+
var cStr = this.allocStringCached(name);
1414+
return binaryen._BinaryenTableSet(this.ref, cStr, index, value);
1415+
}
1416+
13831417
block(
13841418
label: string | null,
13851419
children: ExpressionRef[],
@@ -2267,13 +2301,15 @@ export class Module {
22672301
passes.push("local-cse");
22682302
passes.push("remove-unused-brs");
22692303
passes.push("remove-unused-names");
2304+
passes.push("merge-blocks");
22702305
passes.push("precompute-propagate");
22712306
}
22722307
if (optimizeLevel >= 3) {
22732308
passes.push("simplify-locals-nostructure");
22742309
passes.push("flatten");
22752310
passes.push("vacuum");
22762311
passes.push("simplify-locals-notee-nostructure");
2312+
passes.push("vacuum");
22772313
passes.push("licm");
22782314
passes.push("merge-locals");
22792315
passes.push("reorder-locals");
@@ -2295,6 +2331,7 @@ export class Module {
22952331
if (optimizeLevel >= 2 || shrinkLevel >= 1) {
22962332
passes.push("pick-load-signs");
22972333
passes.push("simplify-globals-optimizing");
2334+
passes.push("simplify-globals-optimizing");
22982335
}
22992336
passes.push("simplify-locals-notee-nostructure");
23002337
passes.push("vacuum");
@@ -2307,25 +2344,24 @@ export class Module {
23072344
passes.push("coalesce-locals");
23082345
passes.push("reorder-locals");
23092346
passes.push("vacuum");
2310-
2347+
if (optimizeLevel >= 2 || shrinkLevel >= 1) {
2348+
passes.push("rse");
2349+
passes.push("vacuum");
2350+
}
23112351
if (optimizeLevel >= 3 || shrinkLevel >= 1) {
23122352
passes.push("merge-locals");
2353+
passes.push("vacuum");
23132354
}
2314-
passes.push("vacuum");
23152355
if (optimizeLevel >= 2 || shrinkLevel >= 1) {
23162356
passes.push("simplify-globals-optimizing");
2357+
passes.push("simplify-globals-optimizing");
23172358
}
2318-
passes.push("merge-blocks");
23192359
passes.push("remove-unused-brs");
23202360
passes.push("remove-unused-names");
23212361
passes.push("merge-blocks");
23222362
if (optimizeLevel >= 3) {
23232363
passes.push("optimize-instructions");
23242364
}
2325-
if (optimizeLevel >= 2 || shrinkLevel >= 1) {
2326-
passes.push("rse");
2327-
passes.push("vacuum");
2328-
}
23292365

23302366
// --- PassRunner::addDefaultGlobalOptimizationPostPasses ---
23312367

@@ -2353,8 +2389,10 @@ export class Module {
23532389
if (optimizeLevel >= 3 || shrinkLevel >= 1) {
23542390
passes.push("code-folding");
23552391
}
2356-
if (optimizeLevel > 1 && (this.getFeatures() & FeatureFlags.GC) != 0) {
2392+
if (optimizeLevel >= 2 && (this.getFeatures() & FeatureFlags.GC) != 0) {
23572393
passes.push("heap2local");
2394+
passes.push("merge-locals");
2395+
passes.push("local-subtyping");
23582396
}
23592397
// precompute works best after global optimizations
23602398
if (optimizeLevel >= 2 || shrinkLevel >= 1) {
@@ -2367,6 +2405,7 @@ export class Module {
23672405
passes.push("dae-optimizing"); // reduce arity
23682406
passes.push("inlining-optimizing"); // and inline if possible
23692407
if (optimizeLevel >= 2 || shrinkLevel >= 1) {
2408+
passes.push("ssa-nomerge");
23702409
passes.push("rse");
23712410
// move code on early return (after CFG cleanup)
23722411
passes.push("code-pushing");
@@ -2390,8 +2429,10 @@ export class Module {
23902429

23912430
passes.push("inlining");
23922431
passes.push("precompute-propagate");
2432+
passes.push("rse");
23932433
passes.push("vacuum");
2394-
2434+
passes.push("ssa-nomerge");
2435+
passes.push("simplify-locals");
23952436
passes.push("coalesce-locals");
23962437
}
23972438
passes.push("remove-unused-brs");
@@ -2963,12 +3004,14 @@ export enum SideEffects {
29633004
WritesGlobal = 32 /* _BinaryenSideEffectWritesGlobal */,
29643005
ReadsMemory = 64 /* _BinaryenSideEffectReadsMemory */,
29653006
WritesMemory = 128 /* _BinaryenSideEffectWritesMemory */,
2966-
ImplicitTrap = 256 /* _BinaryenSideEffectImplicitTrap */,
2967-
IsAtomic = 512 /* _BinaryenSideEffectIsAtomic */,
2968-
Throws = 1024 /* _BinaryenSideEffectThrows */,
2969-
DanglingPop = 2048 /* _BinaryenSideEffectDanglingPop */,
2970-
TrapsNeverHappen = 4096 /* _BinaryenSideEffectTrapsNeverHappen */,
2971-
Any = 8191 /* _BinaryenSideEffectAny */
3007+
ReadsTable = 256 /* _BinaryenSideEffectReadsTable */,
3008+
WritesTable = 512 /* _BinaryenSideEffectWritesTable */,
3009+
ImplicitTrap = 1024 /* _BinaryenSideEffectImplicitTrap */,
3010+
IsAtomic = 2048 /* _BinaryenSideEffectIsAtomic */,
3011+
Throws = 4096 /* _BinaryenSideEffectThrows */,
3012+
DanglingPop = 8192 /* _BinaryenSideEffectDanglingPop */,
3013+
TrapsNeverHappen = 16384 /* _BinaryenSideEffectTrapsNeverHappen */,
3014+
Any = 32767 /* _BinaryenSideEffectAny */
29723015
}
29733016

29743017
export function getSideEffects(expr: ExpressionRef, module: ModuleRef): SideEffects {

std/assembly/util/string.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,7 @@ export function isSpace(c: u32): bool {
512512
if (c < 0x1680) { // < <LS> (1)
513513
// <SP>, <TAB>, <LF>, <VT>, <FF>, <CR> and <NBSP>
514514
// (c == 0x20 || c == 0xA0) was optimized to (c | 0x80) == 0xA0
515-
// @ts-ignore: cast
516-
return ((c | 0x80) == 0xA0) | (c - 0x09 <= 0x0D - 0x09);
515+
return ((c | 0x80) == 0xA0) || (c - 0x09 <= 0x0D - 0x09);
517516
}
518517
if (c - 0x2000 <= 0x200A - 0x2000) return true;
519518
switch (c) {

std/assembly/util/uri.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,5 @@ function loadHex(src: usize, offset: usize): u32 {
271271

272272
// @ts-ignore: decorator
273273
@inline function isHex(ch: u32): bool {
274-
// @ts-ignore
275-
return (ch - CharCode._0 < 10) | ((ch | 32) - CharCode.a < 6);
274+
return (ch - CharCode._0 < 10) || ((ch | 32) - CharCode.a < 6);
276275
}

tests/compiler/NonNullable.optimized.wat

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
i32.load offset=16
4646
i32.const 1
4747
i32.shr_u
48-
local.tee $2
48+
local.tee $3
4949
local.get $1
5050
i32.const 20
5151
i32.sub
@@ -59,32 +59,31 @@
5959
end
6060
block $__inlined_func$~lib/util/string/compareImpl (result i32)
6161
local.get $0
62-
local.tee $3
62+
local.tee $2
6363
i32.const 7
6464
i32.and
6565
local.get $1
6666
i32.const 7
6767
i32.and
6868
i32.or
69-
i32.const 1
70-
local.get $2
69+
i32.eqz
70+
local.get $3
7171
local.tee $0
7272
i32.const 4
7373
i32.ge_u
74-
select
75-
i32.eqz
74+
i32.and
7675
if
7776
loop $do-loop|0
78-
local.get $3
77+
local.get $2
7978
i64.load
8079
local.get $1
8180
i64.load
8281
i64.eq
8382
if
84-
local.get $3
83+
local.get $2
8584
i32.const 8
8685
i32.add
87-
local.set $3
86+
local.set $2
8887
local.get $1
8988
i32.const 8
9089
i32.add
@@ -101,29 +100,29 @@
101100
end
102101
loop $while-continue|1
103102
local.get $0
104-
local.tee $2
103+
local.tee $3
105104
i32.const 1
106105
i32.sub
107106
local.set $0
108-
local.get $2
107+
local.get $3
109108
if
110-
local.get $3
109+
local.get $2
111110
i32.load16_u
112-
local.tee $2
111+
local.tee $3
113112
local.get $1
114113
i32.load16_u
115114
local.tee $4
116115
i32.ne
117116
if
118-
local.get $2
117+
local.get $3
119118
local.get $4
120119
i32.sub
121120
br $__inlined_func$~lib/util/string/compareImpl
122121
end
123-
local.get $3
122+
local.get $2
124123
i32.const 2
125124
i32.add
126-
local.set $3
125+
local.set $2
127126
local.get $1
128127
i32.const 2
129128
i32.add

0 commit comments

Comments
 (0)