-
-
Notifications
You must be signed in to change notification settings - Fork 161
feat(codegen): match the Intl.Segmenter for-of and answer it from the runtime view mode (default OFF) #9859
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
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9229e0a
feat(codegen): match the Intl.Segmenter for-of, and count whether it …
a9b46b2
style: cargo fmt the segment-view matcher and its tests
24b7ea0
docs(changelog): add the segment-view matcher fragment
fee3cd2
docs: point the segment-view references at the issue that exists (#9843)
2ef9b2a
fix(codegen): classify the folded StringCodePointAt node as a segment…
446ad83
feat(codegen): lower a proven segment for-of to the runtime view mode…
122b491
diag(codegen): make the lowering report which entry point each site w…
078c266
feat(codegen): v2 — answer the segment's uses from the view, material…
0530602
fix(codegen): declare the segment-view runtime entry points
cafd9e7
fix(codegen): answer a statically-known RegExpTest from the view too
87b631b
fix(codegen): clear the segment-view cursor at loop exit
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,28 @@ | ||
| Compile-time matcher for the `Intl.Segmenter` `for…of` loop, with the counter | ||
| that decides whether it fires. | ||
|
|
||
| `for (let {segment: O} of X.segment(q))` is where claude-code spends most of a | ||
| turn: the allocation census ranks it 1/2/3 by count (172,032 segment records | ||
| plus 247,808 substrings per 400-character reply, 58 % of the top-30 allocation | ||
| count), and a `sample` puts 60–85 % of active main-thread CPU inside it, under | ||
| ink's `wrapText`. The loop reads one code point per grapheme and retains | ||
| nothing. | ||
|
|
||
| `collectors/segview.rs` joins `escape_news` / `escape_arrays` / | ||
| `escape_objects` as the family's fourth member. It proves one thing: the | ||
| segment RECORD never escapes, because every use of the synthetic | ||
| `__destruct_N` binding is one of the destructuring field reads the loop head | ||
| itself emits. Uses of the segment STRING are classified and counted but never | ||
| gate the proof — a use no view entry point can answer is served by | ||
| materialising the substring once, which is what the loop costs today. | ||
|
|
||
| The escape proof is taken with `perry_hir::collect_local_refs_stmt`, whose | ||
| descent bottoms out in the walker the compiler forces to be exhaustive, so a | ||
| new HIR variant embedding a `LocalGet` cannot silently hide a use of the | ||
| record. | ||
|
|
||
| No lowering yet: the fact is populated and unread until the runtime's | ||
| segment-view entry points exist. `PERRY_SEGVIEW_DIAG=1` reports every site | ||
| examined, its verdict and its per-use tally at the HIR-trace point, and is | ||
| excluded from the build-level cache so a report of zero is a measured zero | ||
| rather than a build that never lowered HIR. | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Describe the final opt-in lowering, not the development slice.
changelog.d/fragments become GitHub Release notes. State thatPERRY_SEGVIEW=1enables the default-off lowering, declined sites retain the iterator fallback, andPERRY_SEGVIEW_DIAG=1reports site verdicts and per-use tallies outside the build cache. The current “No lowering yet” text would make the shipped release notes inaccurate.🤖 Prompt for AI Agents