-
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: Make BasicBlock::bbJumpKind private #92908
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -702,8 +702,26 @@ struct BasicBlock : private LIR::Range | |
// a block corresponding to an exit from the try of a try/finally. | ||
bool isBBCallAlwaysPairTail() const; | ||
|
||
private: | ||
BBjumpKinds bbJumpKind; // jump (if any) at the end of this block | ||
|
||
public: | ||
BBjumpKinds getBBJumpKind() const | ||
{ | ||
return bbJumpKind; | ||
} | ||
|
||
void setBBJumpKind(BBjumpKinds kind DEBUG_ARG(Compiler* comp)) | ||
{ | ||
#ifdef DEBUG | ||
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. I'm probably getting ahead of myself here, but I'm thinking we will need to track whether BBJ_NONE is allowed or not in the current Compiler's state, so passing in a pointer to it will enable us to assert this state. I avoided making this a noway_assert to minimize TP diffs, and made 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. I would personally recommend using a verifier pattern (i. e. adding an assert somewhere in fgdiagnostic.cpp) for checking this property instead of the setters. It will make for less debug-only code overall. 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. I like the cleanliness of your suggestion, but if we move this check to somewhere like 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.
Not strictly, but it is still an improvement. https://github.com/dotnet/runtime/blob/main/docs/coding-guidelines/clr-jit-coding-conventions.md
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. Yes, please keep this field private. Eventually we will probably do more work when the jump kind gets changed -- for instance calling add/remove ref on the appropriate blocks. So having the extra |
||
// BBJ_NONE should only be assigned when optimizing jumps in Compiler::optOptimizeLayout | ||
// TODO: Change assert to check if comp is in appropriate optimization phase to use BBJ_NONE | ||
// (right now, this assertion does the null check to avoid unused variable warnings) | ||
assert((kind != BBJ_NONE) || (comp != nullptr)); | ||
#endif // DEBUG | ||
bbJumpKind = kind; | ||
} | ||
|
||
/* The following union describes the jump target(s) of this block */ | ||
union { | ||
unsigned bbJumpOffs; // PC offset (temporary only) | ||
|
@@ -1556,7 +1574,7 @@ inline BBArrayIterator BBSwitchTargetList::end() const | |
inline BasicBlock::BBSuccList::BBSuccList(const BasicBlock* block) | ||
{ | ||
assert(block != nullptr); | ||
switch (block->bbJumpKind) | ||
switch (block->getBBJumpKind()) | ||
{ | ||
case BBJ_THROW: | ||
case BBJ_RETURN: | ||
|
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.
Looks like most uses can be replaced with an existing
block->KindIs(...)
(it also supports 'params').Also, should it be Get or get?
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.
Thank you for catching that -- I'll push a revision converting all the bbJumpKind comparisons to KindIs().
I'm not sure what the case should be. Some BasicBlock methods (like
KindIs
) use Pascal case, while others (likemakeBlockHot
) use camel case.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.
The convention for all new code in the Jit is to use PascalCase, except in LSRA (where camelCase is used consistently).