-
-
Notifications
You must be signed in to change notification settings - Fork 158
perf(codegen): specialize imported methods capturing this #8731
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
proggeramlug
wants to merge
1
commit into
PerryTS:main
from
proggeramlug:fix/8693-imported-this-specialization
Closed
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
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 @@ | ||
| --- | ||
| category: Performance | ||
| title: Specialize imported methods that capture this | ||
| --- | ||
|
|
||
| ESM import and re-export metadata now carries producer-proven method | ||
| eligibility, allowing guarded direct calls into stable class methods that use | ||
| `this`. Generic dispatch remains available for shadowed or mutated receivers, | ||
| including prototype replacement, deletion, and recreation. |
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
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.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Guard imported pshape-capability publishing against
effective_namecollisions.This loop inserts into
pshape_methods/pshape_tower_routablefor everyimportedentry that has the method in its ownproven_this_method_names, keyed only by(effective_name, method). It does not check whetherimportedis the entry that actually won themethod_names[(effective_name, method)]symbol.method_names(built later inmethod_registry.rs) resolves aneffective_namecollision with first-writer-wins overopts.imported_classes. The pshape-clone extern is declared only for the specificImportedClasswhose ownproven_this_method_namescontains the method. If two imported classes shareeffective_name(for example, two default imports in the same file — a scenario this file already documents as a real recurring collision, see "Refs#665") and only the losing class has the method proven-this,pshape_methodsrecords eligibility for a clone symbol that was never declared for the winningmethod_namesentry.prune_unregistered_clonesonly checks(class, method)presence inmethod_names, not identity of the specific clone, so it does not catch this. The result is a call to an undeclared symbol.Gate this loop on
imported_class_prefix, the first-writer-wins map already built earlier in this function, so only the class that actually won theeffective_nameslot can publish pshape capability for it.🛡️ Proposed fix: only the winning imported class for `effective_name` may publish capability
for imported in &opts.imported_classes { let effective_name = imported .local_alias .as_deref() .unwrap_or(&imported.name) .to_string(); if hir.classes.iter().any(|class| class.name == effective_name) { continue; } + // Match the first-writer-wins winner already selected for + // `imported_class_prefix` / `method_names`. A losing import that + // shares `effective_name` with another import (two default-imported + // classes, for example) must not publish pshape capability for a + // symbol `method_names` will never point at. + if imported_class_prefix.get(&effective_name) != Some(&imported.source_prefix) { + continue; + } for method in &imported.proven_this_method_names {📝 Committable suggestion
🤖 Prompt for AI Agents