@@ -270,7 +270,7 @@ function hasSideEffects(node) {
270
270
// as they appear (like ArrowFunctionExpression). Instead, we do a conservative
271
271
// analysis here.
272
272
273
- function runJSDCE ( ast , aggressive ) {
273
+ function JSDCE ( ast , aggressive ) {
274
274
function iteration ( ) {
275
275
let removed = 0 ;
276
276
const scopes = [ { } ] ; // begin with empty toplevel scope
@@ -457,8 +457,8 @@ function runJSDCE(ast, aggressive) {
457
457
}
458
458
459
459
// Aggressive JSDCE - multiple iterations
460
- function runAJSDCE ( ast ) {
461
- runJSDCE ( ast , /* aggressive= */ true ) ;
460
+ function AJSDCE ( ast ) {
461
+ JSDCE ( ast , /* aggressive= */ true ) ;
462
462
}
463
463
464
464
function isWasmImportsAssign ( node ) {
@@ -2000,6 +2000,11 @@ function trace(...args) {
2000
2000
}
2001
2001
}
2002
2002
2003
+ function error ( ...args ) {
2004
+ console . error ( ...args ) ;
2005
+ throw new Error ( ...args ) ;
2006
+ }
2007
+
2003
2008
// If enabled, output retains parentheses and comments so that the
2004
2009
// output can further be passed out to Closure.
2005
2010
const closureFriendly = getArg ( '--closure-friendly' ) ;
@@ -2051,23 +2056,26 @@ try {
2051
2056
}
2052
2057
2053
2058
const registry = {
2054
- JSDCE : runJSDCE ,
2055
- AJSDCE : runAJSDCE ,
2056
- applyImportAndExportNameChanges : applyImportAndExportNameChanges ,
2057
- emitDCEGraph : emitDCEGraph ,
2058
- applyDCEGraphRemovals : applyDCEGraphRemovals ,
2059
- dump : ( ) => dump ( ast ) ,
2060
- littleEndianHeap : littleEndianHeap ,
2061
- growableHeap : growableHeap ,
2062
- unsignPointers : unsignPointers ,
2063
- minifyLocals : minifyLocals ,
2064
- asanify : asanify ,
2065
- safeHeap : safeHeap ,
2066
- minifyGlobals : minifyGlobals ,
2059
+ JSDCE ,
2060
+ AJSDCE ,
2061
+ applyImportAndExportNameChanges,
2062
+ emitDCEGraph,
2063
+ applyDCEGraphRemovals,
2064
+ dump,
2065
+ littleEndianHeap,
2066
+ growableHeap,
2067
+ unsignPointers,
2068
+ minifyLocals,
2069
+ asanify,
2070
+ safeHeap,
2071
+ minifyGlobals,
2067
2072
} ;
2068
2073
2069
2074
passes . forEach ( ( pass ) => {
2070
2075
trace ( `running AST pass: ${ pass } ` ) ;
2076
+ if ( ! ( pass in registry ) ) {
2077
+ error ( `unknown optimizer pass: ${ pass } ` ) ;
2078
+ }
2071
2079
registry [ pass ] ( ast ) ;
2072
2080
} ) ;
2073
2081
0 commit comments