@@ -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
29743017export function getSideEffects ( expr : ExpressionRef , module : ModuleRef ) : SideEffects {
0 commit comments