< prev index next >

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

Print this page
rev 57716 : [mq]: remove_cbl_mon
   1 /*
   2  * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   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  *


 193   }
 194 
 195   static ByteSize byte_width_of_active() { return in_ByteSize(sizeof(bool)); }
 196 
 197 };
 198 
 199 class BufferNode {
 200   size_t _index;
 201   BufferNode* volatile _next;
 202   void* _buffer[1];             // Pseudo flexible array member.
 203 
 204   BufferNode() : _index(0), _next(NULL) { }
 205   ~BufferNode() { }
 206 
 207   NONCOPYABLE(BufferNode);
 208 
 209   static size_t buffer_offset() {
 210     return offset_of(BufferNode, _buffer);
 211   }
 212 
 213   static BufferNode* volatile* next_ptr(BufferNode& bn) { return &bn._next; }
 214 
 215   // Allocate a new BufferNode with the "buffer" having size elements.
 216   static BufferNode* allocate(size_t size);
 217 
 218   // Free a BufferNode.
 219   static void deallocate(BufferNode* node);
 220 
 221 public:

 222   typedef LockFreeStack<BufferNode, &next_ptr> Stack;
 223 
 224   BufferNode* next() const     { return _next;  }
 225   void set_next(BufferNode* n) { _next = n;     }
 226   size_t index() const         { return _index; }
 227   void set_index(size_t i)     { _index = i; }
 228 
 229   // Return the BufferNode containing the buffer, after setting its index.
 230   static BufferNode* make_node_from_buffer(void** buffer, size_t index) {
 231     BufferNode* node =
 232       reinterpret_cast<BufferNode*>(
 233         reinterpret_cast<char*>(buffer) - buffer_offset());
 234     node->set_index(index);
 235     return node;
 236   }
 237 
 238   // Return the buffer for node.
 239   static void** make_buffer_from_node(BufferNode *node) {
 240     // &_buffer[0] might lead to index out of bounds warnings.
 241     return reinterpret_cast<void**>(


   1 /*
   2  * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   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  *


 193   }
 194 
 195   static ByteSize byte_width_of_active() { return in_ByteSize(sizeof(bool)); }
 196 
 197 };
 198 
 199 class BufferNode {
 200   size_t _index;
 201   BufferNode* volatile _next;
 202   void* _buffer[1];             // Pseudo flexible array member.
 203 
 204   BufferNode() : _index(0), _next(NULL) { }
 205   ~BufferNode() { }
 206 
 207   NONCOPYABLE(BufferNode);
 208 
 209   static size_t buffer_offset() {
 210     return offset_of(BufferNode, _buffer);
 211   }
 212 


 213   // Allocate a new BufferNode with the "buffer" having size elements.
 214   static BufferNode* allocate(size_t size);
 215 
 216   // Free a BufferNode.
 217   static void deallocate(BufferNode* node);
 218 
 219 public:
 220   static BufferNode* volatile* next_ptr(BufferNode& bn) { return &bn._next; }
 221   typedef LockFreeStack<BufferNode, &next_ptr> Stack;
 222 
 223   BufferNode* next() const     { return _next;  }
 224   void set_next(BufferNode* n) { _next = n;     }
 225   size_t index() const         { return _index; }
 226   void set_index(size_t i)     { _index = i; }
 227 
 228   // Return the BufferNode containing the buffer, after setting its index.
 229   static BufferNode* make_node_from_buffer(void** buffer, size_t index) {
 230     BufferNode* node =
 231       reinterpret_cast<BufferNode*>(
 232         reinterpret_cast<char*>(buffer) - buffer_offset());
 233     node->set_index(index);
 234     return node;
 235   }
 236 
 237   // Return the buffer for node.
 238   static void** make_buffer_from_node(BufferNode *node) {
 239     // &_buffer[0] might lead to index out of bounds warnings.
 240     return reinterpret_cast<void**>(


< prev index next >