12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSET_INLINE_HPP
26 #define SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSET_INLINE_HPP
27
28 #include "gc/shared/barrierSet.hpp"
29 #include "gc/shenandoah/shenandoahAsserts.hpp"
30 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
31 #include "gc/shenandoah/shenandoahCollectionSet.inline.hpp"
32 #include "gc/shenandoah/shenandoahForwarding.inline.hpp"
33 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
34 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
35 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
36 #include "gc/shenandoah/shenandoahThreadLocalData.hpp"
37 #include "memory/iterator.inline.hpp"
38 #include "oops/oop.inline.hpp"
39
40 inline oop ShenandoahBarrierSet::resolve_forwarded_not_null(oop p) {
41 return ShenandoahForwarding::get_forwardee(p);
42 }
43
44 inline oop ShenandoahBarrierSet::resolve_forwarded(oop p) {
45 if (p != NULL) {
46 return resolve_forwarded_not_null(p);
47 } else {
48 return p;
49 }
50 }
51
52 inline oop ShenandoahBarrierSet::resolve_forwarded_not_null_mutator(oop p) {
53 return ShenandoahForwarding::get_forwardee_mutator(p);
54 }
55
56 template <class T>
57 inline oop ShenandoahBarrierSet::load_reference_barrier_mutator(oop obj, T* load_addr) {
58 assert(ShenandoahLoadRefBarrier, "should be enabled");
59 shenandoah_assert_in_cset(load_addr, obj);
60
61 oop fwd = resolve_forwarded_not_null_mutator(obj);
62 if (obj == fwd) {
63 assert(_heap->is_evacuation_in_progress(),
64 "evac should be in progress");
65 ShenandoahEvacOOMScope scope;
66 fwd = _heap->evacuate_object(obj, Thread::current());
67 }
68
69 if (load_addr != NULL && fwd != obj) {
70 // Since we are here and we know the load address, update the reference.
71 ShenandoahHeap::cas_oop(fwd, load_addr, obj);
72 }
73
74 return fwd;
75 }
76
77 inline void ShenandoahBarrierSet::enqueue(oop obj) {
78 assert(_satb_mark_queue_set.is_active(), "only get here when SATB active");
79
80 // Filter marked objects before hitting the SATB queues. The same predicate would
81 // be used by SATBMQ::filter to eliminate already marked objects downstream, but
82 // filtering here helps to avoid wasteful SATB queueing work to begin with.
83 if (!_heap->requires_marking<false>(obj)) return;
84
85 ShenandoahThreadLocalData::satb_mark_queue(Thread::current()).enqueue_known_active(obj);
86 }
320 }
321 }
322
323 template <class T>
324 void ShenandoahBarrierSet::arraycopy_marking(T* src, T* dst, size_t count) {
325 assert(_heap->is_concurrent_mark_in_progress(), "only during marking");
326 T* array = ShenandoahSATBBarrier ? dst : src;
327 if (!_heap->marking_context()->allocated_after_mark_start(reinterpret_cast<HeapWord*>(array))) {
328 arraycopy_work<T, false, false, true>(array, count);
329 }
330 }
331
332 inline bool ShenandoahBarrierSet::need_bulk_update(HeapWord* ary) {
333 return ary < _heap->heap_region_containing(ary)->get_update_watermark();
334 }
335
336 template <class T>
337 void ShenandoahBarrierSet::arraycopy_evacuation(T* src, size_t count) {
338 assert(_heap->is_evacuation_in_progress(), "only during evacuation");
339 if (need_bulk_update(reinterpret_cast<HeapWord*>(src))) {
340 ShenandoahEvacOOMScope oom_evac;
341 arraycopy_work<T, true, true, false>(src, count);
342 }
343 }
344
345 template <class T>
346 void ShenandoahBarrierSet::arraycopy_update(T* src, size_t count) {
347 assert(_heap->is_update_refs_in_progress(), "only during update-refs");
348 if (need_bulk_update(reinterpret_cast<HeapWord*>(src))) {
349 arraycopy_work<T, true, false, false>(src, count);
350 }
351 }
352
353 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSET_INLINE_HPP
|
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSET_INLINE_HPP
26 #define SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSET_INLINE_HPP
27
28 #include "gc/shared/barrierSet.hpp"
29 #include "gc/shenandoah/shenandoahAsserts.hpp"
30 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
31 #include "gc/shenandoah/shenandoahCollectionSet.inline.hpp"
32 #include "gc/shenandoah/shenandoahEvacOOMHandler.inline.hpp"
33 #include "gc/shenandoah/shenandoahForwarding.inline.hpp"
34 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
35 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
36 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
37 #include "gc/shenandoah/shenandoahThreadLocalData.hpp"
38 #include "memory/iterator.inline.hpp"
39 #include "oops/oop.inline.hpp"
40
41 inline oop ShenandoahBarrierSet::resolve_forwarded_not_null(oop p) {
42 return ShenandoahForwarding::get_forwardee(p);
43 }
44
45 inline oop ShenandoahBarrierSet::resolve_forwarded(oop p) {
46 if (p != NULL) {
47 return resolve_forwarded_not_null(p);
48 } else {
49 return p;
50 }
51 }
52
53 inline oop ShenandoahBarrierSet::resolve_forwarded_not_null_mutator(oop p) {
54 return ShenandoahForwarding::get_forwardee_mutator(p);
55 }
56
57 template <class T>
58 inline oop ShenandoahBarrierSet::load_reference_barrier_mutator(oop obj, T* load_addr) {
59 assert(ShenandoahLoadRefBarrier, "should be enabled");
60 shenandoah_assert_in_cset(load_addr, obj);
61
62 oop fwd = resolve_forwarded_not_null_mutator(obj);
63 if (obj == fwd) {
64 assert(_heap->is_evacuation_in_progress(),
65 "evac should be in progress");
66 Thread* const t = Thread::current();
67 ShenandoahEvacOOMScope scope(_heap, t);
68 fwd = _heap->evacuate_object(obj, t);
69 }
70
71 if (load_addr != NULL && fwd != obj) {
72 // Since we are here and we know the load address, update the reference.
73 ShenandoahHeap::cas_oop(fwd, load_addr, obj);
74 }
75
76 return fwd;
77 }
78
79 inline void ShenandoahBarrierSet::enqueue(oop obj) {
80 assert(_satb_mark_queue_set.is_active(), "only get here when SATB active");
81
82 // Filter marked objects before hitting the SATB queues. The same predicate would
83 // be used by SATBMQ::filter to eliminate already marked objects downstream, but
84 // filtering here helps to avoid wasteful SATB queueing work to begin with.
85 if (!_heap->requires_marking<false>(obj)) return;
86
87 ShenandoahThreadLocalData::satb_mark_queue(Thread::current()).enqueue_known_active(obj);
88 }
322 }
323 }
324
325 template <class T>
326 void ShenandoahBarrierSet::arraycopy_marking(T* src, T* dst, size_t count) {
327 assert(_heap->is_concurrent_mark_in_progress(), "only during marking");
328 T* array = ShenandoahSATBBarrier ? dst : src;
329 if (!_heap->marking_context()->allocated_after_mark_start(reinterpret_cast<HeapWord*>(array))) {
330 arraycopy_work<T, false, false, true>(array, count);
331 }
332 }
333
334 inline bool ShenandoahBarrierSet::need_bulk_update(HeapWord* ary) {
335 return ary < _heap->heap_region_containing(ary)->get_update_watermark();
336 }
337
338 template <class T>
339 void ShenandoahBarrierSet::arraycopy_evacuation(T* src, size_t count) {
340 assert(_heap->is_evacuation_in_progress(), "only during evacuation");
341 if (need_bulk_update(reinterpret_cast<HeapWord*>(src))) {
342 ShenandoahEvacOOMScope oom_evac(_heap);
343 arraycopy_work<T, true, true, false>(src, count);
344 }
345 }
346
347 template <class T>
348 void ShenandoahBarrierSet::arraycopy_update(T* src, size_t count) {
349 assert(_heap->is_update_refs_in_progress(), "only during update-refs");
350 if (need_bulk_update(reinterpret_cast<HeapWord*>(src))) {
351 arraycopy_work<T, true, false, false>(src, count);
352 }
353 }
354
355 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSET_INLINE_HPP
|