@@ -514,21 +514,28 @@ struct BasicBlock : private LIR::Range
514514
515515 BBjumpKinds bbJumpKind; // jump (if any) at the end of this block
516516
517+ /* The following union describes the jump target(s) of this block */
518+ union {
519+ unsigned bbJumpOffs; // PC offset (temporary only)
520+ BasicBlock* bbJumpDest; // basic block
521+ BBswtDesc* bbJumpSwt; // switch descriptor
522+ };
523+
517524public:
518- BBjumpKinds GetBBJumpKind () const
525+ BBjumpKinds GetJumpKind () const
519526 {
520527 return bbJumpKind;
521528 }
522529
523- void SetBBJumpKind (BBjumpKinds kind DEBUG_ARG (Compiler* compiler))
530+ void SetJumpKind (BBjumpKinds jumpKind DEBUG_ARG (Compiler* compiler))
524531 {
525532#ifdef DEBUG
526533 // BBJ_NONE should only be assigned when optimizing jumps in Compiler::optOptimizeLayout
527534 // TODO: Change assert to check if compiler is in appropriate optimization phase to use BBJ_NONE
528535 // (right now, this assertion does the null check to avoid unused variable warnings)
529- assert ((kind != BBJ_NONE) || (compiler != nullptr ));
536+ assert ((jumpKind != BBJ_NONE) || (compiler != nullptr ));
530537#endif // DEBUG
531- bbJumpKind = kind ;
538+ bbJumpKind = jumpKind ;
532539 }
533540
534541 BasicBlock* Prev () const
@@ -569,12 +576,12 @@ struct BasicBlock : private LIR::Range
569576 return (bbNext == nullptr );
570577 }
571578
572- bool PrevIs (BasicBlock* block) const
579+ bool PrevIs (const BasicBlock* block) const
573580 {
574581 return (bbPrev == block);
575582 }
576583
577- bool NextIs (BasicBlock* block) const
584+ bool NextIs (const BasicBlock* block) const
578585 {
579586 return (bbNext == block);
580587 }
@@ -583,12 +590,61 @@ struct BasicBlock : private LIR::Range
583590
584591 bool IsFirstColdBlock (Compiler* compiler) const ;
585592
586- /* The following union describes the jump target(s) of this block */
587- union {
588- unsigned bbJumpOffs; // PC offset (temporary only)
589- BasicBlock* bbJumpDest; // basic block
590- BBswtDesc* bbJumpSwt; // switch descriptor
591- };
593+ unsigned GetJumpOffs () const
594+ {
595+ return bbJumpOffs;
596+ }
597+
598+ void SetJumpOffs (unsigned jumpOffs)
599+ {
600+ bbJumpOffs = jumpOffs;
601+ }
602+
603+ BasicBlock* GetJumpDest () const
604+ {
605+ return bbJumpDest;
606+ }
607+
608+ void SetJumpDest (BasicBlock* jumpDest)
609+ {
610+ bbJumpDest = jumpDest;
611+ }
612+
613+ void SetJumpKindAndTarget (BBjumpKinds jumpKind, BasicBlock* jumpDest)
614+ {
615+ assert (jumpDest != nullptr );
616+ bbJumpKind = jumpKind;
617+ bbJumpDest = jumpDest;
618+ assert (KindIs (BBJ_ALWAYS, BBJ_CALLFINALLY, BBJ_COND, BBJ_EHCATCHRET, BBJ_LEAVE));
619+ }
620+
621+ bool HasJumpTo (const BasicBlock* jumpDest) const
622+ {
623+ return (bbJumpDest == jumpDest);
624+ }
625+
626+ bool JumpsToNext () const
627+ {
628+ return (bbJumpDest == bbNext);
629+ }
630+
631+ BBswtDesc* GetJumpSwt () const
632+ {
633+ return bbJumpSwt;
634+ }
635+
636+ void SetJumpSwt (BBswtDesc* jumpSwt)
637+ {
638+ bbJumpSwt = jumpSwt;
639+ }
640+
641+ void SetJumpKindAndTarget (BBjumpKinds jumpKind, BBswtDesc* jumpSwt)
642+ {
643+ assert (jumpKind == BBJ_SWITCH);
644+ assert (jumpSwt != nullptr );
645+ bbJumpKind = jumpKind;
646+ bbJumpSwt = jumpSwt;
647+ }
592648
593649 BasicBlockFlags bbFlags;
594650
@@ -1617,7 +1673,7 @@ inline BBArrayIterator BBSwitchTargetList::end() const
16171673inline BasicBlock::BBSuccList::BBSuccList (const BasicBlock* block)
16181674{
16191675 assert (block != nullptr );
1620- switch (block->GetBBJumpKind ())
1676+ switch (block->GetJumpKind ())
16211677 {
16221678 case BBJ_THROW:
16231679 case BBJ_RETURN:
@@ -1633,7 +1689,7 @@ inline BasicBlock::BBSuccList::BBSuccList(const BasicBlock* block)
16331689 case BBJ_ALWAYS:
16341690 case BBJ_EHCATCHRET:
16351691 case BBJ_LEAVE:
1636- m_succs[0 ] = block->bbJumpDest ;
1692+ m_succs[0 ] = block->GetJumpDest () ;
16371693 m_begin = &m_succs[0 ];
16381694 m_end = &m_succs[1 ];
16391695 break ;
@@ -1650,23 +1706,23 @@ inline BasicBlock::BBSuccList::BBSuccList(const BasicBlock* block)
16501706
16511707 // If both fall-through and branch successors are identical, then only include
16521708 // them once in the iteration (this is the same behavior as NumSucc()/GetSucc()).
1653- if (block->NextIs (block-> bbJumpDest ))
1709+ if (block->JumpsToNext ( ))
16541710 {
16551711 m_end = &m_succs[1 ];
16561712 }
16571713 else
16581714 {
1659- m_succs[1 ] = block->bbJumpDest ;
1715+ m_succs[1 ] = block->GetJumpDest () ;
16601716 m_end = &m_succs[2 ];
16611717 }
16621718 break ;
16631719
16641720 case BBJ_SWITCH:
16651721 // We don't use the m_succs in-line data for switches; use the existing jump table in the block.
1666- assert (block->bbJumpSwt != nullptr );
1667- assert (block->bbJumpSwt ->bbsDstTab != nullptr );
1668- m_begin = block->bbJumpSwt ->bbsDstTab ;
1669- m_end = block->bbJumpSwt ->bbsDstTab + block->bbJumpSwt ->bbsCount ;
1722+ assert (block->GetJumpSwt () != nullptr );
1723+ assert (block->GetJumpSwt () ->bbsDstTab != nullptr );
1724+ m_begin = block->GetJumpSwt () ->bbsDstTab ;
1725+ m_end = block->GetJumpSwt () ->bbsDstTab + block->GetJumpSwt () ->bbsCount ;
16701726 break ;
16711727
16721728 default :
0 commit comments