-
-
Notifications
You must be signed in to change notification settings - Fork 159
fix(opt-report): report Ptr<NumArray> pre-filter kills instead of silence (#7112) #7819
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
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,34 @@ | ||
| **`--opt-report` now names the module-wide `Ptr<NumArray>` kill instead of going silent** (#7112, whole-analysis half). | ||
|
|
||
| `collect_num_array_locals` returns an empty map outright when the module has a shape-barrier site, a numarray prototype-index barrier, or an opaque prototype mutation — and when the analysis is switched off entirely. That happens **before** any array local becomes a candidate, so no per-value `deny()` runs and the report shows the module as having no array candidates at all. | ||
|
|
||
| That reads identically to "the analysis never looked at these values", which is precisely the ambiguity the report exists to remove — and it is why 8 of the census's 18 real workloads read "zero candidates". | ||
|
|
||
| The kill is now recorded once, naming which of the four causes fired: | ||
|
|
||
| ``` | ||
| <module> | rule 0 (analysis disabled) | ||
| | cause: an opaque (aliased) prototype mutation in this module | ||
| | tier: compiler-limitation | issue: #7112 | ||
| ``` | ||
|
|
||
| Verified both directions on a two-module pair: a module containing `const p = Array.prototype; p[5] = 1` alongside a numeric array emits exactly one `rule 0` entry with that cause; the same module without the prototype write emits **zero**. So the entry means "the analysis stopped upstream", not "this module has arrays". | ||
|
|
||
| Two deliberate choices worth stating: | ||
|
|
||
| * It is attributed to a pseudo-name `<module>` with no `local_id`, rather than to some array local. A module-wide kill has no value to blame, and inventing one would put a denial on an array that was never examined — the same misattribution in the other direction. | ||
| * The four causes are now separate `if` arms rather than one `||` chain, purely so the report can say *which* barrier fired. The chain's alias-hole rationale (why `has_opaque_prototype_mutation` exists at all, given the direct-form kill above it) moves onto the arm that owns it rather than being left orphaned above a condition it no longer describes. | ||
|
|
||
| **The element-type pre-filter is covered too**, which is the case the issue leads with. `benchmarks/suite/11_prime_sieve.ts` reported **0** `ptr-numarray` candidates — reading as "this program has no array worth promoting", for a program whose 1,000,000-element array is in the hot loop indexed by a proven integer. It now reports: | ||
|
|
||
| ``` | ||
| <array local> | rule 0 (element type) | declared type: Array(Boolean) | tier: fixable | ||
| ``` | ||
|
|
||
| `Fixable`, not `CompilerLimitation`: the declared element type is the trust boundary every numeric fast path uses, so the program can move to `number[]` (or the analysis can grow a boolean slot representation). That is a different answer from "the compiler cannot express this". | ||
|
|
||
| Only ARRAY types are recorded. A non-array `Let` is not a rejected array candidate — it simply is not an array — and filing a denial for every `let x = 1` would drown the report in rows answering a question nobody asked. Verified on a control module: a `number[]` is reported `selected`, and the `const flag = 1` / `const label = "x"` beside it produce **zero** element-type rows. | ||
|
|
||
| Still untouched: the `Ptr<Shape>` side, whose provenance pass has the analogous structure. | ||
|
|
||
| `cargo test -p perry-codegen --lib` 851 passed / 0 failed; fmt and file-size clean. | ||
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.
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.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Use the current PR key in the fragment filename.
The PR objective identifies this change as PR
#7112, but this file is named7819-numarray-analysis-disabled-report.md. Rename it tochangelog.d/7112-numarray-analysis-disabled-report.md, unless the PR objective is incorrect.As per coding guidelines: add one PR-keyed
changelog.d/<PR>-<slug>.mdfragment.🤖 Prompt for AI Agents
Source: Coding guidelines