comparison src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @ 14412:e2722a66aba7

Merge
author kvn
date Thu, 05 Sep 2013 11:04:39 -0700
parents 1bb10d3170fa
children 7944aba7ba41
comparison
equal deleted inserted replaced
14411:bdd155477289 14412:e2722a66aba7
48 #include "memory/gcLocker.inline.hpp" 48 #include "memory/gcLocker.inline.hpp"
49 #include "memory/genCollectedHeap.hpp" 49 #include "memory/genCollectedHeap.hpp"
50 #include "memory/genMarkSweep.hpp" 50 #include "memory/genMarkSweep.hpp"
51 #include "memory/genOopClosures.inline.hpp" 51 #include "memory/genOopClosures.inline.hpp"
52 #include "memory/iterator.hpp" 52 #include "memory/iterator.hpp"
53 #include "memory/padded.hpp"
53 #include "memory/referencePolicy.hpp" 54 #include "memory/referencePolicy.hpp"
54 #include "memory/resourceArea.hpp" 55 #include "memory/resourceArea.hpp"
55 #include "memory/tenuredGeneration.hpp" 56 #include "memory/tenuredGeneration.hpp"
56 #include "oops/oop.inline.hpp" 57 #include "oops/oop.inline.hpp"
57 #include "prims/jvmtiExport.hpp" 58 #include "prims/jvmtiExport.hpp"
3457 } 3458 }
3458 3459
3459 void ConcurrentMarkSweepGeneration::shrink(size_t bytes) { 3460 void ConcurrentMarkSweepGeneration::shrink(size_t bytes) {
3460 assert_locked_or_safepoint(Heap_lock); 3461 assert_locked_or_safepoint(Heap_lock);
3461 size_t size = ReservedSpace::page_align_size_down(bytes); 3462 size_t size = ReservedSpace::page_align_size_down(bytes);
3462 if (size > 0) { 3463 // Only shrink if a compaction was done so that all the free space
3464 // in the generation is in a contiguous block at the end.
3465 if (size > 0 && did_compact()) {
3463 shrink_by(size); 3466 shrink_by(size);
3464 } 3467 }
3465 } 3468 }
3466 3469
3467 bool ConcurrentMarkSweepGeneration::grow_by(size_t bytes) { 3470 bool ConcurrentMarkSweepGeneration::grow_by(size_t bytes) {
5475 5478
5476 ResourceMark rm; 5479 ResourceMark rm;
5477 HandleMark hm; 5480 HandleMark hm;
5478 5481
5479 SequentialSubTasksDone* pst = space->par_seq_tasks(); 5482 SequentialSubTasksDone* pst = space->par_seq_tasks();
5480 assert(pst->valid(), "Uninitialized use?");
5481 5483
5482 uint nth_task = 0; 5484 uint nth_task = 0;
5483 uint n_tasks = pst->n_tasks(); 5485 uint n_tasks = pst->n_tasks();
5484 5486
5485 HeapWord *start, *end; 5487 if (n_tasks > 0) {
5486 while (!pst->is_task_claimed(/* reference */ nth_task)) { 5488 assert(pst->valid(), "Uninitialized use?");
5487 // We claimed task # nth_task; compute its boundaries. 5489 HeapWord *start, *end;
5488 if (chunk_top == 0) { // no samples were taken 5490 while (!pst->is_task_claimed(/* reference */ nth_task)) {
5489 assert(nth_task == 0 && n_tasks == 1, "Can have only 1 EdenSpace task"); 5491 // We claimed task # nth_task; compute its boundaries.
5490 start = space->bottom(); 5492 if (chunk_top == 0) { // no samples were taken
5491 end = space->top(); 5493 assert(nth_task == 0 && n_tasks == 1, "Can have only 1 EdenSpace task");
5492 } else if (nth_task == 0) { 5494 start = space->bottom();
5493 start = space->bottom(); 5495 end = space->top();
5494 end = chunk_array[nth_task]; 5496 } else if (nth_task == 0) {
5495 } else if (nth_task < (uint)chunk_top) { 5497 start = space->bottom();
5496 assert(nth_task >= 1, "Control point invariant"); 5498 end = chunk_array[nth_task];
5497 start = chunk_array[nth_task - 1]; 5499 } else if (nth_task < (uint)chunk_top) {
5498 end = chunk_array[nth_task]; 5500 assert(nth_task >= 1, "Control point invariant");
5499 } else { 5501 start = chunk_array[nth_task - 1];
5500 assert(nth_task == (uint)chunk_top, "Control point invariant"); 5502 end = chunk_array[nth_task];
5501 start = chunk_array[chunk_top - 1]; 5503 } else {
5502 end = space->top(); 5504 assert(nth_task == (uint)chunk_top, "Control point invariant");
5503 } 5505 start = chunk_array[chunk_top - 1];
5504 MemRegion mr(start, end); 5506 end = space->top();
5505 // Verify that mr is in space 5507 }
5506 assert(mr.is_empty() || space->used_region().contains(mr), 5508 MemRegion mr(start, end);
5507 "Should be in space"); 5509 // Verify that mr is in space
5508 // Verify that "start" is an object boundary 5510 assert(mr.is_empty() || space->used_region().contains(mr),
5509 assert(mr.is_empty() || oop(mr.start())->is_oop(), 5511 "Should be in space");
5510 "Should be an oop"); 5512 // Verify that "start" is an object boundary
5511 space->par_oop_iterate(mr, cl); 5513 assert(mr.is_empty() || oop(mr.start())->is_oop(),
5512 } 5514 "Should be an oop");
5513 pst->all_tasks_completed(); 5515 space->par_oop_iterate(mr, cl);
5516 }
5517 pst->all_tasks_completed();
5518 }
5514 } 5519 }
5515 5520
5516 void 5521 void
5517 CMSParRemarkTask::do_dirty_card_rescan_tasks( 5522 CMSParRemarkTask::do_dirty_card_rescan_tasks(
5518 CompactibleFreeListSpace* sp, int i, 5523 CompactibleFreeListSpace* sp, int i,
5785 initialize_sequential_subtasks_for_young_gen_rescan(int n_threads) { 5790 initialize_sequential_subtasks_for_young_gen_rescan(int n_threads) {
5786 assert(n_threads > 0, "Unexpected n_threads argument"); 5791 assert(n_threads > 0, "Unexpected n_threads argument");
5787 DefNewGeneration* dng = (DefNewGeneration*)_young_gen; 5792 DefNewGeneration* dng = (DefNewGeneration*)_young_gen;
5788 5793
5789 // Eden space 5794 // Eden space
5790 { 5795 if (!dng->eden()->is_empty()) {
5791 SequentialSubTasksDone* pst = dng->eden()->par_seq_tasks(); 5796 SequentialSubTasksDone* pst = dng->eden()->par_seq_tasks();
5792 assert(!pst->valid(), "Clobbering existing data?"); 5797 assert(!pst->valid(), "Clobbering existing data?");
5793 // Each valid entry in [0, _eden_chunk_index) represents a task. 5798 // Each valid entry in [0, _eden_chunk_index) represents a task.
5794 size_t n_tasks = _eden_chunk_index + 1; 5799 size_t n_tasks = _eden_chunk_index + 1;
5795 assert(n_tasks == 1 || _eden_chunk_array != NULL, "Error"); 5800 assert(n_tasks == 1 || _eden_chunk_array != NULL, "Error");
8691 // for the sweeper to step over and examine. 8696 // for the sweeper to step over and examine.
8692 void SweepClosure::lookahead_and_flush(FreeChunk* fc, size_t chunk_size) { 8697 void SweepClosure::lookahead_and_flush(FreeChunk* fc, size_t chunk_size) {
8693 assert(inFreeRange(), "Should only be called if currently in a free range."); 8698 assert(inFreeRange(), "Should only be called if currently in a free range.");
8694 HeapWord* const eob = ((HeapWord*)fc) + chunk_size; 8699 HeapWord* const eob = ((HeapWord*)fc) + chunk_size;
8695 assert(_sp->used_region().contains(eob - 1), 8700 assert(_sp->used_region().contains(eob - 1),
8696 err_msg("eob = " PTR_FORMAT " out of bounds wrt _sp = [" PTR_FORMAT "," PTR_FORMAT ")" 8701 err_msg("eob = " PTR_FORMAT " eob-1 = " PTR_FORMAT " _limit = " PTR_FORMAT
8702 " out of bounds wrt _sp = [" PTR_FORMAT "," PTR_FORMAT ")"
8697 " when examining fc = " PTR_FORMAT "(" SIZE_FORMAT ")", 8703 " when examining fc = " PTR_FORMAT "(" SIZE_FORMAT ")",
8698 _limit, _sp->bottom(), _sp->end(), fc, chunk_size)); 8704 eob, eob-1, _limit, _sp->bottom(), _sp->end(), fc, chunk_size));
8699 if (eob >= _limit) { 8705 if (eob >= _limit) {
8700 assert(eob == _limit || fc->is_free(), "Only a free chunk should allow us to cross over the limit"); 8706 assert(eob == _limit || fc->is_free(), "Only a free chunk should allow us to cross over the limit");
8701 if (CMSTraceSweeper) { 8707 if (CMSTraceSweeper) {
8702 gclog_or_tty->print_cr("_limit " PTR_FORMAT " reached or crossed by block " 8708 gclog_or_tty->print_cr("_limit " PTR_FORMAT " reached or crossed by block "
8703 "[" PTR_FORMAT "," PTR_FORMAT ") in space " 8709 "[" PTR_FORMAT "," PTR_FORMAT ") in space "