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

changeset 3463
d30fa85f9994
parent 3455
851b58c26def
child 3464
eff609af17d7
     1.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.hpp	Tue Jan 24 17:08:58 2012 -0500
     1.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.hpp	Thu Jan 12 00:06:47 2012 -0800
     1.3 @@ -426,7 +426,6 @@
     1.4    WorkGangBarrierSync     _first_overflow_barrier_sync;
     1.5    WorkGangBarrierSync     _second_overflow_barrier_sync;
     1.6  
     1.7 -
     1.8    // this is set by any task, when an overflow on the global data
     1.9    // structures is detected.
    1.10    volatile bool           _has_overflown;
    1.11 @@ -578,6 +577,27 @@
    1.12      }
    1.13    }
    1.14  
    1.15 +  // Live Data Counting data structures...
    1.16 +  // These data structures are initialized at the start of
    1.17 +  // marking. They are written to while marking is active.
    1.18 +  // They are aggregated during remark; the aggregated values
    1.19 +  // are then used to populate the _region_bm, _card_bm, and
    1.20 +  // the total live bytes, which are then subsequently updated
    1.21 +  // during cleanup.
    1.22 +
    1.23 +  // An array of bitmaps (one bit map per task). Each bitmap
    1.24 +  // is used to record the cards spanned by the live objects
    1.25 +  // marked by that task/worker.
    1.26 +  BitMap*  _count_card_bitmaps;
    1.27 +
    1.28 +  // Used to record the number of marked live bytes
    1.29 +  // (for each region, by worker thread).
    1.30 +  size_t** _count_marked_bytes;
    1.31 +
    1.32 +  // Card index of the bottom of the G1 heap. Used for biasing indices into
    1.33 +  // the card bitmaps.
    1.34 +  intptr_t _heap_bottom_card_num;
    1.35 +
    1.36  public:
    1.37    // Manipulation of the global mark stack.
    1.38    // Notice that the first mark_stack_push is CAS-based, whereas the
    1.39 @@ -703,6 +723,7 @@
    1.40  
    1.41    ConcurrentMark(ReservedSpace rs, int max_regions);
    1.42    ~ConcurrentMark();
    1.43 +
    1.44    ConcurrentMarkThread* cmThread() { return _cmThread; }
    1.45  
    1.46    CMBitMapRO* prevMarkBitMap() const { return _prevMarkBitMap; }
    1.47 @@ -721,7 +742,7 @@
    1.48  
    1.49    // This notifies CM that a root during initial-mark needs to be
    1.50    // grayed. It is MT-safe.
    1.51 -  inline void grayRoot(oop obj, size_t word_size);
    1.52 +  inline void grayRoot(oop obj, size_t word_size, uint worker_id);
    1.53  
    1.54    // It's used during evacuation pauses to gray a region, if
    1.55    // necessary, and it's MT-safe. It assumes that the caller has
    1.56 @@ -781,15 +802,13 @@
    1.57  
    1.58    void checkpointRootsFinal(bool clear_all_soft_refs);
    1.59    void checkpointRootsFinalWork();
    1.60 -  void calcDesiredRegions();
    1.61    void cleanup();
    1.62    void completeCleanup();
    1.63  
    1.64    // Mark in the previous bitmap.  NB: this is usually read-only, so use
    1.65    // this carefully!
    1.66    inline void markPrev(oop p);
    1.67 -  inline void markNext(oop p);
    1.68 -  void clear(oop p);
    1.69 +
    1.70    // Clears marks for all objects in the given range, for the prev,
    1.71    // next, or both bitmaps.  NB: the previous bitmap is usually
    1.72    // read-only, so use this carefully!
    1.73 @@ -913,6 +932,104 @@
    1.74    bool verbose_high() {
    1.75      return _MARKING_VERBOSE_ && _verbose_level >= high_verbose;
    1.76    }
    1.77 +
    1.78 +  // Counting data structure accessors
    1.79 +
    1.80 +  // Returns the card number of the bottom of the G1 heap.
    1.81 +  // Used in biasing indices into accounting card bitmaps.
    1.82 +  intptr_t heap_bottom_card_num() const {
    1.83 +    return _heap_bottom_card_num;
    1.84 +  }
    1.85 +
    1.86 +  // Returns the card bitmap for a given task or worker id.
    1.87 +  BitMap* count_card_bitmap_for(uint worker_id) {
    1.88 +    assert(0 <= worker_id && worker_id < _max_task_num, "oob");
    1.89 +    assert(_count_card_bitmaps != NULL, "uninitialized");
    1.90 +    BitMap* task_card_bm = &_count_card_bitmaps[worker_id];
    1.91 +    assert(task_card_bm->size() == _card_bm.size(), "size mismatch");
    1.92 +    return task_card_bm;
    1.93 +  }
    1.94 +
    1.95 +  // Returns the array containing the marked bytes for each region,
    1.96 +  // for the given worker or task id.
    1.97 +  size_t* count_marked_bytes_array_for(uint worker_id) {
    1.98 +    assert(0 <= worker_id && worker_id < _max_task_num, "oob");
    1.99 +    assert(_count_marked_bytes != NULL, "uninitialized");
   1.100 +    size_t* marked_bytes_array = _count_marked_bytes[worker_id];
   1.101 +    assert(marked_bytes_array != NULL, "uninitialized");
   1.102 +    return marked_bytes_array;
   1.103 +  }
   1.104 +
   1.105 +  // Returns the index in the liveness accounting card table bitmap
   1.106 +  // for the given address
   1.107 +  inline BitMap::idx_t card_bitmap_index_for(HeapWord* addr);
   1.108 +
   1.109 +  // Counts the size of the given memory region in the the given
   1.110 +  // marked_bytes array slot for the given HeapRegion.
   1.111 +  // Sets the bits in the given card bitmap that are associated with the
   1.112 +  // cards that are spanned by the memory region.
   1.113 +  inline void count_region(MemRegion mr, HeapRegion* hr,
   1.114 +                           size_t* marked_bytes_array,
   1.115 +                           BitMap* task_card_bm);
   1.116 +
   1.117 +  // Counts the given memory region in the task/worker counting
   1.118 +  // data structures for the given worker id.
   1.119 +  inline void count_region(MemRegion mr, uint worker_id);
   1.120 +
   1.121 +  // Counts the given object in the given task/worker counting
   1.122 +  // data structures.
   1.123 +  inline void count_object(oop obj, HeapRegion* hr,
   1.124 +                           size_t* marked_bytes_array,
   1.125 +                           BitMap* task_card_bm);
   1.126 +
   1.127 +  // Counts the given object in the task/worker counting data
   1.128 +  // structures for the given worker id.
   1.129 +  inline void count_object(oop obj, HeapRegion* hr, uint worker_id);
   1.130 +
   1.131 +  // Attempts to mark the given object and, if successful, counts
   1.132 +  // the object in the given task/worker counting structures.
   1.133 +  inline bool par_mark_and_count(oop obj, HeapRegion* hr,
   1.134 +                                 size_t* marked_bytes_array,
   1.135 +                                 BitMap* task_card_bm);
   1.136 +
   1.137 +  // Attempts to mark the given object and, if successful, counts
   1.138 +  // the object in the task/worker counting structures for the
   1.139 +  // given worker id.
   1.140 +  inline bool par_mark_and_count(oop obj, HeapRegion* hr, uint worker_id);
   1.141 +
   1.142 +  // Similar to the above routine but we don't know the heap region that
   1.143 +  // contains the object to be marked/counted, which this routine looks up.
   1.144 +  inline bool par_mark_and_count(oop obj, uint worker_id);
   1.145 +
   1.146 +  // Similar to the above routine but there are times when we cannot
   1.147 +  // safely calculate the size of obj due to races and we, therefore,
   1.148 +  // pass the size in as a parameter. It is the caller's reponsibility
   1.149 +  // to ensure that the size passed in for obj is valid.
   1.150 +  inline bool par_mark_and_count(oop obj, size_t word_size, uint worker_id);
   1.151 +
   1.152 +  // Unconditionally mark the given object, and unconditinally count
   1.153 +  // the object in the counting structures for worker id 0.
   1.154 +  // Should *not* be called from parallel code.
   1.155 +  inline bool mark_and_count(oop obj, HeapRegion* hr);
   1.156 +
   1.157 +  // Similar to the above routine but we don't know the heap region that
   1.158 +  // contains the object to be marked/counted, which this routine looks up.
   1.159 +  // Should *not* be called from parallel code.
   1.160 +  inline bool mark_and_count(oop obj);
   1.161 +
   1.162 +protected:
   1.163 +  // Clear all the per-task bitmaps and arrays used to store the
   1.164 +  // counting data.
   1.165 +  void clear_all_count_data();
   1.166 +
   1.167 +  // Aggregates the counting data for each worker/task
   1.168 +  // that was constructed while marking. Also sets
   1.169 +  // the amount of marked bytes for each region and
   1.170 +  // the top at concurrent mark count.
   1.171 +  void aggregate_count_data();
   1.172 +
   1.173 +  // Verification routine
   1.174 +  void verify_count_data();
   1.175  };
   1.176  
   1.177  // A class representing a marking task.
   1.178 @@ -1031,6 +1148,12 @@
   1.179  
   1.180    TruncatedSeq                _marking_step_diffs_ms;
   1.181  
   1.182 +  // Counting data structures. Embedding the task's marked_bytes_array
   1.183 +  // and card bitmap into the actual task saves having to go through
   1.184 +  // the ConcurrentMark object.
   1.185 +  size_t*                     _marked_bytes_array;
   1.186 +  BitMap*                     _card_bm;
   1.187 +
   1.188    // LOTS of statistics related with this task
   1.189  #if _MARKING_STATS_
   1.190    NumberSeq                   _all_clock_intervals_ms;
   1.191 @@ -1196,6 +1319,7 @@
   1.192    }
   1.193  
   1.194    CMTask(int task_num, ConcurrentMark *cm,
   1.195 +         size_t* marked_bytes, BitMap* card_bm,
   1.196           CMTaskQueue* task_queue, CMTaskQueueSet* task_queues);
   1.197  
   1.198    // it prints statistics associated with this task

mercurial