mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 19:44:26 +08:00
perf(javascript): share one lexical index between static and semantic analysis (#14148)
* perf(javascript): share one lexical index between static and semantic analysis The static and semantic phases each built a private semantic state for the same parsed program, so definitions, ambient writes and member-mutation facts were derived twice per file. Sharing the state requires separating what it holds. Index facts are shared. Memoized query results are declared through one owner so a new consumer or index step starts without them. Observations (resource limits and returned-reference widenings) are recorded per derivation: index steps record into the index's own log and each consumer starts from that log, so the semantic phase reports exactly what a private index would have. The worker builds one index per parsed file and the semantic phase continues from it when its resolution mode matches the static phase. Refs #14147 * fix(javascript): let a shared lexical index continue only one semantic phase The semantic phase appends its module links and callable facts to the state it continues from, so a second phase from the same index reported each import link twice. Admission is now consumed by the first phase and a second is rejected like any other index that does not match.
This commit is contained in:
@@ -39,6 +39,7 @@ import {
|
||||
semanticDirectEvalRecorded,
|
||||
semanticGlobalCodeSites,
|
||||
} from "./javascriptSemanticEffectRecord.js";
|
||||
import { semanticConsumerMemo } from "./javascriptSemanticConsumer.js";
|
||||
|
||||
// Match the complete Rolldown runtime operations, including its live getters.
|
||||
// Names and formatting are irrelevant; lexical roles, operators and keys are not.
|
||||
@@ -999,13 +1000,10 @@ const controlBodyOperation = (node: t.Node): t.Node => {
|
||||
return node;
|
||||
};
|
||||
|
||||
const ambientWriteInterops = new WeakMap<
|
||||
JavaScriptSemanticAnalysisState,
|
||||
{
|
||||
readonly generation: number;
|
||||
readonly interop: ReturnType<typeof createSemanticModuleInterop>;
|
||||
}
|
||||
>();
|
||||
const ambientWriteInterops = semanticConsumerMemo<{
|
||||
readonly generation: number;
|
||||
readonly interop: ReturnType<typeof createSemanticModuleInterop>;
|
||||
}>();
|
||||
|
||||
/**
|
||||
* Module interop that retains every recorded ambient global write, so an
|
||||
|
||||
Reference in New Issue
Block a user