Skip to content

Commit

Permalink
Move the J2clPass from late checks to early optimizations
Browse files Browse the repository at this point in the history
It was originallly in checks to allow it to run before generator transpilation, but generator transpilation has since been moved to the optimizations phase.

PiperOrigin-RevId: 545769000
  • Loading branch information
lauraharker authored and copybara-github committed Jul 5, 2023
1 parent 642bbf6 commit b4730c7
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/com/google/javascript/jscomp/DefaultPassConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,6 @@ protected PassListBuilder getChecks() {
checks.maybeAdd(removeSyntheticScript);
} else if (!options.checksOnly) {
checks.maybeAdd(mergeSyntheticScript);
if (options.j2clPassMode.shouldAddJ2clPasses()) {
checks.maybeAdd(j2clPass);
}
// At this point all checks have been done.
if (options.exportTestFunctions) {
checks.maybeAdd(exportTestFunctions);
Expand Down Expand Up @@ -559,6 +556,10 @@ protected PassListBuilder getOptimizations() {
// This is expected to do nothing when in a monolithic build
passes.maybeAdd(removeUnnecessarySyntheticExterns);

if (options.j2clPassMode.shouldAddJ2clPasses()) {
passes.maybeAdd(j2clPass);
}

TranspilationPasses.addTranspilationRuntimeLibraries(passes);

if (options.rewritePolyfills || options.getIsolatePolyfills()) {
Expand Down Expand Up @@ -1286,11 +1287,6 @@ private void assertValidOrderForChecks(PassListBuilder checks) {
gatherModuleMetadataPass,
checkMissingRequires,
"Need to gather module information before checking for missing requires.");

checks.assertPassOrder(
j2clPass,
TranspilationPasses.rewriteGenerators,
"J2CL normalization should be done before generator re-writing.");
}

/**
Expand All @@ -1301,6 +1297,11 @@ private void assertValidOrderForChecks(PassListBuilder checks) {
* @param optimizations The list of optimization passes
*/
private void assertValidOrderForOptimizations(PassListBuilder optimizations) {
optimizations.assertPassOrder(
j2clPass,
TranspilationPasses.rewriteGenerators,
"J2CL normalization should be done before generator re-writing.");

optimizations.assertPassOrder(
TranspilationPasses.rewritePolyfills,
processDefinesOptimize,
Expand Down

0 comments on commit b4730c7

Please sign in to comment.