aboutsummaryrefslogtreecommitdiff
path: root/src/share/vm/utilities
diff options
context:
space:
mode:
authorjmasa <none@none>2011-12-14 13:34:57 -0800
committerjmasa <none@none>2011-12-14 13:34:57 -0800
commit773ff71f33ee4e51d42a07195f3c538de400c25a (patch)
tree2b4e423111a5b4133a951be046d56e8795eb97b9 /src/share/vm/utilities
parent2e1c93de4ccb5be867e22b57a168100e6d54a9c6 (diff)
7121618: Change type of number of GC workers to unsigned int.
Summary: Change variables representing the number of GC workers to uint from int and size_t. Change the parameter in work(int i) to work(uint worker_id). Reviewed-by: brutisso, tonyp
Diffstat (limited to 'src/share/vm/utilities')
-rw-r--r--src/share/vm/utilities/workgroup.cpp44
-rw-r--r--src/share/vm/utilities/workgroup.hpp84
-rw-r--r--src/share/vm/utilities/yieldingWorkgroup.cpp6
-rw-r--r--src/share/vm/utilities/yieldingWorkgroup.hpp12
4 files changed, 73 insertions, 73 deletions
diff --git a/src/share/vm/utilities/workgroup.cpp b/src/share/vm/utilities/workgroup.cpp
index 8b695528e..0ef1f833d 100644
--- a/src/share/vm/utilities/workgroup.cpp
+++ b/src/share/vm/utilities/workgroup.cpp
@@ -53,14 +53,14 @@ AbstractWorkGang::AbstractWorkGang(const char* name,
}
WorkGang::WorkGang(const char* name,
- int workers,
+ uint workers,
bool are_GC_task_threads,
bool are_ConcurrentGC_threads) :
AbstractWorkGang(name, are_GC_task_threads, are_ConcurrentGC_threads) {
_total_workers = workers;
}
-GangWorker* WorkGang::allocate_worker(int which) {
+GangWorker* WorkGang::allocate_worker(uint which) {
GangWorker* new_worker = new GangWorker(this, which);
return new_worker;
}
@@ -88,7 +88,7 @@ bool WorkGang::initialize_workers() {
} else {
worker_type = os::pgc_thread;
}
- for (int worker = 0; worker < total_workers(); worker += 1) {
+ for (uint worker = 0; worker < total_workers(); worker += 1) {
GangWorker* new_worker = allocate_worker(worker);
assert(new_worker != NULL, "Failed to allocate GangWorker");
_gang_workers[worker] = new_worker;
@@ -108,14 +108,14 @@ AbstractWorkGang::~AbstractWorkGang() {
tty->print_cr("Destructing work gang %s", name());
}
stop(); // stop all the workers
- for (int worker = 0; worker < total_workers(); worker += 1) {
+ for (uint worker = 0; worker < total_workers(); worker += 1) {
delete gang_worker(worker);
}
delete gang_workers();
delete monitor();
}
-GangWorker* AbstractWorkGang::gang_worker(int i) const {
+GangWorker* AbstractWorkGang::gang_worker(uint i) const {
// Array index bounds checking.
GangWorker* result = NULL;
assert(gang_workers() != NULL, "No workers for indexing");
@@ -148,7 +148,7 @@ void WorkGang::run_task(AbstractGangTask* task, uint no_of_parallel_workers) {
// Tell the workers to get to work.
monitor()->notify_all();
// Wait for them to be finished
- while (finished_workers() < (int) no_of_parallel_workers) {
+ while (finished_workers() < no_of_parallel_workers) {
if (TraceWorkGang) {
tty->print_cr("Waiting in work gang %s: %d/%d finished sequence %d",
name(), finished_workers(), no_of_parallel_workers,
@@ -377,12 +377,12 @@ WorkGangBarrierSync::WorkGangBarrierSync()
_n_workers(0), _n_completed(0), _should_reset(false) {
}
-WorkGangBarrierSync::WorkGangBarrierSync(int n_workers, const char* name)
+WorkGangBarrierSync::WorkGangBarrierSync(uint n_workers, const char* name)
: _monitor(Mutex::safepoint, name, true),
_n_workers(n_workers), _n_completed(0), _should_reset(false) {
}
-void WorkGangBarrierSync::set_n_workers(int n_workers) {
+void WorkGangBarrierSync::set_n_workers(uint n_workers) {
_n_workers = n_workers;
_n_completed = 0;
_should_reset = false;
@@ -419,9 +419,9 @@ void WorkGangBarrierSync::enter() {
// SubTasksDone functions.
-SubTasksDone::SubTasksDone(int n) :
+SubTasksDone::SubTasksDone(uint n) :
_n_tasks(n), _n_threads(1), _tasks(NULL) {
- _tasks = NEW_C_HEAP_ARRAY(jint, n);
+ _tasks = NEW_C_HEAP_ARRAY(uint, n);
guarantee(_tasks != NULL, "alloc failure");
clear();
}
@@ -430,14 +430,14 @@ bool SubTasksDone::valid() {
return _tasks != NULL;
}
-void SubTasksDone::set_n_threads(int t) {
+void SubTasksDone::set_n_threads(uint t) {
assert(_claimed == 0 || _threads_completed == _n_threads,
"should not be called while tasks are being processed!");
_n_threads = (t == 0 ? 1 : t);
}
void SubTasksDone::clear() {
- for (int i = 0; i < _n_tasks; i++) {
+ for (uint i = 0; i < _n_tasks; i++) {
_tasks[i] = 0;
}
_threads_completed = 0;
@@ -446,9 +446,9 @@ void SubTasksDone::clear() {
#endif
}
-bool SubTasksDone::is_task_claimed(int t) {
+bool SubTasksDone::is_task_claimed(uint t) {
assert(0 <= t && t < _n_tasks, "bad task id.");
- jint old = _tasks[t];
+ uint old = _tasks[t];
if (old == 0) {
old = Atomic::cmpxchg(1, &_tasks[t], 0);
}
@@ -457,7 +457,7 @@ bool SubTasksDone::is_task_claimed(int t) {
#ifdef ASSERT
if (!res) {
assert(_claimed < _n_tasks, "Too many tasks claimed; missing clear?");
- Atomic::inc(&_claimed);
+ Atomic::inc((volatile jint*) &_claimed);
}
#endif
return res;
@@ -471,7 +471,7 @@ void SubTasksDone::all_tasks_completed() {
observed = Atomic::cmpxchg(old+1, &_threads_completed, old);
} while (observed != old);
// If this was the last thread checking in, clear the tasks.
- if (observed+1 == _n_threads) clear();
+ if (observed+1 == (jint)_n_threads) clear();
}
@@ -490,12 +490,12 @@ bool SequentialSubTasksDone::valid() {
return _n_threads > 0;
}
-bool SequentialSubTasksDone::is_task_claimed(int& t) {
- jint* n_claimed_ptr = &_n_claimed;
+bool SequentialSubTasksDone::is_task_claimed(uint& t) {
+ uint* n_claimed_ptr = &_n_claimed;
t = *n_claimed_ptr;
while (t < _n_tasks) {
jint res = Atomic::cmpxchg(t+1, n_claimed_ptr, t);
- if (res == t) {
+ if (res == (jint)t) {
return false;
}
t = *n_claimed_ptr;
@@ -504,10 +504,10 @@ bool SequentialSubTasksDone::is_task_claimed(int& t) {
}
bool SequentialSubTasksDone::all_tasks_completed() {
- jint* n_completed_ptr = &_n_completed;
- jint complete = *n_completed_ptr;
+ uint* n_completed_ptr = &_n_completed;
+ uint complete = *n_completed_ptr;
while (true) {
- jint res = Atomic::cmpxchg(complete+1, n_completed_ptr, complete);
+ uint res = Atomic::cmpxchg(complete+1, n_completed_ptr, complete);
if (res == complete) {
break;
}
diff --git a/src/share/vm/utilities/workgroup.hpp b/src/share/vm/utilities/workgroup.hpp
index 911616347..7fc0ddf56 100644
--- a/src/share/vm/utilities/workgroup.hpp
+++ b/src/share/vm/utilities/workgroup.hpp
@@ -68,7 +68,7 @@ class AbstractGangTask VALUE_OBJ_CLASS_SPEC {
public:
// The abstract work method.
// The argument tells you which member of the gang you are.
- virtual void work(int i) = 0;
+ virtual void work(uint worker_id) = 0;
// This method configures the task for proper termination.
// Some tasks do not have any requirements on termination
@@ -149,7 +149,7 @@ protected:
// and notifies of changes in it.
Monitor* _monitor;
// The count of the number of workers in the gang.
- int _total_workers;
+ uint _total_workers;
// Whether the workers should terminate.
bool _terminate;
// The array of worker threads for this gang.
@@ -160,18 +160,18 @@ protected:
// A sequence number for the current task.
int _sequence_number;
// The number of started workers.
- int _started_workers;
+ uint _started_workers;
// The number of finished workers.
- int _finished_workers;
+ uint _finished_workers;
public:
// Accessors for fields
Monitor* monitor() const {
return _monitor;
}
- int total_workers() const {
+ uint total_workers() const {
return _total_workers;
}
- virtual int active_workers() const {
+ virtual uint active_workers() const {
return _total_workers;
}
bool terminate() const {
@@ -186,10 +186,10 @@ public:
int sequence_number() const {
return _sequence_number;
}
- int started_workers() const {
+ uint started_workers() const {
return _started_workers;
}
- int finished_workers() const {
+ uint finished_workers() const {
return _finished_workers;
}
bool are_GC_task_threads() const {
@@ -203,7 +203,7 @@ public:
return (task() == NULL);
}
// Return the Ith gang worker.
- GangWorker* gang_worker(int i) const;
+ GangWorker* gang_worker(uint i) const;
void threads_do(ThreadClosure* tc) const;
@@ -255,13 +255,13 @@ public:
class WorkGang: public AbstractWorkGang {
public:
// Constructor
- WorkGang(const char* name, int workers,
+ WorkGang(const char* name, uint workers,
bool are_GC_task_threads, bool are_ConcurrentGC_threads);
// Run a task, returns when the task is done (or terminated).
virtual void run_task(AbstractGangTask* task);
void run_task(AbstractGangTask* task, uint no_of_parallel_workers);
// Allocate a worker and return a pointer to it.
- virtual GangWorker* allocate_worker(int which);
+ virtual GangWorker* allocate_worker(uint which);
// Initialize workers in the gang. Return true if initialization
// succeeded. The type of the worker can be overridden in a derived
// class with the appropriate implementation of allocate_worker().
@@ -323,25 +323,25 @@ class FlexibleWorkGang: public WorkGang {
// determine completion.
protected:
- int _active_workers;
+ uint _active_workers;
public:
// Constructor and destructor.
// Initialize active_workers to a minimum value. Setting it to
// the parameter "workers" will initialize it to a maximum
// value which is not desirable.
- FlexibleWorkGang(const char* name, int workers,
+ FlexibleWorkGang(const char* name, uint workers,
bool are_GC_task_threads,
bool are_ConcurrentGC_threads) :
WorkGang(name, workers, are_GC_task_threads, are_ConcurrentGC_threads),
- _active_workers(UseDynamicNumberOfGCThreads ? 1 : ParallelGCThreads) {};
+ _active_workers(UseDynamicNumberOfGCThreads ? 1U : ParallelGCThreads) {}
// Accessors for fields
- virtual int active_workers() const { return _active_workers; }
- void set_active_workers(int v) {
+ virtual uint active_workers() const { return _active_workers; }
+ void set_active_workers(uint v) {
assert(v <= _total_workers,
"Trying to set more workers active than there are");
_active_workers = MIN2(v, _total_workers);
assert(v != 0, "Trying to set active workers to 0");
- _active_workers = MAX2(1, _active_workers);
+ _active_workers = MAX2(1U, _active_workers);
assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
"Unless dynamic should use total workers");
}
@@ -370,13 +370,13 @@ class FlexibleWorkGang: public WorkGang {
class WorkGangBarrierSync : public StackObj {
protected:
Monitor _monitor;
- int _n_workers;
- int _n_completed;
+ uint _n_workers;
+ uint _n_completed;
bool _should_reset;
Monitor* monitor() { return &_monitor; }
- int n_workers() { return _n_workers; }
- int n_completed() { return _n_completed; }
+ uint n_workers() { return _n_workers; }
+ uint n_completed() { return _n_completed; }
bool should_reset() { return _should_reset; }
void zero_completed() { _n_completed = 0; }
@@ -386,11 +386,11 @@ protected:
public:
WorkGangBarrierSync();
- WorkGangBarrierSync(int n_workers, const char* name);
+ WorkGangBarrierSync(uint n_workers, const char* name);
// Set the number of workers that will use the barrier.
// Must be called before any of the workers start running.
- void set_n_workers(int n_workers);
+ void set_n_workers(uint n_workers);
// Enter the barrier. A worker that enters the barrier will
// not be allowed to leave until all other threads have
@@ -402,18 +402,18 @@ public:
// subtasks will be identified by integer indices, usually elements of an
// enumeration type.
-class SubTasksDone: public CHeapObj {
- jint* _tasks;
- int _n_tasks;
+class SubTasksDone : public CHeapObj {
+ uint* _tasks;
+ uint _n_tasks;
// _n_threads is used to determine when a sub task is done.
// It does not control how many threads will execute the subtask
// but must be initialized to the number that do execute the task
// in order to correctly decide when the subtask is done (all the
// threads working on the task have finished).
- int _n_threads;
- jint _threads_completed;
+ uint _n_threads;
+ uint _threads_completed;
#ifdef ASSERT
- volatile jint _claimed;
+ volatile uint _claimed;
#endif
// Set all tasks to unclaimed.
@@ -423,19 +423,19 @@ public:
// Initializes "this" to a state in which there are "n" tasks to be
// processed, none of the which are originally claimed. The number of
// threads doing the tasks is initialized 1.
- SubTasksDone(int n);
+ SubTasksDone(uint n);
// True iff the object is in a valid state.
bool valid();
// Get/set the number of parallel threads doing the tasks to "t". Can only
// be called before tasks start or after they are complete.
- int n_threads() { return _n_threads; }
- void set_n_threads(int t);
+ uint n_threads() { return _n_threads; }
+ void set_n_threads(uint t);
// Returns "false" if the task "t" is unclaimed, and ensures that task is
// claimed. The task "t" is required to be within the range of "this".
- bool is_task_claimed(int t);
+ bool is_task_claimed(uint t);
// The calling thread asserts that it has attempted to claim all the
// tasks that it will try to claim. Every thread in the parallel task
@@ -456,12 +456,12 @@ public:
class SequentialSubTasksDone : public StackObj {
protected:
- jint _n_tasks; // Total number of tasks available.
- jint _n_claimed; // Number of tasks claimed.
+ uint _n_tasks; // Total number of tasks available.
+ uint _n_claimed; // Number of tasks claimed.
// _n_threads is used to determine when a sub task is done.
// See comments on SubTasksDone::_n_threads
- jint _n_threads; // Total number of parallel threads.
- jint _n_completed; // Number of completed threads.
+ uint _n_threads; // Total number of parallel threads.
+ uint _n_completed; // Number of completed threads.
void clear();
@@ -475,26 +475,26 @@ public:
bool valid();
// number of tasks
- jint n_tasks() const { return _n_tasks; }
+ uint n_tasks() const { return _n_tasks; }
// Get/set the number of parallel threads doing the tasks to t.
// Should be called before the task starts but it is safe
// to call this once a task is running provided that all
// threads agree on the number of threads.
- int n_threads() { return _n_threads; }
- void set_n_threads(int t) { _n_threads = t; }
+ uint n_threads() { return _n_threads; }
+ void set_n_threads(uint t) { _n_threads = t; }
// Set the number of tasks to be claimed to t. As above,
// should be called before the tasks start but it is safe
// to call this once a task is running provided all threads
// agree on the number of tasks.
- void set_n_tasks(int t) { _n_tasks = t; }
+ void set_n_tasks(uint t) { _n_tasks = t; }
// Returns false if the next task in the sequence is unclaimed,
// and ensures that it is claimed. Will set t to be the index
// of the claimed task in the sequence. Will return true if
// the task cannot be claimed and there are none left to claim.
- bool is_task_claimed(int& t);
+ bool is_task_claimed(uint& t);
// The calling thread asserts that it has attempted to claim
// all the tasks it possibly can in the sequence. Every thread
diff --git a/src/share/vm/utilities/yieldingWorkgroup.cpp b/src/share/vm/utilities/yieldingWorkgroup.cpp
index d8daf7a5d..7e594232a 100644
--- a/src/share/vm/utilities/yieldingWorkgroup.cpp
+++ b/src/share/vm/utilities/yieldingWorkgroup.cpp
@@ -33,11 +33,11 @@ class GangWorker;
class WorkData;
YieldingFlexibleWorkGang::YieldingFlexibleWorkGang(
- const char* name, int workers, bool are_GC_task_threads) :
+ const char* name, uint workers, bool are_GC_task_threads) :
FlexibleWorkGang(name, workers, are_GC_task_threads, false),
_yielded_workers(0) {}
-GangWorker* YieldingFlexibleWorkGang::allocate_worker(int which) {
+GangWorker* YieldingFlexibleWorkGang::allocate_worker(uint which) {
YieldingFlexibleGangWorker* new_member =
new YieldingFlexibleGangWorker(this, which);
return (YieldingFlexibleGangWorker*) new_member;
@@ -120,7 +120,7 @@ void YieldingFlexibleWorkGang::start_task(YieldingFlexibleGangTask* new_task) {
new_task->set_gang(this); // Establish 2-way binding to support yielding
_sequence_number++;
- int requested_size = new_task->requested_size();
+ uint requested_size = new_task->requested_size();
assert(requested_size >= 0, "Should be non-negative");
if (requested_size != 0) {
_active_workers = MIN2(requested_size, total_workers());
diff --git a/src/share/vm/utilities/yieldingWorkgroup.hpp b/src/share/vm/utilities/yieldingWorkgroup.hpp
index 6d8c6bf66..a39f8227f 100644
--- a/src/share/vm/utilities/yieldingWorkgroup.hpp
+++ b/src/share/vm/utilities/yieldingWorkgroup.hpp
@@ -71,7 +71,7 @@ public:
// The abstract work method.
// The argument tells you which member of the gang you are.
- virtual void work(int i) = 0;
+ virtual void work(uint worker_id) = 0;
int requested_size() const { return _requested_size; }
int actual_size() const { return _actual_size; }
@@ -128,7 +128,7 @@ protected:
public:
// The abstract work method.
// The argument tells you which member of the gang you are.
- virtual void work(int i) = 0;
+ virtual void work(uint worker_id) = 0;
// Subclasses should call the parent's yield() method
// after having done any work specific to the subclass.
@@ -159,7 +159,7 @@ class YieldingFlexibleWorkGang: public FlexibleWorkGang {
// Here's the public interface to this class.
public:
// Constructor and destructor.
- YieldingFlexibleWorkGang(const char* name, int workers,
+ YieldingFlexibleWorkGang(const char* name, uint workers,
bool are_GC_task_threads);
YieldingFlexibleGangTask* yielding_task() const {
@@ -168,7 +168,7 @@ public:
return (YieldingFlexibleGangTask*)task();
}
// Allocate a worker and return a pointer to it.
- GangWorker* allocate_worker(int which);
+ GangWorker* allocate_worker(uint which);
// Run a task; returns when the task is done, or the workers yield,
// or the task is aborted, or the work gang is terminated via stop().
@@ -199,12 +199,12 @@ public:
void abort();
private:
- int _yielded_workers;
+ uint _yielded_workers;
void wait_for_gang();
public:
// Accessors for fields
- int yielded_workers() const {
+ uint yielded_workers() const {
return _yielded_workers;
}