Parent: #496 Related: #493, #465, #481
Problem
Every ordinary function/method calls ast.sourceMayUseArguments after parsing. That helper scans the complete captured function source once for arguments and again for eval. In a nested function chain, every outer source range contains every inner range, so attacker-controlled nesting causes quadratic post-parse source work. The text scan also treats comments, strings, identifier substrings, and nested ordinary functions as uses, needlessly materializing the arguments exotic object and restricting bytecode/JIT eligibility.
Scope
- Freeze parser-only nested-function growth rows with exact depth, source range, AST topology,
uses_argumentsflags, and checksum validation. - Add anti-specialization and semantic controls for comments/strings/substrings, an innermost ordinary-function use, an arrow-inherited use, methods, generators/async functions, and conservative direct-eval detection.
- Track
arguments/evalidentifier references while parsing the current non-arrow function scope. Nested ordinary functions/methods start fresh state; arrows inherit their nearest ordinary function state. - Remove complete-source rescans without changing retained
Function.prototype.toStringsource bytes or arguments-object semantics.
No-workaround rules
- No globally forcing
uses_argumentstrue or false, skipping arguments materialization, weakening direct-eval conservatism, omitting retained source, benchmark/source recognition, hidden preprocessing, or reduced nesting at larger rows. - Do not touch stacks, queues, jobs, Promise/microtask, or Worker lifecycle code.
Acceptance
- Benchmark source, base/variant/control identities, depths, checksums, warmup, jobs, and timed boundary land before the runtime change.
- Function argument-use derivation adds no post-parse source or AST pass and performs O(1) work per relevant identifier while preserving nested ordinary/arrow scope rules.
- Comments, strings, identifier substrings, and nested ordinary functions do not force an outer arguments object; real
argumentsreferences and conservativeevalidentifiers do. - Function declarations/expressions, methods/accessors, generators, async functions, arrow defaults/bodies, direct eval, and
Function.prototype.toStringretain exact semantics. - OOM/fault behavior remains atomic and no per-function tracking allocation is introduced.
- Focused frontend Debug/TSan, full units, forced tree-walker/required-bytecode witnesses, and exact arguments/eval/function test262 pass without regressions.
- Seven-pair exact-parent evidence publishes wall, CPU, allocations/bytes, peak RSS, instructions/cycles/energy availability, thermal state, and dispersion with no discarded samples.
Security boundary
Source length, nesting depth, token spelling, and comment/string contents are attacker-controlled. The fix must remove repeated range scans without misclassifying a real dynamic arguments access or allowing direct eval to observe a missing arguments object.