This repository has been archived by the owner on Jul 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Better receiver types for static dispatch. #118
Merged
tanishiking
merged 3 commits into
tanishiking:main
from
sjrd:better-receiver-type-for-static-dispatch
May 1, 2024
Merged
Better receiver types for static dispatch. #118
tanishiking
merged 3 commits into
tanishiking:main
from
sjrd:better-receiver-type-for-static-dispatch
May 1, 2024
Conversation
This file contains 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
The real method body goes to a method used for statically resolved calls. That method can take the real `this` type as argument. For table entries, which need to use `(ref any)` as receiver type, we generate a separate function. That bridge function casts down the receiver then performs a tail call to the real function. With this strategy, we do not need to cast down `this` values every time we use them. Since most calls as statically resolved, this also means we don't need any cast at all. For dynamically resolved calls, the overhead should be small thanks to the tail call. This change causes a 30% code size regression for fastLink, but only 6% in fullLink. We should be able to optimize it further by only emitting bridges for methods that actually appear in at least one dispatch table.
This surfaced a few places when instantiating new objects where we need to manipulate non-null values.
sjrd
force-pushed
the
better-receiver-type-for-static-dispatch
branch
from
April 23, 2024 08:24
55388d9
to
b256724
Compare
Rebased. |
Ping @tanishiking about this one? |
Oops, I'll take a look today. thanks for pinging |
tanishiking
approved these changes
May 1, 2024
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.
LGTM, thanks!
fctx.buildAndAddToContext() | ||
|
||
if (namespace == IRTrees.MemberNamespace.Public && !isHijackedClass) { | ||
/* Also generate the bridge that is stored in the table entries. In table |
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.
👍
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Based on #116. Only the last 3 commits belong to this PR.