-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
JIT: Keep delegate object alive during invoke #105099
Closed
Closed
Changes from 12 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
4a90d51
Disable Comparer_get_Default test on win-arm64-crossgen
EgorBo 76c6f4d
Keep 'this' alive for delegate invoke
EgorBo 49b10a6
Update issues.targets
EgorBo 8bf8365
Update lower.cpp
EgorBo 96543b3
less conservative version
EgorBo 5db07f8
fix define
EgorBo 118c8ad
Apply Jakob's suggestion
EgorBo ffe5317
GT_STOP_NOGC
EgorBo 5558203
Merge branch 'main' into keep-this-alive-fptr
EgorBo bfc872f
Update lower.cpp
EgorBo 300ab49
Address feedback
EgorBo 26da6ab
Address feedback
EgorBo f95c267
Merge branch 'main' of https://github.com/dotnet/runtime into keep-th…
EgorBo b35c892
handle tail calls
EgorBo 255c5bd
Merge branch 'main' into keep-this-alive-fptr
EgorBo ffdc8e5
remove bogus assert
EgorBo 9e34a9a
Merge branch 'keep-this-alive-fptr' of github.com:EgorBo/runtime-1 in…
EgorBo 1dac215
Update lower.cpp
EgorBo 7cb1d65
Update lower.cpp
EgorBo f0964fd
Update lower.cpp
EgorBo 126fca9
Update lower.cpp
EgorBo c28b235
Merge branch 'main' of github.com:dotnet/runtime into keep-this-alive…
EgorBo 65d7909
test
EgorBo dded5c9
test2
EgorBo dca303b
test
EgorBo 95b6301
Clean up
EgorBo 2377322
Update lower.cpp
EgorBo bef38f3
clean up
EgorBo 9fba5a3
Update lower.cpp
EgorBo 9ccc937
Update lower.cpp
EgorBo 2ab1e61
Merge branch 'main' of github.com:dotnet/runtime into keep-this-alive…
EgorBo ef49ee6
test
EgorBo f4061ea
Merge branch 'main' into keep-this-alive-fptr
EgorBo a5c4b81
Merge branch 'main' into keep-this-alive-fptr
EgorBo 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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.
I would still do this inside
LowerCall
since it'sLowerCall
responsibility to insert the control expression returned by this function. This is adding an assumption about whereLowerCall
will insert that node.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.
but that's the point, no?
LowerDelegateInvoke
already inserts some trees and at the end of those we conservatively emit a START_NOGC so other functions likeLowerCall
itself,LowerCFGCall
orLowerTailCallViaJitHelper
can insert whatever they want after our NOGC and before the call. Because, presumably, they can extend the dangerous area where GC can kick in and collect our delegateThere 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.
Hmm yeah, that's a good point too. What I dislike here is just that it still relies on
LowerCall
to insert the control expression after theSTART_NONGC
. To be conservatively correct we have to insert theSTART_NOGC
before the last use of the delegate, sinceemitDisableGC()
means something like "the next instruction I emit is going to make GC information wrong, so disable GC after that instruction". Hence insertingSTART_NONGC
afterthisArgNode
is only correct because there ends up being another use inserted after that point byLowerCall
. The main idea behind moving the logic intoLowerCall
is that it has the full overview of what nodes it is going to insert and where, so it can make the decision with more information. So for instance it could insert it before thegtControlExpr
in the delegate case, knowing thatgtControlExpr
has the last use of the delegate instance in the common case.