6725697: par compact - rename class ChunkData to RegionData

Reviewed-by: iveresov, tonyp
This commit is contained in:
John Coomes 2008-09-30 12:20:22 -07:00
parent 2e52e9dff2
commit f2851186bb
9 changed files with 1049 additions and 1040 deletions

View file

@ -146,7 +146,7 @@ void RefProcTaskExecutor::execute(ProcessTask& task)
{ {
ParallelScavengeHeap* heap = PSParallelCompact::gc_heap(); ParallelScavengeHeap* heap = PSParallelCompact::gc_heap();
uint parallel_gc_threads = heap->gc_task_manager()->workers(); uint parallel_gc_threads = heap->gc_task_manager()->workers();
ChunkTaskQueueSet* qset = ParCompactionManager::chunk_array(); RegionTaskQueueSet* qset = ParCompactionManager::region_array();
ParallelTaskTerminator terminator(parallel_gc_threads, qset); ParallelTaskTerminator terminator(parallel_gc_threads, qset);
GCTaskQueue* q = GCTaskQueue::create(); GCTaskQueue* q = GCTaskQueue::create();
for(uint i=0; i<parallel_gc_threads; i++) { for(uint i=0; i<parallel_gc_threads; i++) {
@ -205,38 +205,38 @@ void StealMarkingTask::do_it(GCTaskManager* manager, uint which) {
} }
// //
// StealChunkCompactionTask // StealRegionCompactionTask
// //
StealChunkCompactionTask::StealChunkCompactionTask(ParallelTaskTerminator* t) : StealRegionCompactionTask::StealRegionCompactionTask(ParallelTaskTerminator* t):
_terminator(t) {}; _terminator(t) {}
void StealChunkCompactionTask::do_it(GCTaskManager* manager, uint which) { void StealRegionCompactionTask::do_it(GCTaskManager* manager, uint which) {
assert(Universe::heap()->is_gc_active(), "called outside gc"); assert(Universe::heap()->is_gc_active(), "called outside gc");
NOT_PRODUCT(TraceTime tm("StealChunkCompactionTask", NOT_PRODUCT(TraceTime tm("StealRegionCompactionTask",
PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty)); PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
ParCompactionManager* cm = ParCompactionManager* cm =
ParCompactionManager::gc_thread_compaction_manager(which); ParCompactionManager::gc_thread_compaction_manager(which);
// Has to drain stacks first because there may be chunks on // Has to drain stacks first because there may be regions on
// preloaded onto the stack and this thread may never have // preloaded onto the stack and this thread may never have
// done a draining task. Are the draining tasks needed? // done a draining task. Are the draining tasks needed?
cm->drain_chunk_stacks(); cm->drain_region_stacks();
size_t chunk_index = 0; size_t region_index = 0;
int random_seed = 17; int random_seed = 17;
// If we're the termination task, try 10 rounds of stealing before // If we're the termination task, try 10 rounds of stealing before
// setting the termination flag // setting the termination flag
while(true) { while(true) {
if (ParCompactionManager::steal(which, &random_seed, chunk_index)) { if (ParCompactionManager::steal(which, &random_seed, region_index)) {
PSParallelCompact::fill_and_update_chunk(cm, chunk_index); PSParallelCompact::fill_and_update_region(cm, region_index);
cm->drain_chunk_stacks(); cm->drain_region_stacks();
} else { } else {
if (terminator()->offer_termination()) { if (terminator()->offer_termination()) {
break; break;
@ -249,11 +249,10 @@ void StealChunkCompactionTask::do_it(GCTaskManager* manager, uint which) {
UpdateDensePrefixTask::UpdateDensePrefixTask( UpdateDensePrefixTask::UpdateDensePrefixTask(
PSParallelCompact::SpaceId space_id, PSParallelCompact::SpaceId space_id,
size_t chunk_index_start, size_t region_index_start,
size_t chunk_index_end) : size_t region_index_end) :
_space_id(space_id), _chunk_index_start(chunk_index_start), _space_id(space_id), _region_index_start(region_index_start),
_chunk_index_end(chunk_index_end) _region_index_end(region_index_end) {}
{}
void UpdateDensePrefixTask::do_it(GCTaskManager* manager, uint which) { void UpdateDensePrefixTask::do_it(GCTaskManager* manager, uint which) {
@ -265,8 +264,8 @@ void UpdateDensePrefixTask::do_it(GCTaskManager* manager, uint which) {
PSParallelCompact::update_and_deadwood_in_dense_prefix(cm, PSParallelCompact::update_and_deadwood_in_dense_prefix(cm,
_space_id, _space_id,
_chunk_index_start, _region_index_start,
_chunk_index_end); _region_index_end);
} }
void DrainStacksCompactionTask::do_it(GCTaskManager* manager, uint which) { void DrainStacksCompactionTask::do_it(GCTaskManager* manager, uint which) {
@ -278,6 +277,6 @@ void DrainStacksCompactionTask::do_it(GCTaskManager* manager, uint which) {
ParCompactionManager* cm = ParCompactionManager* cm =
ParCompactionManager::gc_thread_compaction_manager(which); ParCompactionManager::gc_thread_compaction_manager(which);
// Process any chunks already in the compaction managers stacks. // Process any regions already in the compaction managers stacks.
cm->drain_chunk_stacks(); cm->drain_region_stacks();
} }

View file

@ -188,18 +188,18 @@ class StealMarkingTask : public GCTask {
}; };
// //
// StealChunkCompactionTask // StealRegionCompactionTask
// //
// This task is used to distribute work to idle threads. // This task is used to distribute work to idle threads.
// //
class StealChunkCompactionTask : public GCTask { class StealRegionCompactionTask : public GCTask {
private: private:
ParallelTaskTerminator* const _terminator; ParallelTaskTerminator* const _terminator;
public: public:
StealChunkCompactionTask(ParallelTaskTerminator* t); StealRegionCompactionTask(ParallelTaskTerminator* t);
char* name() { return (char *)"steal-chunk-task"; } char* name() { return (char *)"steal-region-task"; }
ParallelTaskTerminator* terminator() { return _terminator; } ParallelTaskTerminator* terminator() { return _terminator; }
virtual void do_it(GCTaskManager* manager, uint which); virtual void do_it(GCTaskManager* manager, uint which);
@ -215,15 +215,15 @@ class StealChunkCompactionTask : public GCTask {
class UpdateDensePrefixTask : public GCTask { class UpdateDensePrefixTask : public GCTask {
private: private:
PSParallelCompact::SpaceId _space_id; PSParallelCompact::SpaceId _space_id;
size_t _chunk_index_start; size_t _region_index_start;
size_t _chunk_index_end; size_t _region_index_end;
public: public:
char* name() { return (char *)"update-dense_prefix-task"; } char* name() { return (char *)"update-dense_prefix-task"; }
UpdateDensePrefixTask(PSParallelCompact::SpaceId space_id, UpdateDensePrefixTask(PSParallelCompact::SpaceId space_id,
size_t chunk_index_start, size_t region_index_start,
size_t chunk_index_end); size_t region_index_end);
virtual void do_it(GCTaskManager* manager, uint which); virtual void do_it(GCTaskManager* manager, uint which);
}; };
@ -231,17 +231,17 @@ class UpdateDensePrefixTask : public GCTask {
// //
// DrainStacksCompactionTask // DrainStacksCompactionTask
// //
// This task processes chunks that have been added to the stacks of each // This task processes regions that have been added to the stacks of each
// compaction manager. // compaction manager.
// //
// Trying to use one draining thread does not work because there are no // Trying to use one draining thread does not work because there are no
// guarantees about which task will be picked up by which thread. For example, // guarantees about which task will be picked up by which thread. For example,
// if thread A gets all the preloaded chunks, thread A may not get a draining // if thread A gets all the preloaded regions, thread A may not get a draining
// task (they may all be done by other threads). // task (they may all be done by other threads).
// //
class DrainStacksCompactionTask : public GCTask { class DrainStacksCompactionTask : public GCTask {
public: public:
char* name() { return (char *)"drain-chunk-task"; } char* name() { return (char *)"drain-region-task"; }
virtual void do_it(GCTaskManager* manager, uint which); virtual void do_it(GCTaskManager* manager, uint which);
}; };

View file

@ -30,7 +30,7 @@ ParCompactionManager** ParCompactionManager::_manager_array = NULL;
OopTaskQueueSet* ParCompactionManager::_stack_array = NULL; OopTaskQueueSet* ParCompactionManager::_stack_array = NULL;
ObjectStartArray* ParCompactionManager::_start_array = NULL; ObjectStartArray* ParCompactionManager::_start_array = NULL;
ParMarkBitMap* ParCompactionManager::_mark_bitmap = NULL; ParMarkBitMap* ParCompactionManager::_mark_bitmap = NULL;
ChunkTaskQueueSet* ParCompactionManager::_chunk_array = NULL; RegionTaskQueueSet* ParCompactionManager::_region_array = NULL;
ParCompactionManager::ParCompactionManager() : ParCompactionManager::ParCompactionManager() :
_action(CopyAndUpdate) { _action(CopyAndUpdate) {
@ -46,13 +46,13 @@ ParCompactionManager::ParCompactionManager() :
// We want the overflow stack to be permanent // We want the overflow stack to be permanent
_overflow_stack = new (ResourceObj::C_HEAP) GrowableArray<oop>(10, true); _overflow_stack = new (ResourceObj::C_HEAP) GrowableArray<oop>(10, true);
#ifdef USE_ChunkTaskQueueWithOverflow #ifdef USE_RegionTaskQueueWithOverflow
chunk_stack()->initialize(); region_stack()->initialize();
#else #else
chunk_stack()->initialize(); region_stack()->initialize();
// We want the overflow stack to be permanent // We want the overflow stack to be permanent
_chunk_overflow_stack = _region_overflow_stack =
new (ResourceObj::C_HEAP) GrowableArray<size_t>(10, true); new (ResourceObj::C_HEAP) GrowableArray<size_t>(10, true);
#endif #endif
@ -86,18 +86,18 @@ void ParCompactionManager::initialize(ParMarkBitMap* mbm) {
_stack_array = new OopTaskQueueSet(parallel_gc_threads); _stack_array = new OopTaskQueueSet(parallel_gc_threads);
guarantee(_stack_array != NULL, "Count not initialize promotion manager"); guarantee(_stack_array != NULL, "Count not initialize promotion manager");
_chunk_array = new ChunkTaskQueueSet(parallel_gc_threads); _region_array = new RegionTaskQueueSet(parallel_gc_threads);
guarantee(_chunk_array != NULL, "Count not initialize promotion manager"); guarantee(_region_array != NULL, "Count not initialize promotion manager");
// Create and register the ParCompactionManager(s) for the worker threads. // Create and register the ParCompactionManager(s) for the worker threads.
for(uint i=0; i<parallel_gc_threads; i++) { for(uint i=0; i<parallel_gc_threads; i++) {
_manager_array[i] = new ParCompactionManager(); _manager_array[i] = new ParCompactionManager();
guarantee(_manager_array[i] != NULL, "Could not create ParCompactionManager"); guarantee(_manager_array[i] != NULL, "Could not create ParCompactionManager");
stack_array()->register_queue(i, _manager_array[i]->marking_stack()); stack_array()->register_queue(i, _manager_array[i]->marking_stack());
#ifdef USE_ChunkTaskQueueWithOverflow #ifdef USE_RegionTaskQueueWithOverflow
chunk_array()->register_queue(i, _manager_array[i]->chunk_stack()->task_queue()); region_array()->register_queue(i, _manager_array[i]->region_stack()->task_queue());
#else #else
chunk_array()->register_queue(i, _manager_array[i]->chunk_stack()); region_array()->register_queue(i, _manager_array[i]->region_stack());
#endif #endif
} }
@ -153,31 +153,31 @@ oop ParCompactionManager::retrieve_for_scanning() {
return NULL; return NULL;
} }
// Save chunk on a stack // Save region on a stack
void ParCompactionManager::save_for_processing(size_t chunk_index) { void ParCompactionManager::save_for_processing(size_t region_index) {
#ifdef ASSERT #ifdef ASSERT
const ParallelCompactData& sd = PSParallelCompact::summary_data(); const ParallelCompactData& sd = PSParallelCompact::summary_data();
ParallelCompactData::ChunkData* const chunk_ptr = sd.chunk(chunk_index); ParallelCompactData::RegionData* const region_ptr = sd.region(region_index);
assert(chunk_ptr->claimed(), "must be claimed"); assert(region_ptr->claimed(), "must be claimed");
assert(chunk_ptr->_pushed++ == 0, "should only be pushed once"); assert(region_ptr->_pushed++ == 0, "should only be pushed once");
#endif #endif
chunk_stack_push(chunk_index); region_stack_push(region_index);
} }
void ParCompactionManager::chunk_stack_push(size_t chunk_index) { void ParCompactionManager::region_stack_push(size_t region_index) {
#ifdef USE_ChunkTaskQueueWithOverflow #ifdef USE_RegionTaskQueueWithOverflow
chunk_stack()->save(chunk_index); region_stack()->save(region_index);
#else #else
if(!chunk_stack()->push(chunk_index)) { if(!region_stack()->push(region_index)) {
chunk_overflow_stack()->push(chunk_index); region_overflow_stack()->push(region_index);
} }
#endif #endif
} }
bool ParCompactionManager::retrieve_for_processing(size_t& chunk_index) { bool ParCompactionManager::retrieve_for_processing(size_t& region_index) {
#ifdef USE_ChunkTaskQueueWithOverflow #ifdef USE_RegionTaskQueueWithOverflow
return chunk_stack()->retrieve(chunk_index); return region_stack()->retrieve(region_index);
#else #else
// Should not be used in the parallel case // Should not be used in the parallel case
ShouldNotReachHere(); ShouldNotReachHere();
@ -230,14 +230,14 @@ void ParCompactionManager::drain_marking_stacks(OopClosure* blk) {
assert(overflow_stack()->length() == 0, "Sanity"); assert(overflow_stack()->length() == 0, "Sanity");
} }
void ParCompactionManager::drain_chunk_overflow_stack() { void ParCompactionManager::drain_region_overflow_stack() {
size_t chunk_index = (size_t) -1; size_t region_index = (size_t) -1;
while(chunk_stack()->retrieve_from_overflow(chunk_index)) { while(region_stack()->retrieve_from_overflow(region_index)) {
PSParallelCompact::fill_and_update_chunk(this, chunk_index); PSParallelCompact::fill_and_update_region(this, region_index);
} }
} }
void ParCompactionManager::drain_chunk_stacks() { void ParCompactionManager::drain_region_stacks() {
#ifdef ASSERT #ifdef ASSERT
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
@ -249,42 +249,42 @@ void ParCompactionManager::drain_chunk_stacks() {
#if 1 // def DO_PARALLEL - the serial code hasn't been updated #if 1 // def DO_PARALLEL - the serial code hasn't been updated
do { do {
#ifdef USE_ChunkTaskQueueWithOverflow #ifdef USE_RegionTaskQueueWithOverflow
// Drain overflow stack first, so other threads can steal from // Drain overflow stack first, so other threads can steal from
// claimed stack while we work. // claimed stack while we work.
size_t chunk_index = (size_t) -1; size_t region_index = (size_t) -1;
while(chunk_stack()->retrieve_from_overflow(chunk_index)) { while(region_stack()->retrieve_from_overflow(region_index)) {
PSParallelCompact::fill_and_update_chunk(this, chunk_index); PSParallelCompact::fill_and_update_region(this, region_index);
} }
while (chunk_stack()->retrieve_from_stealable_queue(chunk_index)) { while (region_stack()->retrieve_from_stealable_queue(region_index)) {
PSParallelCompact::fill_and_update_chunk(this, chunk_index); PSParallelCompact::fill_and_update_region(this, region_index);
} }
} while (!chunk_stack()->is_empty()); } while (!region_stack()->is_empty());
#else #else
// Drain overflow stack first, so other threads can steal from // Drain overflow stack first, so other threads can steal from
// claimed stack while we work. // claimed stack while we work.
while(!chunk_overflow_stack()->is_empty()) { while(!region_overflow_stack()->is_empty()) {
size_t chunk_index = chunk_overflow_stack()->pop(); size_t region_index = region_overflow_stack()->pop();
PSParallelCompact::fill_and_update_chunk(this, chunk_index); PSParallelCompact::fill_and_update_region(this, region_index);
} }
size_t chunk_index = -1; size_t region_index = -1;
// obj is a reference!!! // obj is a reference!!!
while (chunk_stack()->pop_local(chunk_index)) { while (region_stack()->pop_local(region_index)) {
// It would be nice to assert about the type of objects we might // It would be nice to assert about the type of objects we might
// pop, but they can come from anywhere, unfortunately. // pop, but they can come from anywhere, unfortunately.
PSParallelCompact::fill_and_update_chunk(this, chunk_index); PSParallelCompact::fill_and_update_region(this, region_index);
} }
} while((chunk_stack()->size() != 0) || } while((region_stack()->size() != 0) ||
(chunk_overflow_stack()->length() != 0)); (region_overflow_stack()->length() != 0));
#endif #endif
#ifdef USE_ChunkTaskQueueWithOverflow #ifdef USE_RegionTaskQueueWithOverflow
assert(chunk_stack()->is_empty(), "Sanity"); assert(region_stack()->is_empty(), "Sanity");
#else #else
assert(chunk_stack()->size() == 0, "Sanity"); assert(region_stack()->size() == 0, "Sanity");
assert(chunk_overflow_stack()->length() == 0, "Sanity"); assert(region_overflow_stack()->length() == 0, "Sanity");
#endif #endif
#else #else
oop obj; oop obj;

View file

@ -52,7 +52,7 @@ class ParCompactionManager : public CHeapObj {
friend class ParallelTaskTerminator; friend class ParallelTaskTerminator;
friend class ParMarkBitMap; friend class ParMarkBitMap;
friend class PSParallelCompact; friend class PSParallelCompact;
friend class StealChunkCompactionTask; friend class StealRegionCompactionTask;
friend class UpdateAndFillClosure; friend class UpdateAndFillClosure;
friend class RefProcTaskExecutor; friend class RefProcTaskExecutor;
@ -72,27 +72,27 @@ class ParCompactionManager : public CHeapObj {
// ------------------------ End don't putback if not needed // ------------------------ End don't putback if not needed
private: private:
static ParCompactionManager** _manager_array; static ParCompactionManager** _manager_array;
static OopTaskQueueSet* _stack_array; static OopTaskQueueSet* _stack_array;
static ObjectStartArray* _start_array; static ObjectStartArray* _start_array;
static ChunkTaskQueueSet* _chunk_array; static RegionTaskQueueSet* _region_array;
static PSOldGen* _old_gen; static PSOldGen* _old_gen;
OopTaskQueue _marking_stack; OopTaskQueue _marking_stack;
GrowableArray<oop>* _overflow_stack; GrowableArray<oop>* _overflow_stack;
// Is there a way to reuse the _marking_stack for the // Is there a way to reuse the _marking_stack for the
// saving empty chunks? For now just create a different // saving empty regions? For now just create a different
// type of TaskQueue. // type of TaskQueue.
#ifdef USE_ChunkTaskQueueWithOverflow #ifdef USE_RegionTaskQueueWithOverflow
ChunkTaskQueueWithOverflow _chunk_stack; RegionTaskQueueWithOverflow _region_stack;
#else #else
ChunkTaskQueue _chunk_stack; RegionTaskQueue _region_stack;
GrowableArray<size_t>* _chunk_overflow_stack; GrowableArray<size_t>* _region_overflow_stack;
#endif #endif
#if 1 // does this happen enough to need a per thread stack? #if 1 // does this happen enough to need a per thread stack?
GrowableArray<Klass*>* _revisit_klass_stack; GrowableArray<Klass*>* _revisit_klass_stack;
#endif #endif
static ParMarkBitMap* _mark_bitmap; static ParMarkBitMap* _mark_bitmap;
@ -100,21 +100,22 @@ class ParCompactionManager : public CHeapObj {
static PSOldGen* old_gen() { return _old_gen; } static PSOldGen* old_gen() { return _old_gen; }
static ObjectStartArray* start_array() { return _start_array; } static ObjectStartArray* start_array() { return _start_array; }
static OopTaskQueueSet* stack_array() { return _stack_array; } static OopTaskQueueSet* stack_array() { return _stack_array; }
static void initialize(ParMarkBitMap* mbm); static void initialize(ParMarkBitMap* mbm);
protected: protected:
// Array of tasks. Needed by the ParallelTaskTerminator. // Array of tasks. Needed by the ParallelTaskTerminator.
static ChunkTaskQueueSet* chunk_array() { return _chunk_array; } static RegionTaskQueueSet* region_array() { return _region_array; }
OopTaskQueue* marking_stack() { return &_marking_stack; }
OopTaskQueue* marking_stack() { return &_marking_stack; } GrowableArray<oop>* overflow_stack() { return _overflow_stack; }
GrowableArray<oop>* overflow_stack() { return _overflow_stack; } #ifdef USE_RegionTaskQueueWithOverflow
#ifdef USE_ChunkTaskQueueWithOverflow RegionTaskQueueWithOverflow* region_stack() { return &_region_stack; }
ChunkTaskQueueWithOverflow* chunk_stack() { return &_chunk_stack; }
#else #else
ChunkTaskQueue* chunk_stack() { return &_chunk_stack; } RegionTaskQueue* region_stack() { return &_region_stack; }
GrowableArray<size_t>* chunk_overflow_stack() { return _chunk_overflow_stack; } GrowableArray<size_t>* region_overflow_stack() {
return _region_overflow_stack;
}
#endif #endif
// Pushes onto the marking stack. If the marking stack is full, // Pushes onto the marking stack. If the marking stack is full,
@ -123,9 +124,9 @@ class ParCompactionManager : public CHeapObj {
// Do not implement an equivalent stack_pop. Deal with the // Do not implement an equivalent stack_pop. Deal with the
// marking stack and overflow stack directly. // marking stack and overflow stack directly.
// Pushes onto the chunk stack. If the chunk stack is full, // Pushes onto the region stack. If the region stack is full,
// pushes onto the chunk overflow stack. // pushes onto the region overflow stack.
void chunk_stack_push(size_t chunk_index); void region_stack_push(size_t region_index);
public: public:
Action action() { return _action; } Action action() { return _action; }
@ -160,10 +161,10 @@ class ParCompactionManager : public CHeapObj {
// Get a oop for scanning. If returns null, no oop were found. // Get a oop for scanning. If returns null, no oop were found.
oop retrieve_for_scanning(); oop retrieve_for_scanning();
// Save chunk for later processing. Must not fail. // Save region for later processing. Must not fail.
void save_for_processing(size_t chunk_index); void save_for_processing(size_t region_index);
// Get a chunk for processing. If returns null, no chunk were found. // Get a region for processing. If returns null, no region were found.
bool retrieve_for_processing(size_t& chunk_index); bool retrieve_for_processing(size_t& region_index);
// Access function for compaction managers // Access function for compaction managers
static ParCompactionManager* gc_thread_compaction_manager(int index); static ParCompactionManager* gc_thread_compaction_manager(int index);
@ -172,18 +173,18 @@ class ParCompactionManager : public CHeapObj {
return stack_array()->steal(queue_num, seed, t); return stack_array()->steal(queue_num, seed, t);
} }
static bool steal(int queue_num, int* seed, ChunkTask& t) { static bool steal(int queue_num, int* seed, RegionTask& t) {
return chunk_array()->steal(queue_num, seed, t); return region_array()->steal(queue_num, seed, t);
} }
// Process tasks remaining on any stack // Process tasks remaining on any stack
void drain_marking_stacks(OopClosure *blk); void drain_marking_stacks(OopClosure *blk);
// Process tasks remaining on any stack // Process tasks remaining on any stack
void drain_chunk_stacks(); void drain_region_stacks();
// Process tasks remaining on any stack // Process tasks remaining on any stack
void drain_chunk_overflow_stack(); void drain_region_overflow_stack();
// Debugging support // Debugging support
#ifdef ASSERT #ifdef ASSERT

View file

@ -76,87 +76,87 @@ class ParallelCompactData
{ {
public: public:
// Sizes are in HeapWords, unless indicated otherwise. // Sizes are in HeapWords, unless indicated otherwise.
static const size_t Log2ChunkSize; static const size_t Log2RegionSize;
static const size_t ChunkSize; static const size_t RegionSize;
static const size_t ChunkSizeBytes; static const size_t RegionSizeBytes;
// Mask for the bits in a size_t to get an offset within a chunk. // Mask for the bits in a size_t to get an offset within a region.
static const size_t ChunkSizeOffsetMask; static const size_t RegionSizeOffsetMask;
// Mask for the bits in a pointer to get an offset within a chunk. // Mask for the bits in a pointer to get an offset within a region.
static const size_t ChunkAddrOffsetMask; static const size_t RegionAddrOffsetMask;
// Mask for the bits in a pointer to get the address of the start of a chunk. // Mask for the bits in a pointer to get the address of the start of a region.
static const size_t ChunkAddrMask; static const size_t RegionAddrMask;
static const size_t Log2BlockSize; static const size_t Log2BlockSize;
static const size_t BlockSize; static const size_t BlockSize;
static const size_t BlockOffsetMask; static const size_t BlockOffsetMask;
static const size_t BlockMask; static const size_t BlockMask;
static const size_t BlocksPerChunk; static const size_t BlocksPerRegion;
class ChunkData class RegionData
{ {
public: public:
// Destination address of the chunk. // Destination address of the region.
HeapWord* destination() const { return _destination; } HeapWord* destination() const { return _destination; }
// The first chunk containing data destined for this chunk. // The first region containing data destined for this region.
size_t source_chunk() const { return _source_chunk; } size_t source_region() const { return _source_region; }
// The object (if any) starting in this chunk and ending in a different // The object (if any) starting in this region and ending in a different
// chunk that could not be updated during the main (parallel) compaction // region that could not be updated during the main (parallel) compaction
// phase. This is different from _partial_obj_addr, which is an object that // phase. This is different from _partial_obj_addr, which is an object that
// extends onto a source chunk. However, the two uses do not overlap in // extends onto a source region. However, the two uses do not overlap in
// time, so the same field is used to save space. // time, so the same field is used to save space.
HeapWord* deferred_obj_addr() const { return _partial_obj_addr; } HeapWord* deferred_obj_addr() const { return _partial_obj_addr; }
// The starting address of the partial object extending onto the chunk. // The starting address of the partial object extending onto the region.
HeapWord* partial_obj_addr() const { return _partial_obj_addr; } HeapWord* partial_obj_addr() const { return _partial_obj_addr; }
// Size of the partial object extending onto the chunk (words). // Size of the partial object extending onto the region (words).
size_t partial_obj_size() const { return _partial_obj_size; } size_t partial_obj_size() const { return _partial_obj_size; }
// Size of live data that lies within this chunk due to objects that start // Size of live data that lies within this region due to objects that start
// in this chunk (words). This does not include the partial object // in this region (words). This does not include the partial object
// extending onto the chunk (if any), or the part of an object that extends // extending onto the region (if any), or the part of an object that extends
// onto the next chunk (if any). // onto the next region (if any).
size_t live_obj_size() const { return _dc_and_los & los_mask; } size_t live_obj_size() const { return _dc_and_los & los_mask; }
// Total live data that lies within the chunk (words). // Total live data that lies within the region (words).
size_t data_size() const { return partial_obj_size() + live_obj_size(); } size_t data_size() const { return partial_obj_size() + live_obj_size(); }
// The destination_count is the number of other chunks to which data from // The destination_count is the number of other regions to which data from
// this chunk will be copied. At the end of the summary phase, the valid // this region will be copied. At the end of the summary phase, the valid
// values of destination_count are // values of destination_count are
// //
// 0 - data from the chunk will be compacted completely into itself, or the // 0 - data from the region will be compacted completely into itself, or the
// chunk is empty. The chunk can be claimed and then filled. // region is empty. The region can be claimed and then filled.
// 1 - data from the chunk will be compacted into 1 other chunk; some // 1 - data from the region will be compacted into 1 other region; some
// data from the chunk may also be compacted into the chunk itself. // data from the region may also be compacted into the region itself.
// 2 - data from the chunk will be copied to 2 other chunks. // 2 - data from the region will be copied to 2 other regions.
// //
// During compaction as chunks are emptied, the destination_count is // During compaction as regions are emptied, the destination_count is
// decremented (atomically) and when it reaches 0, it can be claimed and // decremented (atomically) and when it reaches 0, it can be claimed and
// then filled. // then filled.
// //
// A chunk is claimed for processing by atomically changing the // A region is claimed for processing by atomically changing the
// destination_count to the claimed value (dc_claimed). After a chunk has // destination_count to the claimed value (dc_claimed). After a region has
// been filled, the destination_count should be set to the completed value // been filled, the destination_count should be set to the completed value
// (dc_completed). // (dc_completed).
inline uint destination_count() const; inline uint destination_count() const;
inline uint destination_count_raw() const; inline uint destination_count_raw() const;
// The location of the java heap data that corresponds to this chunk. // The location of the java heap data that corresponds to this region.
inline HeapWord* data_location() const; inline HeapWord* data_location() const;
// The highest address referenced by objects in this chunk. // The highest address referenced by objects in this region.
inline HeapWord* highest_ref() const; inline HeapWord* highest_ref() const;
// Whether this chunk is available to be claimed, has been claimed, or has // Whether this region is available to be claimed, has been claimed, or has
// been completed. // been completed.
// //
// Minor subtlety: claimed() returns true if the chunk is marked // Minor subtlety: claimed() returns true if the region is marked
// completed(), which is desirable since a chunk must be claimed before it // completed(), which is desirable since a region must be claimed before it
// can be completed. // can be completed.
bool available() const { return _dc_and_los < dc_one; } bool available() const { return _dc_and_los < dc_one; }
bool claimed() const { return _dc_and_los >= dc_claimed; } bool claimed() const { return _dc_and_los >= dc_claimed; }
@ -164,11 +164,11 @@ public:
// These are not atomic. // These are not atomic.
void set_destination(HeapWord* addr) { _destination = addr; } void set_destination(HeapWord* addr) { _destination = addr; }
void set_source_chunk(size_t chunk) { _source_chunk = chunk; } void set_source_region(size_t region) { _source_region = region; }
void set_deferred_obj_addr(HeapWord* addr) { _partial_obj_addr = addr; } void set_deferred_obj_addr(HeapWord* addr) { _partial_obj_addr = addr; }
void set_partial_obj_addr(HeapWord* addr) { _partial_obj_addr = addr; } void set_partial_obj_addr(HeapWord* addr) { _partial_obj_addr = addr; }
void set_partial_obj_size(size_t words) { void set_partial_obj_size(size_t words) {
_partial_obj_size = (chunk_sz_t) words; _partial_obj_size = (region_sz_t) words;
} }
inline void set_destination_count(uint count); inline void set_destination_count(uint count);
@ -184,44 +184,44 @@ public:
inline bool claim(); inline bool claim();
private: private:
// The type used to represent object sizes within a chunk. // The type used to represent object sizes within a region.
typedef uint chunk_sz_t; typedef uint region_sz_t;
// Constants for manipulating the _dc_and_los field, which holds both the // Constants for manipulating the _dc_and_los field, which holds both the
// destination count and live obj size. The live obj size lives at the // destination count and live obj size. The live obj size lives at the
// least significant end so no masking is necessary when adding. // least significant end so no masking is necessary when adding.
static const chunk_sz_t dc_shift; // Shift amount. static const region_sz_t dc_shift; // Shift amount.
static const chunk_sz_t dc_mask; // Mask for destination count. static const region_sz_t dc_mask; // Mask for destination count.
static const chunk_sz_t dc_one; // 1, shifted appropriately. static const region_sz_t dc_one; // 1, shifted appropriately.
static const chunk_sz_t dc_claimed; // Chunk has been claimed. static const region_sz_t dc_claimed; // Region has been claimed.
static const chunk_sz_t dc_completed; // Chunk has been completed. static const region_sz_t dc_completed; // Region has been completed.
static const chunk_sz_t los_mask; // Mask for live obj size. static const region_sz_t los_mask; // Mask for live obj size.
HeapWord* _destination; HeapWord* _destination;
size_t _source_chunk; size_t _source_region;
HeapWord* _partial_obj_addr; HeapWord* _partial_obj_addr;
chunk_sz_t _partial_obj_size; region_sz_t _partial_obj_size;
chunk_sz_t volatile _dc_and_los; region_sz_t volatile _dc_and_los;
#ifdef ASSERT #ifdef ASSERT
// These enable optimizations that are only partially implemented. Use // These enable optimizations that are only partially implemented. Use
// debug builds to prevent the code fragments from breaking. // debug builds to prevent the code fragments from breaking.
HeapWord* _data_location; HeapWord* _data_location;
HeapWord* _highest_ref; HeapWord* _highest_ref;
#endif // #ifdef ASSERT #endif // #ifdef ASSERT
#ifdef ASSERT #ifdef ASSERT
public: public:
uint _pushed; // 0 until chunk is pushed onto a worker's stack uint _pushed; // 0 until region is pushed onto a worker's stack
private: private:
#endif #endif
}; };
// 'Blocks' allow shorter sections of the bitmap to be searched. Each Block // 'Blocks' allow shorter sections of the bitmap to be searched. Each Block
// holds an offset, which is the amount of live data in the Chunk to the left // holds an offset, which is the amount of live data in the Region to the left
// of the first live object in the Block. This amount of live data will // of the first live object in the Block. This amount of live data will
// include any object extending into the block. The first block in // include any object extending into the block. The first block in
// a chunk does not include any partial object extending into the // a region does not include any partial object extending into the
// the chunk. // the region.
// //
// The offset also encodes the // The offset also encodes the
// 'parity' of the first 1 bit in the Block: a positive offset means the // 'parity' of the first 1 bit in the Block: a positive offset means the
@ -286,27 +286,27 @@ public:
ParallelCompactData(); ParallelCompactData();
bool initialize(MemRegion covered_region); bool initialize(MemRegion covered_region);
size_t chunk_count() const { return _chunk_count; } size_t region_count() const { return _region_count; }
// Convert chunk indices to/from ChunkData pointers. // Convert region indices to/from RegionData pointers.
inline ChunkData* chunk(size_t chunk_idx) const; inline RegionData* region(size_t region_idx) const;
inline size_t chunk(const ChunkData* const chunk_ptr) const; inline size_t region(const RegionData* const region_ptr) const;
// Returns true if the given address is contained within the chunk // Returns true if the given address is contained within the region
bool chunk_contains(size_t chunk_index, HeapWord* addr); bool region_contains(size_t region_index, HeapWord* addr);
size_t block_count() const { return _block_count; } size_t block_count() const { return _block_count; }
inline BlockData* block(size_t n) const; inline BlockData* block(size_t n) const;
// Returns true if the given block is in the given chunk. // Returns true if the given block is in the given region.
static bool chunk_contains_block(size_t chunk_index, size_t block_index); static bool region_contains_block(size_t region_index, size_t block_index);
void add_obj(HeapWord* addr, size_t len); void add_obj(HeapWord* addr, size_t len);
void add_obj(oop p, size_t len) { add_obj((HeapWord*)p, len); } void add_obj(oop p, size_t len) { add_obj((HeapWord*)p, len); }
// Fill in the chunks covering [beg, end) so that no data moves; i.e., the // Fill in the regions covering [beg, end) so that no data moves; i.e., the
// destination of chunk n is simply the start of chunk n. The argument beg // destination of region n is simply the start of region n. The argument beg
// must be chunk-aligned; end need not be. // must be region-aligned; end need not be.
void summarize_dense_prefix(HeapWord* beg, HeapWord* end); void summarize_dense_prefix(HeapWord* beg, HeapWord* end);
bool summarize(HeapWord* target_beg, HeapWord* target_end, bool summarize(HeapWord* target_beg, HeapWord* target_end,
@ -314,27 +314,27 @@ public:
HeapWord** target_next, HeapWord** source_next = 0); HeapWord** target_next, HeapWord** source_next = 0);
void clear(); void clear();
void clear_range(size_t beg_chunk, size_t end_chunk); void clear_range(size_t beg_region, size_t end_region);
void clear_range(HeapWord* beg, HeapWord* end) { void clear_range(HeapWord* beg, HeapWord* end) {
clear_range(addr_to_chunk_idx(beg), addr_to_chunk_idx(end)); clear_range(addr_to_region_idx(beg), addr_to_region_idx(end));
} }
// Return the number of words between addr and the start of the chunk // Return the number of words between addr and the start of the region
// containing addr. // containing addr.
inline size_t chunk_offset(const HeapWord* addr) const; inline size_t region_offset(const HeapWord* addr) const;
// Convert addresses to/from a chunk index or chunk pointer. // Convert addresses to/from a region index or region pointer.
inline size_t addr_to_chunk_idx(const HeapWord* addr) const; inline size_t addr_to_region_idx(const HeapWord* addr) const;
inline ChunkData* addr_to_chunk_ptr(const HeapWord* addr) const; inline RegionData* addr_to_region_ptr(const HeapWord* addr) const;
inline HeapWord* chunk_to_addr(size_t chunk) const; inline HeapWord* region_to_addr(size_t region) const;
inline HeapWord* chunk_to_addr(size_t chunk, size_t offset) const; inline HeapWord* region_to_addr(size_t region, size_t offset) const;
inline HeapWord* chunk_to_addr(const ChunkData* chunk) const; inline HeapWord* region_to_addr(const RegionData* region) const;
inline HeapWord* chunk_align_down(HeapWord* addr) const; inline HeapWord* region_align_down(HeapWord* addr) const;
inline HeapWord* chunk_align_up(HeapWord* addr) const; inline HeapWord* region_align_up(HeapWord* addr) const;
inline bool is_chunk_aligned(HeapWord* addr) const; inline bool is_region_aligned(HeapWord* addr) const;
// Analogous to chunk_offset() for blocks. // Analogous to region_offset() for blocks.
size_t block_offset(const HeapWord* addr) const; size_t block_offset(const HeapWord* addr) const;
size_t addr_to_block_idx(const HeapWord* addr) const; size_t addr_to_block_idx(const HeapWord* addr) const;
size_t addr_to_block_idx(const oop obj) const { size_t addr_to_block_idx(const oop obj) const {
@ -344,7 +344,7 @@ public:
inline HeapWord* block_to_addr(size_t block) const; inline HeapWord* block_to_addr(size_t block) const;
// Return the address one past the end of the partial object. // Return the address one past the end of the partial object.
HeapWord* partial_obj_end(size_t chunk_idx) const; HeapWord* partial_obj_end(size_t region_idx) const;
// Return the new location of the object p after the // Return the new location of the object p after the
// the compaction. // the compaction.
@ -353,8 +353,8 @@ public:
// Same as calc_new_pointer() using blocks. // Same as calc_new_pointer() using blocks.
HeapWord* block_calc_new_pointer(HeapWord* addr); HeapWord* block_calc_new_pointer(HeapWord* addr);
// Same as calc_new_pointer() using chunks. // Same as calc_new_pointer() using regions.
HeapWord* chunk_calc_new_pointer(HeapWord* addr); HeapWord* region_calc_new_pointer(HeapWord* addr);
HeapWord* calc_new_pointer(oop p) { HeapWord* calc_new_pointer(oop p) {
return calc_new_pointer((HeapWord*) p); return calc_new_pointer((HeapWord*) p);
@ -364,7 +364,7 @@ public:
klassOop calc_new_klass(klassOop); klassOop calc_new_klass(klassOop);
// Given a block returns true if the partial object for the // Given a block returns true if the partial object for the
// corresponding chunk ends in the block. Returns false, otherwise // corresponding region ends in the block. Returns false, otherwise
// If there is no partial object, returns false. // If there is no partial object, returns false.
bool partial_obj_ends_in_block(size_t block_index); bool partial_obj_ends_in_block(size_t block_index);
@ -378,7 +378,7 @@ public:
private: private:
bool initialize_block_data(size_t region_size); bool initialize_block_data(size_t region_size);
bool initialize_chunk_data(size_t region_size); bool initialize_region_data(size_t region_size);
PSVirtualSpace* create_vspace(size_t count, size_t element_size); PSVirtualSpace* create_vspace(size_t count, size_t element_size);
private: private:
@ -387,9 +387,9 @@ private:
HeapWord* _region_end; HeapWord* _region_end;
#endif // #ifdef ASSERT #endif // #ifdef ASSERT
PSVirtualSpace* _chunk_vspace; PSVirtualSpace* _region_vspace;
ChunkData* _chunk_data; RegionData* _region_data;
size_t _chunk_count; size_t _region_count;
PSVirtualSpace* _block_vspace; PSVirtualSpace* _block_vspace;
BlockData* _block_data; BlockData* _block_data;
@ -397,64 +397,64 @@ private:
}; };
inline uint inline uint
ParallelCompactData::ChunkData::destination_count_raw() const ParallelCompactData::RegionData::destination_count_raw() const
{ {
return _dc_and_los & dc_mask; return _dc_and_los & dc_mask;
} }
inline uint inline uint
ParallelCompactData::ChunkData::destination_count() const ParallelCompactData::RegionData::destination_count() const
{ {
return destination_count_raw() >> dc_shift; return destination_count_raw() >> dc_shift;
} }
inline void inline void
ParallelCompactData::ChunkData::set_destination_count(uint count) ParallelCompactData::RegionData::set_destination_count(uint count)
{ {
assert(count <= (dc_completed >> dc_shift), "count too large"); assert(count <= (dc_completed >> dc_shift), "count too large");
const chunk_sz_t live_sz = (chunk_sz_t) live_obj_size(); const region_sz_t live_sz = (region_sz_t) live_obj_size();
_dc_and_los = (count << dc_shift) | live_sz; _dc_and_los = (count << dc_shift) | live_sz;
} }
inline void ParallelCompactData::ChunkData::set_live_obj_size(size_t words) inline void ParallelCompactData::RegionData::set_live_obj_size(size_t words)
{ {
assert(words <= los_mask, "would overflow"); assert(words <= los_mask, "would overflow");
_dc_and_los = destination_count_raw() | (chunk_sz_t)words; _dc_and_los = destination_count_raw() | (region_sz_t)words;
} }
inline void ParallelCompactData::ChunkData::decrement_destination_count() inline void ParallelCompactData::RegionData::decrement_destination_count()
{ {
assert(_dc_and_los < dc_claimed, "already claimed"); assert(_dc_and_los < dc_claimed, "already claimed");
assert(_dc_and_los >= dc_one, "count would go negative"); assert(_dc_and_los >= dc_one, "count would go negative");
Atomic::add((int)dc_mask, (volatile int*)&_dc_and_los); Atomic::add((int)dc_mask, (volatile int*)&_dc_and_los);
} }
inline HeapWord* ParallelCompactData::ChunkData::data_location() const inline HeapWord* ParallelCompactData::RegionData::data_location() const
{ {
DEBUG_ONLY(return _data_location;) DEBUG_ONLY(return _data_location;)
NOT_DEBUG(return NULL;) NOT_DEBUG(return NULL;)
} }
inline HeapWord* ParallelCompactData::ChunkData::highest_ref() const inline HeapWord* ParallelCompactData::RegionData::highest_ref() const
{ {
DEBUG_ONLY(return _highest_ref;) DEBUG_ONLY(return _highest_ref;)
NOT_DEBUG(return NULL;) NOT_DEBUG(return NULL;)
} }
inline void ParallelCompactData::ChunkData::set_data_location(HeapWord* addr) inline void ParallelCompactData::RegionData::set_data_location(HeapWord* addr)
{ {
DEBUG_ONLY(_data_location = addr;) DEBUG_ONLY(_data_location = addr;)
} }
inline void ParallelCompactData::ChunkData::set_completed() inline void ParallelCompactData::RegionData::set_completed()
{ {
assert(claimed(), "must be claimed first"); assert(claimed(), "must be claimed first");
_dc_and_los = dc_completed | (chunk_sz_t) live_obj_size(); _dc_and_los = dc_completed | (region_sz_t) live_obj_size();
} }
// MT-unsafe claiming of a chunk. Should only be used during single threaded // MT-unsafe claiming of a region. Should only be used during single threaded
// execution. // execution.
inline bool ParallelCompactData::ChunkData::claim_unsafe() inline bool ParallelCompactData::RegionData::claim_unsafe()
{ {
if (available()) { if (available()) {
_dc_and_los |= dc_claimed; _dc_and_los |= dc_claimed;
@ -463,13 +463,13 @@ inline bool ParallelCompactData::ChunkData::claim_unsafe()
return false; return false;
} }
inline void ParallelCompactData::ChunkData::add_live_obj(size_t words) inline void ParallelCompactData::RegionData::add_live_obj(size_t words)
{ {
assert(words <= (size_t)los_mask - live_obj_size(), "overflow"); assert(words <= (size_t)los_mask - live_obj_size(), "overflow");
Atomic::add((int) words, (volatile int*) &_dc_and_los); Atomic::add((int) words, (volatile int*) &_dc_and_los);
} }
inline void ParallelCompactData::ChunkData::set_highest_ref(HeapWord* addr) inline void ParallelCompactData::RegionData::set_highest_ref(HeapWord* addr)
{ {
#ifdef ASSERT #ifdef ASSERT
HeapWord* tmp = _highest_ref; HeapWord* tmp = _highest_ref;
@ -479,7 +479,7 @@ inline void ParallelCompactData::ChunkData::set_highest_ref(HeapWord* addr)
#endif // #ifdef ASSERT #endif // #ifdef ASSERT
} }
inline bool ParallelCompactData::ChunkData::claim() inline bool ParallelCompactData::RegionData::claim()
{ {
const int los = (int) live_obj_size(); const int los = (int) live_obj_size();
const int old = Atomic::cmpxchg(dc_claimed | los, const int old = Atomic::cmpxchg(dc_claimed | los,
@ -487,19 +487,19 @@ inline bool ParallelCompactData::ChunkData::claim()
return old == los; return old == los;
} }
inline ParallelCompactData::ChunkData* inline ParallelCompactData::RegionData*
ParallelCompactData::chunk(size_t chunk_idx) const ParallelCompactData::region(size_t region_idx) const
{ {
assert(chunk_idx <= chunk_count(), "bad arg"); assert(region_idx <= region_count(), "bad arg");
return _chunk_data + chunk_idx; return _region_data + region_idx;
} }
inline size_t inline size_t
ParallelCompactData::chunk(const ChunkData* const chunk_ptr) const ParallelCompactData::region(const RegionData* const region_ptr) const
{ {
assert(chunk_ptr >= _chunk_data, "bad arg"); assert(region_ptr >= _region_data, "bad arg");
assert(chunk_ptr <= _chunk_data + chunk_count(), "bad arg"); assert(region_ptr <= _region_data + region_count(), "bad arg");
return pointer_delta(chunk_ptr, _chunk_data, sizeof(ChunkData)); return pointer_delta(region_ptr, _region_data, sizeof(RegionData));
} }
inline ParallelCompactData::BlockData* inline ParallelCompactData::BlockData*
@ -509,68 +509,69 @@ ParallelCompactData::block(size_t n) const {
} }
inline size_t inline size_t
ParallelCompactData::chunk_offset(const HeapWord* addr) const ParallelCompactData::region_offset(const HeapWord* addr) const
{ {
assert(addr >= _region_start, "bad addr"); assert(addr >= _region_start, "bad addr");
assert(addr <= _region_end, "bad addr"); assert(addr <= _region_end, "bad addr");
return (size_t(addr) & ChunkAddrOffsetMask) >> LogHeapWordSize; return (size_t(addr) & RegionAddrOffsetMask) >> LogHeapWordSize;
} }
inline size_t inline size_t
ParallelCompactData::addr_to_chunk_idx(const HeapWord* addr) const ParallelCompactData::addr_to_region_idx(const HeapWord* addr) const
{ {
assert(addr >= _region_start, "bad addr"); assert(addr >= _region_start, "bad addr");
assert(addr <= _region_end, "bad addr"); assert(addr <= _region_end, "bad addr");
return pointer_delta(addr, _region_start) >> Log2ChunkSize; return pointer_delta(addr, _region_start) >> Log2RegionSize;
} }
inline ParallelCompactData::ChunkData* inline ParallelCompactData::RegionData*
ParallelCompactData::addr_to_chunk_ptr(const HeapWord* addr) const ParallelCompactData::addr_to_region_ptr(const HeapWord* addr) const
{ {
return chunk(addr_to_chunk_idx(addr)); return region(addr_to_region_idx(addr));
} }
inline HeapWord* inline HeapWord*
ParallelCompactData::chunk_to_addr(size_t chunk) const ParallelCompactData::region_to_addr(size_t region) const
{ {
assert(chunk <= _chunk_count, "chunk out of range"); assert(region <= _region_count, "region out of range");
return _region_start + (chunk << Log2ChunkSize); return _region_start + (region << Log2RegionSize);
} }
inline HeapWord* inline HeapWord*
ParallelCompactData::chunk_to_addr(const ChunkData* chunk) const ParallelCompactData::region_to_addr(const RegionData* region) const
{ {
return chunk_to_addr(pointer_delta(chunk, _chunk_data, sizeof(ChunkData))); return region_to_addr(pointer_delta(region, _region_data,
sizeof(RegionData)));
} }
inline HeapWord* inline HeapWord*
ParallelCompactData::chunk_to_addr(size_t chunk, size_t offset) const ParallelCompactData::region_to_addr(size_t region, size_t offset) const
{ {
assert(chunk <= _chunk_count, "chunk out of range"); assert(region <= _region_count, "region out of range");
assert(offset < ChunkSize, "offset too big"); // This may be too strict. assert(offset < RegionSize, "offset too big"); // This may be too strict.
return chunk_to_addr(chunk) + offset; return region_to_addr(region) + offset;
} }
inline HeapWord* inline HeapWord*
ParallelCompactData::chunk_align_down(HeapWord* addr) const ParallelCompactData::region_align_down(HeapWord* addr) const
{ {
assert(addr >= _region_start, "bad addr"); assert(addr >= _region_start, "bad addr");
assert(addr < _region_end + ChunkSize, "bad addr"); assert(addr < _region_end + RegionSize, "bad addr");
return (HeapWord*)(size_t(addr) & ChunkAddrMask); return (HeapWord*)(size_t(addr) & RegionAddrMask);
} }
inline HeapWord* inline HeapWord*
ParallelCompactData::chunk_align_up(HeapWord* addr) const ParallelCompactData::region_align_up(HeapWord* addr) const
{ {
assert(addr >= _region_start, "bad addr"); assert(addr >= _region_start, "bad addr");
assert(addr <= _region_end, "bad addr"); assert(addr <= _region_end, "bad addr");
return chunk_align_down(addr + ChunkSizeOffsetMask); return region_align_down(addr + RegionSizeOffsetMask);
} }
inline bool inline bool
ParallelCompactData::is_chunk_aligned(HeapWord* addr) const ParallelCompactData::is_region_aligned(HeapWord* addr) const
{ {
return chunk_offset(addr) == 0; return region_offset(addr) == 0;
} }
inline size_t inline size_t
@ -692,40 +693,39 @@ class BitBlockUpdateClosure: public ParMarkBitMapClosure {
// ParallelCompactData::BlockData::blk_ofs_t _live_data_left; // ParallelCompactData::BlockData::blk_ofs_t _live_data_left;
size_t _live_data_left; size_t _live_data_left;
size_t _cur_block; size_t _cur_block;
HeapWord* _chunk_start; HeapWord* _region_start;
HeapWord* _chunk_end; HeapWord* _region_end;
size_t _chunk_index; size_t _region_index;
public: public:
BitBlockUpdateClosure(ParMarkBitMap* mbm, BitBlockUpdateClosure(ParMarkBitMap* mbm,
ParCompactionManager* cm, ParCompactionManager* cm,
size_t chunk_index); size_t region_index);
size_t cur_block() { return _cur_block; } size_t cur_block() { return _cur_block; }
size_t chunk_index() { return _chunk_index; } size_t region_index() { return _region_index; }
size_t live_data_left() { return _live_data_left; } size_t live_data_left() { return _live_data_left; }
// Returns true the first bit in the current block (cur_block) is // Returns true the first bit in the current block (cur_block) is
// a start bit. // a start bit.
// Returns true if the current block is within the chunk for the closure; // Returns true if the current block is within the region for the closure;
bool chunk_contains_cur_block(); bool region_contains_cur_block();
// Set the chunk index and related chunk values for // Set the region index and related region values for
// a new chunk. // a new region.
void reset_chunk(size_t chunk_index); void reset_region(size_t region_index);
virtual IterationStatus do_addr(HeapWord* addr, size_t words); virtual IterationStatus do_addr(HeapWord* addr, size_t words);
}; };
// The UseParallelOldGC collector is a stop-the-world garbage // The UseParallelOldGC collector is a stop-the-world garbage collector that
// collector that does parts of the collection using parallel threads. // does parts of the collection using parallel threads. The collection includes
// The collection includes the tenured generation and the young // the tenured generation and the young generation. The permanent generation is
// generation. The permanent generation is collected at the same // collected at the same time as the other two generations but the permanent
// time as the other two generations but the permanent generation // generation is collect by a single GC thread. The permanent generation is
// is collect by a single GC thread. The permanent generation is // collected serially because of the requirement that during the processing of a
// collected serially because of the requirement that during the // klass AAA, any objects reference by AAA must already have been processed.
// processing of a klass AAA, any objects reference by AAA must // This requirement is enforced by a left (lower address) to right (higher
// already have been processed. This requirement is enforced by // address) sliding compaction.
// a left (lower address) to right (higher address) sliding compaction.
// //
// There are four phases of the collection. // There are four phases of the collection.
// //
@ -740,80 +740,75 @@ class BitBlockUpdateClosure: public ParMarkBitMapClosure {
// - move the objects to their destination // - move the objects to their destination
// - update some references and reinitialize some variables // - update some references and reinitialize some variables
// //
// These three phases are invoked in PSParallelCompact::invoke_no_policy(). // These three phases are invoked in PSParallelCompact::invoke_no_policy(). The
// The marking phase is implemented in PSParallelCompact::marking_phase() // marking phase is implemented in PSParallelCompact::marking_phase() and does a
// and does a complete marking of the heap. // complete marking of the heap. The summary phase is implemented in
// The summary phase is implemented in PSParallelCompact::summary_phase(). // PSParallelCompact::summary_phase(). The move and update phase is implemented
// The move and update phase is implemented in PSParallelCompact::compact(). // in PSParallelCompact::compact().
// //
// A space that is being collected is divided into chunks and with // A space that is being collected is divided into regions and with each region
// each chunk is associated an object of type ParallelCompactData. // is associated an object of type ParallelCompactData. Each region is of a
// Each chunk is of a fixed size and typically will contain more than // fixed size and typically will contain more than 1 object and may have parts
// 1 object and may have parts of objects at the front and back of the // of objects at the front and back of the region.
// chunk.
// //
// chunk -----+---------------------+---------- // region -----+---------------------+----------
// objects covered [ AAA )[ BBB )[ CCC )[ DDD ) // objects covered [ AAA )[ BBB )[ CCC )[ DDD )
// //
// The marking phase does a complete marking of all live objects in the // The marking phase does a complete marking of all live objects in the heap.
// heap. The marking also compiles the size of the data for // The marking also compiles the size of the data for all live objects covered
// all live objects covered by the chunk. This size includes the // by the region. This size includes the part of any live object spanning onto
// part of any live object spanning onto the chunk (part of AAA // the region (part of AAA if it is live) from the front, all live objects
// if it is live) from the front, all live objects contained in the chunk // contained in the region (BBB and/or CCC if they are live), and the part of
// (BBB and/or CCC if they are live), and the part of any live objects // any live objects covered by the region that extends off the region (part of
// covered by the chunk that extends off the chunk (part of DDD if it is // DDD if it is live). The marking phase uses multiple GC threads and marking
// live). The marking phase uses multiple GC threads and marking is // is done in a bit array of type ParMarkBitMap. The marking of the bit map is
// done in a bit array of type ParMarkBitMap. The marking of the // done atomically as is the accumulation of the size of the live objects
// bit map is done atomically as is the accumulation of the size of the // covered by a region.
// live objects covered by a chunk.
// //
// The summary phase calculates the total live data to the left of // The summary phase calculates the total live data to the left of each region
// each chunk XXX. Based on that total and the bottom of the space, // XXX. Based on that total and the bottom of the space, it can calculate the
// it can calculate the starting location of the live data in XXX. // starting location of the live data in XXX. The summary phase calculates for
// The summary phase calculates for each chunk XXX quantites such as // each region XXX quantites such as
// //
// - the amount of live data at the beginning of a chunk from an object // - the amount of live data at the beginning of a region from an object
// entering the chunk. // entering the region.
// - the location of the first live data on the chunk // - the location of the first live data on the region
// - a count of the number of chunks receiving live data from XXX. // - a count of the number of regions receiving live data from XXX.
// //
// See ParallelCompactData for precise details. The summary phase also // See ParallelCompactData for precise details. The summary phase also
// calculates the dense prefix for the compaction. The dense prefix // calculates the dense prefix for the compaction. The dense prefix is a
// is a portion at the beginning of the space that is not moved. The // portion at the beginning of the space that is not moved. The objects in the
// objects in the dense prefix do need to have their object references // dense prefix do need to have their object references updated. See method
// updated. See method summarize_dense_prefix(). // summarize_dense_prefix().
// //
// The summary phase is done using 1 GC thread. // The summary phase is done using 1 GC thread.
// //
// The compaction phase moves objects to their new location and updates // The compaction phase moves objects to their new location and updates all
// all references in the object. // references in the object.
// //
// A current exception is that objects that cross a chunk boundary // A current exception is that objects that cross a region boundary are moved
// are moved but do not have their references updated. References are // but do not have their references updated. References are not updated because
// not updated because it cannot easily be determined if the klass // it cannot easily be determined if the klass pointer KKK for the object AAA
// pointer KKK for the object AAA has been updated. KKK likely resides // has been updated. KKK likely resides in a region to the left of the region
// in a chunk to the left of the chunk containing AAA. These AAA's // containing AAA. These AAA's have there references updated at the end in a
// have there references updated at the end in a clean up phase. // clean up phase. See the method PSParallelCompact::update_deferred_objects().
// See the method PSParallelCompact::update_deferred_objects(). An // An alternate strategy is being investigated for this deferral of updating.
// alternate strategy is being investigated for this deferral of updating.
//
// Compaction is done on a chunk basis. A chunk that is ready to be
// filled is put on a ready list and GC threads take chunk off the list
// and fill them. A chunk is ready to be filled if it
// empty of live objects. Such a chunk may have been initially
// empty (only contained
// dead objects) or may have had all its live objects copied out already.
// A chunk that compacts into itself is also ready for filling. The
// ready list is initially filled with empty chunks and chunks compacting
// into themselves. There is always at least 1 chunk that can be put on
// the ready list. The chunks are atomically added and removed from
// the ready list.
// //
// Compaction is done on a region basis. A region that is ready to be filled is
// put on a ready list and GC threads take region off the list and fill them. A
// region is ready to be filled if it empty of live objects. Such a region may
// have been initially empty (only contained dead objects) or may have had all
// its live objects copied out already. A region that compacts into itself is
// also ready for filling. The ready list is initially filled with empty
// regions and regions compacting into themselves. There is always at least 1
// region that can be put on the ready list. The regions are atomically added
// and removed from the ready list.
class PSParallelCompact : AllStatic { class PSParallelCompact : AllStatic {
public: public:
// Convenient access to type names. // Convenient access to type names.
typedef ParMarkBitMap::idx_t idx_t; typedef ParMarkBitMap::idx_t idx_t;
typedef ParallelCompactData::ChunkData ChunkData; typedef ParallelCompactData::RegionData RegionData;
typedef ParallelCompactData::BlockData BlockData; typedef ParallelCompactData::BlockData BlockData;
typedef enum { typedef enum {
@ -977,26 +972,26 @@ class PSParallelCompact : AllStatic {
// not reclaimed). // not reclaimed).
static double dead_wood_limiter(double density, size_t min_percent); static double dead_wood_limiter(double density, size_t min_percent);
// Find the first (left-most) chunk in the range [beg, end) that has at least // Find the first (left-most) region in the range [beg, end) that has at least
// dead_words of dead space to the left. The argument beg must be the first // dead_words of dead space to the left. The argument beg must be the first
// chunk in the space that is not completely live. // region in the space that is not completely live.
static ChunkData* dead_wood_limit_chunk(const ChunkData* beg, static RegionData* dead_wood_limit_region(const RegionData* beg,
const ChunkData* end, const RegionData* end,
size_t dead_words); size_t dead_words);
// Return a pointer to the first chunk in the range [beg, end) that is not // Return a pointer to the first region in the range [beg, end) that is not
// completely full. // completely full.
static ChunkData* first_dead_space_chunk(const ChunkData* beg, static RegionData* first_dead_space_region(const RegionData* beg,
const ChunkData* end); const RegionData* end);
// Return a value indicating the benefit or 'yield' if the compacted region // Return a value indicating the benefit or 'yield' if the compacted region
// were to start (or equivalently if the dense prefix were to end) at the // were to start (or equivalently if the dense prefix were to end) at the
// candidate chunk. Higher values are better. // candidate region. Higher values are better.
// //
// The value is based on the amount of space reclaimed vs. the costs of (a) // The value is based on the amount of space reclaimed vs. the costs of (a)
// updating references in the dense prefix plus (b) copying objects and // updating references in the dense prefix plus (b) copying objects and
// updating references in the compacted region. // updating references in the compacted region.
static inline double reclaimed_ratio(const ChunkData* const candidate, static inline double reclaimed_ratio(const RegionData* const candidate,
HeapWord* const bottom, HeapWord* const bottom,
HeapWord* const top, HeapWord* const top,
HeapWord* const new_top); HeapWord* const new_top);
@ -1005,9 +1000,9 @@ class PSParallelCompact : AllStatic {
static HeapWord* compute_dense_prefix(const SpaceId id, static HeapWord* compute_dense_prefix(const SpaceId id,
bool maximum_compaction); bool maximum_compaction);
// Return true if dead space crosses onto the specified Chunk; bit must be the // Return true if dead space crosses onto the specified Region; bit must be
// bit index corresponding to the first word of the Chunk. // the bit index corresponding to the first word of the Region.
static inline bool dead_space_crosses_boundary(const ChunkData* chunk, static inline bool dead_space_crosses_boundary(const RegionData* region,
idx_t bit); idx_t bit);
// Summary phase utility routine to fill dead space (if any) at the dense // Summary phase utility routine to fill dead space (if any) at the dense
@ -1038,16 +1033,16 @@ class PSParallelCompact : AllStatic {
static void compact_perm(ParCompactionManager* cm); static void compact_perm(ParCompactionManager* cm);
static void compact(); static void compact();
// Add available chunks to the stack and draining tasks to the task queue. // Add available regions to the stack and draining tasks to the task queue.
static void enqueue_chunk_draining_tasks(GCTaskQueue* q, static void enqueue_region_draining_tasks(GCTaskQueue* q,
uint parallel_gc_threads); uint parallel_gc_threads);
// Add dense prefix update tasks to the task queue. // Add dense prefix update tasks to the task queue.
static void enqueue_dense_prefix_tasks(GCTaskQueue* q, static void enqueue_dense_prefix_tasks(GCTaskQueue* q,
uint parallel_gc_threads); uint parallel_gc_threads);
// Add chunk stealing tasks to the task queue. // Add region stealing tasks to the task queue.
static void enqueue_chunk_stealing_tasks( static void enqueue_region_stealing_tasks(
GCTaskQueue* q, GCTaskQueue* q,
ParallelTaskTerminator* terminator_ptr, ParallelTaskTerminator* terminator_ptr,
uint parallel_gc_threads); uint parallel_gc_threads);
@ -1154,56 +1149,56 @@ class PSParallelCompact : AllStatic {
// Move and update the live objects in the specified space. // Move and update the live objects in the specified space.
static void move_and_update(ParCompactionManager* cm, SpaceId space_id); static void move_and_update(ParCompactionManager* cm, SpaceId space_id);
// Process the end of the given chunk range in the dense prefix. // Process the end of the given region range in the dense prefix.
// This includes saving any object not updated. // This includes saving any object not updated.
static void dense_prefix_chunks_epilogue(ParCompactionManager* cm, static void dense_prefix_regions_epilogue(ParCompactionManager* cm,
size_t chunk_start_index, size_t region_start_index,
size_t chunk_end_index, size_t region_end_index,
idx_t exiting_object_offset, idx_t exiting_object_offset,
idx_t chunk_offset_start, idx_t region_offset_start,
idx_t chunk_offset_end); idx_t region_offset_end);
// Update a chunk in the dense prefix. For each live object // Update a region in the dense prefix. For each live object
// in the chunk, update it's interior references. For each // in the region, update it's interior references. For each
// dead object, fill it with deadwood. Dead space at the end // dead object, fill it with deadwood. Dead space at the end
// of a chunk range will be filled to the start of the next // of a region range will be filled to the start of the next
// live object regardless of the chunk_index_end. None of the // live object regardless of the region_index_end. None of the
// objects in the dense prefix move and dead space is dead // objects in the dense prefix move and dead space is dead
// (holds only dead objects that don't need any processing), so // (holds only dead objects that don't need any processing), so
// dead space can be filled in any order. // dead space can be filled in any order.
static void update_and_deadwood_in_dense_prefix(ParCompactionManager* cm, static void update_and_deadwood_in_dense_prefix(ParCompactionManager* cm,
SpaceId space_id, SpaceId space_id,
size_t chunk_index_start, size_t region_index_start,
size_t chunk_index_end); size_t region_index_end);
// Return the address of the count + 1st live word in the range [beg, end). // Return the address of the count + 1st live word in the range [beg, end).
static HeapWord* skip_live_words(HeapWord* beg, HeapWord* end, size_t count); static HeapWord* skip_live_words(HeapWord* beg, HeapWord* end, size_t count);
// Return the address of the word to be copied to dest_addr, which must be // Return the address of the word to be copied to dest_addr, which must be
// aligned to a chunk boundary. // aligned to a region boundary.
static HeapWord* first_src_addr(HeapWord* const dest_addr, static HeapWord* first_src_addr(HeapWord* const dest_addr,
size_t src_chunk_idx); size_t src_region_idx);
// Determine the next source chunk, set closure.source() to the start of the // Determine the next source region, set closure.source() to the start of the
// new chunk return the chunk index. Parameter end_addr is the address one // new region return the region index. Parameter end_addr is the address one
// beyond the end of source range just processed. If necessary, switch to a // beyond the end of source range just processed. If necessary, switch to a
// new source space and set src_space_id (in-out parameter) and src_space_top // new source space and set src_space_id (in-out parameter) and src_space_top
// (out parameter) accordingly. // (out parameter) accordingly.
static size_t next_src_chunk(MoveAndUpdateClosure& closure, static size_t next_src_region(MoveAndUpdateClosure& closure,
SpaceId& src_space_id, SpaceId& src_space_id,
HeapWord*& src_space_top, HeapWord*& src_space_top,
HeapWord* end_addr); HeapWord* end_addr);
// Decrement the destination count for each non-empty source chunk in the // Decrement the destination count for each non-empty source region in the
// range [beg_chunk, chunk(chunk_align_up(end_addr))). // range [beg_region, region(region_align_up(end_addr))).
static void decrement_destination_counts(ParCompactionManager* cm, static void decrement_destination_counts(ParCompactionManager* cm,
size_t beg_chunk, size_t beg_region,
HeapWord* end_addr); HeapWord* end_addr);
// Fill a chunk, copying objects from one or more source chunks. // Fill a region, copying objects from one or more source regions.
static void fill_chunk(ParCompactionManager* cm, size_t chunk_idx); static void fill_region(ParCompactionManager* cm, size_t region_idx);
static void fill_and_update_chunk(ParCompactionManager* cm, size_t chunk) { static void fill_and_update_region(ParCompactionManager* cm, size_t region) {
fill_chunk(cm, chunk); fill_region(cm, region);
} }
// Update the deferred objects in the space. // Update the deferred objects in the space.
@ -1259,7 +1254,7 @@ class PSParallelCompact : AllStatic {
#ifndef PRODUCT #ifndef PRODUCT
// Debugging support. // Debugging support.
static const char* space_names[last_space_id]; static const char* space_names[last_space_id];
static void print_chunk_ranges(); static void print_region_ranges();
static void print_dense_prefix_stats(const char* const algorithm, static void print_dense_prefix_stats(const char* const algorithm,
const SpaceId id, const SpaceId id,
const bool maximum_compaction, const bool maximum_compaction,
@ -1267,7 +1262,7 @@ class PSParallelCompact : AllStatic {
#endif // #ifndef PRODUCT #endif // #ifndef PRODUCT
#ifdef ASSERT #ifdef ASSERT
// Verify that all the chunks have been emptied. // Verify that all the regions have been emptied.
static void verify_complete(SpaceId space_id); static void verify_complete(SpaceId space_id);
#endif // #ifdef ASSERT #endif // #ifdef ASSERT
}; };
@ -1376,17 +1371,17 @@ inline double PSParallelCompact::normal_distribution(double density) {
} }
inline bool inline bool
PSParallelCompact::dead_space_crosses_boundary(const ChunkData* chunk, PSParallelCompact::dead_space_crosses_boundary(const RegionData* region,
idx_t bit) idx_t bit)
{ {
assert(bit > 0, "cannot call this for the first bit/chunk"); assert(bit > 0, "cannot call this for the first bit/region");
assert(_summary_data.chunk_to_addr(chunk) == _mark_bitmap.bit_to_addr(bit), assert(_summary_data.region_to_addr(region) == _mark_bitmap.bit_to_addr(bit),
"sanity check"); "sanity check");
// Dead space crosses the boundary if (1) a partial object does not extend // Dead space crosses the boundary if (1) a partial object does not extend
// onto the chunk, (2) an object does not start at the beginning of the chunk, // onto the region, (2) an object does not start at the beginning of the
// and (3) an object does not end at the end of the prior chunk. // region, and (3) an object does not end at the end of the prior region.
return chunk->partial_obj_size() == 0 && return region->partial_obj_size() == 0 &&
!_mark_bitmap.is_obj_beg(bit) && !_mark_bitmap.is_obj_beg(bit) &&
!_mark_bitmap.is_obj_end(bit - 1); !_mark_bitmap.is_obj_end(bit - 1);
} }

View file

@ -1157,9 +1157,9 @@ class CommandLineFlags {
"In the Parallel Old garbage collector use parallel dense" \ "In the Parallel Old garbage collector use parallel dense" \
" prefix update") \ " prefix update") \
\ \
develop(bool, UseParallelOldGCChunkPointerCalc, true, \ develop(bool, UseParallelOldGCRegionPointerCalc, true, \
"In the Parallel Old garbage collector use chucks to calculate" \ "In the Parallel Old garbage collector use regions to calculate" \
" new object locations") \ "new object locations") \
\ \
product(uintx, HeapMaximumCompactionInterval, 20, \ product(uintx, HeapMaximumCompactionInterval, 20, \
"How often should we maximally compact the heap (not allowing " \ "How often should we maximally compact the heap (not allowing " \
@ -1195,8 +1195,8 @@ class CommandLineFlags {
develop(bool, ParallelOldMTUnsafeUpdateLiveData, false, \ develop(bool, ParallelOldMTUnsafeUpdateLiveData, false, \
"Use the Parallel Old MT unsafe in update of live size") \ "Use the Parallel Old MT unsafe in update of live size") \
\ \
develop(bool, TraceChunkTasksQueuing, false, \ develop(bool, TraceRegionTasksQueuing, false, \
"Trace the queuing of the chunk tasks") \ "Trace the queuing of the region tasks") \
\ \
product(uintx, ParallelMarkingThreads, 0, \ product(uintx, ParallelMarkingThreads, 0, \
"Number of marking threads concurrent gc will use") \ "Number of marking threads concurrent gc will use") \

View file

@ -109,72 +109,72 @@ void ParallelTaskTerminator::reset_for_reuse() {
} }
} }
bool ChunkTaskQueueWithOverflow::is_empty() { bool RegionTaskQueueWithOverflow::is_empty() {
return (_chunk_queue.size() == 0) && return (_region_queue.size() == 0) &&
(_overflow_stack->length() == 0); (_overflow_stack->length() == 0);
} }
bool ChunkTaskQueueWithOverflow::stealable_is_empty() { bool RegionTaskQueueWithOverflow::stealable_is_empty() {
return _chunk_queue.size() == 0; return _region_queue.size() == 0;
} }
bool ChunkTaskQueueWithOverflow::overflow_is_empty() { bool RegionTaskQueueWithOverflow::overflow_is_empty() {
return _overflow_stack->length() == 0; return _overflow_stack->length() == 0;
} }
void ChunkTaskQueueWithOverflow::initialize() { void RegionTaskQueueWithOverflow::initialize() {
_chunk_queue.initialize(); _region_queue.initialize();
assert(_overflow_stack == 0, "Creating memory leak"); assert(_overflow_stack == 0, "Creating memory leak");
_overflow_stack = _overflow_stack =
new (ResourceObj::C_HEAP) GrowableArray<ChunkTask>(10, true); new (ResourceObj::C_HEAP) GrowableArray<RegionTask>(10, true);
} }
void ChunkTaskQueueWithOverflow::save(ChunkTask t) { void RegionTaskQueueWithOverflow::save(RegionTask t) {
if (TraceChunkTasksQueuing && Verbose) { if (TraceRegionTasksQueuing && Verbose) {
gclog_or_tty->print_cr("CTQ: save " PTR_FORMAT, t); gclog_or_tty->print_cr("CTQ: save " PTR_FORMAT, t);
} }
if(!_chunk_queue.push(t)) { if(!_region_queue.push(t)) {
_overflow_stack->push(t); _overflow_stack->push(t);
} }
} }
// Note that using this method will retrieve all chunks // Note that using this method will retrieve all regions
// that have been saved but that it will always check // that have been saved but that it will always check
// the overflow stack. It may be more efficient to // the overflow stack. It may be more efficient to
// check the stealable queue and the overflow stack // check the stealable queue and the overflow stack
// separately. // separately.
bool ChunkTaskQueueWithOverflow::retrieve(ChunkTask& chunk_task) { bool RegionTaskQueueWithOverflow::retrieve(RegionTask& region_task) {
bool result = retrieve_from_overflow(chunk_task); bool result = retrieve_from_overflow(region_task);
if (!result) { if (!result) {
result = retrieve_from_stealable_queue(chunk_task); result = retrieve_from_stealable_queue(region_task);
} }
if (TraceChunkTasksQueuing && Verbose && result) { if (TraceRegionTasksQueuing && Verbose && result) {
gclog_or_tty->print_cr(" CTQ: retrieve " PTR_FORMAT, result); gclog_or_tty->print_cr(" CTQ: retrieve " PTR_FORMAT, result);
} }
return result; return result;
} }
bool ChunkTaskQueueWithOverflow::retrieve_from_stealable_queue( bool RegionTaskQueueWithOverflow::retrieve_from_stealable_queue(
ChunkTask& chunk_task) { RegionTask& region_task) {
bool result = _chunk_queue.pop_local(chunk_task); bool result = _region_queue.pop_local(region_task);
if (TraceChunkTasksQueuing && Verbose) { if (TraceRegionTasksQueuing && Verbose) {
gclog_or_tty->print_cr("CTQ: retrieve_stealable " PTR_FORMAT, chunk_task); gclog_or_tty->print_cr("CTQ: retrieve_stealable " PTR_FORMAT, region_task);
} }
return result; return result;
} }
bool ChunkTaskQueueWithOverflow::retrieve_from_overflow( bool
ChunkTask& chunk_task) { RegionTaskQueueWithOverflow::retrieve_from_overflow(RegionTask& region_task) {
bool result; bool result;
if (!_overflow_stack->is_empty()) { if (!_overflow_stack->is_empty()) {
chunk_task = _overflow_stack->pop(); region_task = _overflow_stack->pop();
result = true; result = true;
} else { } else {
chunk_task = (ChunkTask) NULL; region_task = (RegionTask) NULL;
result = false; result = false;
} }
if (TraceChunkTasksQueuing && Verbose) { if (TraceRegionTasksQueuing && Verbose) {
gclog_or_tty->print_cr("CTQ: retrieve_stealable " PTR_FORMAT, chunk_task); gclog_or_tty->print_cr("CTQ: retrieve_stealable " PTR_FORMAT, region_task);
} }
return result; return result;
} }

View file

@ -557,32 +557,32 @@ class StarTask {
typedef GenericTaskQueue<StarTask> OopStarTaskQueue; typedef GenericTaskQueue<StarTask> OopStarTaskQueue;
typedef GenericTaskQueueSet<StarTask> OopStarTaskQueueSet; typedef GenericTaskQueueSet<StarTask> OopStarTaskQueueSet;
typedef size_t ChunkTask; // index for chunk typedef size_t RegionTask; // index for region
typedef GenericTaskQueue<ChunkTask> ChunkTaskQueue; typedef GenericTaskQueue<RegionTask> RegionTaskQueue;
typedef GenericTaskQueueSet<ChunkTask> ChunkTaskQueueSet; typedef GenericTaskQueueSet<RegionTask> RegionTaskQueueSet;
class ChunkTaskQueueWithOverflow: public CHeapObj { class RegionTaskQueueWithOverflow: public CHeapObj {
protected: protected:
ChunkTaskQueue _chunk_queue; RegionTaskQueue _region_queue;
GrowableArray<ChunkTask>* _overflow_stack; GrowableArray<RegionTask>* _overflow_stack;
public: public:
ChunkTaskQueueWithOverflow() : _overflow_stack(NULL) {} RegionTaskQueueWithOverflow() : _overflow_stack(NULL) {}
// Initialize both stealable queue and overflow // Initialize both stealable queue and overflow
void initialize(); void initialize();
// Save first to stealable queue and then to overflow // Save first to stealable queue and then to overflow
void save(ChunkTask t); void save(RegionTask t);
// Retrieve first from overflow and then from stealable queue // Retrieve first from overflow and then from stealable queue
bool retrieve(ChunkTask& chunk_index); bool retrieve(RegionTask& region_index);
// Retrieve from stealable queue // Retrieve from stealable queue
bool retrieve_from_stealable_queue(ChunkTask& chunk_index); bool retrieve_from_stealable_queue(RegionTask& region_index);
// Retrieve from overflow // Retrieve from overflow
bool retrieve_from_overflow(ChunkTask& chunk_index); bool retrieve_from_overflow(RegionTask& region_index);
bool is_empty(); bool is_empty();
bool stealable_is_empty(); bool stealable_is_empty();
bool overflow_is_empty(); bool overflow_is_empty();
juint stealable_size() { return _chunk_queue.size(); } juint stealable_size() { return _region_queue.size(); }
ChunkTaskQueue* task_queue() { return &_chunk_queue; } RegionTaskQueue* task_queue() { return &_region_queue; }
}; };
#define USE_ChunkTaskQueueWithOverflow #define USE_RegionTaskQueueWithOverflow