Parents: #465, #493, #496
Related: #616
Problem
Repeated loop-body admission still multiplies lexical declaration count by body AST size. loopBodyCapturesLexical, repeatedBodyCapturesSupported, predeclareRepeatedBodyNode, emitDeclareRepeatedBodyNode, and repeatedBodyListNeedsEnvironment each answer per-binding capture questions through another exhaustive nameRefInClosure(body, name, false) walk. A wide block-scoped body with a large closure-free tail therefore performs declaration-count × body-size compiler-classification work before bytecode emission.
This is distinct from #616, which owns lexical names in the for/for-in/of head. This child owns block-scoped declarations inside bodies repeated by while, do-while, for, and for-in/of, including the shared CaseBlock handling for switches nested in such bodies.
Scope
- Freeze production parse + plain-function admission/compile growth witnesses before changing the classifier.
- Collect repeated-body lexical binding names once across the exact existing block/if/try/switch/labeled boundaries while leaving nested loops/functions to their own roots.
- Traverse the repeated-body AST once to classify exact names referenced from nested closures or deferred class bodies.
- Reuse one compile-owned capture result for support checks, lexical predeclaration, Environment Record declaration, and environment-need decisions.
- Preserve conservative shadowing, catch/destructuring behavior, nested-loop ownership, bytecode fallback, structural checksum, and allocation accounting.
- Keep zero- and one-binding common cases allocation-minimal.
No-workaround rules
- No syntax refusal, heuristic cutoff, skipped body region, runtime TDZ broadening, tree-walker fallback presented as optimization, source rewriting, or weakened per-iteration Environment semantics.
- No process-global or cross-compilation mutable cache.
- A new AST node kind must not silently bypass capture classification.
Acceptance
Parents: #465, #493, #496
Related: #616
Problem
Repeated loop-body admission still multiplies lexical declaration count by body AST size.
loopBodyCapturesLexical,repeatedBodyCapturesSupported,predeclareRepeatedBodyNode,emitDeclareRepeatedBodyNode, andrepeatedBodyListNeedsEnvironmenteach answer per-binding capture questions through another exhaustivenameRefInClosure(body, name, false)walk. A wide block-scoped body with a large closure-free tail therefore performs declaration-count × body-size compiler-classification work before bytecode emission.This is distinct from #616, which owns lexical names in the
for/for-in/ofhead. This child owns block-scoped declarations inside bodies repeated bywhile,do-while,for, andfor-in/of, including the shared CaseBlock handling for switches nested in such bodies.Scope
No-workaround rules
Acceptance