@@ -76,7 +76,8 @@ export enum FeatureFlags {
76
76
GC = 1024 /* _BinaryenFeatureGC */ ,
77
77
Memory64 = 2048 /* _BinaryenFeatureMemory64 */ ,
78
78
TypedFunctionReferences = 4096 /* _BinaryenFeatureTypedFunctionReferences */ ,
79
- All = 16383 /* _BinaryenFeatureAll */
79
+ RelaxedSIMD = 16384 /* _BinaryenFeatureRelaxedSIMD */ ,
80
+ All = 32767 /* _BinaryenFeatureAll */
80
81
}
81
82
82
83
/** Binaryen expression id constants. */
@@ -126,28 +127,33 @@ export enum ExpressionId {
126
127
RefIs = 42 /* _BinaryenRefIsId */ ,
127
128
RefFunc = 43 /* _BinaryenRefFuncId */ ,
128
129
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 */
151
157
}
152
158
153
159
/** Binaryen external kind constants. */
@@ -1239,6 +1245,16 @@ export class Module {
1239
1245
return binaryen . _BinaryenMemoryGrow ( this . ref , delta ) ;
1240
1246
}
1241
1247
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
+
1242
1258
local_get (
1243
1259
index : i32 ,
1244
1260
type : TypeRef
@@ -1276,6 +1292,15 @@ export class Module {
1276
1292
return binaryen . _BinaryenGlobalGet ( this . ref , cStr , type ) ;
1277
1293
}
1278
1294
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
+
1279
1304
load (
1280
1305
bytes : Index ,
1281
1306
signed : bool ,
@@ -1380,6 +1405,15 @@ export class Module {
1380
1405
return binaryen . _BinaryenGlobalSet ( this . ref , cStr , value ) ;
1381
1406
}
1382
1407
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
+
1383
1417
block (
1384
1418
label : string | null ,
1385
1419
children : ExpressionRef [ ] ,
@@ -2267,13 +2301,15 @@ export class Module {
2267
2301
passes . push ( "local-cse" ) ;
2268
2302
passes . push ( "remove-unused-brs" ) ;
2269
2303
passes . push ( "remove-unused-names" ) ;
2304
+ passes . push ( "merge-blocks" ) ;
2270
2305
passes . push ( "precompute-propagate" ) ;
2271
2306
}
2272
2307
if ( optimizeLevel >= 3 ) {
2273
2308
passes . push ( "simplify-locals-nostructure" ) ;
2274
2309
passes . push ( "flatten" ) ;
2275
2310
passes . push ( "vacuum" ) ;
2276
2311
passes . push ( "simplify-locals-notee-nostructure" ) ;
2312
+ passes . push ( "vacuum" ) ;
2277
2313
passes . push ( "licm" ) ;
2278
2314
passes . push ( "merge-locals" ) ;
2279
2315
passes . push ( "reorder-locals" ) ;
@@ -2295,6 +2331,7 @@ export class Module {
2295
2331
if ( optimizeLevel >= 2 || shrinkLevel >= 1 ) {
2296
2332
passes . push ( "pick-load-signs" ) ;
2297
2333
passes . push ( "simplify-globals-optimizing" ) ;
2334
+ passes . push ( "simplify-globals-optimizing" ) ;
2298
2335
}
2299
2336
passes . push ( "simplify-locals-notee-nostructure" ) ;
2300
2337
passes . push ( "vacuum" ) ;
@@ -2307,25 +2344,24 @@ export class Module {
2307
2344
passes . push ( "coalesce-locals" ) ;
2308
2345
passes . push ( "reorder-locals" ) ;
2309
2346
passes . push ( "vacuum" ) ;
2310
-
2347
+ if ( optimizeLevel >= 2 || shrinkLevel >= 1 ) {
2348
+ passes . push ( "rse" ) ;
2349
+ passes . push ( "vacuum" ) ;
2350
+ }
2311
2351
if ( optimizeLevel >= 3 || shrinkLevel >= 1 ) {
2312
2352
passes . push ( "merge-locals" ) ;
2353
+ passes . push ( "vacuum" ) ;
2313
2354
}
2314
- passes . push ( "vacuum" ) ;
2315
2355
if ( optimizeLevel >= 2 || shrinkLevel >= 1 ) {
2316
2356
passes . push ( "simplify-globals-optimizing" ) ;
2357
+ passes . push ( "simplify-globals-optimizing" ) ;
2317
2358
}
2318
- passes . push ( "merge-blocks" ) ;
2319
2359
passes . push ( "remove-unused-brs" ) ;
2320
2360
passes . push ( "remove-unused-names" ) ;
2321
2361
passes . push ( "merge-blocks" ) ;
2322
2362
if ( optimizeLevel >= 3 ) {
2323
2363
passes . push ( "optimize-instructions" ) ;
2324
2364
}
2325
- if ( optimizeLevel >= 2 || shrinkLevel >= 1 ) {
2326
- passes . push ( "rse" ) ;
2327
- passes . push ( "vacuum" ) ;
2328
- }
2329
2365
2330
2366
// --- PassRunner::addDefaultGlobalOptimizationPostPasses ---
2331
2367
@@ -2353,8 +2389,10 @@ export class Module {
2353
2389
if ( optimizeLevel >= 3 || shrinkLevel >= 1 ) {
2354
2390
passes . push ( "code-folding" ) ;
2355
2391
}
2356
- if ( optimizeLevel > 1 && ( this . getFeatures ( ) & FeatureFlags . GC ) != 0 ) {
2392
+ if ( optimizeLevel >= 2 && ( this . getFeatures ( ) & FeatureFlags . GC ) != 0 ) {
2357
2393
passes . push ( "heap2local" ) ;
2394
+ passes . push ( "merge-locals" ) ;
2395
+ passes . push ( "local-subtyping" ) ;
2358
2396
}
2359
2397
// precompute works best after global optimizations
2360
2398
if ( optimizeLevel >= 2 || shrinkLevel >= 1 ) {
@@ -2367,6 +2405,7 @@ export class Module {
2367
2405
passes . push ( "dae-optimizing" ) ; // reduce arity
2368
2406
passes . push ( "inlining-optimizing" ) ; // and inline if possible
2369
2407
if ( optimizeLevel >= 2 || shrinkLevel >= 1 ) {
2408
+ passes . push ( "ssa-nomerge" ) ;
2370
2409
passes . push ( "rse" ) ;
2371
2410
// move code on early return (after CFG cleanup)
2372
2411
passes . push ( "code-pushing" ) ;
@@ -2390,8 +2429,10 @@ export class Module {
2390
2429
2391
2430
passes . push ( "inlining" ) ;
2392
2431
passes . push ( "precompute-propagate" ) ;
2432
+ passes . push ( "rse" ) ;
2393
2433
passes . push ( "vacuum" ) ;
2394
-
2434
+ passes . push ( "ssa-nomerge" ) ;
2435
+ passes . push ( "simplify-locals" ) ;
2395
2436
passes . push ( "coalesce-locals" ) ;
2396
2437
}
2397
2438
passes . push ( "remove-unused-brs" ) ;
@@ -2963,12 +3004,14 @@ export enum SideEffects {
2963
3004
WritesGlobal = 32 /* _BinaryenSideEffectWritesGlobal */ ,
2964
3005
ReadsMemory = 64 /* _BinaryenSideEffectReadsMemory */ ,
2965
3006
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 */
2972
3015
}
2973
3016
2974
3017
export function getSideEffects ( expr : ExpressionRef , module : ModuleRef ) : SideEffects {
0 commit comments