fix: preserve loop lexical TDZ and retained closure cells - #10235
proggeramlug wants to merge 1 commit into
Conversation
cc6f53f to
c00ca31
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (13)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe change allocates fresh TDZ cells for captured lexical bindings at each block entry. It preserves shared ChangesCaptured lexical TDZ handling
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~45 minutes Change: Bug fix · Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant TypeScriptSource
participant HIRLowering
participant Codegen
participant PerryBinary
TypeScriptSource->>HIRLowering: lower loop and nested lexical bindings
HIRLowering->>Codegen: emit PreallocateTdzBoxes
Codegen->>PerryBinary: allocate fresh TDZ cells
PerryBinary->>PerryBinary: execute loop entries and closures
Possibly related PRs
Merge Risk: ⚪ Minimal · up to The lexical-binding change preserves per-entry TDZ cells while retaining shared var behavior, with regression coverage across lowering, code generation, runtime modes, and optimization levels. It is ready to merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 42.31% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 12 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Forward-captured block
let/constbindings now get a fresh TDZ cell on each block entry. The reported loop printstdz,undefined,0,0,tdz,undefined,1,1, matching Node 26.5.1, and retained callbacks keep their original iteration's values.HIR previously included nested lexical bindings in function-entry preallocation. Allocate those cells at their own block entry instead, including one shared switch-case environment after discriminant evaluation. Keep function-scoped
varcells shared and allocate TDZ cells before hoisted block-function closures. Codegen also emits the allocation in every copy of a TDZ statement while reusing its stack slot; otherwise the normalfinallypath could miss an allocation emitted only on the exception path.Fixes #10051.
Validation on macOS arm64:
perry-devcompiler, runtime-static and stdlib-static build, withPERRY_RUNTIME_DIRpinned to its archives. The synchronous fixture links the native runtime without application dependencies.finallyallocation before the codegen fix; the shared-cell control stayed green.PERRY_RS4GC=0 PERRY_SHADOW_STACK=1 PERRY_INLINE_SHADOW_SLOT=0 PERRY_FULL_OUTLINE_IC=1. Each compilation disables caching and auto-optimization; each execution has a 15-second timeout.cargo test --profile perry-dev -p perry --test loop_lexical_tdzpassed, exercising the committed integration entry point and all 12 native comparisons.scripts/pre-tag-check.sh --quick: all checks passed except the existing public benchmark evidence-freshness failure. Its artifact, validators and every source/harness fingerprint input are unchanged from based8bfa28a38. Node pin consistency andgit diff --checkpassed.No version bump.
Summary by CodeRabbit
Bug Fixes
let/constbehavior in loops, switches, andfinallyblocks.vardeclarations.Tests
CI update: the current head is red on the same unchanged areas seen on the earlier independent PRs: the
perex_owner.rsraw-TLS policy check, public benchmark freshness, two unused WebAssembly helpers, generated API-doc drift, and Linuxnative_stack::tests::stack_top_respects_custom_thread_stack_sizes(3,765 runtime tests pass, one fails, four are ignored). These files are outside this diff. This comparison identifies shared failures; it is not an exact-base Linux A/B rerun. The scoped native loop-TDZ regression (133.83 seconds) and both HIR regressions have now passed in Linux CI. The shared failures above still prevent an overall green gate.