< prev index next >

src/hotspot/share/gc/g1/ptrQueue.hpp

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_PTRQUEUE_HPP
  26 #define SHARE_VM_GC_G1_PTRQUEUE_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "utilities/align.hpp"
  30 #include "utilities/sizes.hpp"
  31 
  32 // There are various techniques that require threads to be able to log
  33 // addresses.  For example, a generational write barrier might log
  34 // the addresses of modified old-generation objects.  This type supports
  35 // this operation.
  36 
  37 class BufferNode;
  38 class PtrQueueSet;
  39 class PtrQueue VALUE_OBJ_CLASS_SPEC {
  40   friend class VMStructs;
  41 
  42   // Noncopyable - not defined.
  43   PtrQueue(const PtrQueue&);
  44   PtrQueue& operator=(const PtrQueue&);
  45 
  46   // The ptr queue set to which this queue belongs.
  47   PtrQueueSet* const _qset;
  48 
  49   // Whether updates should be logged.
  50   bool _active;
  51 
  52   // If true, the queue is permanent, and doesn't need to deallocate
  53   // its buffer in the destructor (since that obtains a lock which may not
  54   // be legally locked by then.
  55   const bool _permanent;
  56 
  57   // The (byte) index at which an object was last enqueued.  Starts at
  58   // capacity_in_bytes (indicating an empty buffer) and goes towards zero.
  59   // Value is always pointer-size aligned.


 240   static BufferNode* make_node_from_buffer(void** buffer, size_t index) {
 241     BufferNode* node =
 242       reinterpret_cast<BufferNode*>(
 243         reinterpret_cast<char*>(buffer) - buffer_offset());
 244     node->set_index(index);
 245     return node;
 246   }
 247 
 248   // Return the buffer for node.
 249   static void** make_buffer_from_node(BufferNode *node) {
 250     // &_buffer[0] might lead to index out of bounds warnings.
 251     return reinterpret_cast<void**>(
 252       reinterpret_cast<char*>(node) + buffer_offset());
 253   }
 254 };
 255 
 256 // A PtrQueueSet represents resources common to a set of pointer queues.
 257 // In particular, the individual queues allocate buffers from this shared
 258 // set, and return completed buffers to the set.
 259 // All these variables are are protected by the TLOQ_CBL_mon. XXX ???
 260 class PtrQueueSet VALUE_OBJ_CLASS_SPEC {
 261 private:
 262   // The size of all buffers in the set.
 263   size_t _buffer_size;
 264 
 265 protected:
 266   Monitor* _cbl_mon;  // Protects the fields below.
 267   BufferNode* _completed_buffers_head;
 268   BufferNode* _completed_buffers_tail;
 269   size_t _n_completed_buffers;
 270   int _process_completed_threshold;
 271   volatile bool _process_completed;
 272 
 273   // This (and the interpretation of the first element as a "next"
 274   // pointer) are protected by the TLOQ_FL_lock.
 275   Mutex* _fl_lock;
 276   BufferNode* _buf_free_list;
 277   size_t _buf_free_list_sz;
 278   // Queue set can share a freelist. The _fl_owner variable
 279   // specifies the owner. It is set to "this" by default.
 280   PtrQueueSet* _fl_owner;




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_PTRQUEUE_HPP
  26 #define SHARE_VM_GC_G1_PTRQUEUE_HPP
  27 

  28 #include "utilities/align.hpp"
  29 #include "utilities/sizes.hpp"
  30 
  31 // There are various techniques that require threads to be able to log
  32 // addresses.  For example, a generational write barrier might log
  33 // the addresses of modified old-generation objects.  This type supports
  34 // this operation.
  35 
  36 class BufferNode;
  37 class PtrQueueSet;
  38 class PtrQueue {
  39   friend class VMStructs;
  40 
  41   // Noncopyable - not defined.
  42   PtrQueue(const PtrQueue&);
  43   PtrQueue& operator=(const PtrQueue&);
  44 
  45   // The ptr queue set to which this queue belongs.
  46   PtrQueueSet* const _qset;
  47 
  48   // Whether updates should be logged.
  49   bool _active;
  50 
  51   // If true, the queue is permanent, and doesn't need to deallocate
  52   // its buffer in the destructor (since that obtains a lock which may not
  53   // be legally locked by then.
  54   const bool _permanent;
  55 
  56   // The (byte) index at which an object was last enqueued.  Starts at
  57   // capacity_in_bytes (indicating an empty buffer) and goes towards zero.
  58   // Value is always pointer-size aligned.


 239   static BufferNode* make_node_from_buffer(void** buffer, size_t index) {
 240     BufferNode* node =
 241       reinterpret_cast<BufferNode*>(
 242         reinterpret_cast<char*>(buffer) - buffer_offset());
 243     node->set_index(index);
 244     return node;
 245   }
 246 
 247   // Return the buffer for node.
 248   static void** make_buffer_from_node(BufferNode *node) {
 249     // &_buffer[0] might lead to index out of bounds warnings.
 250     return reinterpret_cast<void**>(
 251       reinterpret_cast<char*>(node) + buffer_offset());
 252   }
 253 };
 254 
 255 // A PtrQueueSet represents resources common to a set of pointer queues.
 256 // In particular, the individual queues allocate buffers from this shared
 257 // set, and return completed buffers to the set.
 258 // All these variables are are protected by the TLOQ_CBL_mon. XXX ???
 259 class PtrQueueSet {
 260 private:
 261   // The size of all buffers in the set.
 262   size_t _buffer_size;
 263 
 264 protected:
 265   Monitor* _cbl_mon;  // Protects the fields below.
 266   BufferNode* _completed_buffers_head;
 267   BufferNode* _completed_buffers_tail;
 268   size_t _n_completed_buffers;
 269   int _process_completed_threshold;
 270   volatile bool _process_completed;
 271 
 272   // This (and the interpretation of the first element as a "next"
 273   // pointer) are protected by the TLOQ_FL_lock.
 274   Mutex* _fl_lock;
 275   BufferNode* _buf_free_list;
 276   size_t _buf_free_list_sz;
 277   // Queue set can share a freelist. The _fl_owner variable
 278   // specifies the owner. It is set to "this" by default.
 279   PtrQueueSet* _fl_owner;


< prev index next >