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(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(obj)) return;
86
87 ShenandoahThreadLocalData::satb_mark_queue(Thread::current()).enqueue_known_active(obj);
88 }
89
90 template <DecoratorSet decorators, typename T>
91 inline void ShenandoahBarrierSet::satb_barrier(T *field) {
92 if (HasDecorator<decorators, IS_DEST_UNINITIALIZED>::value ||
93 HasDecorator<decorators, AS_NO_KEEPALIVE>::value) {
94 return;
95 }
96 if (ShenandoahSATBBarrier && _heap->is_concurrent_mark_in_progress()) {
97 T heap_oop = RawAccess<>::oop_load(field);
98 if (!CompressedOops::is_null(heap_oop)) {
99 enqueue(CompressedOops::decode(heap_oop));
100 }
101 }
102 }
103
104 inline void ShenandoahBarrierSet::satb_enqueue(oop value) {
105 assert(value != NULL, "checked before");
106 if (ShenandoahSATBBarrier && _heap->is_concurrent_mark_in_progress()) {
107 enqueue(value);
108 }
109 }
110
111 inline void ShenandoahBarrierSet::storeval_barrier(oop obj) {
112 if (ShenandoahStoreValEnqueueBarrier && obj != NULL && _heap->is_concurrent_mark_in_progress()) {
113 enqueue(obj);
114 }
115 }
116
117 inline void ShenandoahBarrierSet::keep_alive_if_weak(DecoratorSet decorators, oop value) {
118 assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known");
119 const bool on_strong_oop_ref = (decorators & ON_STRONG_OOP_REF) != 0;
120 const bool peek = (decorators & AS_NO_KEEPALIVE) != 0;
121 if (!peek && !on_strong_oop_ref) {
122 satb_enqueue(value);
123 }
124 }
125
126 template <DecoratorSet decorators>
127 inline void ShenandoahBarrierSet::keep_alive_if_weak(oop value) {
128 assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known");
129 if (!HasDecorator<decorators, ON_STRONG_OOP_REF>::value &&
130 !HasDecorator<decorators, AS_NO_KEEPALIVE>::value) {
131 satb_enqueue(value);
132 }
133 }
134
135 template <DecoratorSet decorators, typename BarrierSetT>
136 template <typename T>
137 inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_load_not_in_heap(T* addr) {
138 oop value = Raw::oop_load_not_in_heap(addr);
139 if (value != NULL) {
140 ShenandoahBarrierSet *const bs = ShenandoahBarrierSet::barrier_set();
141 value = bs->load_reference_barrier_native(value, addr);
142 if (value != NULL) {
143 bs->keep_alive_if_weak<decorators>(value);
144 }
145 }
146 return value;
147 }
|
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(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(!CompressedOops::is_null(obj), "checked by caller");
81 assert(_satb_mark_queue_set.is_active(), "only get here when SATB active");
82
83 // Filter marked objects before hitting the SATB queues. The same predicate would
84 // be used by SATBMQ::filter to eliminate already marked objects downstream, but
85 // filtering here helps to avoid wasteful SATB queueing work to begin with.
86 if (!_heap->requires_marking(obj)) return;
87
88 ShenandoahThreadLocalData::satb_mark_queue(Thread::current()).enqueue_known_active(obj);
89 }
90
91 template <DecoratorSet decorators, typename T>
92 inline void ShenandoahBarrierSet::satb_barrier(T *field) {
93 if (HasDecorator<decorators, IS_DEST_UNINITIALIZED>::value ||
94 HasDecorator<decorators, AS_NO_KEEPALIVE>::value) {
95 return;
96 }
97 if (ShenandoahSATBBarrier && _heap->is_concurrent_mark_in_progress()) {
98 T heap_oop = RawAccess<>::oop_load(field);
99 if (!CompressedOops::is_null(heap_oop)) {
100 enqueue(CompressedOops::decode(heap_oop));
101 }
102 }
103 }
104
105 inline void ShenandoahBarrierSet::satb_enqueue(oop value) {
106 assert(value != NULL, "checked before");
107 if (ShenandoahSATBBarrier && _heap->is_concurrent_mark_in_progress()) {
108 enqueue(value);
109 }
110 }
111
112 inline void ShenandoahBarrierSet::storeval_barrier(oop obj) {
113 if (ShenandoahStoreValEnqueueBarrier && obj != NULL && _heap->is_concurrent_mark_in_progress()) {
114 enqueue(obj);
115 }
116 }
117
118 inline void ShenandoahBarrierSet::keep_alive_if_weak(DecoratorSet decorators, oop value) {
119 assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known");
120 assert(!CompressedOops::is_null(value), "checked by caller");
121 const bool on_strong_oop_ref = (decorators & ON_STRONG_OOP_REF) != 0;
122 const bool peek = (decorators & AS_NO_KEEPALIVE) != 0;
123 if (!peek && !on_strong_oop_ref) {
124 satb_enqueue(value);
125 }
126 }
127
128 template <DecoratorSet decorators>
129 inline void ShenandoahBarrierSet::keep_alive_if_weak(oop value) {
130 assert(!CompressedOops::is_null(value), "checked by caller");
131 assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known");
132 if (!HasDecorator<decorators, ON_STRONG_OOP_REF>::value &&
133 !HasDecorator<decorators, AS_NO_KEEPALIVE>::value) {
134 satb_enqueue(value);
135 }
136 }
137
138 template <DecoratorSet decorators, typename BarrierSetT>
139 template <typename T>
140 inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_load_not_in_heap(T* addr) {
141 oop value = Raw::oop_load_not_in_heap(addr);
142 if (value != NULL) {
143 ShenandoahBarrierSet *const bs = ShenandoahBarrierSet::barrier_set();
144 value = bs->load_reference_barrier_native(value, addr);
145 if (value != NULL) {
146 bs->keep_alive_if_weak<decorators>(value);
147 }
148 }
149 return value;
150 }
|