< prev index next >

src/hotspot/share/opto/matcher.cpp

Print this page

2089         }   // if( mem_op &&
2090         mstack.push(m, Pre_Visit);
2091       }     // for(int i = ...)
2092     }
2093     else if (nstate == Alt_Post_Visit) {
2094       mstack.pop(); // Remove node from stack
2095       // We cannot remove the Cmp input from the Bool here, as the Bool may be
2096       // shared and all users of the Bool need to move the Cmp in parallel.
2097       // This leaves both the Bool and the If pointing at the Cmp.  To
2098       // prevent the Matcher from trying to Match the Cmp along both paths
2099       // BoolNode::match_edge always returns a zero.
2100 
2101       // We reorder the Op_If in a pre-order manner, so we can visit without
2102       // accidentally sharing the Cmp (the Bool and the If make 2 users).
2103       n->add_req( n->in(1)->in(1) ); // Add the Cmp next to the Bool
2104     }
2105     else if (nstate == Post_Visit) {
2106       mstack.pop(); // Remove node from stack
2107 
2108       // Now hack a few special opcodes
2109       uint opcode = n->Opcode();
2110       bool gc_handled = BarrierSet::barrier_set()->barrier_set_c2()->matcher_find_shared_post_visit(this, n, opcode);
2111       if (!gc_handled) {
2112         find_shared_post_visit(n, opcode);
2113       }
2114     }
2115     else {
2116       ShouldNotReachHere();
2117     }
2118   } // end of while (mstack.is_nonempty())
2119 }
2120 
2121 bool Matcher::find_shared_visit(MStack& mstack, Node* n, uint opcode, bool& mem_op, int& mem_addr_idx) {
2122   switch(opcode) {  // Handle some opcodes special
2123     case Op_Phi:             // Treat Phis as shared roots
2124     case Op_Parm:
2125     case Op_Proj:            // All handled specially during matching
2126     case Op_SafePointScalarObject:
2127       set_shared(n);
2128       set_dontcare(n);
2129       break;
2130     case Op_If:
2131     case Op_CountedLoopEnd:
2132       mstack.set_state(Alt_Post_Visit); // Alternative way
2133       // Convert (If (Bool (CmpX A B))) into (If (Bool) (CmpX A B)).  Helps

2798     // that a monitor exit operation contains a serializing instruction.
2799 
2800     if (xop == Op_MemBarVolatile ||
2801         xop == Op_CompareAndExchangeB ||
2802         xop == Op_CompareAndExchangeS ||
2803         xop == Op_CompareAndExchangeI ||
2804         xop == Op_CompareAndExchangeL ||
2805         xop == Op_CompareAndExchangeP ||
2806         xop == Op_CompareAndExchangeN ||
2807         xop == Op_WeakCompareAndSwapB ||
2808         xop == Op_WeakCompareAndSwapS ||
2809         xop == Op_WeakCompareAndSwapL ||
2810         xop == Op_WeakCompareAndSwapP ||
2811         xop == Op_WeakCompareAndSwapN ||
2812         xop == Op_WeakCompareAndSwapI ||
2813         xop == Op_CompareAndSwapB ||
2814         xop == Op_CompareAndSwapS ||
2815         xop == Op_CompareAndSwapL ||
2816         xop == Op_CompareAndSwapP ||
2817         xop == Op_CompareAndSwapN ||
2818         xop == Op_CompareAndSwapI ||
2819         BarrierSet::barrier_set()->barrier_set_c2()->matcher_is_store_load_barrier(x, xop)) {
2820       return true;
2821     }
2822 
2823     // Op_FastLock previously appeared in the Op_* list above.
2824     if (xop == Op_FastLock) {
2825       return true;
2826     }
2827 
2828     if (x->is_MemBar()) {
2829       // We must retain this membar if there is an upcoming volatile
2830       // load, which will be followed by acquire membar.
2831       if (xop == Op_MemBarAcquire || xop == Op_LoadFence) {
2832         return false;
2833       } else {
2834         // For other kinds of barriers, check by pretending we
2835         // are them, and seeing if we can be removed.
2836         return post_store_load_barrier(x->as_MemBar());
2837       }
2838     }
2839 

2089         }   // if( mem_op &&
2090         mstack.push(m, Pre_Visit);
2091       }     // for(int i = ...)
2092     }
2093     else if (nstate == Alt_Post_Visit) {
2094       mstack.pop(); // Remove node from stack
2095       // We cannot remove the Cmp input from the Bool here, as the Bool may be
2096       // shared and all users of the Bool need to move the Cmp in parallel.
2097       // This leaves both the Bool and the If pointing at the Cmp.  To
2098       // prevent the Matcher from trying to Match the Cmp along both paths
2099       // BoolNode::match_edge always returns a zero.
2100 
2101       // We reorder the Op_If in a pre-order manner, so we can visit without
2102       // accidentally sharing the Cmp (the Bool and the If make 2 users).
2103       n->add_req( n->in(1)->in(1) ); // Add the Cmp next to the Bool
2104     }
2105     else if (nstate == Post_Visit) {
2106       mstack.pop(); // Remove node from stack
2107 
2108       // Now hack a few special opcodes
2109       find_shared_post_visit(n, n->Opcode());




2110     }
2111     else {
2112       ShouldNotReachHere();
2113     }
2114   } // end of while (mstack.is_nonempty())
2115 }
2116 
2117 bool Matcher::find_shared_visit(MStack& mstack, Node* n, uint opcode, bool& mem_op, int& mem_addr_idx) {
2118   switch(opcode) {  // Handle some opcodes special
2119     case Op_Phi:             // Treat Phis as shared roots
2120     case Op_Parm:
2121     case Op_Proj:            // All handled specially during matching
2122     case Op_SafePointScalarObject:
2123       set_shared(n);
2124       set_dontcare(n);
2125       break;
2126     case Op_If:
2127     case Op_CountedLoopEnd:
2128       mstack.set_state(Alt_Post_Visit); // Alternative way
2129       // Convert (If (Bool (CmpX A B))) into (If (Bool) (CmpX A B)).  Helps

2794     // that a monitor exit operation contains a serializing instruction.
2795 
2796     if (xop == Op_MemBarVolatile ||
2797         xop == Op_CompareAndExchangeB ||
2798         xop == Op_CompareAndExchangeS ||
2799         xop == Op_CompareAndExchangeI ||
2800         xop == Op_CompareAndExchangeL ||
2801         xop == Op_CompareAndExchangeP ||
2802         xop == Op_CompareAndExchangeN ||
2803         xop == Op_WeakCompareAndSwapB ||
2804         xop == Op_WeakCompareAndSwapS ||
2805         xop == Op_WeakCompareAndSwapL ||
2806         xop == Op_WeakCompareAndSwapP ||
2807         xop == Op_WeakCompareAndSwapN ||
2808         xop == Op_WeakCompareAndSwapI ||
2809         xop == Op_CompareAndSwapB ||
2810         xop == Op_CompareAndSwapS ||
2811         xop == Op_CompareAndSwapL ||
2812         xop == Op_CompareAndSwapP ||
2813         xop == Op_CompareAndSwapN ||
2814         xop == Op_CompareAndSwapI) {

2815       return true;
2816     }
2817 
2818     // Op_FastLock previously appeared in the Op_* list above.
2819     if (xop == Op_FastLock) {
2820       return true;
2821     }
2822 
2823     if (x->is_MemBar()) {
2824       // We must retain this membar if there is an upcoming volatile
2825       // load, which will be followed by acquire membar.
2826       if (xop == Op_MemBarAcquire || xop == Op_LoadFence) {
2827         return false;
2828       } else {
2829         // For other kinds of barriers, check by pretending we
2830         // are them, and seeing if we can be removed.
2831         return post_store_load_barrier(x->as_MemBar());
2832       }
2833     }
2834 
< prev index next >