< prev index next >

src/hotspot/share/gc/shared/cardTable.cpp

Print this page
rev 58060 : [mq]: 8238999-iklam-review


  34 #include "utilities/align.hpp"
  35 
  36 size_t CardTable::compute_byte_map_size() {
  37   assert(_guard_index == cards_required(_whole_heap.word_size()) - 1,
  38                                         "uninitialized, check declaration order");
  39   assert(_page_size != 0, "uninitialized, check declaration order");
  40   const size_t granularity = os::vm_allocation_granularity();
  41   return align_up(_guard_index + 1, MAX2(_page_size, granularity));
  42 }
  43 
  44 CardTable::CardTable(MemRegion whole_heap, bool conc_scan) :
  45   _scanned_concurrently(conc_scan),
  46   _whole_heap(whole_heap),
  47   _guard_index(0),
  48   _last_valid_index(0),
  49   _page_size(os::vm_page_size()),
  50   _byte_map_size(0),
  51   _byte_map(NULL),
  52   _byte_map_base(NULL),
  53   _cur_covered_regions(0),
  54   _covered(NEW_C_HEAP_ARRAY(MemRegion, _max_covered_regions, mtGC)),
  55   _committed(NEW_C_HEAP_ARRAY(MemRegion, _max_covered_regions, mtGC)),
  56   _guard_region()
  57 {
  58   assert((uintptr_t(_whole_heap.start())  & (card_size - 1))  == 0, "heap must start at card boundary");
  59   assert((uintptr_t(_whole_heap.end()) & (card_size - 1))  == 0, "heap must end at card boundary");
  60 
  61   assert(card_size <= 512, "card_size must be less than 512"); // why?
  62 
  63   for (int i = 0; i < _max_covered_regions; i++) {
  64     ::new (&_covered[i]) MemRegion();
  65     ::new (&_committed[i]) MemRegion();
  66   }
  67 }
  68 
  69 CardTable::~CardTable() {
  70   FREE_C_HEAP_ARRAY(MemRegion, _covered);
  71   FREE_C_HEAP_ARRAY(MemRegion, _committed);
  72 }
  73 
  74 void CardTable::initialize() {
  75   _guard_index = cards_required(_whole_heap.word_size()) - 1;
  76   _last_valid_index = _guard_index - 1;
  77 
  78   _byte_map_size = compute_byte_map_size();
  79 
  80   HeapWord* low_bound  = _whole_heap.start();
  81   HeapWord* high_bound = _whole_heap.end();
  82 
  83   _cur_covered_regions = 0;
  84 
  85   const size_t rs_align = _page_size == (size_t) os::vm_page_size() ? 0 :
  86     MAX2(_page_size, (size_t) os::vm_allocation_granularity());




  34 #include "utilities/align.hpp"
  35 
  36 size_t CardTable::compute_byte_map_size() {
  37   assert(_guard_index == cards_required(_whole_heap.word_size()) - 1,
  38                                         "uninitialized, check declaration order");
  39   assert(_page_size != 0, "uninitialized, check declaration order");
  40   const size_t granularity = os::vm_allocation_granularity();
  41   return align_up(_guard_index + 1, MAX2(_page_size, granularity));
  42 }
  43 
  44 CardTable::CardTable(MemRegion whole_heap, bool conc_scan) :
  45   _scanned_concurrently(conc_scan),
  46   _whole_heap(whole_heap),
  47   _guard_index(0),
  48   _last_valid_index(0),
  49   _page_size(os::vm_page_size()),
  50   _byte_map_size(0),
  51   _byte_map(NULL),
  52   _byte_map_base(NULL),
  53   _cur_covered_regions(0),
  54   _covered(MemRegion::create(_max_covered_regions, mtGC)),
  55   _committed(MemRegion::create(_max_covered_regions, mtGC)),
  56   _guard_region()
  57 {
  58   assert((uintptr_t(_whole_heap.start())  & (card_size - 1))  == 0, "heap must start at card boundary");
  59   assert((uintptr_t(_whole_heap.end()) & (card_size - 1))  == 0, "heap must end at card boundary");
  60 
  61   assert(card_size <= 512, "card_size must be less than 512"); // why?





  62 }
  63 
  64 CardTable::~CardTable() {
  65   FREE_C_HEAP_ARRAY(MemRegion, _covered);
  66   FREE_C_HEAP_ARRAY(MemRegion, _committed);
  67 }
  68 
  69 void CardTable::initialize() {
  70   _guard_index = cards_required(_whole_heap.word_size()) - 1;
  71   _last_valid_index = _guard_index - 1;
  72 
  73   _byte_map_size = compute_byte_map_size();
  74 
  75   HeapWord* low_bound  = _whole_heap.start();
  76   HeapWord* high_bound = _whole_heap.end();
  77 
  78   _cur_covered_regions = 0;
  79 
  80   const size_t rs_align = _page_size == (size_t) os::vm_page_size() ? 0 :
  81     MAX2(_page_size, (size_t) os::vm_allocation_granularity());


< prev index next >