perf(codegen): #6812 — widen whole-loop write-clone eligibility (Mul RHS, let alias, while form, dynamic bounds)#6830
Merged
proggeramlug merged 4 commits intoJul 25, 2026
Conversation
added 3 commits
July 25, 2026 09:31
…et-alias, inner while form
…-offset matcher must stay Add|Sub The blind text replace widened packed_f64_range_loop_index_offset's guard instead of match_object_array_write_number's — which would have treated an `i * c` index as offset `c` (a wrong-index miscompile) in the packed range-loop family. Reverted there; Mul now admitted where intended, with the endpoint-product range analysis and fmul emission it was built for.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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 |
8 tasks
…the versioned write clone `for (let i = 0; i < arr.length; i++)` over the same array the loop writes qualifies: the guard receives a u32::MAX sentinel and resolves the scan length from the validated array's header (rejecting >16M), and the emitter loads the length register in a new guard-ok fast.entry block — the fast nest can never outrun the proven prefix. Length is loop-invariant by construction (the matched body admits only element-field stores). The 16M cap serves as the finite-range ceiling.
proggeramlug
added a commit
that referenced
this pull request
Jul 25, 2026
…iterals (#6829) * docs: #6812 object-write coverage matrix, measured triage pass * perf(hir): #6812 — fold straight-line builder sequences into object literals (WIP) * docs(changelog): changeset + measured matrix for builder fold * style: cargo fmt * perf(codegen): #6812 — widen whole-loop write-clone eligibility (Mul RHS, let alias, while form, dynamic bounds) (#6830) * perf(codegen): #6812 — widen whole-loop clone eligibility: Mul RHS, let-alias, inner while form * fix(codegen): #6812 — Mul widening landed on the wrong matcher; index-offset matcher must stay Add|Sub The blind text replace widened packed_f64_range_loop_index_offset's guard instead of match_object_array_write_number's — which would have treated an `i * c` index as offset `c` (a wrong-index miscompile) in the packed range-loop family. Reverted there; Mul now admitted where intended, with the endpoint-product range analysis and fmul emission it was built for. * docs(changelog): changeset for clone-eligibility widening * perf(codegen,runtime): #6812 — dynamic array-length inner bounds for the versioned write clone `for (let i = 0; i < arr.length; i++)` over the same array the loop writes qualifies: the guard receives a u32::MAX sentinel and resolves the scan length from the validated array's header (rejecting >16M), and the emitter loads the length register in a new guard-ok fast.entry block — the fast nest can never outrun the proven prefix. Length is loop-invariant by construction (the matched body admits only element-field stores). The 16M cap serves as the finite-range ceiling. --------- Co-authored-by: Ralph Küpper <ralph@skelpo.com> * fix(hir): #6812 — fold values must be provably non-executing (CodeRabbit critical) A call/new/member-read/spread/in/instanceof in a folded value can reach the builder binding through a closure or trap WITHOUT naming it (hoisted fn, getter), turning the original's post-init evaluation into a TDZ ReferenceError. The textual reference check is replaced by a strict whitelist of expressions that cannot execute user code. Also: the candidate pre-scan is now a real recursive scan (the always-true kludge gated nothing), and the mutating walk reaches var-initializer function expressions and class field initializers. --------- Co-authored-by: Ralph Küpper <ralph@skelpo.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second gap-closure slice from the #6812 matrix, stacked on #6829. Widens the whole-loop object-write clone's eligibility — four narrow relaxations of one matcher/emitter pair:
match_object_array_write_numberadmitsMul, with endpoint-product interval arithmetic in the finite-range proof andfmulemission.let-declared receiver aliases — sound because every statement in the matched region must be aPutValueSeton the alias, so reassignment is structurally impossible; captures were already excluded viaboxed_vars.let i = 0; while (i < N) { …; i++ }spelling of the counted inner loop — the store-shape constraints admit nocontinueor other control flow, and the emitter's existing counter finalization gives the function-scoped counter its post-loop value.for (let i = 0; i < arr.length; i++)over the SAME array the loop writes. The guard receives au32::MAXsentinel and resolves the scan length from the validated array's header (rejecting > 16M); the emitter loads the length register in a new guard-okfast.entryblock, so the fast nest can never outrun the proven prefix. Length is loop-invariant by construction (the matched body admits only element-field stores). The 16M cap doubles as the finite-range ceiling.Measured (3-run medians, node v26.3.0/arm64, release + default pipeline)
9 of 18 matrix rows now beat node. Full-sweep regression check, suites, and gap-gate results in the PR comment (re-run on this tip).
Review notes
packed_f64_range_loop_index_offsetshares an identical guard line;Multhere would have read ani * cindex as offsetc). Caught pre-merge because the target cell didn't improve; reverted surgically, and a multiplied-index semantic sanity (byte-diffed vs node) now guards that family.