comparison src/share/vm/gc_implementation/g1/g1ParScanThreadState.hpp @ 20224:a2328cbebb23

8035401: Fix visibility of G1ParScanThreadState members Summary: After JDK-8035400 there were several opportunities to fix the visibility of several members of the G1ParScanThreadState class. Reviewed-by: brutisso, mgerdin
author tschatzl
date Mon, 21 Jul 2014 09:41:06 +0200
parents b0c374311c4e
children 227a9e5e4b4a
comparison
equal deleted inserted replaced
20223:b0c374311c4e 20224:a2328cbebb23
37 37
38 class HeapRegion; 38 class HeapRegion;
39 class outputStream; 39 class outputStream;
40 40
41 class G1ParScanThreadState : public StackObj { 41 class G1ParScanThreadState : public StackObj {
42 protected: 42 private:
43 G1CollectedHeap* _g1h; 43 G1CollectedHeap* _g1h;
44 RefToScanQueue* _refs; 44 RefToScanQueue* _refs;
45 DirtyCardQueue _dcq; 45 DirtyCardQueue _dcq;
46 G1SATBCardTableModRefBS* _ct_bs; 46 G1SATBCardTableModRefBS* _ct_bs;
47 G1RemSet* _g1_rem; 47 G1RemSet* _g1_rem;
96 dirty_card_queue().enqueue((jbyte*)ctbs()->byte_for_index(card_index)); 96 dirty_card_queue().enqueue((jbyte*)ctbs()->byte_for_index(card_index));
97 } 97 }
98 } 98 }
99 } 99 }
100 100
101 public: 101 public:
102 G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num, ReferenceProcessor* rp); 102 G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num, ReferenceProcessor* rp);
103 ~G1ParScanThreadState() { 103 ~G1ParScanThreadState();
104 retire_alloc_buffers(); 104
105 FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_base, mtGC);
106 }
107
108 RefToScanQueue* refs() { return _refs; }
109 ageTable* age_table() { return &_age_table; } 105 ageTable* age_table() { return &_age_table; }
110 106
111 G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose) { 107 G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose) {
112 return _alloc_buffers[purpose]; 108 return _alloc_buffers[purpose];
113 } 109 }
114 110
115 size_t alloc_buffer_waste() const { return _alloc_buffer_waste; } 111 size_t alloc_buffer_waste() const { return _alloc_buffer_waste; }
116 size_t undo_waste() const { return _undo_waste; } 112 size_t undo_waste() const { return _undo_waste; }
117 113
118 #ifdef ASSERT 114 #ifdef ASSERT
115 bool queue_is_empty() const { return _refs->is_empty(); }
116
119 bool verify_ref(narrowOop* ref) const; 117 bool verify_ref(narrowOop* ref) const;
120 bool verify_ref(oop* ref) const; 118 bool verify_ref(oop* ref) const;
121 bool verify_task(StarTask ref) const; 119 bool verify_task(StarTask ref) const;
122 #endif // ASSERT 120 #endif // ASSERT
123 121
124 template <class T> void push_on_queue(T* ref) { 122 template <class T> void push_on_queue(T* ref) {
125 assert(verify_ref(ref), "sanity"); 123 assert(verify_ref(ref), "sanity");
126 refs()->push(ref); 124 _refs->push(ref);
127 } 125 }
128 126
129 template <class T> inline void update_rs(HeapRegion* from, T* p, int tid); 127 template <class T> inline void update_rs(HeapRegion* from, T* p, int tid);
130 128
131 HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz) { 129 private:
132 HeapWord* obj = NULL; 130
133 size_t gclab_word_size = _g1h->desired_plab_sz(purpose); 131 inline HeapWord* allocate(GCAllocPurpose purpose, size_t word_sz);
134 if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) { 132 inline HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz);
135 G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose); 133 inline void undo_allocation(GCAllocPurpose purpose, HeapWord* obj, size_t word_sz);
136 add_to_alloc_buffer_waste(alloc_buf->words_remaining()); 134
137 alloc_buf->retire(false /* end_of_gc */, false /* retain */); 135 public:
138
139 HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size);
140 if (buf == NULL) return NULL; // Let caller handle allocation failure.
141 // Otherwise.
142 alloc_buf->set_word_size(gclab_word_size);
143 alloc_buf->set_buf(buf);
144
145 obj = alloc_buf->allocate(word_sz);
146 assert(obj != NULL, "buffer was definitely big enough...");
147 } else {
148 obj = _g1h->par_allocate_during_gc(purpose, word_sz);
149 }
150 return obj;
151 }
152
153 HeapWord* allocate(GCAllocPurpose purpose, size_t word_sz) {
154 HeapWord* obj = alloc_buffer(purpose)->allocate(word_sz);
155 if (obj != NULL) return obj;
156 return allocate_slow(purpose, word_sz);
157 }
158
159 void undo_allocation(GCAllocPurpose purpose, HeapWord* obj, size_t word_sz) {
160 if (alloc_buffer(purpose)->contains(obj)) {
161 assert(alloc_buffer(purpose)->contains(obj + word_sz - 1),
162 "should contain whole object");
163 alloc_buffer(purpose)->undo_allocation(obj, word_sz);
164 } else {
165 CollectedHeap::fill_with_object(obj, word_sz);
166 add_to_undo_waste(word_sz);
167 }
168 }
169 136
170 void set_evac_failure_closure(OopsInHeapRegionClosure* evac_failure_cl) { 137 void set_evac_failure_closure(OopsInHeapRegionClosure* evac_failure_cl) {
171 _evac_failure_cl = evac_failure_cl; 138 _evac_failure_cl = evac_failure_cl;
172 } 139 }
173 OopsInHeapRegionClosure* evac_failure_closure() { 140
174 return _evac_failure_cl; 141 OopsInHeapRegionClosure* evac_failure_closure() { return _evac_failure_cl; }
175 }
176 142
177 int* hash_seed() { return &_hash_seed; } 143 int* hash_seed() { return &_hash_seed; }
178 uint queue_num() { return _queue_num; } 144 uint queue_num() { return _queue_num; }
179 145
180 size_t term_attempts() const { return _term_attempts; } 146 size_t term_attempts() const { return _term_attempts; }
199 165
200 double elapsed_time() const { 166 double elapsed_time() const {
201 return os::elapsedTime() - _start; 167 return os::elapsedTime() - _start;
202 } 168 }
203 169
204 static void 170 static void print_termination_stats_hdr(outputStream* const st = gclog_or_tty);
205 print_termination_stats_hdr(outputStream* const st = gclog_or_tty); 171 void print_termination_stats(int i, outputStream* const st = gclog_or_tty) const;
206 void
207 print_termination_stats(int i, outputStream* const st = gclog_or_tty) const;
208 172
209 size_t* surviving_young_words() { 173 size_t* surviving_young_words() {
210 // We add on to hide entry 0 which accumulates surviving words for 174 // We add on to hide entry 0 which accumulates surviving words for
211 // age -1 regions (i.e. non-young ones) 175 // age -1 regions (i.e. non-young ones)
212 return _surviving_young_words; 176 return _surviving_young_words;
213 } 177 }
214 178
215 private: 179 private:
216 void retire_alloc_buffers() { 180 void retire_alloc_buffers();
217 for (int ap = 0; ap < GCAllocPurposeCount; ++ap) {
218 size_t waste = _alloc_buffers[ap]->words_remaining();
219 add_to_alloc_buffer_waste(waste);
220 _alloc_buffers[ap]->flush_stats_and_retire(_g1h->stats_for_purpose((GCAllocPurpose)ap),
221 true /* end_of_gc */,
222 false /* retain */);
223 }
224 }
225 181
226 #define G1_PARTIAL_ARRAY_MASK 0x2 182 #define G1_PARTIAL_ARRAY_MASK 0x2
227 183
228 inline bool has_partial_array_mask(oop* ref) const { 184 inline bool has_partial_array_mask(oop* ref) const {
229 return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK; 185 return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK;
252 } 208 }
253 209
254 inline void do_oop_partial_array(oop* p); 210 inline void do_oop_partial_array(oop* p);
255 211
256 // This method is applied to the fields of the objects that have just been copied. 212 // This method is applied to the fields of the objects that have just been copied.
257 template <class T> void do_oop_evac(T* p, HeapRegion* from) { 213 template <class T> inline void do_oop_evac(T* p, HeapRegion* from);
258 assert(!oopDesc::is_null(oopDesc::load_decode_heap_oop(p)), 214
259 "Reference should not be NULL here as such are never pushed to the task queue."); 215 template <class T> inline void deal_with_reference(T* ref_to_scan);
260 oop obj = oopDesc::load_decode_heap_oop_not_null(p); 216
261 217 inline void dispatch_reference(StarTask ref);
262 // Although we never intentionally push references outside of the collection 218 public:
263 // set, due to (benign) races in the claim mechanism during RSet scanning more
264 // than one thread might claim the same card. So the same card may be
265 // processed multiple times. So redo this check.
266 if (_g1h->in_cset_fast_test(obj)) {
267 oop forwardee;
268 if (obj->is_forwarded()) {
269 forwardee = obj->forwardee();
270 } else {
271 forwardee = copy_to_survivor_space(obj);
272 }
273 assert(forwardee != NULL, "forwardee should not be NULL");
274 oopDesc::encode_store_heap_oop(p, forwardee);
275 }
276
277 assert(obj != NULL, "Must be");
278 update_rs(from, p, queue_num());
279 }
280 public:
281 219
282 oop copy_to_survivor_space(oop const obj); 220 oop copy_to_survivor_space(oop const obj);
283 221
284 template <class T> inline void deal_with_reference(T* ref_to_scan);
285
286 inline void deal_with_reference(StarTask ref);
287
288 public:
289 void trim_queue(); 222 void trim_queue();
223
224 inline void steal_and_trim_queue(RefToScanQueueSet *task_queues);
290 }; 225 };
291 226
292 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP 227 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP