-
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
Allow GC on the first instruction of NoGC region (except in prologs/epilogs) #103540
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2a7c328
x64
VSadov 6f726d6
other platforms
VSadov 42a209c
no GC in epilogs
VSadov 7b4feaf
missing change for arm32
VSadov 57591c8
add asserts
VSadov ff4f223
Addressing PR feedback.
VSadov bdb38f9
whitespace formatting
VSadov 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4013,37 +4013,43 @@ void GCInfo::gcInfoBlockHdrSave(GcInfoEncoder* gcInfoEncoder, unsigned methodSiz | |
// | ||
struct InterruptibleRangeReporter | ||
{ | ||
unsigned prevStart; | ||
Encoder* gcInfoEncoderWithLog; | ||
unsigned m_uninterruptibleEnd; | ||
Encoder* m_gcInfoEncoder; | ||
Comment on lines
+4016
to
+4017
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make them private as well? |
||
|
||
InterruptibleRangeReporter(unsigned _prevStart, Encoder* _gcInfo) | ||
: prevStart(_prevStart) | ||
, gcInfoEncoderWithLog(_gcInfo) | ||
InterruptibleRangeReporter(unsigned prologSize, Encoder* gcInfo) | ||
: m_uninterruptibleEnd(prologSize) | ||
, m_gcInfoEncoder(gcInfo) | ||
{ | ||
} | ||
|
||
// This callback is called for each insGroup marked with | ||
// IGF_NOGCINTERRUPT (currently just prologs and epilogs). | ||
// This callback is called for each insGroup marked with IGF_NOGCINTERRUPT. | ||
// Report everything between the previous region and the current | ||
// region as interruptible. | ||
|
||
bool operator()(unsigned igFuncIdx, unsigned igOffs, unsigned igSize) | ||
bool operator()( | ||
unsigned igFuncIdx, unsigned igOffs, unsigned igSize, unsigned firstInstrSize, bool isInPrologOrEpilog) | ||
{ | ||
if (igOffs < prevStart) | ||
if (igOffs < m_uninterruptibleEnd) | ||
{ | ||
// We're still in the main method prolog, which has already | ||
// had it's interruptible range reported. | ||
// We're still in the main method prolog, which we know is not interruptible. | ||
assert(igFuncIdx == 0); | ||
assert(igOffs + igSize <= prevStart); | ||
assert(igOffs + igSize <= m_uninterruptibleEnd); | ||
return true; | ||
} | ||
|
||
assert(igOffs >= prevStart); | ||
if (igOffs > prevStart) | ||
assert(igOffs >= m_uninterruptibleEnd); | ||
if (igOffs > m_uninterruptibleEnd) | ||
{ | ||
gcInfoEncoderWithLog->DefineInterruptibleRange(prevStart, igOffs - prevStart); | ||
// Once the first instruction in IG executes, we cannot have GC. | ||
// But it is ok to have GC while the IP is on the first instruction, unless we are in prolog/epilog. | ||
unsigned interruptibleEnd = igOffs; | ||
if (!isInPrologOrEpilog) | ||
{ | ||
interruptibleEnd += firstInstrSize; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the key change in this PR. |
||
m_gcInfoEncoder->DefineInterruptibleRange(m_uninterruptibleEnd, interruptibleEnd - m_uninterruptibleEnd); | ||
} | ||
prevStart = igOffs + igSize; | ||
m_uninterruptibleEnd = igOffs + igSize; | ||
return true; | ||
} | ||
}; | ||
|
@@ -4396,17 +4402,16 @@ void GCInfo::gcMakeRegPtrTable( | |
{ | ||
assert(prologSize <= codeSize); | ||
|
||
// Now exempt any other region marked as IGF_NOGCINTERRUPT | ||
// Currently just prologs and epilogs. | ||
// Now exempt any region marked as IGF_NOGCINTERRUPT | ||
|
||
InterruptibleRangeReporter reporter(prologSize, gcInfoEncoderWithLog); | ||
compiler->GetEmitter()->emitGenNoGCLst(reporter); | ||
prologSize = reporter.prevStart; | ||
unsigned uninterruptibleEnd = reporter.m_uninterruptibleEnd; | ||
|
||
// Report any remainder | ||
if (prologSize < codeSize) | ||
if (uninterruptibleEnd < codeSize) | ||
{ | ||
gcInfoEncoderWithLog->DefineInterruptibleRange(prologSize, codeSize - prologSize); | ||
gcInfoEncoderWithLog->DefineInterruptibleRange(uninterruptibleEnd, codeSize - uninterruptibleEnd); | ||
} | ||
} | ||
} | ||
|
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.
Unlike other uses of NoGC regions, the use in
genCallFinally
was starting the NoGC region on instruction after the one that makes GC unsafe.We need to agree on the same semantics for all the uses, so
genCallFinally
had to be adjusted to work the same as in other uses of NoGC like block copying, tailcall arg setups,...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.
We could have it the other way (and adjust uses in block copying, etc..), we just need to have it the same way in all cases.
However, starting NoGC region on an instruction group that will make GC unsafe seems a lot more convenient as we may want to start NoGC region before we know exact instructions that will go into it.