src/share/vm/utilities/workgroup.cpp

changeset 3357
441e946dc1af
parent 3294
bca17e38de00
child 3900
d2a62e0f25eb
     1.1 --- a/src/share/vm/utilities/workgroup.cpp	Wed Dec 21 07:53:53 2011 -0500
     1.2 +++ b/src/share/vm/utilities/workgroup.cpp	Wed Dec 14 13:34:57 2011 -0800
     1.3 @@ -53,14 +53,14 @@
     1.4  }
     1.5  
     1.6  WorkGang::WorkGang(const char* name,
     1.7 -                   int         workers,
     1.8 +                   uint        workers,
     1.9                     bool        are_GC_task_threads,
    1.10                     bool        are_ConcurrentGC_threads) :
    1.11    AbstractWorkGang(name, are_GC_task_threads, are_ConcurrentGC_threads) {
    1.12    _total_workers = workers;
    1.13  }
    1.14  
    1.15 -GangWorker* WorkGang::allocate_worker(int which) {
    1.16 +GangWorker* WorkGang::allocate_worker(uint which) {
    1.17    GangWorker* new_worker = new GangWorker(this, which);
    1.18    return new_worker;
    1.19  }
    1.20 @@ -88,7 +88,7 @@
    1.21    } else {
    1.22      worker_type = os::pgc_thread;
    1.23    }
    1.24 -  for (int worker = 0; worker < total_workers(); worker += 1) {
    1.25 +  for (uint worker = 0; worker < total_workers(); worker += 1) {
    1.26      GangWorker* new_worker = allocate_worker(worker);
    1.27      assert(new_worker != NULL, "Failed to allocate GangWorker");
    1.28      _gang_workers[worker] = new_worker;
    1.29 @@ -108,14 +108,14 @@
    1.30      tty->print_cr("Destructing work gang %s", name());
    1.31    }
    1.32    stop();   // stop all the workers
    1.33 -  for (int worker = 0; worker < total_workers(); worker += 1) {
    1.34 +  for (uint worker = 0; worker < total_workers(); worker += 1) {
    1.35      delete gang_worker(worker);
    1.36    }
    1.37    delete gang_workers();
    1.38    delete monitor();
    1.39  }
    1.40  
    1.41 -GangWorker* AbstractWorkGang::gang_worker(int i) const {
    1.42 +GangWorker* AbstractWorkGang::gang_worker(uint i) const {
    1.43    // Array index bounds checking.
    1.44    GangWorker* result = NULL;
    1.45    assert(gang_workers() != NULL, "No workers for indexing");
    1.46 @@ -148,7 +148,7 @@
    1.47    // Tell the workers to get to work.
    1.48    monitor()->notify_all();
    1.49    // Wait for them to be finished
    1.50 -  while (finished_workers() < (int) no_of_parallel_workers) {
    1.51 +  while (finished_workers() < no_of_parallel_workers) {
    1.52      if (TraceWorkGang) {
    1.53        tty->print_cr("Waiting in work gang %s: %d/%d finished sequence %d",
    1.54                      name(), finished_workers(), no_of_parallel_workers,
    1.55 @@ -377,12 +377,12 @@
    1.56      _n_workers(0), _n_completed(0), _should_reset(false) {
    1.57  }
    1.58  
    1.59 -WorkGangBarrierSync::WorkGangBarrierSync(int n_workers, const char* name)
    1.60 +WorkGangBarrierSync::WorkGangBarrierSync(uint n_workers, const char* name)
    1.61    : _monitor(Mutex::safepoint, name, true),
    1.62      _n_workers(n_workers), _n_completed(0), _should_reset(false) {
    1.63  }
    1.64  
    1.65 -void WorkGangBarrierSync::set_n_workers(int n_workers) {
    1.66 +void WorkGangBarrierSync::set_n_workers(uint n_workers) {
    1.67    _n_workers   = n_workers;
    1.68    _n_completed = 0;
    1.69    _should_reset = false;
    1.70 @@ -419,9 +419,9 @@
    1.71  
    1.72  // SubTasksDone functions.
    1.73  
    1.74 -SubTasksDone::SubTasksDone(int n) :
    1.75 +SubTasksDone::SubTasksDone(uint n) :
    1.76    _n_tasks(n), _n_threads(1), _tasks(NULL) {
    1.77 -  _tasks = NEW_C_HEAP_ARRAY(jint, n);
    1.78 +  _tasks = NEW_C_HEAP_ARRAY(uint, n);
    1.79    guarantee(_tasks != NULL, "alloc failure");
    1.80    clear();
    1.81  }
    1.82 @@ -430,14 +430,14 @@
    1.83    return _tasks != NULL;
    1.84  }
    1.85  
    1.86 -void SubTasksDone::set_n_threads(int t) {
    1.87 +void SubTasksDone::set_n_threads(uint t) {
    1.88    assert(_claimed == 0 || _threads_completed == _n_threads,
    1.89           "should not be called while tasks are being processed!");
    1.90    _n_threads = (t == 0 ? 1 : t);
    1.91  }
    1.92  
    1.93  void SubTasksDone::clear() {
    1.94 -  for (int i = 0; i < _n_tasks; i++) {
    1.95 +  for (uint i = 0; i < _n_tasks; i++) {
    1.96      _tasks[i] = 0;
    1.97    }
    1.98    _threads_completed = 0;
    1.99 @@ -446,9 +446,9 @@
   1.100  #endif
   1.101  }
   1.102  
   1.103 -bool SubTasksDone::is_task_claimed(int t) {
   1.104 +bool SubTasksDone::is_task_claimed(uint t) {
   1.105    assert(0 <= t && t < _n_tasks, "bad task id.");
   1.106 -  jint old = _tasks[t];
   1.107 +  uint old = _tasks[t];
   1.108    if (old == 0) {
   1.109      old = Atomic::cmpxchg(1, &_tasks[t], 0);
   1.110    }
   1.111 @@ -457,7 +457,7 @@
   1.112  #ifdef ASSERT
   1.113    if (!res) {
   1.114      assert(_claimed < _n_tasks, "Too many tasks claimed; missing clear?");
   1.115 -    Atomic::inc(&_claimed);
   1.116 +    Atomic::inc((volatile jint*) &_claimed);
   1.117    }
   1.118  #endif
   1.119    return res;
   1.120 @@ -471,7 +471,7 @@
   1.121      observed = Atomic::cmpxchg(old+1, &_threads_completed, old);
   1.122    } while (observed != old);
   1.123    // If this was the last thread checking in, clear the tasks.
   1.124 -  if (observed+1 == _n_threads) clear();
   1.125 +  if (observed+1 == (jint)_n_threads) clear();
   1.126  }
   1.127  
   1.128  
   1.129 @@ -490,12 +490,12 @@
   1.130    return _n_threads > 0;
   1.131  }
   1.132  
   1.133 -bool SequentialSubTasksDone::is_task_claimed(int& t) {
   1.134 -  jint* n_claimed_ptr = &_n_claimed;
   1.135 +bool SequentialSubTasksDone::is_task_claimed(uint& t) {
   1.136 +  uint* n_claimed_ptr = &_n_claimed;
   1.137    t = *n_claimed_ptr;
   1.138    while (t < _n_tasks) {
   1.139      jint res = Atomic::cmpxchg(t+1, n_claimed_ptr, t);
   1.140 -    if (res == t) {
   1.141 +    if (res == (jint)t) {
   1.142        return false;
   1.143      }
   1.144      t = *n_claimed_ptr;
   1.145 @@ -504,10 +504,10 @@
   1.146  }
   1.147  
   1.148  bool SequentialSubTasksDone::all_tasks_completed() {
   1.149 -  jint* n_completed_ptr = &_n_completed;
   1.150 -  jint  complete        = *n_completed_ptr;
   1.151 +  uint* n_completed_ptr = &_n_completed;
   1.152 +  uint  complete        = *n_completed_ptr;
   1.153    while (true) {
   1.154 -    jint res = Atomic::cmpxchg(complete+1, n_completed_ptr, complete);
   1.155 +    uint res = Atomic::cmpxchg(complete+1, n_completed_ptr, complete);
   1.156      if (res == complete) {
   1.157        break;
   1.158      }

mercurial