Mercurial > hg > icedtea8-forest > hotspot
changeset 9573:2198ef7e1c17 jdk8u122-b01
8162496: missing precedence edge for anti_dependence
Summary: fix Implicit Null Check optimization code.
Reviewed-by: roland, aph
author | kvn |
---|---|
date | Thu, 18 Aug 2016 14:31:02 -0700 |
parents | 73ba6fb1df04 |
children | 020cb72be8b7 865c2c3bbf3d |
files | src/share/vm/opto/block.cpp src/share/vm/opto/block.hpp src/share/vm/opto/lcm.cpp |
diffstat | 3 files changed, 32 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/vm/opto/block.cpp Thu Jun 23 17:58:59 2016 +0000 +++ b/src/share/vm/opto/block.cpp Thu Aug 18 14:31:02 2016 -0700 @@ -1208,6 +1208,9 @@ if (j >= 1 && n->is_Mach() && n->as_Mach()->ideal_Opcode() == Op_CreateEx) { assert(j == 1 || block->get_node(j-1)->is_Phi(), "CreateEx must be first instruction in block"); } + if (n->needs_anti_dependence_check()) { + verify_anti_dependences(block, n); + } for (uint k = 0; k < n->req(); k++) { Node *def = n->in(k); if (def && def != n) {
--- a/src/share/vm/opto/block.hpp Thu Jun 23 17:58:59 2016 +0000 +++ b/src/share/vm/opto/block.hpp Thu Aug 18 14:31:02 2016 -0700 @@ -185,14 +185,13 @@ Block* lone_fall_through(); // Return lone fall-through Block or null Block* dom_lca(Block* that); // Compute LCA in dominator tree. -#ifdef ASSERT + bool dominates(Block* that) { int dom_diff = this->_dom_depth - that->_dom_depth; if (dom_diff > 0) return false; for (; dom_diff < 0; dom_diff++) that = that->_idom; return this == that; } -#endif // Report the alignment required by this block. Must be a power of 2. // The previous block will insert nops to get this alignment. @@ -473,9 +472,9 @@ MachNode* _goto; Block* insert_anti_dependences(Block* LCA, Node* load, bool verify = false); - void verify_anti_dependences(Block* LCA, Node* load) { + void verify_anti_dependences(Block* LCA, Node* load) const { assert(LCA == get_block_for_node(load), "should already be scheduled"); - insert_anti_dependences(LCA, load, true); + const_cast<PhaseCFG*>(this)->insert_anti_dependences(LCA, load, true); } bool move_to_next(Block* bx, uint b_index);
--- a/src/share/vm/opto/lcm.cpp Thu Jun 23 17:58:59 2016 +0000 +++ b/src/share/vm/opto/lcm.cpp Thu Aug 18 14:31:02 2016 -0700 @@ -246,6 +246,14 @@ continue; } + // Check that node's control edge is not-null block's head or dominates it, + // otherwise we can't hoist it because there are other control dependencies. + Node* ctrl = mach->in(0); + if (ctrl != NULL && !(ctrl == not_null_block->head() || + get_block_for_node(ctrl)->dominates(not_null_block))) { + continue; + } + // check if the offset is not too high for implicit exception { intptr_t offset = 0; @@ -383,9 +391,12 @@ block->add_inst(best); map_node_to_block(best, block); - // Move the control dependence - if (best->in(0) && best->in(0) == old_block->head()) - best->set_req(0, block->head()); + // Move the control dependence if it is pinned to not-null block. + // Don't change it in other cases: NULL or dominating control. + if (best->in(0) == not_null_block->head()) { + // Set it to control edge of null check. + best->set_req(0, proj->in(0)->in(0)); + } // Check for flag-killing projections that also need to be hoisted // Should be DU safe because no edge updates. @@ -441,6 +452,18 @@ latency_from_uses(nul_chk); latency_from_uses(best); + + // insert anti-dependences to defs in this block + if (! best->needs_anti_dependence_check()) { + for (uint k = 1; k < block->number_of_nodes(); k++) { + Node *n = block->get_node(k); + if (n->needs_anti_dependence_check() && + n->in(LoadNode::Memory) == best->in(StoreNode::Memory)) { + // Found anti-dependent load + insert_anti_dependences(block, n); + } + } + } }