Mercurial > hg > truffle
comparison src/share/vm/opto/superword.cpp @ 8079:ad736b4683b4
8004867: VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
Summary: Added few checks and early bailout from Superword optimization to avoid such cases in a future.
Reviewed-by: roland, twisti
author | kvn |
---|---|
date | Mon, 18 Feb 2013 16:47:15 -0800 |
parents | 410afdc6a07c |
children | de6a9e811145 |
comparison
equal
deleted
inserted
replaced
8078:a2bc322ca273 | 8079:ad736b4683b4 |
---|---|
141 // | 141 // |
142 void SuperWord::SLP_extract() { | 142 void SuperWord::SLP_extract() { |
143 | 143 |
144 // Ready the block | 144 // Ready the block |
145 | 145 |
146 construct_bb(); | 146 if (!construct_bb()) |
147 return; // Exit if no interesting nodes or complex graph. | |
147 | 148 |
148 dependence_graph(); | 149 dependence_graph(); |
149 | 150 |
150 compute_max_depth(); | 151 compute_max_depth(); |
151 | 152 |
613 } | 614 } |
614 } | 615 } |
615 if (n == stop) break; | 616 if (n == stop) break; |
616 preds.push(n); | 617 preds.push(n); |
617 prev = n; | 618 prev = n; |
619 assert(n->is_Mem(), err_msg_res("unexpected node %s", n->Name())); | |
618 n = n->in(MemNode::Memory); | 620 n = n->in(MemNode::Memory); |
619 } | 621 } |
620 } | 622 } |
621 | 623 |
622 //------------------------------stmts_can_pack--------------------------- | 624 //------------------------------stmts_can_pack--------------------------- |
1576 return true; | 1578 return true; |
1577 } | 1579 } |
1578 | 1580 |
1579 //------------------------------construct_bb--------------------------- | 1581 //------------------------------construct_bb--------------------------- |
1580 // Construct reverse postorder list of block members | 1582 // Construct reverse postorder list of block members |
1581 void SuperWord::construct_bb() { | 1583 bool SuperWord::construct_bb() { |
1582 Node* entry = bb(); | 1584 Node* entry = bb(); |
1583 | 1585 |
1584 assert(_stk.length() == 0, "stk is empty"); | 1586 assert(_stk.length() == 0, "stk is empty"); |
1585 assert(_block.length() == 0, "block is empty"); | 1587 assert(_block.length() == 0, "block is empty"); |
1586 assert(_data_entry.length() == 0, "data_entry is empty"); | 1588 assert(_data_entry.length() == 0, "data_entry is empty"); |
1594 int bb_ct = 0; | 1596 int bb_ct = 0; |
1595 for (uint i = 0; i < lpt()->_body.size(); i++ ) { | 1597 for (uint i = 0; i < lpt()->_body.size(); i++ ) { |
1596 Node *n = lpt()->_body.at(i); | 1598 Node *n = lpt()->_body.at(i); |
1597 set_bb_idx(n, i); // Create a temporary map | 1599 set_bb_idx(n, i); // Create a temporary map |
1598 if (in_bb(n)) { | 1600 if (in_bb(n)) { |
1601 if (n->is_LoadStore() || n->is_MergeMem() || | |
1602 (n->is_Proj() && !n->as_Proj()->is_CFG())) { | |
1603 // Bailout if the loop has LoadStore, MergeMem or data Proj | |
1604 // nodes. Superword optimization does not work with them. | |
1605 return false; | |
1606 } | |
1599 bb_ct++; | 1607 bb_ct++; |
1600 if (!n->is_CFG()) { | 1608 if (!n->is_CFG()) { |
1601 bool found = false; | 1609 bool found = false; |
1602 for (uint j = 0; j < n->req(); j++) { | 1610 for (uint j = 0; j < n->req(); j++) { |
1603 Node* def = n->in(j); | 1611 Node* def = n->in(j); |
1618 for (DUIterator_Fast imax, i = lp()->fast_outs(imax); i < imax; i++) { | 1626 for (DUIterator_Fast imax, i = lp()->fast_outs(imax); i < imax; i++) { |
1619 Node *n = lp()->fast_out(i); | 1627 Node *n = lp()->fast_out(i); |
1620 if (in_bb(n) && (n->is_Phi() && n->bottom_type() == Type::MEMORY)) { | 1628 if (in_bb(n) && (n->is_Phi() && n->bottom_type() == Type::MEMORY)) { |
1621 Node* n_tail = n->in(LoopNode::LoopBackControl); | 1629 Node* n_tail = n->in(LoopNode::LoopBackControl); |
1622 if (n_tail != n->in(LoopNode::EntryControl)) { | 1630 if (n_tail != n->in(LoopNode::EntryControl)) { |
1631 if (!n_tail->is_Mem()) { | |
1632 assert(n_tail->is_Mem(), err_msg_res("unexpected node for memory slice: %s", n_tail->Name())); | |
1633 return false; // Bailout | |
1634 } | |
1623 _mem_slice_head.push(n); | 1635 _mem_slice_head.push(n); |
1624 _mem_slice_tail.push(n_tail); | 1636 _mem_slice_tail.push(n_tail); |
1625 } | 1637 } |
1626 } | 1638 } |
1627 } | 1639 } |
1693 tty->print(" "); _mem_slice_tail.at(m)->dump(); | 1705 tty->print(" "); _mem_slice_tail.at(m)->dump(); |
1694 } | 1706 } |
1695 } | 1707 } |
1696 #endif | 1708 #endif |
1697 assert(rpo_idx == -1 && bb_ct == _block.length(), "all block members found"); | 1709 assert(rpo_idx == -1 && bb_ct == _block.length(), "all block members found"); |
1710 return (_mem_slice_head.length() > 0) || (_data_entry.length() > 0); | |
1698 } | 1711 } |
1699 | 1712 |
1700 //------------------------------initialize_bb--------------------------- | 1713 //------------------------------initialize_bb--------------------------- |
1701 // Initialize per node info | 1714 // Initialize per node info |
1702 void SuperWord::initialize_bb() { | 1715 void SuperWord::initialize_bb() { |