55 assert(i < _cnt, "index out of bounds");
56 Copy::conjoint_words_to_lower((HeapWord*)&_blocks[i+1], (HeapWord*)&_blocks[i], ((_cnt-i-1)*sizeof(Block*)));
57 pop(); // shrink list by one block
58 }
59
60 void Block_List::insert(uint i, Block *b) {
61 push(b); // grow list by one block
62 Copy::conjoint_words_to_higher((HeapWord*)&_blocks[i], (HeapWord*)&_blocks[i+1], ((_cnt-i-1)*sizeof(Block*)));
63 _blocks[i] = b;
64 }
65
66 #ifndef PRODUCT
67 void Block_List::print() {
68 for (uint i=0; i < size(); i++) {
69 tty->print("B%d ", _blocks[i]->_pre_order);
70 }
71 tty->print("size = %d\n", size());
72 }
73 #endif
74
75 uint Block::code_alignment() {
76 // Check for Root block
77 if (_pre_order == 0) return CodeEntryAlignment;
78 // Check for Start block
79 if (_pre_order == 1) return InteriorEntryAlignment;
80 // Check for loop alignment
81 if (has_loop_alignment()) return loop_alignment();
82
83 return relocInfo::addr_unit(); // no particular alignment
84 }
85
86 uint Block::compute_loop_alignment() {
87 Node *h = head();
88 int unit_sz = relocInfo::addr_unit();
89 if (h->is_Loop() && h->as_Loop()->is_inner_loop()) {
90 // Pre- and post-loops have low trip count so do not bother with
91 // NOPs for align loop head. The constants are hidden from tuning
92 // but only because my "divide by 4" heuristic surely gets nearly
93 // all possible gain (a "do not align at all" heuristic has a
94 // chance of getting a really tiny gain).
95 if (h->is_CountedLoop() && (h->as_CountedLoop()->is_pre_loop() ||
1709 break_loop_after(b);
1710 }
1711 }
1712
1713 // Backbranch to the top of a trace
1714 // Scroll forward through the trace from the targ_block. If we find
1715 // a loop head before another loop top, use the the loop head alignment.
1716 for (Block *b = targ_block; b != NULL; b = next(b)) {
1717 if (b->has_loop_alignment()) {
1718 break;
1719 }
1720 if (b->head()->is_Loop()) {
1721 targ_block = b;
1722 break;
1723 }
1724 }
1725
1726 first_block()->set_loop_alignment(targ_block);
1727
1728 } else {
1729 // Backbranch into the middle of a trace
1730 targ_block->set_loop_alignment(targ_block);
1731 }
1732
1733 return loop_rotated;
1734 }
1735
1736 // push blocks onto the CFG list
1737 // ensure that blocks have the correct two-way branch sense
1738 void Trace::fixup_blocks(PhaseCFG &cfg) {
1739 Block *last = last_block();
1740 for (Block *b = first_block(); b != NULL; b = next(b)) {
1741 cfg.add_block(b);
1742 if (!b->is_connector()) {
1743 int nfallthru = b->num_fall_throughs();
1744 if (b != last) {
1745 if (nfallthru == 2) {
1746 // Ensure that the sense of the branch is correct
1747 Block *bnext = next(b);
1748 Block *bs0 = b->non_connector_successor(0);
1749
1750 MachNode *iff = b->get_node(b->number_of_nodes() - 3)->as_Mach();
|
55 assert(i < _cnt, "index out of bounds");
56 Copy::conjoint_words_to_lower((HeapWord*)&_blocks[i+1], (HeapWord*)&_blocks[i], ((_cnt-i-1)*sizeof(Block*)));
57 pop(); // shrink list by one block
58 }
59
60 void Block_List::insert(uint i, Block *b) {
61 push(b); // grow list by one block
62 Copy::conjoint_words_to_higher((HeapWord*)&_blocks[i], (HeapWord*)&_blocks[i+1], ((_cnt-i-1)*sizeof(Block*)));
63 _blocks[i] = b;
64 }
65
66 #ifndef PRODUCT
67 void Block_List::print() {
68 for (uint i=0; i < size(); i++) {
69 tty->print("B%d ", _blocks[i]->_pre_order);
70 }
71 tty->print("size = %d\n", size());
72 }
73 #endif
74
75 uint Block::code_alignment() const {
76 // Check for Root block
77 if (_pre_order == 0) return CodeEntryAlignment;
78 // Check for Start block
79 if (_pre_order == 1) return InteriorEntryAlignment;
80 // Check for loop alignment
81 if (has_loop_alignment()) return loop_alignment();
82
83 return relocInfo::addr_unit(); // no particular alignment
84 }
85
86 uint Block::compute_loop_alignment() {
87 Node *h = head();
88 int unit_sz = relocInfo::addr_unit();
89 if (h->is_Loop() && h->as_Loop()->is_inner_loop()) {
90 // Pre- and post-loops have low trip count so do not bother with
91 // NOPs for align loop head. The constants are hidden from tuning
92 // but only because my "divide by 4" heuristic surely gets nearly
93 // all possible gain (a "do not align at all" heuristic has a
94 // chance of getting a really tiny gain).
95 if (h->is_CountedLoop() && (h->as_CountedLoop()->is_pre_loop() ||
1709 break_loop_after(b);
1710 }
1711 }
1712
1713 // Backbranch to the top of a trace
1714 // Scroll forward through the trace from the targ_block. If we find
1715 // a loop head before another loop top, use the the loop head alignment.
1716 for (Block *b = targ_block; b != NULL; b = next(b)) {
1717 if (b->has_loop_alignment()) {
1718 break;
1719 }
1720 if (b->head()->is_Loop()) {
1721 targ_block = b;
1722 break;
1723 }
1724 }
1725
1726 first_block()->set_loop_alignment(targ_block);
1727
1728 } else {
1729 // That loop may already have a loop top (we're reaching it again
1730 // through the backedge of an outer loop)
1731 Block* b = prev(targ_block);
1732 bool has_top = targ_block->head()->is_Loop() && b->has_loop_alignment() && !b->head()->is_Loop();
1733 if (!has_top) {
1734 // Backbranch into the middle of a trace
1735 targ_block->set_loop_alignment(targ_block);
1736 }
1737 }
1738
1739 return loop_rotated;
1740 }
1741
1742 // push blocks onto the CFG list
1743 // ensure that blocks have the correct two-way branch sense
1744 void Trace::fixup_blocks(PhaseCFG &cfg) {
1745 Block *last = last_block();
1746 for (Block *b = first_block(); b != NULL; b = next(b)) {
1747 cfg.add_block(b);
1748 if (!b->is_connector()) {
1749 int nfallthru = b->num_fall_throughs();
1750 if (b != last) {
1751 if (nfallthru == 2) {
1752 // Ensure that the sense of the branch is correct
1753 Block *bnext = next(b);
1754 Block *bs0 = b->non_connector_successor(0);
1755
1756 MachNode *iff = b->get_node(b->number_of_nodes() - 3)->as_Mach();
|