< prev index next >

src/share/vm/gc/g1/g1ConcurrentMark.hpp

Print this page
rev 13284 : imported patch 8184346-cleanup-g1cmbitmap
rev 13286 : imported patch 8184346-erikd-mgerdin-review
rev 13287 : [mq]: 8184346-erikd-review
rev 13288 : [mq]: 8184347-move-g1cmbitmap-into-own-files


   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_G1CONCURRENTMARK_HPP
  26 #define SHARE_VM_GC_G1_G1CONCURRENTMARK_HPP
  27 
  28 #include "classfile/javaClasses.hpp"

  29 #include "gc/g1/g1ConcurrentMarkObjArrayProcessor.hpp"
  30 #include "gc/g1/g1RegionToSpaceMapper.hpp"
  31 #include "gc/g1/heapRegionSet.hpp"
  32 #include "gc/shared/taskqueue.hpp"
  33 
  34 class G1CollectedHeap;
  35 class G1CMBitMap;
  36 class G1CMTask;
  37 class G1ConcurrentMark;
  38 class ConcurrentGCTimer;
  39 class G1OldTracer;
  40 class G1SurvivorRegions;
  41 
  42 #ifdef _MSC_VER
  43 #pragma warning(push)
  44 // warning C4522: multiple assignment operators specified
  45 #pragma warning(disable:4522)
  46 #endif
  47 
  48 // This is a container class for either an oop or a continuation address for
  49 // mark stack entries. Both are pushed onto the mark stack.
  50 class G1TaskQueueEntry VALUE_OBJ_CLASS_SPEC {
  51 private:
  52   void* _holder;
  53 
  54   static const uintptr_t ArraySliceBit = 1;
  55 


  91 
  92 #ifdef _MSC_VER
  93 #pragma warning(pop)
  94 #endif
  95 
  96 typedef GenericTaskQueue<G1TaskQueueEntry, mtGC> G1CMTaskQueue;
  97 typedef GenericTaskQueueSet<G1CMTaskQueue, mtGC> G1CMTaskQueueSet;
  98 
  99 // Closure used by CM during concurrent reference discovery
 100 // and reference processing (during remarking) to determine
 101 // if a particular object is alive. It is primarily used
 102 // to determine if referents of discovered reference objects
 103 // are alive. An instance is also embedded into the
 104 // reference processor as the _is_alive_non_header field
 105 class G1CMIsAliveClosure: public BoolObjectClosure {
 106   G1CollectedHeap* _g1;
 107  public:
 108   G1CMIsAliveClosure(G1CollectedHeap* g1) : _g1(g1) { }
 109 
 110   bool do_object_b(oop obj);
 111 };
 112 
 113 // Closure for iteration over bitmaps
 114 class G1CMBitMapClosure VALUE_OBJ_CLASS_SPEC {
 115 private:
 116   G1ConcurrentMark* const _cm;
 117   G1CMTask* const _task; 
 118 public:
 119   G1CMBitMapClosure(G1CMTask *task, G1ConcurrentMark* cm) : _task(task), _cm(cm) { }
 120 
 121   bool do_addr(HeapWord* const addr);
 122 };
 123 
 124 class G1CMBitMapMappingChangedListener : public G1MappingChangedListener {
 125  private:
 126   G1CMBitMap* _bm;
 127  public:
 128   G1CMBitMapMappingChangedListener() : _bm(NULL) {}
 129 
 130   void set_bitmap(G1CMBitMap* bm) { _bm = bm; }
 131 
 132   virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled);
 133 };
 134 
 135 // A generic mark bitmap for concurrent marking.  This is essentially a wrapper
 136 // around the BitMap class that is based on HeapWords, with one bit per (1 << _shifter) HeapWords.
 137 class G1CMBitMap VALUE_OBJ_CLASS_SPEC {
 138 private:
 139   MemRegion _covered;    // The heap area covered by this bitmap.
 140 
 141   const int _shifter;    // Shift amount from heap index to bit index in the bitmap.
 142 
 143   BitMapView _bm;        // The actual bitmap.
 144  
 145   G1CMBitMapMappingChangedListener _listener;
 146 
 147   inline void check_mark(HeapWord* addr) NOT_DEBUG_RETURN;
 148 
 149   // Convert from bit offset to address.
 150   HeapWord* offset_to_addr(size_t offset) const {
 151     return _covered.start() + (offset << _shifter);
 152   }
 153   // Convert from address to bit offset.
 154   size_t addr_to_offset(const HeapWord* addr) const {
 155     return pointer_delta(addr, _covered.start()) >> _shifter;
 156   }
 157 public:
 158   static size_t compute_size(size_t heap_size);
 159   // Returns the amount of bytes on the heap between two marks in the bitmap.
 160   static size_t mark_distance();
 161   // Returns how many bytes (or bits) of the heap a single byte (or bit) of the
 162   // mark bitmap corresponds to. This is the same as the mark distance above.
 163   static size_t heap_map_factor() {
 164     return mark_distance();
 165   }
 166 
 167   G1CMBitMap() : _covered(), _bm(), _shifter(LogMinObjAlignment), _listener() { _listener.set_bitmap(this); }
 168 
 169   // Initializes the underlying BitMap to cover the given area.
 170   void initialize(MemRegion heap, G1RegionToSpaceMapper* storage);
 171 
 172   // read marks
 173   bool is_marked(HeapWord* addr) const {
 174     assert(_covered.contains(addr), "Address " PTR_FORMAT " is outside underlying space from " PTR_FORMAT " to " PTR_FORMAT, p2i(addr), p2i(_covered.start()), p2i(_covered.end()));
 175     return _bm.at(addr_to_offset(addr));
 176   }
 177 
 178   // Apply the closure to the addresses that correspond to marked bits in the bitmap.
 179   inline bool iterate(G1CMBitMapClosure* cl, MemRegion mr);
 180 
 181   // Return the address corresponding to the next marked bit at or after
 182   // "addr", and before "limit", if "limit" is non-NULL.  If there is no
 183   // such bit, returns "limit" if that is non-NULL, or else "endWord()".
 184   inline HeapWord* get_next_marked_addr(const HeapWord* addr,
 185                                         const HeapWord* limit) const;
 186 
 187   // The argument addr should be the start address of a valid object
 188   inline HeapWord* addr_after_obj(HeapWord* addr);
 189 
 190   void print_on_error(outputStream* st, const char* prefix) const;
 191 
 192   // Write marks.
 193   inline void mark(HeapWord* addr);
 194   inline void clear(HeapWord* addr);
 195   inline bool par_mark(HeapWord* addr);
 196 
 197   void clear_range(MemRegion mr);
 198 };
 199 
 200 // Represents the overflow mark stack used by concurrent marking.
 201 //
 202 // Stores oops in a huge buffer in virtual memory that is always fully committed.
 203 // Resizing may only happen during a STW pause when the stack is empty.
 204 //
 205 // Memory is allocated on a "chunk" basis, i.e. a set of oops. For this, the mark
 206 // stack memory is split into evenly sized chunks of oops. Users can only
 207 // add or remove entries on that basis.
 208 // Chunks are filled in increasing address order. Not completely filled chunks
 209 // have a NULL element as a terminating element.
 210 //
 211 // Every chunk has a header containing a single pointer element used for memory
 212 // management. This wastes some space, but is negligible (< .1% with current sizing).
 213 //
 214 // Memory management is done using a mix of tracking a high water-mark indicating
 215 // that all chunks at a lower address are valid chunks, and a singly linked free
 216 // list connecting all empty chunks.
 217 class G1CMMarkStack VALUE_OBJ_CLASS_SPEC {




   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_G1CONCURRENTMARK_HPP
  26 #define SHARE_VM_GC_G1_G1CONCURRENTMARK_HPP
  27 
  28 #include "classfile/javaClasses.hpp"
  29 #include "gc/g1/g1ConcurrentMarkBitMap.hpp"
  30 #include "gc/g1/g1ConcurrentMarkObjArrayProcessor.hpp"
  31 #include "gc/g1/g1RegionToSpaceMapper.hpp"
  32 #include "gc/g1/heapRegionSet.hpp"
  33 #include "gc/shared/taskqueue.hpp"
  34 
  35 class G1CollectedHeap;

  36 class G1CMTask;
  37 class G1ConcurrentMark;
  38 class ConcurrentGCTimer;
  39 class G1OldTracer;
  40 class G1SurvivorRegions;
  41 
  42 #ifdef _MSC_VER
  43 #pragma warning(push)
  44 // warning C4522: multiple assignment operators specified
  45 #pragma warning(disable:4522)
  46 #endif
  47 
  48 // This is a container class for either an oop or a continuation address for
  49 // mark stack entries. Both are pushed onto the mark stack.
  50 class G1TaskQueueEntry VALUE_OBJ_CLASS_SPEC {
  51 private:
  52   void* _holder;
  53 
  54   static const uintptr_t ArraySliceBit = 1;
  55 


  91 
  92 #ifdef _MSC_VER
  93 #pragma warning(pop)
  94 #endif
  95 
  96 typedef GenericTaskQueue<G1TaskQueueEntry, mtGC> G1CMTaskQueue;
  97 typedef GenericTaskQueueSet<G1CMTaskQueue, mtGC> G1CMTaskQueueSet;
  98 
  99 // Closure used by CM during concurrent reference discovery
 100 // and reference processing (during remarking) to determine
 101 // if a particular object is alive. It is primarily used
 102 // to determine if referents of discovered reference objects
 103 // are alive. An instance is also embedded into the
 104 // reference processor as the _is_alive_non_header field
 105 class G1CMIsAliveClosure: public BoolObjectClosure {
 106   G1CollectedHeap* _g1;
 107  public:
 108   G1CMIsAliveClosure(G1CollectedHeap* g1) : _g1(g1) { }
 109 
 110   bool do_object_b(oop obj);























































































 111 };
 112 
 113 // Represents the overflow mark stack used by concurrent marking.
 114 //
 115 // Stores oops in a huge buffer in virtual memory that is always fully committed.
 116 // Resizing may only happen during a STW pause when the stack is empty.
 117 //
 118 // Memory is allocated on a "chunk" basis, i.e. a set of oops. For this, the mark
 119 // stack memory is split into evenly sized chunks of oops. Users can only
 120 // add or remove entries on that basis.
 121 // Chunks are filled in increasing address order. Not completely filled chunks
 122 // have a NULL element as a terminating element.
 123 //
 124 // Every chunk has a header containing a single pointer element used for memory
 125 // management. This wastes some space, but is negligible (< .1% with current sizing).
 126 //
 127 // Memory management is done using a mix of tracking a high water-mark indicating
 128 // that all chunks at a lower address are valid chunks, and a singly linked free
 129 // list connecting all empty chunks.
 130 class G1CMMarkStack VALUE_OBJ_CLASS_SPEC {


< prev index next >