comparison src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp @ 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 cd43876f692e
comparison
equal deleted inserted replaced
20223:b0c374311c4e 20224:a2328cbebb23
67 _alloc_buffers[GCAllocForTenured] = &_tenured_alloc_buffer; 67 _alloc_buffers[GCAllocForTenured] = &_tenured_alloc_buffer;
68 68
69 _start = os::elapsedTime(); 69 _start = os::elapsedTime();
70 } 70 }
71 71
72 G1ParScanThreadState::~G1ParScanThreadState() {
73 retire_alloc_buffers();
74 FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_base, mtGC);
75 }
76
72 void 77 void
73 G1ParScanThreadState::print_termination_stats_hdr(outputStream* const st) 78 G1ParScanThreadState::print_termination_stats_hdr(outputStream* const st)
74 { 79 {
75 st->print_raw_cr("GC Termination Stats"); 80 st->print_raw_cr("GC Termination Stats");
76 st->print_raw_cr(" elapsed --strong roots-- -------termination-------" 81 st->print_raw_cr(" elapsed --strong roots-- -------termination-------"
137 assert(_evac_failure_cl != NULL, "not set"); 142 assert(_evac_failure_cl != NULL, "not set");
138 143
139 StarTask ref; 144 StarTask ref;
140 do { 145 do {
141 // Drain the overflow stack first, so other threads can steal. 146 // Drain the overflow stack first, so other threads can steal.
142 while (refs()->pop_overflow(ref)) { 147 while (_refs->pop_overflow(ref)) {
143 deal_with_reference(ref); 148 dispatch_reference(ref);
144 } 149 }
145 150
146 while (refs()->pop_local(ref)) { 151 while (_refs->pop_local(ref)) {
147 deal_with_reference(ref); 152 dispatch_reference(ref);
148 } 153 }
149 } while (!refs()->is_empty()); 154 } while (!_refs->is_empty());
150 } 155 }
151 156
152 oop G1ParScanThreadState::copy_to_survivor_space(oop const old) { 157 oop G1ParScanThreadState::copy_to_survivor_space(oop const old) {
153 size_t word_sz = old->size(); 158 size_t word_sz = old->size();
154 HeapRegion* from_region = _g1h->heap_region_containing_raw(old); 159 HeapRegion* from_region = _g1h->heap_region_containing_raw(old);
247 undo_allocation(alloc_purpose, obj_ptr, word_sz); 252 undo_allocation(alloc_purpose, obj_ptr, word_sz);
248 obj = forward_ptr; 253 obj = forward_ptr;
249 } 254 }
250 return obj; 255 return obj;
251 } 256 }
257
258 HeapWord* G1ParScanThreadState::allocate_slow(GCAllocPurpose purpose, size_t word_sz) {
259 HeapWord* obj = NULL;
260 size_t gclab_word_size = _g1h->desired_plab_sz(purpose);
261 if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) {
262 G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose);
263 add_to_alloc_buffer_waste(alloc_buf->words_remaining());
264 alloc_buf->retire(false /* end_of_gc */, false /* retain */);
265
266 HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size);
267 if (buf == NULL) {
268 return NULL; // Let caller handle allocation failure.
269 }
270 // Otherwise.
271 alloc_buf->set_word_size(gclab_word_size);
272 alloc_buf->set_buf(buf);
273
274 obj = alloc_buf->allocate(word_sz);
275 assert(obj != NULL, "buffer was definitely big enough...");
276 } else {
277 obj = _g1h->par_allocate_during_gc(purpose, word_sz);
278 }
279 return obj;
280 }
281
282 void G1ParScanThreadState::undo_allocation(GCAllocPurpose purpose, HeapWord* obj, size_t word_sz) {
283 if (alloc_buffer(purpose)->contains(obj)) {
284 assert(alloc_buffer(purpose)->contains(obj + word_sz - 1),
285 "should contain whole object");
286 alloc_buffer(purpose)->undo_allocation(obj, word_sz);
287 } else {
288 CollectedHeap::fill_with_object(obj, word_sz);
289 add_to_undo_waste(word_sz);
290 }
291 }
292
293 HeapWord* G1ParScanThreadState::allocate(GCAllocPurpose purpose, size_t word_sz) {
294 HeapWord* obj = alloc_buffer(purpose)->allocate(word_sz);
295 if (obj != NULL) {
296 return obj;
297 }
298 return allocate_slow(purpose, word_sz);
299 }
300
301 void G1ParScanThreadState::retire_alloc_buffers() {
302 for (int ap = 0; ap < GCAllocPurposeCount; ++ap) {
303 size_t waste = _alloc_buffers[ap]->words_remaining();
304 add_to_alloc_buffer_waste(waste);
305 _alloc_buffers[ap]->flush_stats_and_retire(_g1h->stats_for_purpose((GCAllocPurpose)ap),
306 true /* end_of_gc */,
307 false /* retain */);
308 }
309 }