File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ import {
60
60
ensureType ,
61
61
createType ,
62
62
getConstValueInteger ,
63
- isConstNonZero
63
+ isConstZero
64
64
} from "./module" ;
65
65
66
66
import {
@@ -10026,6 +10026,14 @@ export class Compiler extends DiagnosticEmitter {
10026
10026
10027
10027
// === Specialized code generation ==============================================================
10028
10028
10029
+ /** Check if possible to optimize the active initialization away if it's zero */
10030
+ canOptimizeZeroInitialization ( valueExpr : ExpressionRef ) : bool {
10031
+ if ( ( this . options . runtime != Runtime . Incremental ) && ( this . options . runtime != Runtime . Stub ) ) {
10032
+ return false ;
10033
+ }
10034
+ return isConstZero ( valueExpr ) ;
10035
+ }
10036
+
10029
10037
/** Makes a constant zero of the specified type. */
10030
10038
makeZero ( type : Type ) : ExpressionRef {
10031
10039
let module = this . module ;
@@ -10417,7 +10425,7 @@ export class Compiler extends DiagnosticEmitter {
10417
10425
// Memory will be filled with 0 on itcms.__new
10418
10426
// Memory grow will default to initialized with 0 as wasm spec
10419
10427
// So, optimize the active initialization away if it's zero
10420
- if ( ( this . options . runtime == Runtime . Incremental || this . options . runtime == Runtime . Stub ) && isConstNonZero ( valueExpr ) ) {
10428
+ if ( ! this . canOptimizeZeroInitialization ( valueExpr ) ) {
10421
10429
let expr = this . makeCallDirect ( setterInstance , [
10422
10430
module . local_get ( thisLocalIndex , sizeTypeRef ) ,
10423
10431
valueExpr
You can’t perform that action at this time.
0 commit comments