6407976: GC worker number should be unsigned

Reviewed-by: jwilhelm, tschatzl
This commit is contained in:
Evgeniya Stepanova 2015-04-29 15:12:33 +03:00
parent 4ff6849791
commit 19e80a1f8f
16 changed files with 91 additions and 95 deletions

View File

@ -2898,8 +2898,8 @@ CMSPhaseAccounting::~CMSPhaseAccounting() {
class CMSParMarkTask : public AbstractGangTask {
protected:
CMSCollector* _collector;
int _n_workers;
CMSParMarkTask(const char* name, CMSCollector* collector, int n_workers) :
uint _n_workers;
CMSParMarkTask(const char* name, CMSCollector* collector, uint n_workers) :
AbstractGangTask(name),
_collector(collector),
_n_workers(n_workers) {}
@ -2913,7 +2913,7 @@ class CMSParMarkTask : public AbstractGangTask {
// Parallel initial mark task
class CMSParInitialMarkTask: public CMSParMarkTask {
public:
CMSParInitialMarkTask(CMSCollector* collector, int n_workers) :
CMSParInitialMarkTask(CMSCollector* collector, uint n_workers) :
CMSParMarkTask("Scan roots and young gen for initial mark in parallel",
collector, n_workers) {}
void work(uint worker_id);
@ -3002,7 +3002,7 @@ void CMSCollector::checkpointRootsInitialWork() {
// The parallel version.
FlexibleWorkGang* workers = gch->workers();
assert(workers != NULL, "Need parallel worker threads.");
int n_workers = workers->active_workers();
uint n_workers = workers->active_workers();
CMSParInitialMarkTask tsk(this, n_workers);
gch->set_par_threads(n_workers);
initialize_sequential_subtasks_for_young_gen_rescan(n_workers);
@ -3143,7 +3143,7 @@ class CMSConcMarkingTerminatorTerminator: public TerminatorTerminator {
// MT Concurrent Marking Task
class CMSConcMarkingTask: public YieldingFlexibleGangTask {
CMSCollector* _collector;
int _n_workers; // requested/desired # workers
uint _n_workers; // requested/desired # workers
bool _result;
CompactibleFreeListSpace* _cms_space;
char _pad_front[64]; // padding to ...
@ -3189,7 +3189,7 @@ class CMSConcMarkingTask: public YieldingFlexibleGangTask {
CMSConcMarkingTerminator* terminator() { return &_term; }
virtual void set_for_termination(int active_workers) {
virtual void set_for_termination(uint active_workers) {
terminator()->reset_for_reuse(active_workers);
}
@ -3635,10 +3635,9 @@ void CMSConcMarkingTask::coordinator_yield() {
bool CMSCollector::do_marking_mt() {
assert(ConcGCThreads > 0 && conc_workers() != NULL, "precondition");
int num_workers = AdaptiveSizePolicy::calc_active_conc_workers(
conc_workers()->total_workers(),
conc_workers()->active_workers(),
Threads::number_of_non_daemon_threads());
uint num_workers = AdaptiveSizePolicy::calc_active_conc_workers(conc_workers()->total_workers(),
conc_workers()->active_workers(),
Threads::number_of_non_daemon_threads());
conc_workers()->set_active_workers(num_workers);
CompactibleFreeListSpace* cms_space = _cmsGen->cmsSpace();
@ -4484,7 +4483,7 @@ class CMSParRemarkTask: public CMSParMarkTask {
// workers to be taken from the active workers in the work gang.
CMSParRemarkTask(CMSCollector* collector,
CompactibleFreeListSpace* cms_space,
int n_workers, FlexibleWorkGang* workers,
uint n_workers, FlexibleWorkGang* workers,
OopTaskQueueSet* task_queues):
CMSParMarkTask("Rescan roots and grey objects in parallel",
collector, n_workers),
@ -4497,7 +4496,7 @@ class CMSParRemarkTask: public CMSParMarkTask {
OopTaskQueue* work_queue(int i) { return task_queues()->queue(i); }
ParallelTaskTerminator* terminator() { return &_term; }
int n_workers() { return _n_workers; }
uint n_workers() { return _n_workers; }
void work(uint worker_id);
@ -5060,7 +5059,7 @@ void CMSCollector::do_remark_parallel() {
// Choose to use the number of GC workers most recently set
// into "active_workers". If active_workers is not set, set it
// to ParallelGCThreads.
int n_workers = workers->active_workers();
uint n_workers = workers->active_workers();
if (n_workers == 0) {
assert(n_workers > 0, "Should have been set during scavenge");
n_workers = ParallelGCThreads;
@ -5426,7 +5425,7 @@ void CMSCollector::refProcessingWork() {
// That is OK as long as the Reference lists are balanced (see
// balance_all_queues() and balance_queues()).
GenCollectedHeap* gch = GenCollectedHeap::heap();
int active_workers = ParallelGCThreads;
uint active_workers = ParallelGCThreads;
FlexibleWorkGang* workers = gch->workers();
if (workers != NULL) {
active_workers = workers->active_workers();

View File

@ -2315,13 +2315,13 @@ private:
G1CollectedHeap* _g1h;
ConcurrentMark* _cm;
WorkGang* _workers;
int _active_workers;
uint _active_workers;
public:
G1CMRefProcTaskExecutor(G1CollectedHeap* g1h,
ConcurrentMark* cm,
WorkGang* workers,
int n_workers) :
ConcurrentMark* cm,
WorkGang* workers,
uint n_workers) :
_g1h(g1h), _cm(cm),
_workers(workers), _active_workers(n_workers) { }
@ -2650,7 +2650,7 @@ public:
}
}
CMRemarkTask(ConcurrentMark* cm, int active_workers) :
CMRemarkTask(ConcurrentMark* cm, uint active_workers) :
AbstractGangTask("Par Remark"), _cm(cm) {
_cm->terminator()->reset_for_reuse(active_workers);
}
@ -3028,7 +3028,7 @@ protected:
ConcurrentMark* _cm;
BitMap* _cm_card_bm;
uint _max_worker_id;
int _active_workers;
uint _active_workers;
HeapRegionClaimer _hrclaimer;
public:
@ -3036,7 +3036,7 @@ public:
ConcurrentMark* cm,
BitMap* cm_card_bm,
uint max_worker_id,
int n_workers) :
uint n_workers) :
AbstractGangTask("Count Aggregation"),
_g1h(g1h), _cm(cm), _cm_card_bm(cm_card_bm),
_max_worker_id(max_worker_id),
@ -3053,7 +3053,7 @@ public:
void ConcurrentMark::aggregate_count_data() {
int n_workers = _g1h->workers()->active_workers();
uint n_workers = _g1h->workers()->active_workers();
G1AggregateCountDataTask g1_par_agg_task(_g1h, this, &_card_bm,
_max_worker_id, n_workers);

View File

@ -1084,11 +1084,9 @@ void G1CollectedHeap::clear_rsets_post_compaction() {
class RebuildRSOutOfRegionClosure: public HeapRegionClosure {
G1CollectedHeap* _g1h;
UpdateRSOopClosure _cl;
int _worker_i;
public:
RebuildRSOutOfRegionClosure(G1CollectedHeap* g1, int worker_i = 0) :
RebuildRSOutOfRegionClosure(G1CollectedHeap* g1, uint worker_i = 0) :
_cl(g1->g1_rem_set(), worker_i),
_worker_i(worker_i),
_g1h(g1)
{ }
@ -3041,7 +3039,7 @@ void G1CollectedHeap::verify(bool silent, VerifyOption vo) {
assert(UseDynamicNumberOfGCThreads ||
workers()->active_workers() == workers()->total_workers(),
"If not dynamic should be using all the workers");
int n_workers = workers()->active_workers();
uint n_workers = workers()->active_workers();
set_par_threads(n_workers);
workers()->run_task(&task);
set_par_threads(0);
@ -3579,9 +3577,9 @@ void G1CollectedHeap::print_taskqueue_stats(outputStream* const st) const {
print_taskqueue_stats_hdr(st);
TaskQueueStats totals;
const int n = workers()->total_workers();
for (int i = 0; i < n; ++i) {
st->print("%3d ", i); task_queue(i)->stats.print(st); st->cr();
const uint n = workers()->total_workers();
for (uint i = 0; i < n; ++i) {
st->print("%3u ", i); task_queue(i)->stats.print(st); st->cr();
totals += task_queue(i)->stats;
}
st->print_raw("tot "); totals.print(st); st->cr();
@ -3590,8 +3588,8 @@ void G1CollectedHeap::print_taskqueue_stats(outputStream* const st) const {
}
void G1CollectedHeap::reset_taskqueue_stats() {
const int n = workers()->total_workers();
for (int i = 0; i < n; ++i) {
const uint n = workers()->total_workers();
for (uint i = 0; i < n; ++i) {
task_queue(i)->stats.reset();
}
}
@ -4321,7 +4319,7 @@ public:
ParallelTaskTerminator* terminator() { return &_terminator; }
virtual void set_for_termination(int active_workers) {
virtual void set_for_termination(uint active_workers) {
_root_processor->set_num_workers(active_workers);
terminator()->reset_for_reuse(active_workers);
_n_workers = active_workers;
@ -5000,13 +4998,13 @@ private:
G1CollectedHeap* _g1h;
RefToScanQueueSet* _queues;
FlexibleWorkGang* _workers;
int _active_workers;
uint _active_workers;
public:
G1STWRefProcTaskExecutor(G1CollectedHeap* g1h,
FlexibleWorkGang* workers,
RefToScanQueueSet *task_queues,
int n_workers) :
FlexibleWorkGang* workers,
RefToScanQueueSet *task_queues,
uint n_workers) :
_g1h(g1h),
_queues(task_queues),
_workers(workers),
@ -5139,7 +5137,7 @@ protected:
uint _n_workers;
public:
G1ParPreserveCMReferentsTask(G1CollectedHeap* g1h,int workers, RefToScanQueueSet *task_queues) :
G1ParPreserveCMReferentsTask(G1CollectedHeap* g1h, uint workers, RefToScanQueueSet *task_queues) :
AbstractGangTask("ParPreserveCMReferents"),
_g1h(g1h),
_queues(task_queues),

View File

@ -979,7 +979,7 @@ public:
void set_refine_cte_cl_concurrency(bool concurrent);
RefToScanQueue *task_queue(int i) const;
RefToScanQueue *task_queue(uint i) const;
// A set of cards where updates happened during the GC
DirtyCardQueueSet& dirty_card_queue_set() { return _dirty_card_queue_set; }

View File

@ -210,7 +210,7 @@ G1CollectedHeap::dirty_young_block(HeapWord* start, size_t word_size) {
g1_barrier_set()->g1_mark_as_young(mr);
}
inline RefToScanQueue* G1CollectedHeap::task_queue(int i) const {
inline RefToScanQueue* G1CollectedHeap::task_queue(uint i) const {
return _task_queues->queue(i);
}

View File

@ -329,6 +329,6 @@ void G1RootProcessor::scan_remembered_sets(G1ParPushHeapRSClosure* scan_rs,
_g1h->g1_rem_set()->oops_into_collection_set_do(scan_rs, &scavenge_cs_nmethods, worker_i);
}
void G1RootProcessor::set_num_workers(int active_workers) {
void G1RootProcessor::set_num_workers(uint active_workers) {
_process_strong_tasks->set_n_threads(active_workers);
}

View File

@ -115,7 +115,7 @@ public:
uint worker_i);
// Inform the root processor about the number of worker threads
void set_num_workers(int active_workers);
void set_num_workers(uint active_workers);
};
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1ROOTPROCESSOR_HPP

View File

@ -301,7 +301,7 @@ public:
inline ParScanThreadState& thread_state(int i);
void trace_promotion_failed(const YoungGCTracer* gc_tracer);
void reset(int active_workers, bool promotion_failed);
void reset(uint active_workers, bool promotion_failed);
void flush();
#if TASKQUEUE_STATS
@ -358,7 +358,7 @@ void ParScanThreadStateSet::trace_promotion_failed(const YoungGCTracer* gc_trace
}
}
void ParScanThreadStateSet::reset(int active_threads, bool promotion_failed)
void ParScanThreadStateSet::reset(uint active_threads, bool promotion_failed)
{
_term.reset_for_reuse(active_threads);
if (promotion_failed) {
@ -576,7 +576,7 @@ ParNewGenTask::ParNewGenTask(ParNewGeneration* gen, Generation* old_gen,
// Reset the terminator for the given number of
// active threads.
void ParNewGenTask::set_for_termination(int active_workers) {
void ParNewGenTask::set_for_termination(uint active_workers) {
_state_set->reset(active_workers, _gen->promotion_failed());
// Should the heap be passed in? There's only 1 for now so
// grab it instead.
@ -759,7 +759,7 @@ public:
private:
virtual void work(uint worker_id);
virtual void set_for_termination(int active_workers) {
virtual void set_for_termination(uint active_workers) {
_state_set.terminator()->reset_for_reuse(active_workers);
}
private:
@ -905,10 +905,10 @@ void ParNewGeneration::collect(bool full,
AdaptiveSizePolicy* size_policy = gch->gen_policy()->size_policy();
FlexibleWorkGang* workers = gch->workers();
assert(workers != NULL, "Need workgang for parallel work");
int active_workers =
AdaptiveSizePolicy::calc_active_workers(workers->total_workers(),
workers->active_workers(),
Threads::number_of_non_daemon_threads());
uint active_workers =
AdaptiveSizePolicy::calc_active_workers(workers->total_workers(),
workers->active_workers(),
Threads::number_of_non_daemon_threads());
workers->set_active_workers(active_workers);
_old_gen = gch->old_gen();
@ -940,7 +940,7 @@ void ParNewGeneration::collect(bool full,
gch->save_marks();
assert(workers != NULL, "Need parallel worker threads.");
int n_workers = active_workers;
uint n_workers = active_workers;
// Set the correct parallelism (number of queues) in the reference processor
ref_processor()->set_active_mt_degree(n_workers);

View File

@ -250,7 +250,7 @@ public:
// Reset the terminator in ParScanThreadStateSet for
// "active_workers" threads.
virtual void set_for_termination(int active_workers);
virtual void set_for_termination(uint active_workers);
};
class KeepAliveClosure: public DefNewGeneration::KeepAliveClosure {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -97,10 +97,10 @@ AdaptiveSizePolicy::AdaptiveSizePolicy(size_t init_eden_size,
// Calculate the number of GC threads based on the size of the heap.
// Use the larger.
int AdaptiveSizePolicy::calc_default_active_workers(uintx total_workers,
const uintx min_workers,
uintx active_workers,
uintx application_workers) {
uint AdaptiveSizePolicy::calc_default_active_workers(uintx total_workers,
const uintx min_workers,
uintx active_workers,
uintx application_workers) {
// If the user has specifically set the number of
// GC threads, use them.
@ -178,9 +178,9 @@ int AdaptiveSizePolicy::calc_default_active_workers(uintx total_workers,
return new_active_workers;
}
int AdaptiveSizePolicy::calc_active_workers(uintx total_workers,
uintx active_workers,
uintx application_workers) {
uint AdaptiveSizePolicy::calc_active_workers(uintx total_workers,
uintx active_workers,
uintx application_workers) {
// If the user has specifically set the number of
// GC threads, use them.
@ -188,7 +188,7 @@ int AdaptiveSizePolicy::calc_active_workers(uintx total_workers,
// or the users has requested a specific number, set the active
// number of workers to all the workers.
int new_active_workers;
uint new_active_workers;
if (!UseDynamicNumberOfGCThreads ||
(!FLAG_IS_DEFAULT(ParallelGCThreads) && !ForceDynamicNumberOfGCThreads)) {
new_active_workers = total_workers;
@ -203,18 +203,17 @@ int AdaptiveSizePolicy::calc_active_workers(uintx total_workers,
return new_active_workers;
}
int AdaptiveSizePolicy::calc_active_conc_workers(uintx total_workers,
uintx active_workers,
uintx application_workers) {
uint AdaptiveSizePolicy::calc_active_conc_workers(uintx total_workers,
uintx active_workers,
uintx application_workers) {
if (!UseDynamicNumberOfGCThreads ||
(!FLAG_IS_DEFAULT(ConcGCThreads) && !ForceDynamicNumberOfGCThreads)) {
return ConcGCThreads;
} else {
int no_of_gc_threads = calc_default_active_workers(
total_workers,
1, /* Minimum number of workers */
active_workers,
application_workers);
uint no_of_gc_threads = calc_default_active_workers(total_workers,
1, /* Minimum number of workers */
active_workers,
application_workers);
return no_of_gc_threads;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -343,10 +343,10 @@ class AdaptiveSizePolicy : public CHeapObj<mtGC> {
uint gc_cost_ratio);
// Return number default GC threads to use in the next GC.
static int calc_default_active_workers(uintx total_workers,
const uintx min_workers,
uintx active_workers,
uintx application_workers);
static uint calc_default_active_workers(uintx total_workers,
const uintx min_workers,
uintx active_workers,
uintx application_workers);
// Return number of GC threads to use in the next GC.
// This is called sparingly so as not to change the
@ -358,14 +358,14 @@ class AdaptiveSizePolicy : public CHeapObj<mtGC> {
// GC workers from the calls above. For example,
// a CMS parallel remark uses the same number of GC
// workers as the most recent ParNew collection.
static int calc_active_workers(uintx total_workers,
uintx active_workers,
uintx application_workers);
static uint calc_active_workers(uintx total_workers,
uintx active_workers,
uintx application_workers);
// Return number of GC threads to use in the next concurrent GC phase.
static int calc_active_conc_workers(uintx total_workers,
uintx active_workers,
uintx application_workers);
static uint calc_active_conc_workers(uintx total_workers,
uintx active_workers,
uintx application_workers);
bool is_gc_cms_adaptive_size_policy() {
return kind() == _gc_cms_adaptive_size_policy;

View File

@ -78,7 +78,7 @@ int Abstract_VM_Version::_vm_minor_version = 0;
int Abstract_VM_Version::_vm_micro_version = 0;
int Abstract_VM_Version::_vm_build_number = 0;
bool Abstract_VM_Version::_initialized = false;
int Abstract_VM_Version::_parallel_worker_threads = 0;
unsigned int Abstract_VM_Version::_parallel_worker_threads = 0;
bool Abstract_VM_Version::_parallel_worker_threads_initialized = false;
#ifdef ASSERT

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -48,7 +48,7 @@ class Abstract_VM_Version: AllStatic {
static int _vm_micro_version;
static int _vm_build_number;
static bool _initialized;
static int _parallel_worker_threads;
static unsigned int _parallel_worker_threads;
static bool _parallel_worker_threads_initialized;
static int _reserve_for_allocation_prefetch;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -129,7 +129,7 @@ int TaskQueueSetSuper::randomParkAndMiller(int *seed0) {
}
ParallelTaskTerminator::
ParallelTaskTerminator(int n_threads, TaskQueueSetSuper* queue_set) :
ParallelTaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set) :
_n_threads(n_threads),
_queue_set(queue_set),
_offered_termination(0) {}
@ -152,7 +152,7 @@ bool
ParallelTaskTerminator::offer_termination(TerminatorTerminator* terminator) {
assert(_n_threads > 0, "Initialization is incorrect");
assert(_offered_termination < _n_threads, "Invariant");
Atomic::inc(&_offered_termination);
Atomic::inc((int *)&_offered_termination);
uint yield_count = 0;
// Number of hard spin loops done since last yield
@ -230,7 +230,7 @@ ParallelTaskTerminator::offer_termination(TerminatorTerminator* terminator) {
#endif
if (peek_in_queue_set() ||
(terminator != NULL && terminator->should_exit_termination())) {
Atomic::dec(&_offered_termination);
Atomic::dec((int *)&_offered_termination);
assert(_offered_termination < _n_threads, "Invariant");
return false;
}
@ -263,7 +263,7 @@ bool ObjArrayTask::is_valid() const {
}
#endif // ASSERT
void ParallelTaskTerminator::reset_for_reuse(int n_threads) {
void ParallelTaskTerminator::reset_for_reuse(uint n_threads) {
reset_for_reuse();
_n_threads = n_threads;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -418,9 +418,9 @@ public:
class ParallelTaskTerminator: public StackObj {
private:
int _n_threads;
uint _n_threads;
TaskQueueSetSuper* _queue_set;
int _offered_termination;
uint _offered_termination;
#ifdef TRACESPINNING
static uint _total_yields;
@ -437,7 +437,7 @@ public:
// "n_threads" is the number of threads to be terminated. "queue_set" is a
// queue sets of work queues of other threads.
ParallelTaskTerminator(int n_threads, TaskQueueSetSuper* queue_set);
ParallelTaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set);
// The current thread has no work, and is ready to terminate if everyone
// else is. If returns "true", all threads are terminated. If returns
@ -459,7 +459,7 @@ public:
void reset_for_reuse();
// Same as above but the number of parallel threads is set to the
// given number.
void reset_for_reuse(int n_threads);
void reset_for_reuse(uint n_threads);
#ifdef TRACESPINNING
static uint total_yields() { return _total_yields; }

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -64,7 +64,7 @@ public:
// and may inherit this method that does nothing. Some
// tasks do some coordination on termination and override
// this method to implement that coordination.
virtual void set_for_termination(int active_workers) {};
virtual void set_for_termination(uint active_workers) {};
// Debugging accessor for the name.
const char* name() const PRODUCT_RETURN_(return NULL;);
@ -102,7 +102,7 @@ class AbstractGangTaskWOopQueues : public AbstractGangTask {
AbstractGangTaskWOopQueues(const char* name, OopTaskQueueSet* queues) :
AbstractGangTask(name), _queues(queues), _terminator(0, _queues) {}
ParallelTaskTerminator* terminator() { return &_terminator; }
virtual void set_for_termination(int active_workers) {
virtual void set_for_termination(uint active_workers) {
terminator()->reset_for_reuse(active_workers);
}
OopTaskQueueSet* queues() { return _queues; }