< prev index next >

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

Print this page




  32 #include "runtime/atomic.inline.hpp"
  33 #include "runtime/mutexLocker.hpp"
  34 #include "utilities/stack.inline.hpp"
  35 
  36 G1StringDedupQueue* G1StringDedupQueue::_queue = NULL;
  37 const size_t        G1StringDedupQueue::_max_size = 1000000; // Max number of elements per queue
  38 const size_t        G1StringDedupQueue::_max_cache_size = 0; // Max cache size per queue
  39 
  40 G1StringDedupQueue::G1StringDedupQueue() :
  41   _cursor(0),
  42   _cancel(false),
  43   _empty(true),
  44   _dropped(0) {
  45   _nqueues = MAX2(ParallelGCThreads, (size_t)1);
  46   _queues = NEW_C_HEAP_ARRAY(G1StringDedupWorkerQueue, _nqueues, mtGC);
  47   for (size_t i = 0; i < _nqueues; i++) {
  48     new (_queues + i) G1StringDedupWorkerQueue(G1StringDedupWorkerQueue::default_segment_size(), _max_cache_size, _max_size);
  49   }
  50 }
  51 
  52 G1StringDedupQueue::~G1StringDedupQueue() {
  53   ShouldNotReachHere();
  54 }
  55 
  56 void G1StringDedupQueue::create() {
  57   assert(_queue == NULL, "One string deduplication queue allowed");
  58   _queue = new G1StringDedupQueue();
  59 }
  60 
  61 void G1StringDedupQueue::wait() {
  62   MonitorLockerEx ml(StringDedupQueue_lock, Mutex::_no_safepoint_check_flag);
  63   while (_queue->_empty && !_queue->_cancel) {
  64     ml.wait(Mutex::_no_safepoint_check_flag);
  65   }
  66 }
  67 
  68 void G1StringDedupQueue::cancel_wait() {
  69   MonitorLockerEx ml(StringDedupQueue_lock, Mutex::_no_safepoint_check_flag);
  70   _queue->_cancel = true;
  71   ml.notify();
  72 }
  73 
  74 void G1StringDedupQueue::push(uint worker_id, oop java_string) {
  75   assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint");




  32 #include "runtime/atomic.inline.hpp"
  33 #include "runtime/mutexLocker.hpp"
  34 #include "utilities/stack.inline.hpp"
  35 
  36 G1StringDedupQueue* G1StringDedupQueue::_queue = NULL;
  37 const size_t        G1StringDedupQueue::_max_size = 1000000; // Max number of elements per queue
  38 const size_t        G1StringDedupQueue::_max_cache_size = 0; // Max cache size per queue
  39 
  40 G1StringDedupQueue::G1StringDedupQueue() :
  41   _cursor(0),
  42   _cancel(false),
  43   _empty(true),
  44   _dropped(0) {
  45   _nqueues = MAX2(ParallelGCThreads, (size_t)1);
  46   _queues = NEW_C_HEAP_ARRAY(G1StringDedupWorkerQueue, _nqueues, mtGC);
  47   for (size_t i = 0; i < _nqueues; i++) {
  48     new (_queues + i) G1StringDedupWorkerQueue(G1StringDedupWorkerQueue::default_segment_size(), _max_cache_size, _max_size);
  49   }
  50 }
  51 




  52 void G1StringDedupQueue::create() {
  53   assert(_queue == NULL, "One string deduplication queue allowed");
  54   _queue = new G1StringDedupQueue();
  55 }
  56 
  57 void G1StringDedupQueue::wait() {
  58   MonitorLockerEx ml(StringDedupQueue_lock, Mutex::_no_safepoint_check_flag);
  59   while (_queue->_empty && !_queue->_cancel) {
  60     ml.wait(Mutex::_no_safepoint_check_flag);
  61   }
  62 }
  63 
  64 void G1StringDedupQueue::cancel_wait() {
  65   MonitorLockerEx ml(StringDedupQueue_lock, Mutex::_no_safepoint_check_flag);
  66   _queue->_cancel = true;
  67   ml.notify();
  68 }
  69 
  70 void G1StringDedupQueue::push(uint worker_id, oop java_string) {
  71   assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint");


< prev index next >