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