Skip to content

Commit

Permalink
Reduce some megamorphism in nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckton committed Nov 1, 2022
1 parent 8efa88f commit 976cced
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -84,3 +84,4 @@ tests/cases/user/puppeteer/puppeteer
tests/cases/user/axios-src/axios-src
tests/cases/user/prettier/prettier
.eslintcache
isolate-*-v8.log
40 changes: 36 additions & 4 deletions src/compiler/factory/nodeFactory.ts
Expand Up @@ -1171,6 +1171,9 @@ namespace ts {
node.constraint = constraint;
node.default = defaultType;
node.transformFlags = TransformFlags.ContainsTypeScript;

// prevent megamorphism
node.expression = undefined;
return node;
}

Expand Down Expand Up @@ -1372,6 +1375,8 @@ namespace ts {
);
node.questionToken = questionToken;
node.transformFlags = TransformFlags.ContainsTypeScript;
node.jsDoc = undefined; // added by parser
node.jsDocCache = undefined; // added by utilities
return node;
}

Expand Down Expand Up @@ -1438,6 +1443,12 @@ namespace ts {

// The following properties are used only to report grammar errors
node.exclamationToken = undefined;

// prevent megamorphism
node.jsDoc = undefined; // added by parser
node.jsDocCache = undefined; // added by utilities
node.flowNode = undefined; // added by binder
node.endFlowNode = undefined; // added by binder
return node;
}

Expand Down Expand Up @@ -2363,6 +2374,11 @@ namespace ts {
node.properties = createNodeArray(properties);
node.multiLine = multiLine;
node.transformFlags |= propagateChildrenFlags(node.properties);

// prevent megamorphism
node.symbol = undefined!;
node.nextContainer = undefined;
(node as JSDocContainer).jsDocCache = undefined;
return node;
}

Expand Down Expand Up @@ -2732,6 +2748,14 @@ namespace ts {
if (modifiersToFlags(node.modifiers) & ModifierFlags.Async) {
node.transformFlags |= TransformFlags.ContainsES2017 | TransformFlags.ContainsLexicalThis;
}

// prevent megamorphism
node.flowNode = undefined;
node.endFlowNode = undefined;
node.jsDoc = undefined;
node.jsDocCache = undefined;
node.contextualType = undefined;
node.inferenceContext = undefined;
return node;
}

Expand Down Expand Up @@ -3729,6 +3753,12 @@ namespace ts {

// The following properties are used only to report grammar errors
node.illegalDecorators = undefined;

// prevent megamorphism
node.jsDoc = undefined; // added by parser
node.jsDocCache = undefined; // added by utilities
node.endFlowNode = undefined; // added by binder

return node;
}

Expand Down Expand Up @@ -5232,11 +5262,13 @@ namespace ts {
propagateChildFlags(node.name) |
propagateChildFlags(node.initializer);

node.jsDoc = undefined; // added by parser

// The following properties are used only to report grammar errors
node.illegalDecorators = undefined;
node.modifiers = undefined;
node.questionToken = undefined;
node.exclamationToken = undefined;
node.illegalDecorators = undefined; // added by parser
node.modifiers = undefined; // added by parser
node.questionToken = undefined; // added by parser
node.exclamationToken = undefined; // added by parser
return node;
}

Expand Down

0 comments on commit 976cced

Please sign in to comment.