< prev index next >

src/share/vm/gc/g1/g1StringDedupQueue.cpp

Print this page




  79   // Push and notify waiter
  80   G1StringDedupWorkerQueue& worker_queue = _queue->_queues[worker_id];
  81   if (!worker_queue.is_full()) {
  82     worker_queue.push(java_string);
  83     if (_queue->_empty) {
  84       MonitorLockerEx ml(StringDedupQueue_lock, Mutex::_no_safepoint_check_flag);
  85       if (_queue->_empty) {
  86         // Mark non-empty and notify waiter
  87         _queue->_empty = false;
  88         ml.notify();
  89       }
  90     }
  91   } else {
  92     // Queue is full, drop the string and update the statistics
  93     Atomic::inc_ptr(&_queue->_dropped);
  94   }
  95 }
  96 
  97 oop G1StringDedupQueue::pop() {
  98   assert(!SafepointSynchronize::is_at_safepoint(), "Must not be at safepoint");
  99   No_Safepoint_Verifier nsv;
 100 
 101   // Try all queues before giving up
 102   for (size_t tries = 0; tries < _queue->_nqueues; tries++) {
 103     // The cursor indicates where we left of last time
 104     G1StringDedupWorkerQueue* queue = &_queue->_queues[_queue->_cursor];
 105     while (!queue->is_empty()) {
 106       oop obj = queue->pop();
 107       // The oop we pop can be NULL if it was marked
 108       // dead. Just ignore those and pop the next oop.
 109       if (obj != NULL) {
 110         return obj;
 111       }
 112     }
 113 
 114     // Try next queue
 115     _queue->_cursor = (_queue->_cursor + 1) % _queue->_nqueues;
 116   }
 117 
 118   // Mark empty
 119   _queue->_empty = true;




  79   // Push and notify waiter
  80   G1StringDedupWorkerQueue& worker_queue = _queue->_queues[worker_id];
  81   if (!worker_queue.is_full()) {
  82     worker_queue.push(java_string);
  83     if (_queue->_empty) {
  84       MonitorLockerEx ml(StringDedupQueue_lock, Mutex::_no_safepoint_check_flag);
  85       if (_queue->_empty) {
  86         // Mark non-empty and notify waiter
  87         _queue->_empty = false;
  88         ml.notify();
  89       }
  90     }
  91   } else {
  92     // Queue is full, drop the string and update the statistics
  93     Atomic::inc_ptr(&_queue->_dropped);
  94   }
  95 }
  96 
  97 oop G1StringDedupQueue::pop() {
  98   assert(!SafepointSynchronize::is_at_safepoint(), "Must not be at safepoint");
  99   NoSafepointVerifier nsv;
 100 
 101   // Try all queues before giving up
 102   for (size_t tries = 0; tries < _queue->_nqueues; tries++) {
 103     // The cursor indicates where we left of last time
 104     G1StringDedupWorkerQueue* queue = &_queue->_queues[_queue->_cursor];
 105     while (!queue->is_empty()) {
 106       oop obj = queue->pop();
 107       // The oop we pop can be NULL if it was marked
 108       // dead. Just ignore those and pop the next oop.
 109       if (obj != NULL) {
 110         return obj;
 111       }
 112     }
 113 
 114     // Try next queue
 115     _queue->_cursor = (_queue->_cursor + 1) % _queue->_nqueues;
 116   }
 117 
 118   // Mark empty
 119   _queue->_empty = true;


< prev index next >