perf(codegen): inline trusted boxed capture access; reject legacy numerics in strict eval - #8705
Conversation
…feedback `typed_feedback_guards_direct_class_method_specialization` asserted `call double @js_class_field_add`, which #8653 deliberately stopped emitting for this shape when it restored the guarded field-init fast path (the #8648 3.11x `shapes` regression). Red on main since then, and invisible to per-PR CI because codegen integration suites only run when the diff names them. Assert the guarded fast path instead, and that the unconditional helper is NOT called.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (12)
📝 WalkthroughWalkthroughThe PR adds trusted boxed-capture pointer access across closure code generation, adds strict direct-eval validation for legacy numeric literals, updates related changelog entries, and changes a typed-feedback test to expect guarded class-field initialization. ChangesTrusted boxed-capture access
Strict direct-eval numeric validation
Typed-feedback expectation
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant TrustedClosure as Trusted closure codegen
participant FnCtx
participant CaptureBody as Capture body lowering
TrustedClosure->>TrustedClosure: Load boxed-capture pointers from closure storage
TrustedClosure->>FnCtx: Pass trusted_box_capture_ptrs
CaptureBody->>FnCtx: Read cached capture pointer
CaptureBody->>CaptureBody: Load or store capture cell
sequenceDiagram
participant ConstFoldDirectEval
participant StrictEvalDiagnostic
participant StrictParser
ConstFoldDirectEval->>StrictEvalDiagnostic: Check constant eval source
StrictEvalDiagnostic->>StrictParser: Reparse source with use strict
StrictParser-->>StrictEvalDiagnostic: Return legacy numeric diagnostic
StrictEvalDiagnostic-->>ConstFoldDirectEval: Report diagnostic result
ConstFoldDirectEval->>ConstFoldDirectEval: Synthesize runtime SyntaxError
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Lands #8702 and #8698, plus a stale-test fix.
#8702 — inline trusted boxed capture access
Loads compiler-validated raw box capture pointers once at entry to private exact-arrow clones and reads/writes the box cell directly, keeping public and indirect closure bodies on the checked runtime accessors.
I verified the safety argument rather than taking it on trust, since caching a raw heap pointer across a collection is precisely how this codebase has been bitten before. The claim holds: box cells are malloc-side, not GC-heap —
closure/box_captures.rsopens with "Lifetime bridge between GC closures and malloc-side async box cells" — so they genuinely do not move under evacuation. The crate already carriesclosure_box_captures_owner_movedto rekey when the closure relocates, which matches the PR's "retains each non-moving box cell for the invocation even if the closure relocates". TDZ keeps itsTAG_TDZtest plus the trusted getter on the cold path, and direct stores keep the child-shading barrier.#8698 — reject legacy numerics in strict eval
Re-lexes constant direct-eval bodies under inherited strict mode and surfaces the deferred legacy decimal/octal diagnostics as
SyntaxError, leaving modern octal literals and numeric-looking text in comments/strings valid. The PR carried no changelog fragment and noskip-changeloglabel, so I added one rather than block on it.Stale test fixed — red on
mainsince #8653typed_feedback_guards_direct_class_method_specializationassertedcall double @js_class_field_add. #8653 deliberately stopped emitting that for this shape when it restored the guarded field-init fast path and reverted the #8648 3.11×shapesregression — so the test has been red since, and invisible to per-PR CI because codegen integration suites only run when the diff names them. #8702's author flagged it as pre-existing; I confirmed that independently on cleanmainbefore touching it.The assertion now pins the actual emitted shape rather than the old helper:
js_class_field_set_fallbackon the slow arm is what preserves DefineField semantics (an inherited setter must not run), so the negative assertion is safe.Validation
lint-job checkers passperry-runtime --lib(RUST_TEST_THREADS=1): 2655 passed, 0 failedperry-codegen --lib: 1214 passed, 0 failedperry-codegen --tests(all 28 integration suites): 0 failuresperry-hir --lib: 331 passed, 0 failedAn intermediate run showed 2 GC failures in
gc::tests::handle_bound_method_name::*. They are not from this stack: I reproduced them on cleanmainand isolated the cause to forcingCARGO_INCREMENTAL=0onto theperry-devprofile, which declaresincremental = true— same commit gives 2655/0 with incremental on and 2 failures with it off. CI's actual invocation (CARGO_INCREMENTAL=0, default test profile) gives 2655/0, so CI is unaffected. Worth knowing those two tests compare literal addresses and are therefore build-config sensitive.No version bump.
Summary by CodeRabbit
Bug Fixes
evalnow correctly raisesSyntaxErrorfor legacy decimal and octal numeric literals.Performance