perf(codegen): const-len Uint8Array inline + skip unused scalar literal inits (salvage andrewtdiz #5341/#5367)#5401
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds two new HIR-level escape analysis collectors that track which array indices and object-literal fields are actually read for non-escaping locals. These facts flow through ChangesEscape Analysis Precision and Scalar Replacement Elision
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/perry-codegen/tests/native_proof_buffer_views.rs`:
- Around line 1623-1629: The assertions checking for `@js_uint8array_set` and
`@js_uint8array_get` helper calls are matching full call signatures including
return types (call void and call i32), which makes them fragile if those
signatures change. Instead of matching the complete call signatures, update both
assertion string patterns to match only the helper symbol names themselves.
Replace the full patterns like "call void `@js_uint8array_set`" and "call i32
`@js_uint8array_get`" with just the symbol names "`@js_uint8array_set`" and
"`@js_uint8array_get`" so the assertions remain robust to future signature
changes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: cf66badf-1fa1-467d-816a-ceb36616e0fb
📒 Files selected for processing (11)
crates/perry-codegen/src/codegen/closure.rscrates/perry-codegen/src/codegen/entry.rscrates/perry-codegen/src/codegen/function.rscrates/perry-codegen/src/codegen/method.rscrates/perry-codegen/src/collectors/escape_arrays.rscrates/perry-codegen/src/collectors/escape_objects.rscrates/perry-codegen/src/collectors/hir_facts.rscrates/perry-codegen/src/expr/mod.rscrates/perry-codegen/src/stmt/let_stmt.rscrates/perry-codegen/tests/native_proof_buffer_views.rscrates/perry-codegen/tests/typed_shape_descriptors.rs
| assert!( | ||
| !ir.contains("call void @js_uint8array_set"), | ||
| "inline Uint8Array set should not call the runtime helper:\n{ir}" | ||
| ); | ||
| assert!( | ||
| !ir.contains("call i32 @js_uint8array_get"), | ||
| "inline Uint8Array get should not call the runtime helper:\n{ir}" |
There was a problem hiding this comment.
Harden helper-call assertions against signature drift.
Line 1624 and Line 1628 assert full call signatures; if runtime helper signatures change, fallback helper calls could slip through undetected. Match the helper symbol names instead.
Suggested patch
assert!(
- !ir.contains("call void `@js_uint8array_set`"),
+ !ir.contains("`@js_uint8array_set`("),
"inline Uint8Array set should not call the runtime helper:\n{ir}"
);
assert!(
- !ir.contains("call i32 `@js_uint8array_get`"),
+ !ir.contains("`@js_uint8array_get`("),
"inline Uint8Array get should not call the runtime helper:\n{ir}"
);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| assert!( | |
| !ir.contains("call void @js_uint8array_set"), | |
| "inline Uint8Array set should not call the runtime helper:\n{ir}" | |
| ); | |
| assert!( | |
| !ir.contains("call i32 @js_uint8array_get"), | |
| "inline Uint8Array get should not call the runtime helper:\n{ir}" | |
| assert!( | |
| !ir.contains("`@js_uint8array_set`("), | |
| "inline Uint8Array set should not call the runtime helper:\n{ir}" | |
| ); | |
| assert!( | |
| !ir.contains("`@js_uint8array_get`("), | |
| "inline Uint8Array get should not call the runtime helper:\n{ir}" | |
| ); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/perry-codegen/tests/native_proof_buffer_views.rs` around lines 1623 -
1629, The assertions checking for `@js_uint8array_set` and `@js_uint8array_get`
helper calls are matching full call signatures including return types (call void
and call i32), which makes them fragile if those signatures change. Instead of
matching the complete call signatures, update both assertion string patterns to
match only the helper symbol names themselves. Replace the full patterns like
"call void `@js_uint8array_set`" and "call i32 `@js_uint8array_get`" with just the
symbol names "`@js_uint8array_set`" and "`@js_uint8array_get`" so the assertions
remain robust to future signature changes.
Salvages the two cleanly-rebasable commits from andrewtdiz's perf-optimization stack (originally #5341 and #5367) onto current
main, with original authorship preserved:Why just these two
The original 41-PR stack (#5302→#5380) went stale during review: #5291 (representation-aware type lowering) and the #5334 codegen levers merged to
mainand implement overlapping work. The stack's numeric-array base (#5302) is now superseded by #5291, andmainhas advanced ~25 commits into the same files.Attempting to rebase/cherry-pick the stack showed the commits are a tightly-coupled series that does not extract cleanly:
These two commits are the only ones that rebased onto current
mainand pass the fullperry-codegen+perry-runtimetest suites locally. The rest needs an integrated rebase by the original author against currentmain.🤖 Generated with Claude Code
Summary by CodeRabbit
Uint8Arraylength scenarios.