Skip to content

Commit e9c7a50

Browse files
lauraharkercopybara-github
authored andcommitted
Include TypedAST deserialization data in tracer mode
PiperOrigin-RevId: 499598876
1 parent 7863097 commit e9c7a50

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

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

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,9 @@ public final void initWithTypedAstFilesystem(
545545
ImmutableSet<SourceFile> files =
546546
ImmutableSet.<SourceFile>builder().addAll(externs).addAll(sources).build();
547547

548-
this.initTypedAstFilesystem(files, typedAstListStream, options);
548+
this.initOptions(options);
549549
this.init(externs, sources, options);
550+
this.initTypedAstFilesystem(files, typedAstListStream, options);
550551
}
551552

552553
/**
@@ -569,8 +570,9 @@ public void initModulesWithTypedAstFilesystem(
569570
}
570571
ImmutableSet<SourceFile> files = filesBuilder.build();
571572

572-
this.initTypedAstFilesystem(files, typedAstListStream, options);
573+
this.initOptions(options);
573574
this.initModules(externs, modules, options);
575+
this.initTypedAstFilesystem(files, typedAstListStream, options);
574576
}
575577

576578
@GwtIncompatible
@@ -579,26 +581,38 @@ private void initTypedAstFilesystem(
579581
InputStream typedAstListStream,
580582
CompilerOptions options) {
581583
checkState(this.typedAstFilesystem == null);
584+
maybeSetTracker();
582585

583586
options.setMergedPrecompiledLibraries(true);
584587

585588
this.setLifeCycleStage(LifeCycleStage.COLORS_AND_SIMPLIFIED_JSDOC);
586589
// To speed up builds that don't run type-based optimizations, skip type deserialization
587590
boolean deserializeTypes = options.requiresTypesForOptimization();
591+
588592
TypedAstDeserializer.DeserializedAst astData =
589-
TypedAstDeserializer.deserializeFullAst(
590-
this,
591-
SYNTHETIC_EXTERNS_FILE,
592-
requiredInputFiles,
593-
typedAstListStream,
594-
deserializeTypes,
595-
options.resolveSourceMapAnnotations,
596-
options.parseInlineSourceMaps);
593+
runInCompilerThread(
594+
() -> {
595+
Tracer tracer = newTracer("deserializeTypedAst");
596+
try {
597+
return TypedAstDeserializer.deserializeFullAst(
598+
this,
599+
SYNTHETIC_EXTERNS_FILE,
600+
requiredInputFiles,
601+
typedAstListStream,
602+
deserializeTypes,
603+
options.resolveSourceMapAnnotations,
604+
options.parseInlineSourceMaps);
605+
} finally {
606+
stopTracer(tracer, "deserializeTypedAst");
607+
}
608+
});
597609

598610
this.typedAstFilesystem = astData.getFilesystem();
599611
this.externProperties = astData.getExternProperties();
600612
this.colorRegistry = astData.getColorRegistry().orNull();
601613
this.setTypeCheckingHasRun(deserializeTypes);
614+
615+
this.getSynthesizedExternsInput(); // Force lazy creation.
602616
}
603617

604618
@Override
@@ -789,10 +803,6 @@ private void initAST() {
789803
jsRoot = IR.root();
790804
externsRoot = IR.root();
791805
externAndJsRoot = IR.root(externsRoot, jsRoot);
792-
793-
if (this.typedAstFilesystem != null) {
794-
this.getSynthesizedExternsInput(); // Force lazy creation.
795-
}
796806
}
797807

798808
/** Compiles a single source file and a single externs file. */
@@ -1775,7 +1785,7 @@ StaticScope getTranspilationNamespace() {
17751785
}
17761786

17771787
public void maybeSetTracker() {
1778-
if (!options.getTracerMode().isOn()) {
1788+
if (!options.getTracerMode().isOn() || tracker != null) {
17791789
return;
17801790
}
17811791

0 commit comments

Comments
 (0)