319 } else {
320 HeapRegion* const to_region = _g1h->heap_region_containing(obj_ptr);
321 _scanner.set_region(to_region);
322 obj->oop_iterate_backwards(&_scanner);
323 }
324 return obj;
325 } else {
326 _plab_allocator->undo_allocation(dest_state, obj_ptr, word_sz, context);
327 return forward_ptr;
328 }
329 }
330
331 G1ParScanThreadState* G1ParScanThreadStateSet::state_for_worker(uint worker_id) {
332 assert(worker_id < _n_workers, "out of bounds access");
333 if (_states[worker_id] == NULL) {
334 _states[worker_id] = new_par_scan_state(worker_id, _young_cset_length);
335 }
336 return _states[worker_id];
337 }
338
339 void G1ParScanThreadStateSet::add_cards_scanned(uint worker_id, size_t cards_scanned) {
340 assert(worker_id < _n_workers, "out of bounds access");
341 _cards_scanned[worker_id] += cards_scanned;
342 }
343
344 size_t G1ParScanThreadStateSet::total_cards_scanned() const {
345 assert(_flushed, "thread local state from the per thread states should have been flushed");
346 return _total_cards_scanned;
347 }
348
349 const size_t* G1ParScanThreadStateSet::surviving_young_words() const {
350 assert(_flushed, "thread local state from the per thread states should have been flushed");
351 return _surviving_young_words_total;
352 }
353
354 void G1ParScanThreadStateSet::flush() {
355 assert(!_flushed, "thread local state from the per thread states should be flushed once");
356 assert(_total_cards_scanned == 0, "should have been cleared");
357
358 for (uint worker_index = 0; worker_index < _n_workers; ++worker_index) {
359 G1ParScanThreadState* pss = _states[worker_index];
360
361 if (pss == NULL) {
362 continue;
363 }
364
365 _total_cards_scanned += _cards_scanned[worker_index];
366
367 pss->flush(_surviving_young_words_total);
368 delete pss;
369 _states[worker_index] = NULL;
370 }
371 _flushed = true;
372 }
373
374 oop G1ParScanThreadState::handle_evacuation_failure_par(oop old, markOop m) {
375 assert(_g1h->is_in_cset(old), "Object " PTR_FORMAT " should be in the CSet", p2i(old));
376
377 oop forward_ptr = old->forward_to_atomic(old);
378 if (forward_ptr == NULL) {
379 // Forward-to-self succeeded. We are the "owner" of the object.
380 HeapRegion* r = _g1h->heap_region_containing(old);
381
382 if (!r->evacuation_failed()) {
383 r->set_evacuation_failed(true);
384 _g1h->hr_printer()->evac_failure(r);
385 }
|
319 } else {
320 HeapRegion* const to_region = _g1h->heap_region_containing(obj_ptr);
321 _scanner.set_region(to_region);
322 obj->oop_iterate_backwards(&_scanner);
323 }
324 return obj;
325 } else {
326 _plab_allocator->undo_allocation(dest_state, obj_ptr, word_sz, context);
327 return forward_ptr;
328 }
329 }
330
331 G1ParScanThreadState* G1ParScanThreadStateSet::state_for_worker(uint worker_id) {
332 assert(worker_id < _n_workers, "out of bounds access");
333 if (_states[worker_id] == NULL) {
334 _states[worker_id] = new_par_scan_state(worker_id, _young_cset_length);
335 }
336 return _states[worker_id];
337 }
338
339 const size_t* G1ParScanThreadStateSet::surviving_young_words() const {
340 assert(_flushed, "thread local state from the per thread states should have been flushed");
341 return _surviving_young_words_total;
342 }
343
344 void G1ParScanThreadStateSet::flush() {
345 assert(!_flushed, "thread local state from the per thread states should be flushed once");
346
347 for (uint worker_index = 0; worker_index < _n_workers; ++worker_index) {
348 G1ParScanThreadState* pss = _states[worker_index];
349
350 if (pss == NULL) {
351 continue;
352 }
353
354 pss->flush(_surviving_young_words_total);
355 delete pss;
356 _states[worker_index] = NULL;
357 }
358 _flushed = true;
359 }
360
361 oop G1ParScanThreadState::handle_evacuation_failure_par(oop old, markOop m) {
362 assert(_g1h->is_in_cset(old), "Object " PTR_FORMAT " should be in the CSet", p2i(old));
363
364 oop forward_ptr = old->forward_to_atomic(old);
365 if (forward_ptr == NULL) {
366 // Forward-to-self succeeded. We are the "owner" of the object.
367 HeapRegion* r = _g1h->heap_region_containing(old);
368
369 if (!r->evacuation_failed()) {
370 r->set_evacuation_failed(true);
371 _g1h->hr_printer()->evac_failure(r);
372 }
|