< prev index next >

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

Print this page
rev 12906 : [mq]: gc_interface


  55   }
  56 }
  57 
  58 
  59 void PtrQueue::enqueue_known_active(void* ptr) {
  60   assert(_index <= _sz, "Invariant.");
  61   assert(_index == 0 || _buf != NULL, "invariant");
  62 
  63   while (_index == 0) {
  64     handle_zero_index();
  65   }
  66 
  67   assert(_index > 0, "postcondition");
  68   _index -= sizeof(void*);
  69   _buf[byte_index_to_index(_index)] = ptr;
  70   assert(_index <= _sz, "Invariant.");
  71 }
  72 
  73 void PtrQueue::locking_enqueue_completed_buffer(BufferNode* node) {
  74   assert(_lock->owned_by_self(), "Required.");
  75 
  76   // We have to unlock _lock (which may be Shared_DirtyCardQ_lock) before
  77   // we acquire DirtyCardQ_CBL_mon inside enqueue_complete_buffer as they
  78   // have the same rank and we may get the "possible deadlock" message
  79   _lock->unlock();
  80 
  81   qset()->enqueue_complete_buffer(node);
  82   // We must relock only because the caller will unlock, for the normal
  83   // case.
  84   _lock->lock_without_safepoint_check();
  85 }
  86 
  87 
  88 BufferNode* BufferNode::allocate(size_t byte_size) {
  89   assert(byte_size > 0, "precondition");
  90   assert(is_size_aligned(byte_size, sizeof(void**)),
  91          "Invalid buffer size " SIZE_FORMAT, byte_size);
  92   void* data = NEW_C_HEAP_ARRAY(char, buffer_offset() + byte_size, mtGC);
  93   return new (data) BufferNode;
  94 }
  95 
  96 void BufferNode::deallocate(BufferNode* node) {
  97   node->~BufferNode();
  98   FREE_C_HEAP_ARRAY(char, node);
  99 }
 100 
 101 PtrQueueSet::PtrQueueSet(bool notify_when_complete) :
 102   _max_completed_queue(0),
 103   _cbl_mon(NULL), _fl_lock(NULL),
 104   _notify_when_complete(notify_when_complete),




  55   }
  56 }
  57 
  58 
  59 void PtrQueue::enqueue_known_active(void* ptr) {
  60   assert(_index <= _sz, "Invariant.");
  61   assert(_index == 0 || _buf != NULL, "invariant");
  62 
  63   while (_index == 0) {
  64     handle_zero_index();
  65   }
  66 
  67   assert(_index > 0, "postcondition");
  68   _index -= sizeof(void*);
  69   _buf[byte_index_to_index(_index)] = ptr;
  70   assert(_index <= _sz, "Invariant.");
  71 }
  72 
  73 void PtrQueue::locking_enqueue_completed_buffer(BufferNode* node) {
  74   assert(_lock->owned_by_self(), "Required.");






  75   qset()->enqueue_complete_buffer(node);



  76 }
  77 
  78 
  79 BufferNode* BufferNode::allocate(size_t byte_size) {
  80   assert(byte_size > 0, "precondition");
  81   assert(is_size_aligned(byte_size, sizeof(void**)),
  82          "Invalid buffer size " SIZE_FORMAT, byte_size);
  83   void* data = NEW_C_HEAP_ARRAY(char, buffer_offset() + byte_size, mtGC);
  84   return new (data) BufferNode;
  85 }
  86 
  87 void BufferNode::deallocate(BufferNode* node) {
  88   node->~BufferNode();
  89   FREE_C_HEAP_ARRAY(char, node);
  90 }
  91 
  92 PtrQueueSet::PtrQueueSet(bool notify_when_complete) :
  93   _max_completed_queue(0),
  94   _cbl_mon(NULL), _fl_lock(NULL),
  95   _notify_when_complete(notify_when_complete),


< prev index next >