-
-
Notifications
You must be signed in to change notification settings - Fork 158
perf(codegen): inline probes before the typed-feedback method + field guards (typed-param receivers 118.6→3.8 ns) #9124
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
proggeramlug
merged 2 commits into
PerryTS:main
from
proggeramlug:perf/method-probe-first
Aug 30, 2026
+57
−1
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
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.
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.
🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 50370
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 37276
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 14853
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 50370
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 50370
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 47720
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 47549
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 7663
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 7558
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 50370
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 50370
Denial of Service (CWE-822)
Reachability: External · Exploitability: Difficult
Reject untagged
recv_boxvalues before dereference.Expr::Numberuses raw IEEE-754 bits, while the helper treats a zero upper word as an internal raw pointer. A crafted positive subnormal can therefore produce an in-range address and reach theobj_ptr - 8load before the runtime guard. Require the0x7FFDpointer tag or another proof of the raw-pointer ABI.🤖 Prompt for AI Agents
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.
Analysed rather than changed: the receiver-before-arguments lowering with no re-read is the direct-method tower's pre-existing structure (
dynamic_dispatch.rs:recv_boxlowered, then each arg), and the samerecv_boxSSA value already feeds both the runtime typed-feedback guard and the shape-only inline guard. All of them — including this probe — test the GC header's forwarded bit and reject a moved receiver, falling to the runtime guard, which resolves forwarding as it always did. So the probe-first edge introduces no new window relative to the two existing consumers; making the whole tower root-and-re-read its receiver across argument lowering would be a separate change to shared structure, and I'd rather not fold it into this PR.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.
🧩 Analysis chain
🏁 Script executed:
Length of output: 183064
@proggeramlug, thanks for the analysis. It addresses receiver lifetime and forwarding. It does not address this finding.The inline guard accepts
tag == 0before it readsobj_ptr - 8. Mainstream targets accept low addresses from0x10_0000to2^47or2^48. A JavaScriptNumbercan have a positive subnormal bit pattern in that range withtag == 0.The runtime guard is not equivalent here. Its
gc_header_for_user_addrpath callsis_valid_obj_ptrbefore it reads the GC header. The inline guard has only a range check. Therefore, it can dereference an unmapped address before it reaches the forwarded-bit check.Please either reject
tag == 0in this source-levelrecv_boxpath or add a separate, explicit proof that the value uses the internal raw-pointer ABI. The receiver root-and-re-read change is independent of this fix.✏️ Learnings added
🧠 Learnings used
You are interacting with an AI system.