From 6874d6514dea4679c39185790764bbf990777567 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 3 Nov 2020 12:32:56 -0800 Subject: [PATCH] Cache flow label results the same way as flow loop results --- src/compiler/checker.ts | 27 +- ...rolFlowManyCallExpressionStatementsPerf.js | 125 +++++ ...owManyCallExpressionStatementsPerf.symbols | 292 +++++++++++ ...FlowManyCallExpressionStatementsPerf.types | 461 ++++++++++++++++++ ...rolFlowManyCallExpressionStatementsPerf.ts | 62 +++ 5 files changed, 964 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.js create mode 100644 tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.symbols create mode 100644 tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.types create mode 100644 tests/cases/compiler/controlFlowManyCallExpressionStatementsPerf.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 07996e0bcdd41..b48e84ede5411 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -940,7 +940,7 @@ namespace ts { const mergedSymbols: Symbol[] = []; const symbolLinks: SymbolLinks[] = []; const nodeLinks: NodeLinks[] = []; - const flowLoopCaches: ESMap[] = []; + const flowLabelCaches: ESMap[] = []; const flowLoopNodes: FlowNode[] = []; const flowLoopKeys: string[] = []; const flowLoopTypes: Type[][] = []; @@ -21656,6 +21656,7 @@ namespace ts { let key: string | undefined; let isKeySet = false; let flowDepth = 0; + let cacheableBranches = true; if (flowAnalysisDisabled) { return errorType; } @@ -21747,9 +21748,14 @@ namespace ts { else if (flags & FlowFlags.ReduceLabel) { const target = (flow).target; const saveAntecedents = target.antecedents; + // Modifying the antecedents of a node means we lose our ability to use the cross-invocation branch cache + // (since that may have follow-on effects on analysis returned by other nodes if the results get cached) + const oldCacheableBranches = cacheableBranches; + cacheableBranches = false; target.antecedents = (flow).antecedents; type = getTypeAtFlowNode((flow).antecedent); target.antecedents = saveAntecedents; + cacheableBranches = oldCacheableBranches; } else if (flags & FlowFlags.Start) { // Check if we should continue with the control flow of the containing function. @@ -21955,6 +21961,17 @@ namespace ts { } function getTypeAtFlowBranchLabel(flow: FlowLabel): FlowType { + const id = getFlowNodeId(flow); + const cache = flowLabelCaches[id] || (flowLabelCaches[id] = new Map()); + const key = getOrSetCacheKey(); + if (!key) { + // No cache key is generated when binding patterns are in unnarrowable situations + return declaredType; + } + const cached = cacheableBranches && cache.get(key); + if (cached) { + return cached; + } const antecedentTypes: Type[] = []; let subtypeReduction = false; let seenIncomplete = false; @@ -22004,14 +22021,18 @@ namespace ts { } } } - return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? UnionReduction.Subtype : UnionReduction.Literal), seenIncomplete); + const result = createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? UnionReduction.Subtype : UnionReduction.Literal), seenIncomplete); + if (!seenIncomplete && cacheableBranches) { + cache.set(key, result as Type); + } + return result; } function getTypeAtFlowLoopLabel(flow: FlowLabel): FlowType { // If we have previously computed the control flow type for the reference at // this flow loop junction, return the cached type. const id = getFlowNodeId(flow); - const cache = flowLoopCaches[id] || (flowLoopCaches[id] = new Map()); + const cache = flowLabelCaches[id] || (flowLabelCaches[id] = new Map()); const key = getOrSetCacheKey(); if (!key) { // No cache key is generated when binding patterns are in unnarrowable situations diff --git a/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.js b/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.js new file mode 100644 index 0000000000000..67d874126ea07 --- /dev/null +++ b/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.js @@ -0,0 +1,125 @@ +//// [controlFlowManyCallExpressionStatementsPerf.ts] +function test(x: boolean): boolean { return x; } + +let state = true; + +if (state) { + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); +} + +//// [controlFlowManyCallExpressionStatementsPerf.js] +function test(x) { return x; } +var state = true; +if (state) { + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); +} diff --git a/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.symbols b/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.symbols new file mode 100644 index 0000000000000..913da921c38dc --- /dev/null +++ b/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.symbols @@ -0,0 +1,292 @@ +=== tests/cases/compiler/controlFlowManyCallExpressionStatementsPerf.ts === +function test(x: boolean): boolean { return x; } +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>x : Symbol(x, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 14)) +>x : Symbol(x, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 14)) + +let state = true; +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + +if (state) { +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +} diff --git a/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.types b/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.types new file mode 100644 index 0000000000000..f6241fb55e0d4 --- /dev/null +++ b/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.types @@ -0,0 +1,461 @@ +=== tests/cases/compiler/controlFlowManyCallExpressionStatementsPerf.ts === +function test(x: boolean): boolean { return x; } +>test : (x: boolean) => boolean +>x : boolean +>x : boolean + +let state = true; +>state : boolean +>true : true + +if (state) { +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true +} diff --git a/tests/cases/compiler/controlFlowManyCallExpressionStatementsPerf.ts b/tests/cases/compiler/controlFlowManyCallExpressionStatementsPerf.ts new file mode 100644 index 0000000000000..00805a485f618 --- /dev/null +++ b/tests/cases/compiler/controlFlowManyCallExpressionStatementsPerf.ts @@ -0,0 +1,62 @@ +function test(x: boolean): boolean { return x; } + +let state = true; + +if (state) { + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); +} \ No newline at end of file