-
-
Notifications
You must be signed in to change notification settings - Fork 160
perf(codegen): masked-window hoist for untyped array params + straight-line region versioning (bcryptjs) #6794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f54cbfe
perf(codegen): masked-window read hoist for loop-invariant untyped ar…
4a6509e
perf(codegen): masked-window region versioning for straight-line unro…
d3cf49d
perf(codegen): fact-aware dispatch + region type refinement for untyp…
04e7b65
test(gap): untyped-param masked-window correctness matrix
3a8cf7a
fix(codegen): skip region versioning for arrays already covered by an…
1652fe8
test(gap): straight-line region shapes for the masked-window region v…
4b72f12
docs(changelog): changeset for #6794
037cd9f
fix(codegen): BigInt-sound region type refinement + canonical heap-ad…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| perf(codegen): masked-window read hoist for loop-invariant array params of unknown static type, plus straight-line region versioning (#6794; follow-up to #6750) | ||
|
|
||
| #6750's masked-index fast paths only fired when the array's static type proved a numeric array, so an array arriving as an untyped (`any`) function parameter — the bcryptjs Blowfish S-box shape, and the common shape across real npm code — kept paying one guard call per access (~40× slower than Node on `S[i & 1023]` loops). | ||
|
|
||
| - **Dense range-loop tiers for untyped bindings**: the read-only dense matcher also admits bindings with no usable static type (the entry guards re-validate the actual runtime value; a wrong hint costs one failed guard → slow loop). New O(1) typed-array probe tiers (`js_typed_feedback_masked_window_ta_kind` + preheader data-pointer hoist) give Int32Array / Uint32Array / Float64Array receivers width-correct bare inline loads; untyped plain Arrays version through the existing plain tiers. `MaskedWindowArrayFact` now carries a `MaskedWindowElem` storage kind. | ||
| - **Masked-window region versioning** (`stmt/masked_window_region.rs`): bcryptjs ships `_encipher` fully unrolled — ~130 consecutive masked reads with no loop — so a maximal straight-line run of scalar statements with ≥8 static-window reads gets the same probe → fast-copy/slow-copy treatment. | ||
| - **Fast copies made real for untyped locals**: unknown-receiver IndexGet routes consult masked-window facts before the per-access inline-TA/`js_dyn_index_get` paths; `is_numeric_expr` and the shadow-value classifier recognize fact-covered reads; region-local flow refinement types untyped locals as `Number` once every prior write is provably numeric (killing `js_dynamic_*` dispatch calls), with shadow-slot suppression and, outside `try`, privatization into non-escaping allocas so LLVM promotes the region to registers. | ||
|
|
||
| Measured: untyped-param Int32Array `S[i & 1023]` 20M-read loop 535 ms → 3 ms, untyped-param plain Array 934 ms → 5 ms (Node: 15/21 ms); real `bcryptjs.compareSync` (cost 10) 3.68 s → 1.03 s per op (5.6 s before the #6750 series; Node 71 ms). Statically-typed loops and pure-arithmetic loops unchanged. New gap test `test_gap_untyped_param_masked_window.ts` covers the deopt matrix (OOB → `undefined`, holey/mixed plain arrays, unsupported TA kinds, detached views, heterogeneous multi-array loops, mid-loop/mid-region rebinding, polymorphic call sites, mid-region throw in `try`). | ||
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.