1.1 --- a/src/share/vm/utilities/workgroup.hpp Wed Dec 21 07:53:53 2011 -0500 1.2 +++ b/src/share/vm/utilities/workgroup.hpp Wed Dec 14 13:34:57 2011 -0800 1.3 @@ -68,7 +68,7 @@ 1.4 public: 1.5 // The abstract work method. 1.6 // The argument tells you which member of the gang you are. 1.7 - virtual void work(int i) = 0; 1.8 + virtual void work(uint worker_id) = 0; 1.9 1.10 // This method configures the task for proper termination. 1.11 // Some tasks do not have any requirements on termination 1.12 @@ -149,7 +149,7 @@ 1.13 // and notifies of changes in it. 1.14 Monitor* _monitor; 1.15 // The count of the number of workers in the gang. 1.16 - int _total_workers; 1.17 + uint _total_workers; 1.18 // Whether the workers should terminate. 1.19 bool _terminate; 1.20 // The array of worker threads for this gang. 1.21 @@ -160,18 +160,18 @@ 1.22 // A sequence number for the current task. 1.23 int _sequence_number; 1.24 // The number of started workers. 1.25 - int _started_workers; 1.26 + uint _started_workers; 1.27 // The number of finished workers. 1.28 - int _finished_workers; 1.29 + uint _finished_workers; 1.30 public: 1.31 // Accessors for fields 1.32 Monitor* monitor() const { 1.33 return _monitor; 1.34 } 1.35 - int total_workers() const { 1.36 + uint total_workers() const { 1.37 return _total_workers; 1.38 } 1.39 - virtual int active_workers() const { 1.40 + virtual uint active_workers() const { 1.41 return _total_workers; 1.42 } 1.43 bool terminate() const { 1.44 @@ -186,10 +186,10 @@ 1.45 int sequence_number() const { 1.46 return _sequence_number; 1.47 } 1.48 - int started_workers() const { 1.49 + uint started_workers() const { 1.50 return _started_workers; 1.51 } 1.52 - int finished_workers() const { 1.53 + uint finished_workers() const { 1.54 return _finished_workers; 1.55 } 1.56 bool are_GC_task_threads() const { 1.57 @@ -203,7 +203,7 @@ 1.58 return (task() == NULL); 1.59 } 1.60 // Return the Ith gang worker. 1.61 - GangWorker* gang_worker(int i) const; 1.62 + GangWorker* gang_worker(uint i) const; 1.63 1.64 void threads_do(ThreadClosure* tc) const; 1.65 1.66 @@ -255,13 +255,13 @@ 1.67 class WorkGang: public AbstractWorkGang { 1.68 public: 1.69 // Constructor 1.70 - WorkGang(const char* name, int workers, 1.71 + WorkGang(const char* name, uint workers, 1.72 bool are_GC_task_threads, bool are_ConcurrentGC_threads); 1.73 // Run a task, returns when the task is done (or terminated). 1.74 virtual void run_task(AbstractGangTask* task); 1.75 void run_task(AbstractGangTask* task, uint no_of_parallel_workers); 1.76 // Allocate a worker and return a pointer to it. 1.77 - virtual GangWorker* allocate_worker(int which); 1.78 + virtual GangWorker* allocate_worker(uint which); 1.79 // Initialize workers in the gang. Return true if initialization 1.80 // succeeded. The type of the worker can be overridden in a derived 1.81 // class with the appropriate implementation of allocate_worker(). 1.82 @@ -323,25 +323,25 @@ 1.83 // determine completion. 1.84 1.85 protected: 1.86 - int _active_workers; 1.87 + uint _active_workers; 1.88 public: 1.89 // Constructor and destructor. 1.90 // Initialize active_workers to a minimum value. Setting it to 1.91 // the parameter "workers" will initialize it to a maximum 1.92 // value which is not desirable. 1.93 - FlexibleWorkGang(const char* name, int workers, 1.94 + FlexibleWorkGang(const char* name, uint workers, 1.95 bool are_GC_task_threads, 1.96 bool are_ConcurrentGC_threads) : 1.97 WorkGang(name, workers, are_GC_task_threads, are_ConcurrentGC_threads), 1.98 - _active_workers(UseDynamicNumberOfGCThreads ? 1 : ParallelGCThreads) {}; 1.99 + _active_workers(UseDynamicNumberOfGCThreads ? 1U : ParallelGCThreads) {} 1.100 // Accessors for fields 1.101 - virtual int active_workers() const { return _active_workers; } 1.102 - void set_active_workers(int v) { 1.103 + virtual uint active_workers() const { return _active_workers; } 1.104 + void set_active_workers(uint v) { 1.105 assert(v <= _total_workers, 1.106 "Trying to set more workers active than there are"); 1.107 _active_workers = MIN2(v, _total_workers); 1.108 assert(v != 0, "Trying to set active workers to 0"); 1.109 - _active_workers = MAX2(1, _active_workers); 1.110 + _active_workers = MAX2(1U, _active_workers); 1.111 assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers, 1.112 "Unless dynamic should use total workers"); 1.113 } 1.114 @@ -370,13 +370,13 @@ 1.115 class WorkGangBarrierSync : public StackObj { 1.116 protected: 1.117 Monitor _monitor; 1.118 - int _n_workers; 1.119 - int _n_completed; 1.120 + uint _n_workers; 1.121 + uint _n_completed; 1.122 bool _should_reset; 1.123 1.124 Monitor* monitor() { return &_monitor; } 1.125 - int n_workers() { return _n_workers; } 1.126 - int n_completed() { return _n_completed; } 1.127 + uint n_workers() { return _n_workers; } 1.128 + uint n_completed() { return _n_completed; } 1.129 bool should_reset() { return _should_reset; } 1.130 1.131 void zero_completed() { _n_completed = 0; } 1.132 @@ -386,11 +386,11 @@ 1.133 1.134 public: 1.135 WorkGangBarrierSync(); 1.136 - WorkGangBarrierSync(int n_workers, const char* name); 1.137 + WorkGangBarrierSync(uint n_workers, const char* name); 1.138 1.139 // Set the number of workers that will use the barrier. 1.140 // Must be called before any of the workers start running. 1.141 - void set_n_workers(int n_workers); 1.142 + void set_n_workers(uint n_workers); 1.143 1.144 // Enter the barrier. A worker that enters the barrier will 1.145 // not be allowed to leave until all other threads have 1.146 @@ -402,18 +402,18 @@ 1.147 // subtasks will be identified by integer indices, usually elements of an 1.148 // enumeration type. 1.149 1.150 -class SubTasksDone: public CHeapObj { 1.151 - jint* _tasks; 1.152 - int _n_tasks; 1.153 +class SubTasksDone : public CHeapObj { 1.154 + uint* _tasks; 1.155 + uint _n_tasks; 1.156 // _n_threads is used to determine when a sub task is done. 1.157 // It does not control how many threads will execute the subtask 1.158 // but must be initialized to the number that do execute the task 1.159 // in order to correctly decide when the subtask is done (all the 1.160 // threads working on the task have finished). 1.161 - int _n_threads; 1.162 - jint _threads_completed; 1.163 + uint _n_threads; 1.164 + uint _threads_completed; 1.165 #ifdef ASSERT 1.166 - volatile jint _claimed; 1.167 + volatile uint _claimed; 1.168 #endif 1.169 1.170 // Set all tasks to unclaimed. 1.171 @@ -423,19 +423,19 @@ 1.172 // Initializes "this" to a state in which there are "n" tasks to be 1.173 // processed, none of the which are originally claimed. The number of 1.174 // threads doing the tasks is initialized 1. 1.175 - SubTasksDone(int n); 1.176 + SubTasksDone(uint n); 1.177 1.178 // True iff the object is in a valid state. 1.179 bool valid(); 1.180 1.181 // Get/set the number of parallel threads doing the tasks to "t". Can only 1.182 // be called before tasks start or after they are complete. 1.183 - int n_threads() { return _n_threads; } 1.184 - void set_n_threads(int t); 1.185 + uint n_threads() { return _n_threads; } 1.186 + void set_n_threads(uint t); 1.187 1.188 // Returns "false" if the task "t" is unclaimed, and ensures that task is 1.189 // claimed. The task "t" is required to be within the range of "this". 1.190 - bool is_task_claimed(int t); 1.191 + bool is_task_claimed(uint t); 1.192 1.193 // The calling thread asserts that it has attempted to claim all the 1.194 // tasks that it will try to claim. Every thread in the parallel task 1.195 @@ -456,12 +456,12 @@ 1.196 1.197 class SequentialSubTasksDone : public StackObj { 1.198 protected: 1.199 - jint _n_tasks; // Total number of tasks available. 1.200 - jint _n_claimed; // Number of tasks claimed. 1.201 + uint _n_tasks; // Total number of tasks available. 1.202 + uint _n_claimed; // Number of tasks claimed. 1.203 // _n_threads is used to determine when a sub task is done. 1.204 // See comments on SubTasksDone::_n_threads 1.205 - jint _n_threads; // Total number of parallel threads. 1.206 - jint _n_completed; // Number of completed threads. 1.207 + uint _n_threads; // Total number of parallel threads. 1.208 + uint _n_completed; // Number of completed threads. 1.209 1.210 void clear(); 1.211 1.212 @@ -475,26 +475,26 @@ 1.213 bool valid(); 1.214 1.215 // number of tasks 1.216 - jint n_tasks() const { return _n_tasks; } 1.217 + uint n_tasks() const { return _n_tasks; } 1.218 1.219 // Get/set the number of parallel threads doing the tasks to t. 1.220 // Should be called before the task starts but it is safe 1.221 // to call this once a task is running provided that all 1.222 // threads agree on the number of threads. 1.223 - int n_threads() { return _n_threads; } 1.224 - void set_n_threads(int t) { _n_threads = t; } 1.225 + uint n_threads() { return _n_threads; } 1.226 + void set_n_threads(uint t) { _n_threads = t; } 1.227 1.228 // Set the number of tasks to be claimed to t. As above, 1.229 // should be called before the tasks start but it is safe 1.230 // to call this once a task is running provided all threads 1.231 // agree on the number of tasks. 1.232 - void set_n_tasks(int t) { _n_tasks = t; } 1.233 + void set_n_tasks(uint t) { _n_tasks = t; } 1.234 1.235 // Returns false if the next task in the sequence is unclaimed, 1.236 // and ensures that it is claimed. Will set t to be the index 1.237 // of the claimed task in the sequence. Will return true if 1.238 // the task cannot be claimed and there are none left to claim. 1.239 - bool is_task_claimed(int& t); 1.240 + bool is_task_claimed(uint& t); 1.241 1.242 // The calling thread asserts that it has attempted to claim 1.243 // all the tasks it possibly can in the sequence. Every thread