--- old/src/hotspot/share/opto/loopnode.cpp 2020-02-06 19:18:15.500549271 +0100 +++ new/src/hotspot/share/opto/loopnode.cpp 2020-02-06 19:18:15.329549286 +0100 @@ -40,6 +40,10 @@ #include "opto/mulnode.hpp" #include "opto/rootnode.hpp" #include "opto/superword.hpp" +#include "utilities/macros.hpp" +#if INCLUDE_SHENANDOAHGC +#include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp" +#endif //============================================================================= //------------------------------is_loop_iv------------------------------------- @@ -2716,6 +2720,9 @@ void PhaseIdealLoop::build_and_optimize(LoopOptsMode mode) { bool do_split_ifs = (mode == LoopOptsDefault || mode == LoopOptsLastRound); bool skip_loop_opts = (mode == LoopOptsNone); + bool shenandoah_opts = (mode == LoopOptsShenandoahExpand || + mode == LoopOptsShenandoahPostExpand); + ResourceMark rm; @@ -2780,7 +2787,7 @@ } // Nothing to do, so get out - bool stop_early = !C->has_loops() && !skip_loop_opts && !do_split_ifs && !_verify_me && !_verify_only; + bool stop_early = !C->has_loops() && !skip_loop_opts && !do_split_ifs && !_verify_me && !_verify_only && !shenandoah_opts; bool do_expensive_nodes = C->should_optimize_expensive_nodes(_igvn); if (stop_early && !do_expensive_nodes) { _igvn.optimize(); // Cleanup NeverBranches @@ -2859,8 +2866,9 @@ // Given early legal placement, try finding counted loops. This placement // is good enough to discover most loop invariants. - if( !_verify_me && !_verify_only ) - _ltree_root->counted_loop( this ); + if (!_verify_me && !_verify_only && !shenandoah_opts) { + _ltree_root->counted_loop(this); + } // Find latest loop placement. Find ideal loop placement. visited.Clear(); @@ -2931,6 +2939,16 @@ return; } +#if INCLUDE_SHENANDOAHGC + if (UseShenandoahGC && ((ShenandoahBarrierSetC2*) BarrierSet::barrier_set()->barrier_set_c2())->optimize_loops(this, mode, visited, nstack, worklist)) { + _igvn.optimize(); + if (C->log() != NULL) { + log_loop_tree(_ltree_root, _ltree_root, C->log()); + } + return; + } +#endif + if (ReassociateInvariants) { // Reassociate invariants and prep for split_thru_phi for (LoopTreeIterator iter(_ltree_root); !iter.done(); iter.next()) { @@ -3961,7 +3979,8 @@ } while(worklist.size() != 0 && LCA != early) { Node* s = worklist.pop(); - if (s->is_Load() || s->Opcode() == Op_SafePoint) { + if (s->is_Load() || s->is_ShenandoahBarrier() || s->Opcode() == Op_SafePoint || + (UseShenandoahGC && s->is_CallStaticJava() && s->as_CallStaticJava()->uncommon_trap_request() != 0)) { continue; } else if (s->is_MergeMem()) { for (DUIterator_Fast imax, i = s->fast_outs(imax); i < imax; i++) { @@ -4149,7 +4168,9 @@ } IdealLoopTree* loop = get_loop(least); Node* head = loop->_head; - if (head->is_OuterStripMinedLoop()) { + if (head->is_OuterStripMinedLoop() && + // Verification can't be applied to fully built strip mined loops + head->as_Loop()->outer_loop_end()->in(1)->find_int_con(-1) == 0) { Node* sfpt = head->as_Loop()->outer_safepoint(); ResourceMark rm; Unique_Node_List wq; @@ -4229,6 +4250,9 @@ case Op_HasNegatives: pinned = false; } + if (UseShenandoahGC && n->is_CMove()) { + pinned = false; + } if( pinned ) { IdealLoopTree *chosen_loop = get_loop(n->is_CFG() ? n : get_ctrl(n)); if( !chosen_loop->_child ) // Inner loop? @@ -4493,6 +4517,7 @@ } } } +#endif // Collect a R-P-O for the whole CFG. // Result list is in post-order (scan backwards for RPO) @@ -4515,7 +4540,6 @@ } } } -#endif //=============================================================================