-
Notifications
You must be signed in to change notification settings - Fork 5.2k
JIT: Make BasicBlock::bbPrev and bbNext private #93032
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
Changes from 12 commits
3a4bdf5
2378797
a8c8a6c
7aadbdc
754743d
b31fee9
0a16a8f
254c362
f6dfb21
52370b0
b0fc610
59e9455
1fb10a8
5bb73fe
c03b7c9
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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -508,10 +508,49 @@ struct BasicBlock : private LIR::Range | |||||||||
| { | ||||||||||
| friend class LIR; | ||||||||||
|
|
||||||||||
| private: | ||||||||||
| BasicBlock* bbNext; // next BB in ascending PC offset order | ||||||||||
| BasicBlock* bbPrev; | ||||||||||
|
|
||||||||||
| void setNext(BasicBlock* next) | ||||||||||
| BBjumpKinds bbJumpKind; // jump (if any) at the end of this block | ||||||||||
|
|
||||||||||
| public: | ||||||||||
| BBjumpKinds GetBBJumpKind() const | ||||||||||
| { | ||||||||||
| return bbJumpKind; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| void SetBBJumpKind(BBjumpKinds kind DEBUG_ARG(Compiler* compiler)) | ||||||||||
| { | ||||||||||
| #ifdef DEBUG | ||||||||||
| // BBJ_NONE should only be assigned when optimizing jumps in Compiler::optOptimizeLayout | ||||||||||
| // TODO: Change assert to check if compiler 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) || (compiler != nullptr)); | ||||||||||
| #endif // DEBUG | ||||||||||
| bbJumpKind = kind; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| BasicBlock* Prev() const | ||||||||||
| { | ||||||||||
| return bbPrev; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| void SetPrev(BasicBlock* prev) | ||||||||||
| { | ||||||||||
| bbPrev = prev; | ||||||||||
| if (prev) | ||||||||||
| { | ||||||||||
| prev->bbNext = this; | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| BasicBlock* Next() const | ||||||||||
| { | ||||||||||
| return bbNext; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| void SetNext(BasicBlock* next) | ||||||||||
| { | ||||||||||
| bbNext = next; | ||||||||||
| if (next) | ||||||||||
|
|
@@ -520,6 +559,35 @@ struct BasicBlock : private LIR::Range | |||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| bool IsFirst() const | ||||||||||
| { | ||||||||||
| return (bbPrev == nullptr); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| bool IsLast() const | ||||||||||
| { | ||||||||||
| return (bbNext == nullptr); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| bool PrevIs(BasicBlock* block) const | ||||||||||
| { | ||||||||||
| return (bbPrev == block); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| bool NextIs(BasicBlock* block) const | ||||||||||
| { | ||||||||||
| return (bbNext == block); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| bool IsLastHotBlock(Compiler* compiler) const; | ||||||||||
|
|
||||||||||
| /* The following union describes the jump target(s) of this block */ | ||||||||||
| union { | ||||||||||
| unsigned bbJumpOffs; // PC offset (temporary only) | ||||||||||
| BasicBlock* bbJumpDest; // basic block | ||||||||||
| BBswtDesc* bbJumpSwt; // switch descriptor | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| BasicBlockFlags bbFlags; | ||||||||||
|
|
||||||||||
| static_assert_no_msg((BBF_SPLIT_NONEXIST & BBF_SPLIT_LOST) == 0); | ||||||||||
|
|
@@ -702,33 +770,6 @@ 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 | ||||||||||
| // 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) | ||||||||||
| BasicBlock* bbJumpDest; // basic block | ||||||||||
| BBswtDesc* bbJumpSwt; // switch descriptor | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| bool KindIs(BBjumpKinds kind) const | ||||||||||
| { | ||||||||||
| return bbJumpKind == kind; | ||||||||||
|
|
@@ -1435,10 +1476,10 @@ class BasicBlockIterator | |||||||||
| { | ||||||||||
| assert(m_block != nullptr); | ||||||||||
| // Check that we haven't been spliced out of the list. | ||||||||||
| assert((m_block->bbNext == nullptr) || (m_block->bbNext->bbPrev == m_block)); | ||||||||||
| assert((m_block->bbPrev == nullptr) || (m_block->bbPrev->bbNext == m_block)); | ||||||||||
| assert((m_block->IsLast()) || m_block->Next()->PrevIs(m_block)); | ||||||||||
| assert((m_block->IsFirst()) || m_block->Prev()->NextIs(m_block)); | ||||||||||
|
||||||||||
| assert((m_block->IsLast()) || m_block->Next()->PrevIs(m_block)); | |
| assert((m_block->IsFirst()) || m_block->Prev()->NextIs(m_block)); | |
| assert(m_block->IsLast() || m_block->Next()->PrevIs(m_block)); | |
| assert(m_block->IsFirst() || m_block->Prev()->NextIs(m_block)); |
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.
Thanks for catching all these nits (sorry, these kinds of PRs seem especially tedious to review).
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -402,10 +402,10 @@ void CodeGen::genMarkLabelsForCodegen() | |||||
| { | ||||||
| // For callfinally thunks, we need to mark the block following the callfinally/always pair, | ||||||
| // as that's needed for identifying the range of the "duplicate finally" region in EH data. | ||||||
| BasicBlock* bbToLabel = block->bbNext; | ||||||
| BasicBlock* bbToLabel = block->Next(); | ||||||
| if (block->isBBCallAlwaysPair()) | ||||||
| { | ||||||
| bbToLabel = bbToLabel->bbNext; // skip the BBJ_ALWAYS | ||||||
| bbToLabel = bbToLabel->Next(); // skip the BBJ_ALWAYS | ||||||
| } | ||||||
| if (bbToLabel != nullptr) | ||||||
| { | ||||||
|
|
@@ -446,16 +446,16 @@ void CodeGen::genMarkLabelsForCodegen() | |||||
| JITDUMP(" " FMT_BB " : try begin\n", HBtab->ebdTryBeg->bbNum); | ||||||
| JITDUMP(" " FMT_BB " : hnd begin\n", HBtab->ebdHndBeg->bbNum); | ||||||
|
|
||||||
| if (HBtab->ebdTryLast->bbNext != nullptr) | ||||||
| if (!HBtab->ebdTryLast->IsLast()) | ||||||
| { | ||||||
| HBtab->ebdTryLast->bbNext->bbFlags |= BBF_HAS_LABEL; | ||||||
| JITDUMP(" " FMT_BB " : try end\n", HBtab->ebdTryLast->bbNext->bbNum); | ||||||
| HBtab->ebdTryLast->Next()->bbFlags |= BBF_HAS_LABEL; | ||||||
| JITDUMP(" " FMT_BB " : try end\n", HBtab->ebdTryLast->Next()->bbNum); | ||||||
| } | ||||||
|
|
||||||
| if (HBtab->ebdHndLast->bbNext != nullptr) | ||||||
| if (!HBtab->ebdHndLast->IsLast()) | ||||||
| { | ||||||
| HBtab->ebdHndLast->bbNext->bbFlags |= BBF_HAS_LABEL; | ||||||
| JITDUMP(" " FMT_BB " : hnd end\n", HBtab->ebdHndLast->bbNext->bbNum); | ||||||
| HBtab->ebdHndLast->Next()->bbFlags |= BBF_HAS_LABEL; | ||||||
| JITDUMP(" " FMT_BB " : hnd end\n", HBtab->ebdHndLast->Next()->bbNum); | ||||||
| } | ||||||
|
|
||||||
| if (HBtab->HasFilter()) | ||||||
|
|
@@ -2302,9 +2302,9 @@ void CodeGen::genReportEH() | |||||
| hndBeg = compiler->ehCodeOffset(HBtab->ebdHndBeg); | ||||||
|
|
||||||
| tryEnd = (HBtab->ebdTryLast == compiler->fgLastBB) ? compiler->info.compNativeCodeSize | ||||||
| : compiler->ehCodeOffset(HBtab->ebdTryLast->bbNext); | ||||||
| : compiler->ehCodeOffset(HBtab->ebdTryLast->Next()); | ||||||
| hndEnd = (HBtab->ebdHndLast == compiler->fgLastBB) ? compiler->info.compNativeCodeSize | ||||||
| : compiler->ehCodeOffset(HBtab->ebdHndLast->bbNext); | ||||||
| : compiler->ehCodeOffset(HBtab->ebdHndLast->Next()); | ||||||
|
|
||||||
| if (HBtab->HasFilter()) | ||||||
| { | ||||||
|
|
@@ -2524,9 +2524,9 @@ void CodeGen::genReportEH() | |||||
| hndBeg = compiler->ehCodeOffset(bbHndBeg); | ||||||
|
|
||||||
| tryEnd = (bbTryLast == compiler->fgLastBB) ? compiler->info.compNativeCodeSize | ||||||
| : compiler->ehCodeOffset(bbTryLast->bbNext); | ||||||
| : compiler->ehCodeOffset(bbTryLast->Next()); | ||||||
| hndEnd = (bbHndLast == compiler->fgLastBB) ? compiler->info.compNativeCodeSize | ||||||
| : compiler->ehCodeOffset(bbHndLast->bbNext); | ||||||
| : compiler->ehCodeOffset(bbHndLast->Next()); | ||||||
|
|
||||||
| if (encTab->HasFilter()) | ||||||
| { | ||||||
|
|
@@ -2590,10 +2590,10 @@ void CodeGen::genReportEH() | |||||
|
|
||||||
| // How big is it? The BBJ_ALWAYS has a null bbEmitCookie! Look for the block after, which must be | ||||||
| // a label or jump target, since the BBJ_CALLFINALLY doesn't fall through. | ||||||
| BasicBlock* bbLabel = block->bbNext; | ||||||
| BasicBlock* bbLabel = block->Next(); | ||||||
| if (block->isBBCallAlwaysPair()) | ||||||
| { | ||||||
| bbLabel = bbLabel->bbNext; // skip the BBJ_ALWAYS | ||||||
| bbLabel = bbLabel->Next(); // skip the BBJ_ALWAYS | ||||||
| } | ||||||
| if (bbLabel == nullptr) | ||||||
| { | ||||||
|
|
@@ -5210,7 +5210,7 @@ void CodeGen::genReserveEpilog(BasicBlock* block) | |||||
|
|
||||||
| assert(block != nullptr); | ||||||
| const VARSET_TP& gcrefVarsArg(GetEmitter()->emitThisGCrefVars); | ||||||
| bool last = (block->bbNext == nullptr); | ||||||
| bool last = (block->IsLast()); | ||||||
|
||||||
| bool last = (block->IsLast()); | |
| bool last = block->IsLast(); |
or just substitute it in the call below and eliminate the last var
Outdated
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.
ditto
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.
Should we have a corresponding
IsFirstColdBlock(Compiler*)?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 can add that in for consistency.