< prev index next >

src/share/vm/gc/g1/heapRegionRemSet.cpp

Print this page
rev 10742 : Make fields used in lock-free algorithms volatile


  39 #include "utilities/growableArray.hpp"
  40 
  41 class PerRegionTable: public CHeapObj<mtGC> {
  42   friend class OtherRegionsTable;
  43   friend class HeapRegionRemSetIterator;
  44 
  45   HeapRegion*     _hr;
  46   BitMap          _bm;
  47   jint            _occupied;
  48 
  49   // next pointer for free/allocated 'all' list
  50   PerRegionTable* _next;
  51 
  52   // prev pointer for the allocated 'all' list
  53   PerRegionTable* _prev;
  54 
  55   // next pointer in collision list
  56   PerRegionTable * _collision_list_next;
  57 
  58   // Global free list of PRTs
  59   static PerRegionTable* _free_list;
  60 
  61 protected:
  62   // We need access in order to union things into the base table.
  63   BitMap* bm() { return &_bm; }
  64 
  65   void recount_occupied() {
  66     _occupied = (jint) bm()->count_one_bits();
  67   }
  68 
  69   PerRegionTable(HeapRegion* hr) :
  70     _hr(hr),
  71     _occupied(0),
  72     _bm(HeapRegion::CardsPerRegion, false /* in-resource-area */),
  73     _collision_list_next(NULL), _next(NULL), _prev(NULL)
  74   {}
  75 
  76   void add_card_work(CardIdx_t from_card, bool par) {
  77     if (!_bm.at(from_card)) {
  78       if (par) {
  79         if (_bm.par_at_put(from_card, 1)) {


 232     _collision_list_next = next;
 233   }
 234 
 235   PerRegionTable** collision_list_next_addr() {
 236     return &_collision_list_next;
 237   }
 238 
 239   static size_t fl_mem_size() {
 240     PerRegionTable* cur = _free_list;
 241     size_t res = 0;
 242     while (cur != NULL) {
 243       res += cur->mem_size();
 244       cur = cur->next();
 245     }
 246     return res;
 247   }
 248 
 249   static void test_fl_mem_size();
 250 };
 251 
 252 PerRegionTable* PerRegionTable::_free_list = NULL;
 253 
 254 size_t OtherRegionsTable::_max_fine_entries = 0;
 255 size_t OtherRegionsTable::_mod_max_fine_entries_mask = 0;
 256 size_t OtherRegionsTable::_fine_eviction_stride = 0;
 257 size_t OtherRegionsTable::_fine_eviction_sample_size = 0;
 258 
 259 OtherRegionsTable::OtherRegionsTable(HeapRegion* hr, Mutex* m) :
 260   _g1h(G1CollectedHeap::heap()),
 261   _hr(hr), _m(m),
 262   _coarse_map(G1CollectedHeap::heap()->max_regions(),
 263               false /* in-resource-area */),
 264   _fine_grain_regions(NULL),
 265   _first_all_fine_prts(NULL), _last_all_fine_prts(NULL),
 266   _n_fine_entries(0), _n_coarse_entries(0),
 267   _fine_eviction_start(0),
 268   _sparse_table(hr)
 269 {
 270   typedef PerRegionTable* PerRegionTablePtr;
 271 
 272   if (_max_fine_entries == 0) {




  39 #include "utilities/growableArray.hpp"
  40 
  41 class PerRegionTable: public CHeapObj<mtGC> {
  42   friend class OtherRegionsTable;
  43   friend class HeapRegionRemSetIterator;
  44 
  45   HeapRegion*     _hr;
  46   BitMap          _bm;
  47   jint            _occupied;
  48 
  49   // next pointer for free/allocated 'all' list
  50   PerRegionTable* _next;
  51 
  52   // prev pointer for the allocated 'all' list
  53   PerRegionTable* _prev;
  54 
  55   // next pointer in collision list
  56   PerRegionTable * _collision_list_next;
  57 
  58   // Global free list of PRTs
  59   static PerRegionTable* volatile _free_list;
  60 
  61 protected:
  62   // We need access in order to union things into the base table.
  63   BitMap* bm() { return &_bm; }
  64 
  65   void recount_occupied() {
  66     _occupied = (jint) bm()->count_one_bits();
  67   }
  68 
  69   PerRegionTable(HeapRegion* hr) :
  70     _hr(hr),
  71     _occupied(0),
  72     _bm(HeapRegion::CardsPerRegion, false /* in-resource-area */),
  73     _collision_list_next(NULL), _next(NULL), _prev(NULL)
  74   {}
  75 
  76   void add_card_work(CardIdx_t from_card, bool par) {
  77     if (!_bm.at(from_card)) {
  78       if (par) {
  79         if (_bm.par_at_put(from_card, 1)) {


 232     _collision_list_next = next;
 233   }
 234 
 235   PerRegionTable** collision_list_next_addr() {
 236     return &_collision_list_next;
 237   }
 238 
 239   static size_t fl_mem_size() {
 240     PerRegionTable* cur = _free_list;
 241     size_t res = 0;
 242     while (cur != NULL) {
 243       res += cur->mem_size();
 244       cur = cur->next();
 245     }
 246     return res;
 247   }
 248 
 249   static void test_fl_mem_size();
 250 };
 251 
 252 PerRegionTable* volatile PerRegionTable::_free_list = NULL;
 253 
 254 size_t OtherRegionsTable::_max_fine_entries = 0;
 255 size_t OtherRegionsTable::_mod_max_fine_entries_mask = 0;
 256 size_t OtherRegionsTable::_fine_eviction_stride = 0;
 257 size_t OtherRegionsTable::_fine_eviction_sample_size = 0;
 258 
 259 OtherRegionsTable::OtherRegionsTable(HeapRegion* hr, Mutex* m) :
 260   _g1h(G1CollectedHeap::heap()),
 261   _hr(hr), _m(m),
 262   _coarse_map(G1CollectedHeap::heap()->max_regions(),
 263               false /* in-resource-area */),
 264   _fine_grain_regions(NULL),
 265   _first_all_fine_prts(NULL), _last_all_fine_prts(NULL),
 266   _n_fine_entries(0), _n_coarse_entries(0),
 267   _fine_eviction_start(0),
 268   _sparse_table(hr)
 269 {
 270   typedef PerRegionTable* PerRegionTablePtr;
 271 
 272   if (_max_fine_entries == 0) {


< prev index next >