1 /* 2 * Copyright (c) 2015, Red Hat, Inc. and/or its affiliates. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. 7 * 8 * This code is distributed in the hope that it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 * version 2 for more details (a copy is included in the LICENSE file that 12 * accompanied this code). 13 * 14 * You should have received a copy of the GNU General Public License version 15 * 2 along with this work; if not, write to the Free Software Foundation, 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 * 18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19 * or visit www.oracle.com if you need additional information or have any 20 * questions. 21 * 22 */ 23 24 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHBARRIERSET_INLINE_HPP 25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHBARRIERSET_INLINE_HPP 26 27 #include "gc/shenandoah/shenandoahBarrierSet.hpp" 28 #include "gc/shenandoah/shenandoahConnectionMatrix.hpp" 29 #include "gc/shenandoah/shenandoahHeap.inline.hpp" 30 31 inline oop ShenandoahBarrierSet::resolve_forwarded_not_null(oop p) { 32 return BrooksPointer::forwardee(p); 33 } 34 35 inline oop ShenandoahBarrierSet::resolve_forwarded(oop p) { 36 if (((HeapWord*) p) != NULL) { 37 return resolve_forwarded_not_null(p); 38 } else { 39 return p; 40 } 41 } 42 43 template <DecoratorSet decorators, typename BarrierSetT> 44 template <typename T> 45 inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_cmpxchg_in_heap(oop new_value, T* addr, oop compare_value) { 46 oop res; 47 oop expected = compare_value; 48 do { 49 compare_value = expected; 50 res = Raw::oop_atomic_cmpxchg(new_value, addr, compare_value); 51 expected = res; 52 } while ((! oopDesc::unsafe_equals(compare_value, expected)) && oopDesc::unsafe_equals(BarrierSet::barrier_set()->read_barrier(compare_value), BarrierSet::barrier_set()->read_barrier(expected))); 53 if (oopDesc::unsafe_equals(expected, compare_value)) { 54 if (ShenandoahSATBBarrier && !oopDesc::is_null(compare_value)) { 55 ShenandoahBarrierSet::enqueue(compare_value); 56 } 57 if (UseShenandoahMatrix && ! oopDesc::is_null(new_value)) { 58 ShenandoahConnectionMatrix* matrix = ShenandoahHeap::heap()->connection_matrix(); 59 matrix->set_connected(addr, new_value); 60 } 61 } 62 return res; 63 } 64 65 template <DecoratorSet decorators, typename BarrierSetT> 66 template <typename T> 67 inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_xchg_in_heap(oop new_value, T* addr) { 68 oop previous = Raw::oop_atomic_xchg(new_value, addr); 69 if (ShenandoahSATBBarrier) { 70 if (!oopDesc::is_null(previous)) { 71 ShenandoahBarrierSet::enqueue(previous); 72 } 73 } 74 if (UseShenandoahMatrix && ! oopDesc::is_null(new_value)) { 75 ShenandoahConnectionMatrix* matrix = ShenandoahHeap::heap()->connection_matrix(); 76 matrix->set_connected(addr, new_value); 77 } 78 return previous; 79 } 80 81 #endif //SHARE_VM_GC_SHENANDOAH_SHENANDOAHBARRIERSET_INLINE_HPP