1.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp Tue Nov 22 04:47:10 2011 -0500 1.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp Tue Aug 09 10:16:01 2011 -0700 1.3 @@ -39,6 +39,9 @@ 1.4 1.5 PSOldGen* ParCompactionManager::_old_gen = NULL; 1.6 ParCompactionManager** ParCompactionManager::_manager_array = NULL; 1.7 + 1.8 +RegionTaskQueue** ParCompactionManager::_region_list = NULL; 1.9 + 1.10 OopTaskQueueSet* ParCompactionManager::_stack_array = NULL; 1.11 ParCompactionManager::ObjArrayTaskQueueSet* 1.12 ParCompactionManager::_objarray_queues = NULL; 1.13 @@ -46,8 +49,14 @@ 1.14 ParMarkBitMap* ParCompactionManager::_mark_bitmap = NULL; 1.15 RegionTaskQueueSet* ParCompactionManager::_region_array = NULL; 1.16 1.17 +uint* ParCompactionManager::_recycled_stack_index = NULL; 1.18 +int ParCompactionManager::_recycled_top = -1; 1.19 +int ParCompactionManager::_recycled_bottom = -1; 1.20 + 1.21 ParCompactionManager::ParCompactionManager() : 1.22 - _action(CopyAndUpdate) { 1.23 + _action(CopyAndUpdate), 1.24 + _region_stack(NULL), 1.25 + _region_stack_index((uint)max_uintx) { 1.26 1.27 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 1.28 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); 1.29 @@ -57,7 +66,10 @@ 1.30 1.31 marking_stack()->initialize(); 1.32 _objarray_stack.initialize(); 1.33 - region_stack()->initialize(); 1.34 +} 1.35 + 1.36 +ParCompactionManager::~ParCompactionManager() { 1.37 + delete _recycled_stack_index; 1.38 } 1.39 1.40 void ParCompactionManager::initialize(ParMarkBitMap* mbm) { 1.41 @@ -72,6 +84,19 @@ 1.42 _manager_array = NEW_C_HEAP_ARRAY(ParCompactionManager*, parallel_gc_threads+1 ); 1.43 guarantee(_manager_array != NULL, "Could not allocate manager_array"); 1.44 1.45 + _region_list = NEW_C_HEAP_ARRAY(RegionTaskQueue*, 1.46 + parallel_gc_threads+1); 1.47 + guarantee(_region_list != NULL, "Could not initialize promotion manager"); 1.48 + 1.49 + _recycled_stack_index = NEW_C_HEAP_ARRAY(uint, parallel_gc_threads); 1.50 + 1.51 + // parallel_gc-threads + 1 to be consistent with the number of 1.52 + // compaction managers. 1.53 + for(uint i=0; i<parallel_gc_threads + 1; i++) { 1.54 + _region_list[i] = new RegionTaskQueue(); 1.55 + region_list(i)->initialize(); 1.56 + } 1.57 + 1.58 _stack_array = new OopTaskQueueSet(parallel_gc_threads); 1.59 guarantee(_stack_array != NULL, "Could not allocate stack_array"); 1.60 _objarray_queues = new ObjArrayTaskQueueSet(parallel_gc_threads); 1.61 @@ -85,7 +110,7 @@ 1.62 guarantee(_manager_array[i] != NULL, "Could not create ParCompactionManager"); 1.63 stack_array()->register_queue(i, _manager_array[i]->marking_stack()); 1.64 _objarray_queues->register_queue(i, &_manager_array[i]->_objarray_stack); 1.65 - region_array()->register_queue(i, _manager_array[i]->region_stack()); 1.66 + region_array()->register_queue(i, region_list(i)); 1.67 } 1.68 1.69 // The VMThread gets its own ParCompactionManager, which is not available 1.70 @@ -97,6 +122,29 @@ 1.71 "Not initialized?"); 1.72 } 1.73 1.74 +int ParCompactionManager::pop_recycled_stack_index() { 1.75 + assert(_recycled_bottom <= _recycled_top, "list is empty"); 1.76 + // Get the next available index 1.77 + if (_recycled_bottom < _recycled_top) { 1.78 + uint cur, next, last; 1.79 + do { 1.80 + cur = _recycled_bottom; 1.81 + next = cur + 1; 1.82 + last = Atomic::cmpxchg(next, &_recycled_bottom, cur); 1.83 + } while (cur != last); 1.84 + return _recycled_stack_index[next]; 1.85 + } else { 1.86 + return -1; 1.87 + } 1.88 +} 1.89 + 1.90 +void ParCompactionManager::push_recycled_stack_index(uint v) { 1.91 + // Get the next available index 1.92 + int cur = Atomic::add(1, &_recycled_top); 1.93 + _recycled_stack_index[cur] = v; 1.94 + assert(_recycled_bottom <= _recycled_top, "list top and bottom are wrong"); 1.95 +} 1.96 + 1.97 bool ParCompactionManager::should_update() { 1.98 assert(action() != NotValid, "Action is not set"); 1.99 return (action() == ParCompactionManager::Update) || 1.100 @@ -121,6 +169,15 @@ 1.101 return action() == ParCompactionManager::ResetObjects; 1.102 } 1.103 1.104 +void ParCompactionManager::region_list_push(uint list_index, 1.105 + size_t region_index) { 1.106 + region_list(list_index)->push(region_index); 1.107 +} 1.108 + 1.109 +void ParCompactionManager::verify_region_list_empty(uint list_index) { 1.110 + assert(region_list(list_index)->is_empty(), "Not empty"); 1.111 +} 1.112 + 1.113 ParCompactionManager* 1.114 ParCompactionManager::gc_thread_compaction_manager(int index) { 1.115 assert(index >= 0 && index < (int)ParallelGCThreads, "index out of range");