mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
6725697: par compact - rename class ChunkData to RegionData
Reviewed-by: iveresov, tonyp
This commit is contained in:
parent
2e52e9dff2
commit
f2851186bb
9 changed files with 1049 additions and 1040 deletions
|
@ -146,7 +146,7 @@ void RefProcTaskExecutor::execute(ProcessTask& task)
|
|||
{
|
||||
ParallelScavengeHeap* heap = PSParallelCompact::gc_heap();
|
||||
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);
|
||||
GCTaskQueue* q = GCTaskQueue::create();
|
||||
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) :
|
||||
_terminator(t) {};
|
||||
StealRegionCompactionTask::StealRegionCompactionTask(ParallelTaskTerminator* 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");
|
||||
|
||||
NOT_PRODUCT(TraceTime tm("StealChunkCompactionTask",
|
||||
NOT_PRODUCT(TraceTime tm("StealRegionCompactionTask",
|
||||
PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
|
||||
|
||||
ParCompactionManager* cm =
|
||||
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
|
||||
// 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;
|
||||
|
||||
// If we're the termination task, try 10 rounds of stealing before
|
||||
// setting the termination flag
|
||||
|
||||
while(true) {
|
||||
if (ParCompactionManager::steal(which, &random_seed, chunk_index)) {
|
||||
PSParallelCompact::fill_and_update_chunk(cm, chunk_index);
|
||||
cm->drain_chunk_stacks();
|
||||
if (ParCompactionManager::steal(which, &random_seed, region_index)) {
|
||||
PSParallelCompact::fill_and_update_region(cm, region_index);
|
||||
cm->drain_region_stacks();
|
||||
} else {
|
||||
if (terminator()->offer_termination()) {
|
||||
break;
|
||||
|
@ -249,11 +249,10 @@ void StealChunkCompactionTask::do_it(GCTaskManager* manager, uint which) {
|
|||
|
||||
UpdateDensePrefixTask::UpdateDensePrefixTask(
|
||||
PSParallelCompact::SpaceId space_id,
|
||||
size_t chunk_index_start,
|
||||
size_t chunk_index_end) :
|
||||
_space_id(space_id), _chunk_index_start(chunk_index_start),
|
||||
_chunk_index_end(chunk_index_end)
|
||||
{}
|
||||
size_t region_index_start,
|
||||
size_t region_index_end) :
|
||||
_space_id(space_id), _region_index_start(region_index_start),
|
||||
_region_index_end(region_index_end) {}
|
||||
|
||||
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,
|
||||
_space_id,
|
||||
_chunk_index_start,
|
||||
_chunk_index_end);
|
||||
_region_index_start,
|
||||
_region_index_end);
|
||||
}
|
||||
|
||||
void DrainStacksCompactionTask::do_it(GCTaskManager* manager, uint which) {
|
||||
|
@ -278,6 +277,6 @@ void DrainStacksCompactionTask::do_it(GCTaskManager* manager, uint which) {
|
|||
ParCompactionManager* cm =
|
||||
ParCompactionManager::gc_thread_compaction_manager(which);
|
||||
|
||||
// Process any chunks already in the compaction managers stacks.
|
||||
cm->drain_chunk_stacks();
|
||||
// Process any regions already in the compaction managers stacks.
|
||||
cm->drain_region_stacks();
|
||||
}
|
||||
|
|
|
@ -188,18 +188,18 @@ class StealMarkingTask : public GCTask {
|
|||
};
|
||||
|
||||
//
|
||||
// StealChunkCompactionTask
|
||||
// StealRegionCompactionTask
|
||||
//
|
||||
// This task is used to distribute work to idle threads.
|
||||
//
|
||||
|
||||
class StealChunkCompactionTask : public GCTask {
|
||||
class StealRegionCompactionTask : public GCTask {
|
||||
private:
|
||||
ParallelTaskTerminator* const _terminator;
|
||||
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; }
|
||||
|
||||
virtual void do_it(GCTaskManager* manager, uint which);
|
||||
|
@ -215,15 +215,15 @@ class StealChunkCompactionTask : public GCTask {
|
|||
class UpdateDensePrefixTask : public GCTask {
|
||||
private:
|
||||
PSParallelCompact::SpaceId _space_id;
|
||||
size_t _chunk_index_start;
|
||||
size_t _chunk_index_end;
|
||||
size_t _region_index_start;
|
||||
size_t _region_index_end;
|
||||
|
||||
public:
|
||||
char* name() { return (char *)"update-dense_prefix-task"; }
|
||||
|
||||
UpdateDensePrefixTask(PSParallelCompact::SpaceId space_id,
|
||||
size_t chunk_index_start,
|
||||
size_t chunk_index_end);
|
||||
size_t region_index_start,
|
||||
size_t region_index_end);
|
||||
|
||||
virtual void do_it(GCTaskManager* manager, uint which);
|
||||
};
|
||||
|
@ -231,17 +231,17 @@ class UpdateDensePrefixTask : public GCTask {
|
|||
//
|
||||
// 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.
|
||||
//
|
||||
// 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,
|
||||
// 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).
|
||||
//
|
||||
|
||||
class DrainStacksCompactionTask : public GCTask {
|
||||
public:
|
||||
char* name() { return (char *)"drain-chunk-task"; }
|
||||
char* name() { return (char *)"drain-region-task"; }
|
||||
virtual void do_it(GCTaskManager* manager, uint which);
|
||||
};
|
||||
|
|
|
@ -30,7 +30,7 @@ ParCompactionManager** ParCompactionManager::_manager_array = NULL;
|
|||
OopTaskQueueSet* ParCompactionManager::_stack_array = NULL;
|
||||
ObjectStartArray* ParCompactionManager::_start_array = NULL;
|
||||
ParMarkBitMap* ParCompactionManager::_mark_bitmap = NULL;
|
||||
ChunkTaskQueueSet* ParCompactionManager::_chunk_array = NULL;
|
||||
RegionTaskQueueSet* ParCompactionManager::_region_array = NULL;
|
||||
|
||||
ParCompactionManager::ParCompactionManager() :
|
||||
_action(CopyAndUpdate) {
|
||||
|
@ -46,13 +46,13 @@ ParCompactionManager::ParCompactionManager() :
|
|||
|
||||
// We want the overflow stack to be permanent
|
||||
_overflow_stack = new (ResourceObj::C_HEAP) GrowableArray<oop>(10, true);
|
||||
#ifdef USE_ChunkTaskQueueWithOverflow
|
||||
chunk_stack()->initialize();
|
||||
#ifdef USE_RegionTaskQueueWithOverflow
|
||||
region_stack()->initialize();
|
||||
#else
|
||||
chunk_stack()->initialize();
|
||||
region_stack()->initialize();
|
||||
|
||||
// We want the overflow stack to be permanent
|
||||
_chunk_overflow_stack =
|
||||
_region_overflow_stack =
|
||||
new (ResourceObj::C_HEAP) GrowableArray<size_t>(10, true);
|
||||
#endif
|
||||
|
||||
|
@ -86,18 +86,18 @@ void ParCompactionManager::initialize(ParMarkBitMap* mbm) {
|
|||
|
||||
_stack_array = new OopTaskQueueSet(parallel_gc_threads);
|
||||
guarantee(_stack_array != NULL, "Count not initialize promotion manager");
|
||||
_chunk_array = new ChunkTaskQueueSet(parallel_gc_threads);
|
||||
guarantee(_chunk_array != NULL, "Count not initialize promotion manager");
|
||||
_region_array = new RegionTaskQueueSet(parallel_gc_threads);
|
||||
guarantee(_region_array != NULL, "Count not initialize promotion manager");
|
||||
|
||||
// Create and register the ParCompactionManager(s) for the worker threads.
|
||||
for(uint i=0; i<parallel_gc_threads; i++) {
|
||||
_manager_array[i] = new ParCompactionManager();
|
||||
guarantee(_manager_array[i] != NULL, "Could not create ParCompactionManager");
|
||||
stack_array()->register_queue(i, _manager_array[i]->marking_stack());
|
||||
#ifdef USE_ChunkTaskQueueWithOverflow
|
||||
chunk_array()->register_queue(i, _manager_array[i]->chunk_stack()->task_queue());
|
||||
#ifdef USE_RegionTaskQueueWithOverflow
|
||||
region_array()->register_queue(i, _manager_array[i]->region_stack()->task_queue());
|
||||
#else
|
||||
chunk_array()->register_queue(i, _manager_array[i]->chunk_stack());
|
||||
region_array()->register_queue(i, _manager_array[i]->region_stack());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -153,31 +153,31 @@ oop ParCompactionManager::retrieve_for_scanning() {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// Save chunk on a stack
|
||||
void ParCompactionManager::save_for_processing(size_t chunk_index) {
|
||||
// Save region on a stack
|
||||
void ParCompactionManager::save_for_processing(size_t region_index) {
|
||||
#ifdef ASSERT
|
||||
const ParallelCompactData& sd = PSParallelCompact::summary_data();
|
||||
ParallelCompactData::ChunkData* const chunk_ptr = sd.chunk(chunk_index);
|
||||
assert(chunk_ptr->claimed(), "must be claimed");
|
||||
assert(chunk_ptr->_pushed++ == 0, "should only be pushed once");
|
||||
ParallelCompactData::RegionData* const region_ptr = sd.region(region_index);
|
||||
assert(region_ptr->claimed(), "must be claimed");
|
||||
assert(region_ptr->_pushed++ == 0, "should only be pushed once");
|
||||
#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
|
||||
chunk_stack()->save(chunk_index);
|
||||
#ifdef USE_RegionTaskQueueWithOverflow
|
||||
region_stack()->save(region_index);
|
||||
#else
|
||||
if(!chunk_stack()->push(chunk_index)) {
|
||||
chunk_overflow_stack()->push(chunk_index);
|
||||
if(!region_stack()->push(region_index)) {
|
||||
region_overflow_stack()->push(region_index);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ParCompactionManager::retrieve_for_processing(size_t& chunk_index) {
|
||||
#ifdef USE_ChunkTaskQueueWithOverflow
|
||||
return chunk_stack()->retrieve(chunk_index);
|
||||
bool ParCompactionManager::retrieve_for_processing(size_t& region_index) {
|
||||
#ifdef USE_RegionTaskQueueWithOverflow
|
||||
return region_stack()->retrieve(region_index);
|
||||
#else
|
||||
// Should not be used in the parallel case
|
||||
ShouldNotReachHere();
|
||||
|
@ -230,14 +230,14 @@ void ParCompactionManager::drain_marking_stacks(OopClosure* blk) {
|
|||
assert(overflow_stack()->length() == 0, "Sanity");
|
||||
}
|
||||
|
||||
void ParCompactionManager::drain_chunk_overflow_stack() {
|
||||
size_t chunk_index = (size_t) -1;
|
||||
while(chunk_stack()->retrieve_from_overflow(chunk_index)) {
|
||||
PSParallelCompact::fill_and_update_chunk(this, chunk_index);
|
||||
void ParCompactionManager::drain_region_overflow_stack() {
|
||||
size_t region_index = (size_t) -1;
|
||||
while(region_stack()->retrieve_from_overflow(region_index)) {
|
||||
PSParallelCompact::fill_and_update_region(this, region_index);
|
||||
}
|
||||
}
|
||||
|
||||
void ParCompactionManager::drain_chunk_stacks() {
|
||||
void ParCompactionManager::drain_region_stacks() {
|
||||
#ifdef ASSERT
|
||||
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
|
||||
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
|
||||
do {
|
||||
|
||||
#ifdef USE_ChunkTaskQueueWithOverflow
|
||||
#ifdef USE_RegionTaskQueueWithOverflow
|
||||
// Drain overflow stack first, so other threads can steal from
|
||||
// claimed stack while we work.
|
||||
size_t chunk_index = (size_t) -1;
|
||||
while(chunk_stack()->retrieve_from_overflow(chunk_index)) {
|
||||
PSParallelCompact::fill_and_update_chunk(this, chunk_index);
|
||||
size_t region_index = (size_t) -1;
|
||||
while(region_stack()->retrieve_from_overflow(region_index)) {
|
||||
PSParallelCompact::fill_and_update_region(this, region_index);
|
||||
}
|
||||
|
||||
while (chunk_stack()->retrieve_from_stealable_queue(chunk_index)) {
|
||||
PSParallelCompact::fill_and_update_chunk(this, chunk_index);
|
||||
while (region_stack()->retrieve_from_stealable_queue(region_index)) {
|
||||
PSParallelCompact::fill_and_update_region(this, region_index);
|
||||
}
|
||||
} while (!chunk_stack()->is_empty());
|
||||
} while (!region_stack()->is_empty());
|
||||
#else
|
||||
// Drain overflow stack first, so other threads can steal from
|
||||
// claimed stack while we work.
|
||||
while(!chunk_overflow_stack()->is_empty()) {
|
||||
size_t chunk_index = chunk_overflow_stack()->pop();
|
||||
PSParallelCompact::fill_and_update_chunk(this, chunk_index);
|
||||
while(!region_overflow_stack()->is_empty()) {
|
||||
size_t region_index = region_overflow_stack()->pop();
|
||||
PSParallelCompact::fill_and_update_region(this, region_index);
|
||||
}
|
||||
|
||||
size_t chunk_index = -1;
|
||||
size_t region_index = -1;
|
||||
// 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
|
||||
// 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) ||
|
||||
(chunk_overflow_stack()->length() != 0));
|
||||
} while((region_stack()->size() != 0) ||
|
||||
(region_overflow_stack()->length() != 0));
|
||||
#endif
|
||||
|
||||
#ifdef USE_ChunkTaskQueueWithOverflow
|
||||
assert(chunk_stack()->is_empty(), "Sanity");
|
||||
#ifdef USE_RegionTaskQueueWithOverflow
|
||||
assert(region_stack()->is_empty(), "Sanity");
|
||||
#else
|
||||
assert(chunk_stack()->size() == 0, "Sanity");
|
||||
assert(chunk_overflow_stack()->length() == 0, "Sanity");
|
||||
assert(region_stack()->size() == 0, "Sanity");
|
||||
assert(region_overflow_stack()->length() == 0, "Sanity");
|
||||
#endif
|
||||
#else
|
||||
oop obj;
|
||||
|
|
|
@ -52,7 +52,7 @@ class ParCompactionManager : public CHeapObj {
|
|||
friend class ParallelTaskTerminator;
|
||||
friend class ParMarkBitMap;
|
||||
friend class PSParallelCompact;
|
||||
friend class StealChunkCompactionTask;
|
||||
friend class StealRegionCompactionTask;
|
||||
friend class UpdateAndFillClosure;
|
||||
friend class RefProcTaskExecutor;
|
||||
|
||||
|
@ -75,20 +75,20 @@ class ParCompactionManager : public CHeapObj {
|
|||
static ParCompactionManager** _manager_array;
|
||||
static OopTaskQueueSet* _stack_array;
|
||||
static ObjectStartArray* _start_array;
|
||||
static ChunkTaskQueueSet* _chunk_array;
|
||||
static RegionTaskQueueSet* _region_array;
|
||||
static PSOldGen* _old_gen;
|
||||
|
||||
OopTaskQueue _marking_stack;
|
||||
GrowableArray<oop>* _overflow_stack;
|
||||
// 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.
|
||||
|
||||
#ifdef USE_ChunkTaskQueueWithOverflow
|
||||
ChunkTaskQueueWithOverflow _chunk_stack;
|
||||
#ifdef USE_RegionTaskQueueWithOverflow
|
||||
RegionTaskQueueWithOverflow _region_stack;
|
||||
#else
|
||||
ChunkTaskQueue _chunk_stack;
|
||||
GrowableArray<size_t>* _chunk_overflow_stack;
|
||||
RegionTaskQueue _region_stack;
|
||||
GrowableArray<size_t>* _region_overflow_stack;
|
||||
#endif
|
||||
|
||||
#if 1 // does this happen enough to need a per thread stack?
|
||||
|
@ -106,15 +106,16 @@ class ParCompactionManager : public CHeapObj {
|
|||
|
||||
protected:
|
||||
// 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; }
|
||||
GrowableArray<oop>* overflow_stack() { return _overflow_stack; }
|
||||
#ifdef USE_ChunkTaskQueueWithOverflow
|
||||
ChunkTaskQueueWithOverflow* chunk_stack() { return &_chunk_stack; }
|
||||
#ifdef USE_RegionTaskQueueWithOverflow
|
||||
RegionTaskQueueWithOverflow* region_stack() { return &_region_stack; }
|
||||
#else
|
||||
ChunkTaskQueue* chunk_stack() { return &_chunk_stack; }
|
||||
GrowableArray<size_t>* chunk_overflow_stack() { return _chunk_overflow_stack; }
|
||||
RegionTaskQueue* region_stack() { return &_region_stack; }
|
||||
GrowableArray<size_t>* region_overflow_stack() {
|
||||
return _region_overflow_stack;
|
||||
}
|
||||
#endif
|
||||
|
||||
// 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
|
||||
// marking stack and overflow stack directly.
|
||||
|
||||
// Pushes onto the chunk stack. If the chunk stack is full,
|
||||
// pushes onto the chunk overflow stack.
|
||||
void chunk_stack_push(size_t chunk_index);
|
||||
// Pushes onto the region stack. If the region stack is full,
|
||||
// pushes onto the region overflow stack.
|
||||
void region_stack_push(size_t region_index);
|
||||
public:
|
||||
|
||||
Action action() { return _action; }
|
||||
|
@ -160,10 +161,10 @@ class ParCompactionManager : public CHeapObj {
|
|||
// Get a oop for scanning. If returns null, no oop were found.
|
||||
oop retrieve_for_scanning();
|
||||
|
||||
// Save chunk for later processing. Must not fail.
|
||||
void save_for_processing(size_t chunk_index);
|
||||
// Get a chunk for processing. If returns null, no chunk were found.
|
||||
bool retrieve_for_processing(size_t& chunk_index);
|
||||
// Save region for later processing. Must not fail.
|
||||
void save_for_processing(size_t region_index);
|
||||
// Get a region for processing. If returns null, no region were found.
|
||||
bool retrieve_for_processing(size_t& region_index);
|
||||
|
||||
// Access function for compaction managers
|
||||
static ParCompactionManager* gc_thread_compaction_manager(int index);
|
||||
|
@ -172,18 +173,18 @@ class ParCompactionManager : public CHeapObj {
|
|||
return stack_array()->steal(queue_num, seed, t);
|
||||
}
|
||||
|
||||
static bool steal(int queue_num, int* seed, ChunkTask& t) {
|
||||
return chunk_array()->steal(queue_num, seed, t);
|
||||
static bool steal(int queue_num, int* seed, RegionTask& t) {
|
||||
return region_array()->steal(queue_num, seed, t);
|
||||
}
|
||||
|
||||
// Process tasks remaining on any stack
|
||||
void drain_marking_stacks(OopClosure *blk);
|
||||
|
||||
// Process tasks remaining on any stack
|
||||
void drain_chunk_stacks();
|
||||
void drain_region_stacks();
|
||||
|
||||
// Process tasks remaining on any stack
|
||||
void drain_chunk_overflow_stack();
|
||||
void drain_region_overflow_stack();
|
||||
|
||||
// Debugging support
|
||||
#ifdef ASSERT
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -76,87 +76,87 @@ class ParallelCompactData
|
|||
{
|
||||
public:
|
||||
// Sizes are in HeapWords, unless indicated otherwise.
|
||||
static const size_t Log2ChunkSize;
|
||||
static const size_t ChunkSize;
|
||||
static const size_t ChunkSizeBytes;
|
||||
static const size_t Log2RegionSize;
|
||||
static const size_t RegionSize;
|
||||
static const size_t RegionSizeBytes;
|
||||
|
||||
// Mask for the bits in a size_t to get an offset within a chunk.
|
||||
static const size_t ChunkSizeOffsetMask;
|
||||
// Mask for the bits in a pointer to get an offset within a chunk.
|
||||
static const size_t ChunkAddrOffsetMask;
|
||||
// Mask for the bits in a pointer to get the address of the start of a chunk.
|
||||
static const size_t ChunkAddrMask;
|
||||
// Mask for the bits in a size_t to get an offset within a region.
|
||||
static const size_t RegionSizeOffsetMask;
|
||||
// Mask for the bits in a pointer to get an offset within a region.
|
||||
static const size_t RegionAddrOffsetMask;
|
||||
// Mask for the bits in a pointer to get the address of the start of a region.
|
||||
static const size_t RegionAddrMask;
|
||||
|
||||
static const size_t Log2BlockSize;
|
||||
static const size_t BlockSize;
|
||||
static const size_t BlockOffsetMask;
|
||||
static const size_t BlockMask;
|
||||
|
||||
static const size_t BlocksPerChunk;
|
||||
static const size_t BlocksPerRegion;
|
||||
|
||||
class ChunkData
|
||||
class RegionData
|
||||
{
|
||||
public:
|
||||
// Destination address of the chunk.
|
||||
// Destination address of the region.
|
||||
HeapWord* destination() const { return _destination; }
|
||||
|
||||
// The first chunk containing data destined for this chunk.
|
||||
size_t source_chunk() const { return _source_chunk; }
|
||||
// The first region containing data destined for this region.
|
||||
size_t source_region() const { return _source_region; }
|
||||
|
||||
// The object (if any) starting in this chunk and ending in a different
|
||||
// chunk that could not be updated during the main (parallel) compaction
|
||||
// The object (if any) starting in this region and ending in a different
|
||||
// region that could not be updated during the main (parallel) compaction
|
||||
// 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.
|
||||
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; }
|
||||
|
||||
// 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 of live data that lies within this chunk due to objects that start
|
||||
// in this chunk (words). This does not include the partial object
|
||||
// extending onto the chunk (if any), or the part of an object that extends
|
||||
// onto the next chunk (if any).
|
||||
// Size of live data that lies within this region due to objects that start
|
||||
// in this region (words). This does not include the partial object
|
||||
// extending onto the region (if any), or the part of an object that extends
|
||||
// onto the next region (if any).
|
||||
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(); }
|
||||
|
||||
// The destination_count is the number of other chunks to which data from
|
||||
// this chunk will be copied. At the end of the summary phase, the valid
|
||||
// The destination_count is the number of other regions to which data from
|
||||
// this region will be copied. At the end of the summary phase, the valid
|
||||
// values of destination_count are
|
||||
//
|
||||
// 0 - data from the chunk will be compacted completely into itself, or the
|
||||
// chunk is empty. The chunk can be claimed and then filled.
|
||||
// 1 - data from the chunk will be compacted into 1 other chunk; some
|
||||
// data from the chunk may also be compacted into the chunk itself.
|
||||
// 2 - data from the chunk will be copied to 2 other chunks.
|
||||
// 0 - data from the region will be compacted completely into itself, or the
|
||||
// region is empty. The region can be claimed and then filled.
|
||||
// 1 - data from the region will be compacted into 1 other region; some
|
||||
// data from the region may also be compacted into the region itself.
|
||||
// 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
|
||||
// then filled.
|
||||
//
|
||||
// A chunk is claimed for processing by atomically changing the
|
||||
// destination_count to the claimed value (dc_claimed). After a chunk has
|
||||
// A region is claimed for processing by atomically changing the
|
||||
// destination_count to the claimed value (dc_claimed). After a region has
|
||||
// been filled, the destination_count should be set to the completed value
|
||||
// (dc_completed).
|
||||
inline uint destination_count() 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;
|
||||
|
||||
// The highest address referenced by objects in this chunk.
|
||||
// The highest address referenced by objects in this region.
|
||||
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.
|
||||
//
|
||||
// Minor subtlety: claimed() returns true if the chunk is marked
|
||||
// completed(), which is desirable since a chunk must be claimed before it
|
||||
// Minor subtlety: claimed() returns true if the region is marked
|
||||
// completed(), which is desirable since a region must be claimed before it
|
||||
// can be completed.
|
||||
bool available() const { return _dc_and_los < dc_one; }
|
||||
bool claimed() const { return _dc_and_los >= dc_claimed; }
|
||||
|
@ -164,11 +164,11 @@ public:
|
|||
|
||||
// These are not atomic.
|
||||
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_partial_obj_addr(HeapWord* addr) { _partial_obj_addr = addr; }
|
||||
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);
|
||||
|
@ -184,24 +184,24 @@ public:
|
|||
inline bool claim();
|
||||
|
||||
private:
|
||||
// The type used to represent object sizes within a chunk.
|
||||
typedef uint chunk_sz_t;
|
||||
// The type used to represent object sizes within a region.
|
||||
typedef uint region_sz_t;
|
||||
|
||||
// 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
|
||||
// least significant end so no masking is necessary when adding.
|
||||
static const chunk_sz_t dc_shift; // Shift amount.
|
||||
static const chunk_sz_t dc_mask; // Mask for destination count.
|
||||
static const chunk_sz_t dc_one; // 1, shifted appropriately.
|
||||
static const chunk_sz_t dc_claimed; // Chunk has been claimed.
|
||||
static const chunk_sz_t dc_completed; // Chunk has been completed.
|
||||
static const chunk_sz_t los_mask; // Mask for live obj size.
|
||||
static const region_sz_t dc_shift; // Shift amount.
|
||||
static const region_sz_t dc_mask; // Mask for destination count.
|
||||
static const region_sz_t dc_one; // 1, shifted appropriately.
|
||||
static const region_sz_t dc_claimed; // Region has been claimed.
|
||||
static const region_sz_t dc_completed; // Region has been completed.
|
||||
static const region_sz_t los_mask; // Mask for live obj size.
|
||||
|
||||
HeapWord* _destination;
|
||||
size_t _source_chunk;
|
||||
size_t _source_region;
|
||||
HeapWord* _partial_obj_addr;
|
||||
chunk_sz_t _partial_obj_size;
|
||||
chunk_sz_t volatile _dc_and_los;
|
||||
region_sz_t _partial_obj_size;
|
||||
region_sz_t volatile _dc_and_los;
|
||||
#ifdef ASSERT
|
||||
// These enable optimizations that are only partially implemented. Use
|
||||
// debug builds to prevent the code fragments from breaking.
|
||||
|
@ -211,17 +211,17 @@ public:
|
|||
|
||||
#ifdef ASSERT
|
||||
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:
|
||||
#endif
|
||||
};
|
||||
|
||||
// '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
|
||||
// include any object extending into the block. The first block in
|
||||
// a chunk does not include any partial object extending into the
|
||||
// the chunk.
|
||||
// a region does not include any partial object extending into the
|
||||
// the region.
|
||||
//
|
||||
// The offset also encodes the
|
||||
// 'parity' of the first 1 bit in the Block: a positive offset means the
|
||||
|
@ -286,27 +286,27 @@ public:
|
|||
ParallelCompactData();
|
||||
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.
|
||||
inline ChunkData* chunk(size_t chunk_idx) const;
|
||||
inline size_t chunk(const ChunkData* const chunk_ptr) const;
|
||||
// Convert region indices to/from RegionData pointers.
|
||||
inline RegionData* region(size_t region_idx) const;
|
||||
inline size_t region(const RegionData* const region_ptr) const;
|
||||
|
||||
// Returns true if the given address is contained within the chunk
|
||||
bool chunk_contains(size_t chunk_index, HeapWord* addr);
|
||||
// Returns true if the given address is contained within the region
|
||||
bool region_contains(size_t region_index, HeapWord* addr);
|
||||
|
||||
size_t block_count() const { return _block_count; }
|
||||
inline BlockData* block(size_t n) const;
|
||||
|
||||
// Returns true if the given block is in the given chunk.
|
||||
static bool chunk_contains_block(size_t chunk_index, size_t block_index);
|
||||
// Returns true if the given block is in the given region.
|
||||
static bool region_contains_block(size_t region_index, size_t block_index);
|
||||
|
||||
void add_obj(HeapWord* addr, size_t 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
|
||||
// destination of chunk n is simply the start of chunk n. The argument beg
|
||||
// must be chunk-aligned; end need not be.
|
||||
// Fill in the regions covering [beg, end) so that no data moves; i.e., the
|
||||
// destination of region n is simply the start of region n. The argument beg
|
||||
// must be region-aligned; end need not be.
|
||||
void summarize_dense_prefix(HeapWord* beg, HeapWord* end);
|
||||
|
||||
bool summarize(HeapWord* target_beg, HeapWord* target_end,
|
||||
|
@ -314,27 +314,27 @@ public:
|
|||
HeapWord** target_next, HeapWord** source_next = 0);
|
||||
|
||||
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) {
|
||||
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.
|
||||
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.
|
||||
inline size_t addr_to_chunk_idx(const HeapWord* addr) const;
|
||||
inline ChunkData* addr_to_chunk_ptr(const HeapWord* addr) const;
|
||||
inline HeapWord* chunk_to_addr(size_t chunk) const;
|
||||
inline HeapWord* chunk_to_addr(size_t chunk, size_t offset) const;
|
||||
inline HeapWord* chunk_to_addr(const ChunkData* chunk) const;
|
||||
// Convert addresses to/from a region index or region pointer.
|
||||
inline size_t addr_to_region_idx(const HeapWord* addr) const;
|
||||
inline RegionData* addr_to_region_ptr(const HeapWord* addr) const;
|
||||
inline HeapWord* region_to_addr(size_t region) const;
|
||||
inline HeapWord* region_to_addr(size_t region, size_t offset) const;
|
||||
inline HeapWord* region_to_addr(const RegionData* region) const;
|
||||
|
||||
inline HeapWord* chunk_align_down(HeapWord* addr) const;
|
||||
inline HeapWord* chunk_align_up(HeapWord* addr) const;
|
||||
inline bool is_chunk_aligned(HeapWord* addr) const;
|
||||
inline HeapWord* region_align_down(HeapWord* addr) const;
|
||||
inline HeapWord* region_align_up(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 addr_to_block_idx(const HeapWord* addr) 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;
|
||||
|
||||
// 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
|
||||
// the compaction.
|
||||
|
@ -353,8 +353,8 @@ public:
|
|||
// Same as calc_new_pointer() using blocks.
|
||||
HeapWord* block_calc_new_pointer(HeapWord* addr);
|
||||
|
||||
// Same as calc_new_pointer() using chunks.
|
||||
HeapWord* chunk_calc_new_pointer(HeapWord* addr);
|
||||
// Same as calc_new_pointer() using regions.
|
||||
HeapWord* region_calc_new_pointer(HeapWord* addr);
|
||||
|
||||
HeapWord* calc_new_pointer(oop p) {
|
||||
return calc_new_pointer((HeapWord*) p);
|
||||
|
@ -364,7 +364,7 @@ public:
|
|||
klassOop calc_new_klass(klassOop);
|
||||
|
||||
// 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.
|
||||
bool partial_obj_ends_in_block(size_t block_index);
|
||||
|
||||
|
@ -378,7 +378,7 @@ public:
|
|||
|
||||
private:
|
||||
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);
|
||||
|
||||
private:
|
||||
|
@ -387,9 +387,9 @@ private:
|
|||
HeapWord* _region_end;
|
||||
#endif // #ifdef ASSERT
|
||||
|
||||
PSVirtualSpace* _chunk_vspace;
|
||||
ChunkData* _chunk_data;
|
||||
size_t _chunk_count;
|
||||
PSVirtualSpace* _region_vspace;
|
||||
RegionData* _region_data;
|
||||
size_t _region_count;
|
||||
|
||||
PSVirtualSpace* _block_vspace;
|
||||
BlockData* _block_data;
|
||||
|
@ -397,64 +397,64 @@ private:
|
|||
};
|
||||
|
||||
inline uint
|
||||
ParallelCompactData::ChunkData::destination_count_raw() const
|
||||
ParallelCompactData::RegionData::destination_count_raw() const
|
||||
{
|
||||
return _dc_and_los & dc_mask;
|
||||
}
|
||||
|
||||
inline uint
|
||||
ParallelCompactData::ChunkData::destination_count() const
|
||||
ParallelCompactData::RegionData::destination_count() const
|
||||
{
|
||||
return destination_count_raw() >> dc_shift;
|
||||
}
|
||||
|
||||
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");
|
||||
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;
|
||||
}
|
||||
|
||||
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");
|
||||
_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_one, "count would go negative");
|
||||
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;)
|
||||
NOT_DEBUG(return NULL;)
|
||||
}
|
||||
|
||||
inline HeapWord* ParallelCompactData::ChunkData::highest_ref() const
|
||||
inline HeapWord* ParallelCompactData::RegionData::highest_ref() const
|
||||
{
|
||||
DEBUG_ONLY(return _highest_ref;)
|
||||
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;)
|
||||
}
|
||||
|
||||
inline void ParallelCompactData::ChunkData::set_completed()
|
||||
inline void ParallelCompactData::RegionData::set_completed()
|
||||
{
|
||||
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.
|
||||
inline bool ParallelCompactData::ChunkData::claim_unsafe()
|
||||
inline bool ParallelCompactData::RegionData::claim_unsafe()
|
||||
{
|
||||
if (available()) {
|
||||
_dc_and_los |= dc_claimed;
|
||||
|
@ -463,13 +463,13 @@ inline bool ParallelCompactData::ChunkData::claim_unsafe()
|
|||
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");
|
||||
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
|
||||
HeapWord* tmp = _highest_ref;
|
||||
|
@ -479,7 +479,7 @@ inline void ParallelCompactData::ChunkData::set_highest_ref(HeapWord* addr)
|
|||
#endif // #ifdef ASSERT
|
||||
}
|
||||
|
||||
inline bool ParallelCompactData::ChunkData::claim()
|
||||
inline bool ParallelCompactData::RegionData::claim()
|
||||
{
|
||||
const int los = (int) live_obj_size();
|
||||
const int old = Atomic::cmpxchg(dc_claimed | los,
|
||||
|
@ -487,19 +487,19 @@ inline bool ParallelCompactData::ChunkData::claim()
|
|||
return old == los;
|
||||
}
|
||||
|
||||
inline ParallelCompactData::ChunkData*
|
||||
ParallelCompactData::chunk(size_t chunk_idx) const
|
||||
inline ParallelCompactData::RegionData*
|
||||
ParallelCompactData::region(size_t region_idx) const
|
||||
{
|
||||
assert(chunk_idx <= chunk_count(), "bad arg");
|
||||
return _chunk_data + chunk_idx;
|
||||
assert(region_idx <= region_count(), "bad arg");
|
||||
return _region_data + region_idx;
|
||||
}
|
||||
|
||||
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(chunk_ptr <= _chunk_data + chunk_count(), "bad arg");
|
||||
return pointer_delta(chunk_ptr, _chunk_data, sizeof(ChunkData));
|
||||
assert(region_ptr >= _region_data, "bad arg");
|
||||
assert(region_ptr <= _region_data + region_count(), "bad arg");
|
||||
return pointer_delta(region_ptr, _region_data, sizeof(RegionData));
|
||||
}
|
||||
|
||||
inline ParallelCompactData::BlockData*
|
||||
|
@ -509,68 +509,69 @@ ParallelCompactData::block(size_t n) const {
|
|||
}
|
||||
|
||||
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_end, "bad addr");
|
||||
return (size_t(addr) & ChunkAddrOffsetMask) >> LogHeapWordSize;
|
||||
return (size_t(addr) & RegionAddrOffsetMask) >> LogHeapWordSize;
|
||||
}
|
||||
|
||||
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_end, "bad addr");
|
||||
return pointer_delta(addr, _region_start) >> Log2ChunkSize;
|
||||
return pointer_delta(addr, _region_start) >> Log2RegionSize;
|
||||
}
|
||||
|
||||
inline ParallelCompactData::ChunkData*
|
||||
ParallelCompactData::addr_to_chunk_ptr(const HeapWord* addr) const
|
||||
inline ParallelCompactData::RegionData*
|
||||
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*
|
||||
ParallelCompactData::chunk_to_addr(size_t chunk) const
|
||||
ParallelCompactData::region_to_addr(size_t region) const
|
||||
{
|
||||
assert(chunk <= _chunk_count, "chunk out of range");
|
||||
return _region_start + (chunk << Log2ChunkSize);
|
||||
assert(region <= _region_count, "region out of range");
|
||||
return _region_start + (region << Log2RegionSize);
|
||||
}
|
||||
|
||||
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*
|
||||
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(offset < ChunkSize, "offset too big"); // This may be too strict.
|
||||
return chunk_to_addr(chunk) + offset;
|
||||
assert(region <= _region_count, "region out of range");
|
||||
assert(offset < RegionSize, "offset too big"); // This may be too strict.
|
||||
return region_to_addr(region) + offset;
|
||||
}
|
||||
|
||||
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_end + ChunkSize, "bad addr");
|
||||
return (HeapWord*)(size_t(addr) & ChunkAddrMask);
|
||||
assert(addr < _region_end + RegionSize, "bad addr");
|
||||
return (HeapWord*)(size_t(addr) & RegionAddrMask);
|
||||
}
|
||||
|
||||
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_end, "bad addr");
|
||||
return chunk_align_down(addr + ChunkSizeOffsetMask);
|
||||
return region_align_down(addr + RegionSizeOffsetMask);
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -692,40 +693,39 @@ class BitBlockUpdateClosure: public ParMarkBitMapClosure {
|
|||
// ParallelCompactData::BlockData::blk_ofs_t _live_data_left;
|
||||
size_t _live_data_left;
|
||||
size_t _cur_block;
|
||||
HeapWord* _chunk_start;
|
||||
HeapWord* _chunk_end;
|
||||
size_t _chunk_index;
|
||||
HeapWord* _region_start;
|
||||
HeapWord* _region_end;
|
||||
size_t _region_index;
|
||||
|
||||
public:
|
||||
BitBlockUpdateClosure(ParMarkBitMap* mbm,
|
||||
ParCompactionManager* cm,
|
||||
size_t chunk_index);
|
||||
size_t region_index);
|
||||
|
||||
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; }
|
||||
// Returns true the first bit in the current block (cur_block) is
|
||||
// a start bit.
|
||||
// Returns true if the current block is within the chunk for the closure;
|
||||
bool chunk_contains_cur_block();
|
||||
// Returns true if the current block is within the region for the closure;
|
||||
bool region_contains_cur_block();
|
||||
|
||||
// Set the chunk index and related chunk values for
|
||||
// a new chunk.
|
||||
void reset_chunk(size_t chunk_index);
|
||||
// Set the region index and related region values for
|
||||
// a new region.
|
||||
void reset_region(size_t region_index);
|
||||
|
||||
virtual IterationStatus do_addr(HeapWord* addr, size_t words);
|
||||
};
|
||||
|
||||
// The UseParallelOldGC collector is a stop-the-world garbage
|
||||
// collector that does parts of the collection using parallel threads.
|
||||
// The collection includes the tenured generation and the young
|
||||
// generation. The permanent generation is collected at the same
|
||||
// time as the other two generations but the permanent generation
|
||||
// is collect by a single GC thread. The permanent generation is
|
||||
// collected serially because of the requirement that during the
|
||||
// processing of a klass AAA, any objects reference by AAA must
|
||||
// already have been processed. This requirement is enforced by
|
||||
// a left (lower address) to right (higher address) sliding compaction.
|
||||
// The UseParallelOldGC collector is a stop-the-world garbage collector that
|
||||
// does parts of the collection using parallel threads. The collection includes
|
||||
// the tenured generation and the young generation. The permanent generation is
|
||||
// collected at the same time as the other two generations but the permanent
|
||||
// generation is collect by a single GC thread. The permanent generation is
|
||||
// collected serially because of the requirement that during the processing of a
|
||||
// klass AAA, any objects reference by AAA must already have been processed.
|
||||
// This requirement is enforced by a left (lower address) to right (higher
|
||||
// address) sliding compaction.
|
||||
//
|
||||
// There are four phases of the collection.
|
||||
//
|
||||
|
@ -740,80 +740,75 @@ class BitBlockUpdateClosure: public ParMarkBitMapClosure {
|
|||
// - move the objects to their destination
|
||||
// - update some references and reinitialize some variables
|
||||
//
|
||||
// These three phases are invoked in PSParallelCompact::invoke_no_policy().
|
||||
// The marking phase is implemented in PSParallelCompact::marking_phase()
|
||||
// and does a complete marking of the heap.
|
||||
// The summary phase is implemented in PSParallelCompact::summary_phase().
|
||||
// The move and update phase is implemented in PSParallelCompact::compact().
|
||||
// These three phases are invoked in PSParallelCompact::invoke_no_policy(). The
|
||||
// marking phase is implemented in PSParallelCompact::marking_phase() and does a
|
||||
// complete marking of the heap. The summary phase is implemented in
|
||||
// PSParallelCompact::summary_phase(). The move and update phase is implemented
|
||||
// in PSParallelCompact::compact().
|
||||
//
|
||||
// A space that is being collected is divided into chunks and with
|
||||
// each chunk is associated an object of type ParallelCompactData.
|
||||
// Each chunk is of a fixed size and typically will contain more than
|
||||
// 1 object and may have parts of objects at the front and back of the
|
||||
// chunk.
|
||||
// A space that is being collected is divided into regions and with each region
|
||||
// is associated an object of type ParallelCompactData. Each region is of a
|
||||
// fixed size and typically will contain more than 1 object and may have parts
|
||||
// of objects at the front and back of the region.
|
||||
//
|
||||
// chunk -----+---------------------+----------
|
||||
// region -----+---------------------+----------
|
||||
// objects covered [ AAA )[ BBB )[ CCC )[ DDD )
|
||||
//
|
||||
// The marking phase does a complete marking of all live objects in the
|
||||
// heap. The marking also compiles the size of the data for
|
||||
// all live objects covered by the chunk. This size includes the
|
||||
// part of any live object spanning onto the chunk (part of AAA
|
||||
// if it is live) from the front, all live objects contained in the chunk
|
||||
// (BBB and/or CCC if they are live), and the part of any live objects
|
||||
// covered by the chunk that extends off the chunk (part of DDD if it is
|
||||
// live). The marking phase uses multiple GC threads and marking is
|
||||
// done in a bit array of type ParMarkBitMap. The marking of the
|
||||
// bit map is done atomically as is the accumulation of the size of the
|
||||
// live objects covered by a chunk.
|
||||
// The marking phase does a complete marking of all live objects in the heap.
|
||||
// The marking also compiles the size of the data for all live objects covered
|
||||
// by the region. This size includes the part of any live object spanning onto
|
||||
// the region (part of AAA if it is live) from the front, all live objects
|
||||
// contained in the region (BBB and/or CCC if they are live), and the part of
|
||||
// any live objects covered by the region that extends off the region (part of
|
||||
// DDD if it is live). The marking phase uses multiple GC threads and marking
|
||||
// is done in a bit array of type ParMarkBitMap. The marking of the bit map is
|
||||
// done atomically as is the accumulation of the size of the live objects
|
||||
// covered by a region.
|
||||
//
|
||||
// The summary phase calculates the total live data to the left of
|
||||
// each chunk XXX. Based on that total and the bottom of the space,
|
||||
// it can calculate the starting location of the live data in XXX.
|
||||
// The summary phase calculates for each chunk XXX quantites such as
|
||||
// The summary phase calculates the total live data to the left of each region
|
||||
// XXX. Based on that total and the bottom of the space, it can calculate the
|
||||
// starting location of the live data in XXX. The summary phase calculates for
|
||||
// each region XXX quantites such as
|
||||
//
|
||||
// - the amount of live data at the beginning of a chunk from an object
|
||||
// entering the chunk.
|
||||
// - the location of the first live data on the chunk
|
||||
// - a count of the number of chunks receiving live data from XXX.
|
||||
// - the amount of live data at the beginning of a region from an object
|
||||
// entering the region.
|
||||
// - the location of the first live data on the region
|
||||
// - a count of the number of regions receiving live data from XXX.
|
||||
//
|
||||
// See ParallelCompactData for precise details. The summary phase also
|
||||
// calculates the dense prefix for the compaction. The dense prefix
|
||||
// is a portion at the beginning of the space that is not moved. The
|
||||
// objects in the dense prefix do need to have their object references
|
||||
// updated. See method summarize_dense_prefix().
|
||||
// calculates the dense prefix for the compaction. The dense prefix is a
|
||||
// portion at the beginning of the space that is not moved. The objects in the
|
||||
// dense prefix do need to have their object references updated. See method
|
||||
// summarize_dense_prefix().
|
||||
//
|
||||
// The summary phase is done using 1 GC thread.
|
||||
//
|
||||
// The compaction phase moves objects to their new location and updates
|
||||
// all references in the object.
|
||||
// The compaction phase moves objects to their new location and updates all
|
||||
// references in the object.
|
||||
//
|
||||
// A current exception is that objects that cross a chunk boundary
|
||||
// are moved but do not have their references updated. References are
|
||||
// not updated because it cannot easily be determined if the klass
|
||||
// pointer KKK for the object AAA has been updated. KKK likely resides
|
||||
// in a chunk to the left of the chunk containing AAA. These AAA's
|
||||
// have there references updated at the end in a clean up phase.
|
||||
// See the method PSParallelCompact::update_deferred_objects(). An
|
||||
// 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.
|
||||
// A current exception is that objects that cross a region boundary are moved
|
||||
// but do not have their references updated. References are not updated because
|
||||
// it cannot easily be determined if the klass pointer KKK for the object AAA
|
||||
// has been updated. KKK likely resides in a region to the left of the region
|
||||
// containing AAA. These AAA's have there references updated at the end in a
|
||||
// clean up phase. See the method PSParallelCompact::update_deferred_objects().
|
||||
// An alternate strategy is being investigated for this deferral of updating.
|
||||
//
|
||||
// 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 {
|
||||
public:
|
||||
// Convenient access to type names.
|
||||
typedef ParMarkBitMap::idx_t idx_t;
|
||||
typedef ParallelCompactData::ChunkData ChunkData;
|
||||
typedef ParallelCompactData::RegionData RegionData;
|
||||
typedef ParallelCompactData::BlockData BlockData;
|
||||
|
||||
typedef enum {
|
||||
|
@ -977,26 +972,26 @@ class PSParallelCompact : AllStatic {
|
|||
// not reclaimed).
|
||||
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
|
||||
// chunk in the space that is not completely live.
|
||||
static ChunkData* dead_wood_limit_chunk(const ChunkData* beg,
|
||||
const ChunkData* end,
|
||||
// region in the space that is not completely live.
|
||||
static RegionData* dead_wood_limit_region(const RegionData* beg,
|
||||
const RegionData* end,
|
||||
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.
|
||||
static ChunkData* first_dead_space_chunk(const ChunkData* beg,
|
||||
const ChunkData* end);
|
||||
static RegionData* first_dead_space_region(const RegionData* beg,
|
||||
const RegionData* end);
|
||||
|
||||
// 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
|
||||
// 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)
|
||||
// updating references in the dense prefix plus (b) copying objects and
|
||||
// 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 top,
|
||||
HeapWord* const new_top);
|
||||
|
@ -1005,9 +1000,9 @@ class PSParallelCompact : AllStatic {
|
|||
static HeapWord* compute_dense_prefix(const SpaceId id,
|
||||
bool maximum_compaction);
|
||||
|
||||
// Return true if dead space crosses onto the specified Chunk; bit must be the
|
||||
// bit index corresponding to the first word of the Chunk.
|
||||
static inline bool dead_space_crosses_boundary(const ChunkData* chunk,
|
||||
// Return true if dead space crosses onto the specified Region; bit must be
|
||||
// the bit index corresponding to the first word of the Region.
|
||||
static inline bool dead_space_crosses_boundary(const RegionData* region,
|
||||
idx_t bit);
|
||||
|
||||
// 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();
|
||||
|
||||
// Add available chunks to the stack and draining tasks to the task queue.
|
||||
static void enqueue_chunk_draining_tasks(GCTaskQueue* q,
|
||||
// Add available regions to the stack and draining tasks to the task queue.
|
||||
static void enqueue_region_draining_tasks(GCTaskQueue* q,
|
||||
uint parallel_gc_threads);
|
||||
|
||||
// Add dense prefix update tasks to the task queue.
|
||||
static void enqueue_dense_prefix_tasks(GCTaskQueue* q,
|
||||
uint parallel_gc_threads);
|
||||
|
||||
// Add chunk stealing tasks to the task queue.
|
||||
static void enqueue_chunk_stealing_tasks(
|
||||
// Add region stealing tasks to the task queue.
|
||||
static void enqueue_region_stealing_tasks(
|
||||
GCTaskQueue* q,
|
||||
ParallelTaskTerminator* terminator_ptr,
|
||||
uint parallel_gc_threads);
|
||||
|
@ -1154,56 +1149,56 @@ class PSParallelCompact : AllStatic {
|
|||
// Move and update the live objects in the specified space.
|
||||
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.
|
||||
static void dense_prefix_chunks_epilogue(ParCompactionManager* cm,
|
||||
size_t chunk_start_index,
|
||||
size_t chunk_end_index,
|
||||
static void dense_prefix_regions_epilogue(ParCompactionManager* cm,
|
||||
size_t region_start_index,
|
||||
size_t region_end_index,
|
||||
idx_t exiting_object_offset,
|
||||
idx_t chunk_offset_start,
|
||||
idx_t chunk_offset_end);
|
||||
idx_t region_offset_start,
|
||||
idx_t region_offset_end);
|
||||
|
||||
// Update a chunk in the dense prefix. For each live object
|
||||
// in the chunk, update it's interior references. For each
|
||||
// Update a region in the dense prefix. For each live object
|
||||
// in the region, update it's interior references. For each
|
||||
// dead object, fill it with deadwood. Dead space at the end
|
||||
// of a chunk range will be filled to the start of the next
|
||||
// live object regardless of the chunk_index_end. None of the
|
||||
// of a region range will be filled to the start of the next
|
||||
// live object regardless of the region_index_end. None of the
|
||||
// objects in the dense prefix move and dead space is dead
|
||||
// (holds only dead objects that don't need any processing), so
|
||||
// dead space can be filled in any order.
|
||||
static void update_and_deadwood_in_dense_prefix(ParCompactionManager* cm,
|
||||
SpaceId space_id,
|
||||
size_t chunk_index_start,
|
||||
size_t chunk_index_end);
|
||||
size_t region_index_start,
|
||||
size_t region_index_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);
|
||||
|
||||
// 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,
|
||||
size_t src_chunk_idx);
|
||||
size_t src_region_idx);
|
||||
|
||||
// Determine the next source chunk, set closure.source() to the start of the
|
||||
// new chunk return the chunk index. Parameter end_addr is the address one
|
||||
// Determine the next source region, set closure.source() to the start of the
|
||||
// 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
|
||||
// new source space and set src_space_id (in-out parameter) and src_space_top
|
||||
// (out parameter) accordingly.
|
||||
static size_t next_src_chunk(MoveAndUpdateClosure& closure,
|
||||
static size_t next_src_region(MoveAndUpdateClosure& closure,
|
||||
SpaceId& src_space_id,
|
||||
HeapWord*& src_space_top,
|
||||
HeapWord* end_addr);
|
||||
|
||||
// Decrement the destination count for each non-empty source chunk in the
|
||||
// range [beg_chunk, chunk(chunk_align_up(end_addr))).
|
||||
// Decrement the destination count for each non-empty source region in the
|
||||
// range [beg_region, region(region_align_up(end_addr))).
|
||||
static void decrement_destination_counts(ParCompactionManager* cm,
|
||||
size_t beg_chunk,
|
||||
size_t beg_region,
|
||||
HeapWord* end_addr);
|
||||
|
||||
// Fill a chunk, copying objects from one or more source chunks.
|
||||
static void fill_chunk(ParCompactionManager* cm, size_t chunk_idx);
|
||||
static void fill_and_update_chunk(ParCompactionManager* cm, size_t chunk) {
|
||||
fill_chunk(cm, chunk);
|
||||
// Fill a region, copying objects from one or more source regions.
|
||||
static void fill_region(ParCompactionManager* cm, size_t region_idx);
|
||||
static void fill_and_update_region(ParCompactionManager* cm, size_t region) {
|
||||
fill_region(cm, region);
|
||||
}
|
||||
|
||||
// Update the deferred objects in the space.
|
||||
|
@ -1259,7 +1254,7 @@ class PSParallelCompact : AllStatic {
|
|||
#ifndef PRODUCT
|
||||
// Debugging support.
|
||||
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,
|
||||
const SpaceId id,
|
||||
const bool maximum_compaction,
|
||||
|
@ -1267,7 +1262,7 @@ class PSParallelCompact : AllStatic {
|
|||
#endif // #ifndef PRODUCT
|
||||
|
||||
#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);
|
||||
#endif // #ifdef ASSERT
|
||||
};
|
||||
|
@ -1376,17 +1371,17 @@ inline double PSParallelCompact::normal_distribution(double density) {
|
|||
}
|
||||
|
||||
inline bool
|
||||
PSParallelCompact::dead_space_crosses_boundary(const ChunkData* chunk,
|
||||
PSParallelCompact::dead_space_crosses_boundary(const RegionData* region,
|
||||
idx_t bit)
|
||||
{
|
||||
assert(bit > 0, "cannot call this for the first bit/chunk");
|
||||
assert(_summary_data.chunk_to_addr(chunk) == _mark_bitmap.bit_to_addr(bit),
|
||||
assert(bit > 0, "cannot call this for the first bit/region");
|
||||
assert(_summary_data.region_to_addr(region) == _mark_bitmap.bit_to_addr(bit),
|
||||
"sanity check");
|
||||
|
||||
// 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,
|
||||
// and (3) an object does not end at the end of the prior chunk.
|
||||
return chunk->partial_obj_size() == 0 &&
|
||||
// onto the region, (2) an object does not start at the beginning of the
|
||||
// region, and (3) an object does not end at the end of the prior region.
|
||||
return region->partial_obj_size() == 0 &&
|
||||
!_mark_bitmap.is_obj_beg(bit) &&
|
||||
!_mark_bitmap.is_obj_end(bit - 1);
|
||||
}
|
||||
|
|
|
@ -1157,8 +1157,8 @@ class CommandLineFlags {
|
|||
"In the Parallel Old garbage collector use parallel dense" \
|
||||
" prefix update") \
|
||||
\
|
||||
develop(bool, UseParallelOldGCChunkPointerCalc, true, \
|
||||
"In the Parallel Old garbage collector use chucks to calculate" \
|
||||
develop(bool, UseParallelOldGCRegionPointerCalc, true, \
|
||||
"In the Parallel Old garbage collector use regions to calculate" \
|
||||
"new object locations") \
|
||||
\
|
||||
product(uintx, HeapMaximumCompactionInterval, 20, \
|
||||
|
@ -1195,8 +1195,8 @@ class CommandLineFlags {
|
|||
develop(bool, ParallelOldMTUnsafeUpdateLiveData, false, \
|
||||
"Use the Parallel Old MT unsafe in update of live size") \
|
||||
\
|
||||
develop(bool, TraceChunkTasksQueuing, false, \
|
||||
"Trace the queuing of the chunk tasks") \
|
||||
develop(bool, TraceRegionTasksQueuing, false, \
|
||||
"Trace the queuing of the region tasks") \
|
||||
\
|
||||
product(uintx, ParallelMarkingThreads, 0, \
|
||||
"Number of marking threads concurrent gc will use") \
|
||||
|
|
|
@ -109,72 +109,72 @@ void ParallelTaskTerminator::reset_for_reuse() {
|
|||
}
|
||||
}
|
||||
|
||||
bool ChunkTaskQueueWithOverflow::is_empty() {
|
||||
return (_chunk_queue.size() == 0) &&
|
||||
bool RegionTaskQueueWithOverflow::is_empty() {
|
||||
return (_region_queue.size() == 0) &&
|
||||
(_overflow_stack->length() == 0);
|
||||
}
|
||||
|
||||
bool ChunkTaskQueueWithOverflow::stealable_is_empty() {
|
||||
return _chunk_queue.size() == 0;
|
||||
bool RegionTaskQueueWithOverflow::stealable_is_empty() {
|
||||
return _region_queue.size() == 0;
|
||||
}
|
||||
|
||||
bool ChunkTaskQueueWithOverflow::overflow_is_empty() {
|
||||
bool RegionTaskQueueWithOverflow::overflow_is_empty() {
|
||||
return _overflow_stack->length() == 0;
|
||||
}
|
||||
|
||||
void ChunkTaskQueueWithOverflow::initialize() {
|
||||
_chunk_queue.initialize();
|
||||
void RegionTaskQueueWithOverflow::initialize() {
|
||||
_region_queue.initialize();
|
||||
assert(_overflow_stack == 0, "Creating memory leak");
|
||||
_overflow_stack =
|
||||
new (ResourceObj::C_HEAP) GrowableArray<ChunkTask>(10, true);
|
||||
new (ResourceObj::C_HEAP) GrowableArray<RegionTask>(10, true);
|
||||
}
|
||||
|
||||
void ChunkTaskQueueWithOverflow::save(ChunkTask t) {
|
||||
if (TraceChunkTasksQueuing && Verbose) {
|
||||
void RegionTaskQueueWithOverflow::save(RegionTask t) {
|
||||
if (TraceRegionTasksQueuing && Verbose) {
|
||||
gclog_or_tty->print_cr("CTQ: save " PTR_FORMAT, t);
|
||||
}
|
||||
if(!_chunk_queue.push(t)) {
|
||||
if(!_region_queue.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
|
||||
// the overflow stack. It may be more efficient to
|
||||
// check the stealable queue and the overflow stack
|
||||
// separately.
|
||||
bool ChunkTaskQueueWithOverflow::retrieve(ChunkTask& chunk_task) {
|
||||
bool result = retrieve_from_overflow(chunk_task);
|
||||
bool RegionTaskQueueWithOverflow::retrieve(RegionTask& region_task) {
|
||||
bool result = retrieve_from_overflow(region_task);
|
||||
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);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ChunkTaskQueueWithOverflow::retrieve_from_stealable_queue(
|
||||
ChunkTask& chunk_task) {
|
||||
bool result = _chunk_queue.pop_local(chunk_task);
|
||||
if (TraceChunkTasksQueuing && Verbose) {
|
||||
gclog_or_tty->print_cr("CTQ: retrieve_stealable " PTR_FORMAT, chunk_task);
|
||||
bool RegionTaskQueueWithOverflow::retrieve_from_stealable_queue(
|
||||
RegionTask& region_task) {
|
||||
bool result = _region_queue.pop_local(region_task);
|
||||
if (TraceRegionTasksQueuing && Verbose) {
|
||||
gclog_or_tty->print_cr("CTQ: retrieve_stealable " PTR_FORMAT, region_task);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ChunkTaskQueueWithOverflow::retrieve_from_overflow(
|
||||
ChunkTask& chunk_task) {
|
||||
bool
|
||||
RegionTaskQueueWithOverflow::retrieve_from_overflow(RegionTask& region_task) {
|
||||
bool result;
|
||||
if (!_overflow_stack->is_empty()) {
|
||||
chunk_task = _overflow_stack->pop();
|
||||
region_task = _overflow_stack->pop();
|
||||
result = true;
|
||||
} else {
|
||||
chunk_task = (ChunkTask) NULL;
|
||||
region_task = (RegionTask) NULL;
|
||||
result = false;
|
||||
}
|
||||
if (TraceChunkTasksQueuing && Verbose) {
|
||||
gclog_or_tty->print_cr("CTQ: retrieve_stealable " PTR_FORMAT, chunk_task);
|
||||
if (TraceRegionTasksQueuing && Verbose) {
|
||||
gclog_or_tty->print_cr("CTQ: retrieve_stealable " PTR_FORMAT, region_task);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -557,32 +557,32 @@ class StarTask {
|
|||
typedef GenericTaskQueue<StarTask> OopStarTaskQueue;
|
||||
typedef GenericTaskQueueSet<StarTask> OopStarTaskQueueSet;
|
||||
|
||||
typedef size_t ChunkTask; // index for chunk
|
||||
typedef GenericTaskQueue<ChunkTask> ChunkTaskQueue;
|
||||
typedef GenericTaskQueueSet<ChunkTask> ChunkTaskQueueSet;
|
||||
typedef size_t RegionTask; // index for region
|
||||
typedef GenericTaskQueue<RegionTask> RegionTaskQueue;
|
||||
typedef GenericTaskQueueSet<RegionTask> RegionTaskQueueSet;
|
||||
|
||||
class ChunkTaskQueueWithOverflow: public CHeapObj {
|
||||
class RegionTaskQueueWithOverflow: public CHeapObj {
|
||||
protected:
|
||||
ChunkTaskQueue _chunk_queue;
|
||||
GrowableArray<ChunkTask>* _overflow_stack;
|
||||
RegionTaskQueue _region_queue;
|
||||
GrowableArray<RegionTask>* _overflow_stack;
|
||||
|
||||
public:
|
||||
ChunkTaskQueueWithOverflow() : _overflow_stack(NULL) {}
|
||||
RegionTaskQueueWithOverflow() : _overflow_stack(NULL) {}
|
||||
// Initialize both stealable queue and overflow
|
||||
void initialize();
|
||||
// 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
|
||||
bool retrieve(ChunkTask& chunk_index);
|
||||
bool retrieve(RegionTask& region_index);
|
||||
// Retrieve from stealable queue
|
||||
bool retrieve_from_stealable_queue(ChunkTask& chunk_index);
|
||||
bool retrieve_from_stealable_queue(RegionTask& region_index);
|
||||
// Retrieve from overflow
|
||||
bool retrieve_from_overflow(ChunkTask& chunk_index);
|
||||
bool retrieve_from_overflow(RegionTask& region_index);
|
||||
bool is_empty();
|
||||
bool stealable_is_empty();
|
||||
bool overflow_is_empty();
|
||||
juint stealable_size() { return _chunk_queue.size(); }
|
||||
ChunkTaskQueue* task_queue() { return &_chunk_queue; }
|
||||
juint stealable_size() { return _region_queue.size(); }
|
||||
RegionTaskQueue* task_queue() { return &_region_queue; }
|
||||
};
|
||||
|
||||
#define USE_ChunkTaskQueueWithOverflow
|
||||
#define USE_RegionTaskQueueWithOverflow
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue