Compare commits

...

15 commits

Author SHA1 Message Date
Daniel Rosenwasser b7d31bcd69 Switch to sparse array for deferred nodes. 2021-11-09 02:23:49 +00:00
Daniel Rosenwasser e23710aae5 Redo checker changes, see if these are wins. 2021-11-09 01:34:49 +00:00
Daniel Rosenwasser d42b2b708d Try just the fetching change in checker. 2021-11-09 01:09:57 +00:00
Daniel Rosenwasser 083db3a677 Fix ID usage in services. 2021-11-09 00:58:52 +00:00
Daniel Rosenwasser cc3836911f Switch to Set of Symbols in extractSymbol. 2021-11-09 00:35:10 +00:00
Daniel Rosenwasser ced38f315e Same trick for symbol.id, and always set it to 0. 2021-11-09 00:34:36 +00:00
Daniel Rosenwasser f9d2db3540 Restore id check to harness. 2021-11-08 07:12:41 +00:00
Daniel Rosenwasser 6a7d2c0a3e Restore redirect accessors. 2021-11-08 07:10:36 +00:00
Daniel Rosenwasser 41faf73bfc Switch back to putting Node IDs on Nodes. 2021-11-08 07:09:06 +00:00
Daniel Rosenwasser 5479adffc3 node -> originalNode 2021-11-06 10:49:42 +00:00
Daniel Rosenwasser 6f76b625a1 Remove uses of getNodeId in compiler outside of checker. 2021-11-06 10:41:57 +00:00
Daniel Rosenwasser ca13132e84 Remove getOriginalNodeId. 2021-11-06 10:39:03 +00:00
Daniel Rosenwasser e64dbabab8 More removals. 2021-11-06 09:33:40 +00:00
Daniel Rosenwasser 044de3ec63 More removal of getNodeId uses. 2021-11-06 07:59:41 +00:00
Daniel Rosenwasser e83d14434d Use getNodeId() less, specifically for NodeLinks. 2021-10-29 22:49:47 +00:00
5 changed files with 22 additions and 21 deletions

View file

@ -278,20 +278,22 @@ namespace ts {
} }
export function getNodeId(node: Node): number { export function getNodeId(node: Node): number {
if (!node.id) { let id = node.id;
node.id = nextNodeId; if (!id) {
node.id = id = nextNodeId;
nextNodeId++; nextNodeId++;
} }
return node.id; return id;
} }
export function getSymbolId(symbol: Symbol): SymbolId { export function getSymbolId(symbol: Symbol): SymbolId {
if (!symbol.id) { let id = symbol.id;
symbol.id = nextSymbolId; if (!id) {
symbol.id = id = nextSymbolId;
nextSymbolId++; nextSymbolId++;
} }
return symbol.id; return id;
} }
export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean) { export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean) {
@ -3885,10 +3887,9 @@ namespace ts {
function getAlternativeContainingModules(symbol: Symbol, enclosingDeclaration: Node): Symbol[] { function getAlternativeContainingModules(symbol: Symbol, enclosingDeclaration: Node): Symbol[] {
const containingFile = getSourceFileOfNode(enclosingDeclaration); const containingFile = getSourceFileOfNode(enclosingDeclaration);
const id = getNodeId(containingFile);
const links = getSymbolLinks(symbol); const links = getSymbolLinks(symbol);
let results: Symbol[] | undefined; let results: Symbol[] | undefined;
if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(id))) { if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(containingFile))) {
return results; return results;
} }
if (containingFile && containingFile.imports) { if (containingFile && containingFile.imports) {
@ -3902,7 +3903,7 @@ namespace ts {
results = append(results, resolvedModule); results = append(results, resolvedModule);
} }
if (length(results)) { if (length(results)) {
(links.extendedContainersByFile || (links.extendedContainersByFile = new Map())).set(id, results!); (links.extendedContainersByFile ||= new Map()).set(containingFile, results!);
return results!; return results!;
} }
} }
@ -33794,7 +33795,7 @@ namespace ts {
const type = checkExpression(node); const type = checkExpression(node);
// If control flow analysis was required to determine the type, it is worth caching. // If control flow analysis was required to determine the type, it is worth caching.
if (flowInvocationCount !== startInvocationCount) { if (flowInvocationCount !== startInvocationCount) {
const cache = flowTypeCache || (flowTypeCache = []); const cache = (flowTypeCache ||= []);
cache[getNodeId(node)] = type; cache[getNodeId(node)] = type;
setNodeFlags(node, node.flags | NodeFlags.TypeCached); setNodeFlags(node, node.flags | NodeFlags.TypeCached);
} }
@ -40316,9 +40317,8 @@ namespace ts {
const enclosingFile = getSourceFileOfNode(node); const enclosingFile = getSourceFileOfNode(node);
const links = getNodeLinks(enclosingFile); const links = getNodeLinks(enclosingFile);
if (!(links.flags & NodeCheckFlags.TypeChecked)) { if (!(links.flags & NodeCheckFlags.TypeChecked)) {
links.deferredNodes = links.deferredNodes || new Map(); links.deferredNodes ||= [];
const id = getNodeId(node); links.deferredNodes[getNodeId(node)] = node;
links.deferredNodes.set(id, node);
} }
} }

View file

@ -4900,7 +4900,7 @@ namespace ts {
members?: SymbolTable; // Class, interface or object literal instance members members?: SymbolTable; // Class, interface or object literal instance members
exports?: SymbolTable; // Module exports exports?: SymbolTable; // Module exports
globalExports?: SymbolTable; // Conditional global UMD exports globalExports?: SymbolTable; // Conditional global UMD exports
/* @internal */ id?: SymbolId; // Unique id (used to look up SymbolLinks) /* @internal */ id: SymbolId; // Unique id (used to look up SymbolLinks)
/* @internal */ mergeId?: number; // Merge id (used to look up merged symbol) /* @internal */ mergeId?: number; // Merge id (used to look up merged symbol)
/* @internal */ parent?: Symbol; // Parent symbol /* @internal */ parent?: Symbol; // Parent symbol
/* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol /* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol
@ -4946,7 +4946,7 @@ namespace ts {
lateSymbol?: Symbol; // Late-bound symbol for a computed property lateSymbol?: Symbol; // Late-bound symbol for a computed property
specifierCache?: ESMap<string, string>; // For symbols corresponding to external modules, a cache of incoming path -> module specifier name mappings specifierCache?: ESMap<string, string>; // For symbols corresponding to external modules, a cache of incoming path -> module specifier name mappings
extendedContainers?: Symbol[]; // Containers (other than the parent) which this symbol is aliased in extendedContainers?: Symbol[]; // Containers (other than the parent) which this symbol is aliased in
extendedContainersByFile?: ESMap<NodeId, Symbol[]>; // Containers (other than the parent) which this symbol is aliased in extendedContainersByFile?: ESMap<Node, Symbol[]>; // Containers (other than the parent) which this symbol is aliased in
variances?: VarianceFlags[]; // Alias symbol type argument variance cache variances?: VarianceFlags[]; // Alias symbol type argument variance cache
deferralConstituents?: Type[]; // Calculated list of constituents for a deferred type deferralConstituents?: Type[]; // Calculated list of constituents for a deferred type
deferralParent?: Type; // Source union/intersection of a deferred type deferralParent?: Type; // Source union/intersection of a deferred type
@ -5106,7 +5106,7 @@ namespace ts {
jsxNamespace?: Symbol | false; // Resolved jsx namespace symbol for this node jsxNamespace?: Symbol | false; // Resolved jsx namespace symbol for this node
jsxImplicitImportContainer?: Symbol | false; // Resolved module symbol the implicit jsx import of this file should refer to jsxImplicitImportContainer?: Symbol | false; // Resolved module symbol the implicit jsx import of this file should refer to
contextFreeType?: Type; // Cached context-free type used by the first pass of inference; used when a function's return is partially contextually sensitive contextFreeType?: Type; // Cached context-free type used by the first pass of inference; used when a function's return is partially contextually sensitive
deferredNodes?: ESMap<NodeId, Node>; // Set of nodes whose checking has been deferred deferredNodes?: Node[]; // Sparse array of nodes whose checking has been deferred
capturedBlockScopeBindings?: Symbol[]; // Block-scoped bindings captured beneath this part of an IterationStatement capturedBlockScopeBindings?: Symbol[]; // Block-scoped bindings captured beneath this part of an IterationStatement
outerTypeParameters?: TypeParameter[]; // Outer type parameters of anonymous object type outerTypeParameters?: TypeParameter[]; // Outer type parameters of anonymous object type
isExhaustive?: boolean; // Is node an exhaustive switch statement isExhaustive?: boolean; // Is node an exhaustive switch statement

View file

@ -5798,7 +5798,7 @@ namespace ts {
this.escapedName = name; this.escapedName = name;
this.declarations = undefined; this.declarations = undefined;
this.valueDeclaration = undefined; this.valueDeclaration = undefined;
this.id = undefined; this.id = 0;
this.mergeId = undefined; this.mergeId = undefined;
this.parent = undefined; this.parent = undefined;
} }

View file

@ -1597,7 +1597,7 @@ namespace ts.refactor.extractSymbol {
const functionErrorsPerScope: Diagnostic[][] = []; const functionErrorsPerScope: Diagnostic[][] = [];
const constantErrorsPerScope: Diagnostic[][] = []; const constantErrorsPerScope: Diagnostic[][] = [];
const visibleDeclarationsInExtractedRange: NamedDeclaration[] = []; const visibleDeclarationsInExtractedRange: NamedDeclaration[] = [];
const exposedVariableSymbolSet = new Map<string, true>(); // Key is symbol ID const exposedVariableSymbolSet = new Set<Symbol>(); // Key is symbol ID
const exposedVariableDeclarations: VariableDeclaration[] = []; const exposedVariableDeclarations: VariableDeclaration[] = [];
let firstExposedNonVariableDeclaration: NamedDeclaration | undefined; let firstExposedNonVariableDeclaration: NamedDeclaration | undefined;
@ -1903,10 +1903,10 @@ namespace ts.refactor.extractSymbol {
const decl = find(visibleDeclarationsInExtractedRange, d => d.symbol === sym); const decl = find(visibleDeclarationsInExtractedRange, d => d.symbol === sym);
if (decl) { if (decl) {
if (isVariableDeclaration(decl)) { if (isVariableDeclaration(decl)) {
const idString = decl.symbol.id!.toString(); const declSymbol = decl.symbol;
if (!exposedVariableSymbolSet.has(idString)) { if (!exposedVariableSymbolSet.has(declSymbol)) {
exposedVariableDeclarations.push(decl); exposedVariableDeclarations.push(decl);
exposedVariableSymbolSet.set(idString, true); exposedVariableSymbolSet.add(declSymbol);
} }
} }
else { else {

View file

@ -287,6 +287,7 @@ namespace ts {
class SymbolObject implements Symbol { class SymbolObject implements Symbol {
flags: SymbolFlags; flags: SymbolFlags;
id = 0;
escapedName: __String; escapedName: __String;
declarations!: Declaration[]; declarations!: Declaration[];
valueDeclaration!: Declaration; valueDeclaration!: Declaration;