4463 4464 if (!_drain_in_progress) { 4465 // prevent recursion in copy_to_survivor_space() 4466 _drain_in_progress = true; 4467 drain_evac_failure_scan_stack(); 4468 _drain_in_progress = false; 4469 } 4470 } 4471 4472 void G1CollectedHeap::preserve_mark_if_necessary(oop obj, markOop m) { 4473 assert(evacuation_failed(), "Oversaving!"); 4474 // We want to call the "for_promotion_failure" version only in the 4475 // case of a promotion failure. 4476 if (m->must_be_preserved_for_promotion_failure(obj)) { 4477 _objs_with_preserved_marks.push(obj); 4478 _preserved_marks_of_objs.push(m); 4479 } 4480 } 4481 4482 HeapWord* G1CollectedHeap::par_allocate_during_gc(GCAllocPurpose purpose, 4483 size_t word_size) { 4484 if (purpose == GCAllocForSurvived) { 4485 HeapWord* result = survivor_attempt_allocation(word_size); 4486 if (result != NULL) { 4487 return result; 4488 } else { 4489 // Let's try to allocate in the old gen in case we can fit the 4490 // object there. 4491 return old_attempt_allocation(word_size); 4492 } 4493 } else { 4494 assert(purpose == GCAllocForTenured, "sanity"); 4495 HeapWord* result = old_attempt_allocation(word_size); 4496 if (result != NULL) { 4497 return result; 4498 } else { 4499 // Let's try to allocate in the survivors in case we can fit the 4500 // object there. 4501 return survivor_attempt_allocation(word_size); 4502 } 4503 } 4504 4505 ShouldNotReachHere(); 4506 // Trying to keep some compilers happy. 4507 return NULL; 4508 } 4509 4510 G1ParGCAllocBuffer::G1ParGCAllocBuffer(size_t gclab_word_size) : 4511 ParGCAllocBuffer(gclab_word_size), _retired(true) { } 4512 4513 void G1ParCopyHelper::mark_object(oop obj) { 4514 assert(!_g1->heap_region_containing(obj)->in_collection_set(), "should not mark objects in the CSet"); 4515 4516 // We know that the object is not moving so it's safe to read its size. 4517 _cm->grayRoot(obj, (size_t) obj->size(), _worker_id); 4518 } 4519 4520 void G1ParCopyHelper::mark_forwarded_object(oop from_obj, oop to_obj) { 4521 assert(from_obj->is_forwarded(), "from obj should be forwarded"); 4522 assert(from_obj->forwardee() == to_obj, "to obj should be the forwardee"); 4523 assert(from_obj != to_obj, "should not be self-forwarded"); 4524 4525 assert(_g1->heap_region_containing(from_obj)->in_collection_set(), "from obj should be in the CSet"); 4526 assert(!_g1->heap_region_containing(to_obj)->in_collection_set(), "should not mark objects in the CSet"); 4527 | 4463 4464 if (!_drain_in_progress) { 4465 // prevent recursion in copy_to_survivor_space() 4466 _drain_in_progress = true; 4467 drain_evac_failure_scan_stack(); 4468 _drain_in_progress = false; 4469 } 4470 } 4471 4472 void G1CollectedHeap::preserve_mark_if_necessary(oop obj, markOop m) { 4473 assert(evacuation_failed(), "Oversaving!"); 4474 // We want to call the "for_promotion_failure" version only in the 4475 // case of a promotion failure. 4476 if (m->must_be_preserved_for_promotion_failure(obj)) { 4477 _objs_with_preserved_marks.push(obj); 4478 _preserved_marks_of_objs.push(m); 4479 } 4480 } 4481 4482 HeapWord* G1CollectedHeap::par_allocate_during_gc(GCAllocPurpose purpose, 4483 size_t word_size, 4484 oop const old, 4485 uint age) { 4486 4487 HeapWord* result = NULL; 4488 4489 if (purpose == GCAllocForSurvived) { 4490 result = survivor_attempt_allocation(word_size); 4491 if (result != NULL) { 4492 _g1h->_gc_tracer_stw->report_promotion_to_new_plab(old, age, false, word_size); 4493 } else { 4494 // Let's try to allocate in the old gen in case we can fit the 4495 // object there. 4496 result = old_attempt_allocation(word_size); 4497 if (result != NULL) { 4498 _g1h->_gc_tracer_stw->report_promotion_to_new_plab(old, age, true, word_size); 4499 } 4500 } 4501 } else { 4502 assert(purpose == GCAllocForTenured, "sanity"); 4503 result = old_attempt_allocation(word_size); 4504 if (result != NULL) { 4505 _g1h->_gc_tracer_stw->report_promotion_to_new_plab(old, age, true, word_size); 4506 } else { 4507 // Let's try to allocate in the survivors in case we can fit the 4508 // object there. 4509 result = survivor_attempt_allocation(word_size); 4510 if (result != NULL) { 4511 _g1h->_gc_tracer_stw->report_promotion_to_new_plab(old, age, false, word_size); 4512 } 4513 } 4514 } 4515 4516 return result; 4517 } 4518 4519 G1ParGCAllocBuffer::G1ParGCAllocBuffer(size_t gclab_word_size) : 4520 ParGCAllocBuffer(gclab_word_size), _retired(true) { } 4521 4522 void G1ParCopyHelper::mark_object(oop obj) { 4523 assert(!_g1->heap_region_containing(obj)->in_collection_set(), "should not mark objects in the CSet"); 4524 4525 // We know that the object is not moving so it's safe to read its size. 4526 _cm->grayRoot(obj, (size_t) obj->size(), _worker_id); 4527 } 4528 4529 void G1ParCopyHelper::mark_forwarded_object(oop from_obj, oop to_obj) { 4530 assert(from_obj->is_forwarded(), "from obj should be forwarded"); 4531 assert(from_obj->forwardee() == to_obj, "to obj should be the forwardee"); 4532 assert(from_obj != to_obj, "should not be self-forwarded"); 4533 4534 assert(_g1->heap_region_containing(from_obj)->in_collection_set(), "from obj should be in the CSet"); 4535 assert(!_g1->heap_region_containing(to_obj)->in_collection_set(), "should not mark objects in the CSet"); 4536 |