1 /*
   2  * Copyright (c) 2013, 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  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_PRESERVEDMARKSQUEUE_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_PRESERVEDMARKSQUEUE_HPP
  27 
  28 #include "oops/oopsHierarchy.hpp"
  29 
  30 struct G1PreservedMarksQueueEntry {
  31   oop obj;
  32   markOop mark;
  33 };
  34 
  35 class G1PreservedMarksChunk;
  36 
  37 class G1PreservedMarksQueue {
  38   const size_t _initial_chunk_capacity;
  39   const size_t _max_chunk_capacity;
  40   size_t _current_capacity;
  41   G1PreservedMarksChunk* _current_write_chunk;
  42   G1PreservedMarksChunk* _current_read_chunk;
  43 
  44   size_t new_chunk_capacity();
  45   G1PreservedMarksChunk* new_chunk();
  46 
  47  public:
  48   G1PreservedMarksQueue(size_t initial_chunk_capacity, size_t max_chunk_capacity) :
  49     _initial_chunk_capacity(initial_chunk_capacity), _current_capacity(0), _max_chunk_capacity(max_chunk_capacity),
  50     _current_write_chunk(NULL), _current_read_chunk(NULL) {
  51     assert(_initial_chunk_capacity <= _max_chunk_capacity, "initial must be <= max");
  52   }
  53 
  54   bool has_data();
  55   void append(const oop& obj, const markOop& mark);
  56   G1PreservedMarksQueueEntry remove_first();
  57 
  58   NOT_PRODUCT(void verify_empty());
  59 };
  60 
  61 NOT_PRODUCT(void g1PreservedMarksChunkTests());
  62 NOT_PRODUCT(void g1PreservedMarksQueueTests());
  63 
  64 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_PRESERVEDMARKSQUEUE_HPP