Skip to content

Commit 8dfc4f7

Browse files
rahul-kamatcopybara-github
authored andcommitted
Pass explicit list of stage 2 passes to stage2Passes()
PiperOrigin-RevId: 716443092
1 parent c464aa5 commit 8dfc4f7

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

src/com/google/javascript/jscomp/AbstractCommandLineRunner.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import com.google.javascript.jscomp.CompilerOptions.JsonStreamMode;
4949
import com.google.javascript.jscomp.CompilerOptions.OutputJs;
5050
import com.google.javascript.jscomp.CompilerOptions.TweakProcessing;
51+
import com.google.javascript.jscomp.PassConfig.OptimizationPasses;
5152
import com.google.javascript.jscomp.deps.ModuleLoader;
5253
import com.google.javascript.jscomp.deps.SourceCodeEscapers;
5354
import com.google.javascript.jscomp.ijs.IjsErrors;
@@ -1386,7 +1387,7 @@ private Result restoreTypedAstsPerformStage2AndSave(
13861387
try {
13871388
if (!compiler.hasErrors()) {
13881389
metricsRecorder.recordStartState(compiler);
1389-
compiler.stage2Passes();
1390+
compiler.stage2Passes(OptimizationPasses.ALL);
13901391
if (!compiler.hasErrors()) {
13911392
try (BufferedOutputStream serializedOutputStream =
13921393
new BufferedOutputStream(new FileOutputStream(outputFilename))) {
@@ -1411,7 +1412,7 @@ private Result restoreTypedAstsPerformStages2and3(
14111412
try {
14121413
if (!compiler.hasErrors()) {
14131414
metricsRecorder.recordStartState(compiler);
1414-
compiler.stage2Passes();
1415+
compiler.stage2Passes(OptimizationPasses.ALL);
14151416
if (!compiler.hasErrors()) {
14161417
compiler.stage3Passes();
14171418
}
@@ -1435,7 +1436,7 @@ private Result restoreAndPerformStage2AndSave(
14351436
compiler.restoreState(serializedInputStream);
14361437
if (!compiler.hasErrors()) {
14371438
metricsRecorder.recordStartState(compiler);
1438-
compiler.stage2Passes();
1439+
compiler.stage2Passes(OptimizationPasses.ALL);
14391440
if (!compiler.hasErrors()) {
14401441
try (BufferedOutputStream serializedOutputStream =
14411442
new BufferedOutputStream(new FileOutputStream(outputFilename))) {
@@ -1465,7 +1466,7 @@ private Result restoreAndPerformStages2and3(
14651466
compiler.restoreState(serializedInputStream);
14661467
if (!compiler.hasErrors()) {
14671468
metricsRecorder.recordStartState(compiler);
1468-
compiler.stage2Passes();
1469+
compiler.stage2Passes(OptimizationPasses.ALL);
14691470
if (!compiler.hasErrors()) {
14701471
compiler.stage3Passes();
14711472
}
@@ -1513,7 +1514,7 @@ private Result performFullCompilation(CompileMetricsRecorderInterface metricsRec
15131514
metricsRecorder.recordStartState(compiler);
15141515
compiler.stage1Passes();
15151516
if (!compiler.hasErrors()) {
1516-
compiler.stage2Passes();
1517+
compiler.stage2Passes(OptimizationPasses.ALL);
15171518
if (!compiler.hasErrors()) {
15181519
compiler.stage3Passes();
15191520
}

src/com/google/javascript/jscomp/Compiler.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ public Result compile(
939939
} else {
940940
stage1Passes();
941941
if (!hasErrors()) {
942-
stage2Passes();
942+
stage2Passes(OptimizationPasses.ALL);
943943
if (!hasErrors()) {
944944
stage3Passes();
945945
}
@@ -995,7 +995,7 @@ public Result compileChunks(
995995
} else {
996996
stage1Passes();
997997
if (!hasErrors()) {
998-
stage2Passes();
998+
stage2Passes(OptimizationPasses.ALL);
999999
if (!hasErrors()) {
10001000
stage3Passes();
10011001
}
@@ -1040,7 +1040,7 @@ public void stage1Passes() {
10401040
* <p>The caller is responsible for also calling {@code generateReport()} to generate a report of
10411041
* warnings and errors to stderr. See the invocation in {@link #compile} for a good example.
10421042
*/
1043-
public void stage2Passes() {
1043+
public void stage2Passes(OptimizationPasses optimizationPasses) {
10441044
checkState(chunkGraph != null, "No inputs. Did you call init() or initChunks()?");
10451045
checkState(!hasErrors());
10461046
checkState(!options.getInstrumentForCoverageOnly());
@@ -1056,7 +1056,7 @@ public void stage2Passes() {
10561056
runInCompilerThread(
10571057
() -> {
10581058
if (options.shouldOptimize()) {
1059-
performTranspilationAndOptimizations(OptimizationPasses.ALL);
1059+
performTranspilationAndOptimizations(optimizationPasses);
10601060
}
10611061
return null;
10621062
});

test/com/google/javascript/jscomp/integration/TypedAstIntegrationTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.google.javascript.jscomp.DiagnosticGroups;
3636
import com.google.javascript.jscomp.JSChunk;
3737
import com.google.javascript.jscomp.ModuleIdentifier;
38+
import com.google.javascript.jscomp.PassConfig.OptimizationPasses;
3839
import com.google.javascript.jscomp.PropertyRenamingPolicy;
3940
import com.google.javascript.jscomp.SourceFile;
4041
import com.google.javascript.jscomp.VariableRenamingPolicy;
@@ -659,7 +660,7 @@ public void testCrossChunkMethodMotion() throws IOException {
659660
options,
660661
inputStream);
661662
}
662-
compiler.stage2Passes();
663+
compiler.stage2Passes(OptimizationPasses.ALL);
663664
compiler.stage3Passes();
664665

665666
String[] expected =
@@ -925,7 +926,7 @@ private Compiler compileTypedAstShardsWithoutErrorChecks(CompilerOptions options
925926
options,
926927
inputStream);
927928
}
928-
compiler.stage2Passes();
929+
compiler.stage2Passes(OptimizationPasses.ALL);
929930
if (!compiler.hasErrors()) {
930931
compiler.stage3Passes();
931932
}

0 commit comments

Comments
 (0)