src/share/vm/gc_implementation/g1/concurrentMark.hpp

changeset 4333
442f942757c0
parent 4173
8a5ea0a9ccc4
child 4386
d275c3dc73e6
     1.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.hpp	Thu Nov 29 10:09:04 2012 -0800
     1.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.hpp	Mon Oct 01 09:28:13 2012 -0700
     1.3 @@ -63,7 +63,7 @@
     1.4  
     1.5   public:
     1.6    // constructor
     1.7 -  CMBitMapRO(ReservedSpace rs, int shifter);
     1.8 +  CMBitMapRO(int shifter);
     1.9  
    1.10    enum { do_yield = true };
    1.11  
    1.12 @@ -117,8 +117,11 @@
    1.13  
    1.14   public:
    1.15    // constructor
    1.16 -  CMBitMap(ReservedSpace rs, int shifter) :
    1.17 -    CMBitMapRO(rs, shifter) {}
    1.18 +  CMBitMap(int shifter) :
    1.19 +    CMBitMapRO(shifter) {}
    1.20 +
    1.21 +  // Allocates the back store for the marking bitmap
    1.22 +  bool allocate(ReservedSpace heap_rs);
    1.23  
    1.24    // write marks
    1.25    void mark(HeapWord* addr) {
    1.26 @@ -155,17 +158,18 @@
    1.27    MemRegion getAndClearMarkedRegion(HeapWord* addr, HeapWord* end_addr);
    1.28  };
    1.29  
    1.30 -// Represents a marking stack used by the CM collector.
    1.31 -// Ideally this should be GrowableArray<> just like MSC's marking stack(s).
    1.32 +// Represents a marking stack used by ConcurrentMarking in the G1 collector.
    1.33  class CMMarkStack VALUE_OBJ_CLASS_SPEC {
    1.34 +  VirtualSpace _virtual_space;   // Underlying backing store for actual stack
    1.35    ConcurrentMark* _cm;
    1.36    oop*   _base;        // bottom of stack
    1.37 -  jint   _index;       // one more than last occupied index
    1.38 -  jint   _capacity;    // max #elements
    1.39 -  jint   _saved_index; // value of _index saved at start of GC
    1.40 -  NOT_PRODUCT(jint _max_depth;)  // max depth plumbed during run
    1.41 +  jint _index;       // one more than last occupied index
    1.42 +  jint _capacity;    // max #elements
    1.43 +  jint _saved_index; // value of _index saved at start of GC
    1.44 +  NOT_PRODUCT(jint _max_depth;)   // max depth plumbed during run
    1.45  
    1.46 -  bool   _overflow;
    1.47 +  bool  _overflow;
    1.48 +  bool  _should_expand;
    1.49    DEBUG_ONLY(bool _drain_in_progress;)
    1.50    DEBUG_ONLY(bool _drain_in_progress_yields;)
    1.51  
    1.52 @@ -173,7 +177,13 @@
    1.53    CMMarkStack(ConcurrentMark* cm);
    1.54    ~CMMarkStack();
    1.55  
    1.56 -  void allocate(size_t size);
    1.57 +#ifndef PRODUCT
    1.58 +  jint max_depth() const {
    1.59 +    return _max_depth;
    1.60 +  }
    1.61 +#endif
    1.62 +
    1.63 +  bool allocate(size_t capacity);
    1.64  
    1.65    oop pop() {
    1.66      if (!isEmpty()) {
    1.67 @@ -231,11 +241,17 @@
    1.68  
    1.69    bool isEmpty()    { return _index == 0; }
    1.70    bool isFull()     { return _index == _capacity; }
    1.71 -  int maxElems()    { return _capacity; }
    1.72 +  int  maxElems()   { return _capacity; }
    1.73  
    1.74    bool overflow() { return _overflow; }
    1.75    void clear_overflow() { _overflow = false; }
    1.76  
    1.77 +  bool should_expand() const { return _should_expand; }
    1.78 +  void set_should_expand();
    1.79 +
    1.80 +  // Expand the stack, typically in response to an overflow condition
    1.81 +  void expand();
    1.82 +
    1.83    int  size() { return _index; }
    1.84  
    1.85    void setEmpty()   { _index = 0; clear_overflow(); }
    1.86 @@ -344,6 +360,7 @@
    1.87  class ConcurrentMarkThread;
    1.88  
    1.89  class ConcurrentMark: public CHeapObj<mtGC> {
    1.90 +  friend class CMMarkStack;
    1.91    friend class ConcurrentMarkThread;
    1.92    friend class CMTask;
    1.93    friend class CMBitMapClosure;
    1.94 @@ -577,6 +594,9 @@
    1.95    // the card bitmaps.
    1.96    intptr_t _heap_bottom_card_num;
    1.97  
    1.98 +  // Set to true when initialization is complete
    1.99 +  bool _completed_initialization;
   1.100 +
   1.101  public:
   1.102    // Manipulation of the global mark stack.
   1.103    // Notice that the first mark_stack_push is CAS-based, whereas the
   1.104 @@ -636,7 +656,7 @@
   1.105      return _task_queues->steal(worker_id, hash_seed, obj);
   1.106    }
   1.107  
   1.108 -  ConcurrentMark(ReservedSpace rs, uint max_regions);
   1.109 +  ConcurrentMark(G1CollectedHeap* g1h, ReservedSpace heap_rs);
   1.110    ~ConcurrentMark();
   1.111  
   1.112    ConcurrentMarkThread* cmThread() { return _cmThread; }
   1.113 @@ -907,6 +927,11 @@
   1.114    // Should *not* be called from parallel code.
   1.115    inline bool mark_and_count(oop obj);
   1.116  
   1.117 +  // Returns true if initialization was successfully completed.
   1.118 +  bool completed_initialization() const {
   1.119 +    return _completed_initialization;
   1.120 +  }
   1.121 +
   1.122  protected:
   1.123    // Clear all the per-task bitmaps and arrays used to store the
   1.124    // counting data.

mercurial