2088 } // if( mem_op &&
2089 mstack.push(m, Pre_Visit);
2090 } // for(int i = ...)
2091 }
2092 else if (nstate == Alt_Post_Visit) {
2093 mstack.pop(); // Remove node from stack
2094 // We cannot remove the Cmp input from the Bool here, as the Bool may be
2095 // shared and all users of the Bool need to move the Cmp in parallel.
2096 // This leaves both the Bool and the If pointing at the Cmp. To
2097 // prevent the Matcher from trying to Match the Cmp along both paths
2098 // BoolNode::match_edge always returns a zero.
2099
2100 // We reorder the Op_If in a pre-order manner, so we can visit without
2101 // accidentally sharing the Cmp (the Bool and the If make 2 users).
2102 n->add_req( n->in(1)->in(1) ); // Add the Cmp next to the Bool
2103 }
2104 else if (nstate == Post_Visit) {
2105 mstack.pop(); // Remove node from stack
2106
2107 // Now hack a few special opcodes
2108 uint opcode = n->Opcode();
2109 bool gc_handled = BarrierSet::barrier_set()->barrier_set_c2()->matcher_find_shared_post_visit(this, n, opcode);
2110 if (!gc_handled) {
2111 find_shared_post_visit(n, opcode);
2112 }
2113 }
2114 else {
2115 ShouldNotReachHere();
2116 }
2117 } // end of while (mstack.is_nonempty())
2118 }
2119
2120 bool Matcher::find_shared_visit(MStack& mstack, Node* n, uint opcode, bool& mem_op, int& mem_addr_idx) {
2121 switch(opcode) { // Handle some opcodes special
2122 case Op_Phi: // Treat Phis as shared roots
2123 case Op_Parm:
2124 case Op_Proj: // All handled specially during matching
2125 case Op_SafePointScalarObject:
2126 set_shared(n);
2127 set_dontcare(n);
2128 break;
2129 case Op_If:
2130 case Op_CountedLoopEnd:
2131 mstack.set_state(Alt_Post_Visit); // Alternative way
2132 // Convert (If (Bool (CmpX A B))) into (If (Bool) (CmpX A B)). Helps
2797 // that a monitor exit operation contains a serializing instruction.
2798
2799 if (xop == Op_MemBarVolatile ||
2800 xop == Op_CompareAndExchangeB ||
2801 xop == Op_CompareAndExchangeS ||
2802 xop == Op_CompareAndExchangeI ||
2803 xop == Op_CompareAndExchangeL ||
2804 xop == Op_CompareAndExchangeP ||
2805 xop == Op_CompareAndExchangeN ||
2806 xop == Op_WeakCompareAndSwapB ||
2807 xop == Op_WeakCompareAndSwapS ||
2808 xop == Op_WeakCompareAndSwapL ||
2809 xop == Op_WeakCompareAndSwapP ||
2810 xop == Op_WeakCompareAndSwapN ||
2811 xop == Op_WeakCompareAndSwapI ||
2812 xop == Op_CompareAndSwapB ||
2813 xop == Op_CompareAndSwapS ||
2814 xop == Op_CompareAndSwapL ||
2815 xop == Op_CompareAndSwapP ||
2816 xop == Op_CompareAndSwapN ||
2817 xop == Op_CompareAndSwapI ||
2818 BarrierSet::barrier_set()->barrier_set_c2()->matcher_is_store_load_barrier(x, xop)) {
2819 return true;
2820 }
2821
2822 // Op_FastLock previously appeared in the Op_* list above.
2823 if (xop == Op_FastLock) {
2824 return true;
2825 }
2826
2827 if (x->is_MemBar()) {
2828 // We must retain this membar if there is an upcoming volatile
2829 // load, which will be followed by acquire membar.
2830 if (xop == Op_MemBarAcquire || xop == Op_LoadFence) {
2831 return false;
2832 } else {
2833 // For other kinds of barriers, check by pretending we
2834 // are them, and seeing if we can be removed.
2835 return post_store_load_barrier(x->as_MemBar());
2836 }
2837 }
2838
|
2088 } // if( mem_op &&
2089 mstack.push(m, Pre_Visit);
2090 } // for(int i = ...)
2091 }
2092 else if (nstate == Alt_Post_Visit) {
2093 mstack.pop(); // Remove node from stack
2094 // We cannot remove the Cmp input from the Bool here, as the Bool may be
2095 // shared and all users of the Bool need to move the Cmp in parallel.
2096 // This leaves both the Bool and the If pointing at the Cmp. To
2097 // prevent the Matcher from trying to Match the Cmp along both paths
2098 // BoolNode::match_edge always returns a zero.
2099
2100 // We reorder the Op_If in a pre-order manner, so we can visit without
2101 // accidentally sharing the Cmp (the Bool and the If make 2 users).
2102 n->add_req( n->in(1)->in(1) ); // Add the Cmp next to the Bool
2103 }
2104 else if (nstate == Post_Visit) {
2105 mstack.pop(); // Remove node from stack
2106
2107 // Now hack a few special opcodes
2108 find_shared_post_visit(n, n->Opcode());
2109 }
2110 else {
2111 ShouldNotReachHere();
2112 }
2113 } // end of while (mstack.is_nonempty())
2114 }
2115
2116 bool Matcher::find_shared_visit(MStack& mstack, Node* n, uint opcode, bool& mem_op, int& mem_addr_idx) {
2117 switch(opcode) { // Handle some opcodes special
2118 case Op_Phi: // Treat Phis as shared roots
2119 case Op_Parm:
2120 case Op_Proj: // All handled specially during matching
2121 case Op_SafePointScalarObject:
2122 set_shared(n);
2123 set_dontcare(n);
2124 break;
2125 case Op_If:
2126 case Op_CountedLoopEnd:
2127 mstack.set_state(Alt_Post_Visit); // Alternative way
2128 // Convert (If (Bool (CmpX A B))) into (If (Bool) (CmpX A B)). Helps
2793 // that a monitor exit operation contains a serializing instruction.
2794
2795 if (xop == Op_MemBarVolatile ||
2796 xop == Op_CompareAndExchangeB ||
2797 xop == Op_CompareAndExchangeS ||
2798 xop == Op_CompareAndExchangeI ||
2799 xop == Op_CompareAndExchangeL ||
2800 xop == Op_CompareAndExchangeP ||
2801 xop == Op_CompareAndExchangeN ||
2802 xop == Op_WeakCompareAndSwapB ||
2803 xop == Op_WeakCompareAndSwapS ||
2804 xop == Op_WeakCompareAndSwapL ||
2805 xop == Op_WeakCompareAndSwapP ||
2806 xop == Op_WeakCompareAndSwapN ||
2807 xop == Op_WeakCompareAndSwapI ||
2808 xop == Op_CompareAndSwapB ||
2809 xop == Op_CompareAndSwapS ||
2810 xop == Op_CompareAndSwapL ||
2811 xop == Op_CompareAndSwapP ||
2812 xop == Op_CompareAndSwapN ||
2813 xop == Op_CompareAndSwapI) {
2814 return true;
2815 }
2816
2817 // Op_FastLock previously appeared in the Op_* list above.
2818 if (xop == Op_FastLock) {
2819 return true;
2820 }
2821
2822 if (x->is_MemBar()) {
2823 // We must retain this membar if there is an upcoming volatile
2824 // load, which will be followed by acquire membar.
2825 if (xop == Op_MemBarAcquire || xop == Op_LoadFence) {
2826 return false;
2827 } else {
2828 // For other kinds of barriers, check by pretending we
2829 // are them, and seeing if we can be removed.
2830 return post_store_load_barrier(x->as_MemBar());
2831 }
2832 }
2833
|