diff --git a/package-lock.json b/package-lock.json index 125cc69c01..2ead3eb333 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1163,9 +1163,9 @@ "optional": true }, "binaryen": { - "version": "95.0.0-nightly.20200813", - "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-95.0.0-nightly.20200813.tgz", - "integrity": "sha512-xY+fhSAkVxptBoQAn9X4o21zTFycOjc+PeqbWSwcDqrSmXBXUMeq7qHhz4EWSWlFDKobHeUaiIbzLzlmciDWHw==" + "version": "96.0.0-nightly.20200911", + "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-96.0.0-nightly.20200911.tgz", + "integrity": "sha512-/mFIOMaaGsKcWZcwcrCGVVAtqI5le0rySoZSuS1a+3W878co883NLHOtbV2owDjAT7QELnsmjeKEAh+5VC+gbQ==" }, "bluebird": { "version": "3.7.2", diff --git a/package.json b/package.json index 1dc71a82c0..8536556016 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "url": "https://github.com/AssemblyScript/assemblyscript/issues" }, "dependencies": { - "binaryen": "95.0.0-nightly.20200813", + "binaryen": "96.0.0-nightly.20200911", "long": "^4.0.0", "source-map-support": "^0.5.19", "ts-node": "^6.2.0" diff --git a/src/glue/binaryen.d.ts b/src/glue/binaryen.d.ts index 5c70897850..9e703eb38a 100644 --- a/src/glue/binaryen.d.ts +++ b/src/glue/binaryen.d.ts @@ -986,3 +986,5 @@ export declare function _BinaryenGetFlexibleInlineMaxSize(): BinaryenIndex; export declare function _BinaryenSetFlexibleInlineMaxSize(size: BinaryenIndex): void; export declare function _BinaryenGetOneCallerInlineMaxSize(): BinaryenIndex; export declare function _BinaryenSetOneCallerInlineMaxSize(size: BinaryenIndex): void; +export declare function _BinaryenGetAllowInliningFunctionsWithLoops(): bool; +export declare function _BinaryenSetAllowInliningFunctionsWithLoops(enabled: bool): void; diff --git a/src/module.ts b/src/module.ts index 938c122f91..a26d4b84d3 100644 --- a/src/module.ts +++ b/src/module.ts @@ -1434,6 +1434,14 @@ export class Module { binaryen._BinaryenSetOneCallerInlineMaxSize(size); } + getAllowInliningFunctionsWithLoops(): bool { + return binaryen._BinaryenGetAllowInliningFunctionsWithLoops(); + } + + setAllowInliningFunctionsWithLoops(enabled: bool): void { + binaryen._BinaryenSetAllowInliningFunctionsWithLoops(enabled); + } + // meta (module) getFeatures(): FeatureFlags { @@ -1474,23 +1482,26 @@ export class Module { // Implicitly run costly non-LLVM optimizations on -O3 or -Oz if (optimizeLevel >= 3 || shrinkLevel >= 2) optimizeLevel = 4; - binaryen._BinaryenSetOptimizeLevel(optimizeLevel); - binaryen._BinaryenSetShrinkLevel(shrinkLevel); - binaryen._BinaryenSetDebugInfo(debugInfo); + this.setOptimizeLevel(optimizeLevel); + this.setShrinkLevel(shrinkLevel); + this.setDebugInfo(debugInfo); + this.clearPassArguments(); // Tweak inlining limits based on optimization levels - if (optimizeLevel >= 2 && shrinkLevel === 0) { - binaryen._BinaryenSetAlwaysInlineMaxSize(12); - binaryen._BinaryenSetFlexibleInlineMaxSize(70); - binaryen._BinaryenSetOneCallerInlineMaxSize(200); + if (optimizeLevel >= 2 && shrinkLevel == 0) { + this.setAlwaysInlineMaxSize(12); + this.setFlexibleInlineMaxSize(70); + this.setOneCallerInlineMaxSize(200); + this.setAllowInliningFunctionsWithLoops(optimizeLevel >= 3); } else { - binaryen._BinaryenSetAlwaysInlineMaxSize( + this.setAlwaysInlineMaxSize( optimizeLevel == 0 && shrinkLevel >= 0 ? 2 : 4 ); - binaryen._BinaryenSetFlexibleInlineMaxSize(65); - binaryen._BinaryenSetOneCallerInlineMaxSize(80); + this.setFlexibleInlineMaxSize(65); + this.setOneCallerInlineMaxSize(80); + this.setAllowInliningFunctionsWithLoops(false); } // Pass order here differs substantially from Binaryen's defaults @@ -1596,7 +1607,7 @@ export class Module { if (optimizeLevel >= 2 || shrinkLevel >= 2) { passes.push("inlining-optimizing"); } - if (binaryen._BinaryenGetLowMemoryUnused()) { + if (this.getLowMemoryUnused()) { if (optimizeLevel >= 3 || shrinkLevel >= 1) { passes.push("optimize-added-constants-propagate"); } else {