mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-01 07:33:12 +08:00
Batch the program's identifier symbols before collection (#2254)
This commit is contained in:
@@ -5235,11 +5235,11 @@ export class Lowerer {
|
||||
const sourceFiles = parts.map((p) => p.sf);
|
||||
const fnDecls = parts.flatMap((p) => p.fnDecls);
|
||||
// This fixed-point scan intentionally sees deferred bodies before
|
||||
// reachability is known. Batch their binding queries through the
|
||||
// facade's panic fence, then keep lookup free of lowering side effects:
|
||||
// resolveValueSymbol also flushes deferred diagnostics and applies
|
||||
// merged-namespace fences, whose authority remains ordinary lowering.
|
||||
this.checker.prefetchSymbolRoots(sourceFiles, true);
|
||||
// reachability is known. Its binding queries were batched through the
|
||||
// facade's panic fence before collection (prefetchProgramSymbols); keep
|
||||
// lookup free of lowering side effects: resolveValueSymbol also flushes
|
||||
// deferred diagnostics and applies merged-namespace fences, whose
|
||||
// authority remains ordinary lowering.
|
||||
// The facts each fixed-point site reads, by the symbols, nodes and
|
||||
// element keys they belong to (created with the site list below).
|
||||
let siteDependencies: SiteDependencies | null = null;
|
||||
@@ -8041,6 +8041,7 @@ export class Lowerer {
|
||||
if (this.remainder) {
|
||||
for (const fp of parts) this.checker.prefetchSourceFile(fp.sf);
|
||||
}
|
||||
this.prefetchProgramSymbols(parts);
|
||||
this.collectProgram(parts);
|
||||
this.speculativeTypeQueries(() => {
|
||||
extendAssertedRecordMembers(
|
||||
@@ -8500,6 +8501,7 @@ export class Lowerer {
|
||||
this.onEdge = (name) => {
|
||||
collectionEdges.add(name);
|
||||
};
|
||||
this.prefetchProgramSymbols(parts);
|
||||
this.collectProgram(parts);
|
||||
this.speculativeTypeQueries(() => {
|
||||
extendAssertedRecordMembers(
|
||||
@@ -12210,6 +12212,17 @@ export class Lowerer {
|
||||
return lowerClassExpressionInfo(this, expr);
|
||||
}
|
||||
|
||||
/** Batch-prefetches the symbols of every runtime identifier of the
|
||||
* program's files. Collection's early-binding scan and the runtime-
|
||||
* optional analysis look them up across every body, reached or not;
|
||||
* one batch answers both, instead of one request per identifier. */
|
||||
private prefetchProgramSymbols(parts: FileParts[]): void {
|
||||
this.checker.prefetchSymbolRoots(
|
||||
parts.map((fp) => fp.sf),
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
/** Depth of the whole-program analyses that query types across every
|
||||
* file before reachability is known (speculativeTypeQueries). */
|
||||
private speculativeTypeQueryDepth = 0;
|
||||
|
||||
Reference in New Issue
Block a user