src/share/vm/memory/cardTableModRefBS.cpp

changeset 7051
1f1d373cd044
parent 6992
2c6ef90f030a
child 7535
7ae4e26cb1e0
child 9327
f96fcd9e1e1b
     1.1 --- a/src/share/vm/memory/cardTableModRefBS.cpp	Tue Aug 19 10:50:27 2014 +0200
     1.2 +++ b/src/share/vm/memory/cardTableModRefBS.cpp	Thu Aug 21 11:47:10 2014 +0200
     1.3 @@ -44,13 +44,6 @@
     1.4  // enumerate ref fields that have been modified (since the last
     1.5  // enumeration.)
     1.6  
     1.7 -size_t CardTableModRefBS::cards_required(size_t covered_words)
     1.8 -{
     1.9 -  // Add one for a guard card, used to detect errors.
    1.10 -  const size_t words = align_size_up(covered_words, card_size_in_words);
    1.11 -  return words / card_size_in_words + 1;
    1.12 -}
    1.13 -
    1.14  size_t CardTableModRefBS::compute_byte_map_size()
    1.15  {
    1.16    assert(_guard_index == cards_required(_whole_heap.word_size()) - 1,
    1.17 @@ -64,27 +57,50 @@
    1.18                                       int max_covered_regions):
    1.19    ModRefBarrierSet(max_covered_regions),
    1.20    _whole_heap(whole_heap),
    1.21 -  _guard_index(cards_required(whole_heap.word_size()) - 1),
    1.22 -  _last_valid_index(_guard_index - 1),
    1.23 +  _guard_index(0),
    1.24 +  _guard_region(),
    1.25 +  _last_valid_index(0),
    1.26    _page_size(os::vm_page_size()),
    1.27 -  _byte_map_size(compute_byte_map_size())
    1.28 +  _byte_map_size(0),
    1.29 +  _covered(NULL),
    1.30 +  _committed(NULL),
    1.31 +  _cur_covered_regions(0),
    1.32 +  _byte_map(NULL),
    1.33 +  byte_map_base(NULL),
    1.34 +  // LNC functionality
    1.35 +  _lowest_non_clean(NULL),
    1.36 +  _lowest_non_clean_chunk_size(NULL),
    1.37 +  _lowest_non_clean_base_chunk_index(NULL),
    1.38 +  _last_LNC_resizing_collection(NULL)
    1.39  {
    1.40    _kind = BarrierSet::CardTableModRef;
    1.41  
    1.42 -  HeapWord* low_bound  = _whole_heap.start();
    1.43 -  HeapWord* high_bound = _whole_heap.end();
    1.44 -  assert((uintptr_t(low_bound)  & (card_size - 1))  == 0, "heap must start at card boundary");
    1.45 -  assert((uintptr_t(high_bound) & (card_size - 1))  == 0, "heap must end at card boundary");
    1.46 +  assert((uintptr_t(_whole_heap.start())  & (card_size - 1))  == 0, "heap must start at card boundary");
    1.47 +  assert((uintptr_t(_whole_heap.end()) & (card_size - 1))  == 0, "heap must end at card boundary");
    1.48  
    1.49    assert(card_size <= 512, "card_size must be less than 512"); // why?
    1.50  
    1.51 -  _covered   = new MemRegion[max_covered_regions];
    1.52 -  _committed = new MemRegion[max_covered_regions];
    1.53 -  if (_covered == NULL || _committed == NULL) {
    1.54 -    vm_exit_during_initialization("couldn't alloc card table covered region set.");
    1.55 +  _covered   = new MemRegion[_max_covered_regions];
    1.56 +  if (_covered == NULL) {
    1.57 +    vm_exit_during_initialization("Could not allocate card table covered region set.");
    1.58 +  }
    1.59 +}
    1.60 +
    1.61 +void CardTableModRefBS::initialize() {
    1.62 +  _guard_index = cards_required(_whole_heap.word_size()) - 1;
    1.63 +  _last_valid_index = _guard_index - 1;
    1.64 +
    1.65 +  _byte_map_size = compute_byte_map_size();
    1.66 +
    1.67 +  HeapWord* low_bound  = _whole_heap.start();
    1.68 +  HeapWord* high_bound = _whole_heap.end();
    1.69 +
    1.70 +  _cur_covered_regions = 0;
    1.71 +  _committed = new MemRegion[_max_covered_regions];
    1.72 +  if (_committed == NULL) {
    1.73 +    vm_exit_during_initialization("Could not allocate card table committed region set.");
    1.74    }
    1.75  
    1.76 -  _cur_covered_regions = 0;
    1.77    const size_t rs_align = _page_size == (size_t) os::vm_page_size() ? 0 :
    1.78      MAX2(_page_size, (size_t) os::vm_allocation_granularity());
    1.79    ReservedSpace heap_rs(_byte_map_size, rs_align, false);
    1.80 @@ -114,20 +130,20 @@
    1.81                              !ExecMem, "card table last card");
    1.82    *guard_card = last_card;
    1.83  
    1.84 -   _lowest_non_clean =
    1.85 -    NEW_C_HEAP_ARRAY(CardArr, max_covered_regions, mtGC);
    1.86 +  _lowest_non_clean =
    1.87 +    NEW_C_HEAP_ARRAY(CardArr, _max_covered_regions, mtGC);
    1.88    _lowest_non_clean_chunk_size =
    1.89 -    NEW_C_HEAP_ARRAY(size_t, max_covered_regions, mtGC);
    1.90 +    NEW_C_HEAP_ARRAY(size_t, _max_covered_regions, mtGC);
    1.91    _lowest_non_clean_base_chunk_index =
    1.92 -    NEW_C_HEAP_ARRAY(uintptr_t, max_covered_regions, mtGC);
    1.93 +    NEW_C_HEAP_ARRAY(uintptr_t, _max_covered_regions, mtGC);
    1.94    _last_LNC_resizing_collection =
    1.95 -    NEW_C_HEAP_ARRAY(int, max_covered_regions, mtGC);
    1.96 +    NEW_C_HEAP_ARRAY(int, _max_covered_regions, mtGC);
    1.97    if (_lowest_non_clean == NULL
    1.98        || _lowest_non_clean_chunk_size == NULL
    1.99        || _lowest_non_clean_base_chunk_index == NULL
   1.100        || _last_LNC_resizing_collection == NULL)
   1.101      vm_exit_during_initialization("couldn't allocate an LNC array.");
   1.102 -  for (int i = 0; i < max_covered_regions; i++) {
   1.103 +  for (int i = 0; i < _max_covered_regions; i++) {
   1.104      _lowest_non_clean[i] = NULL;
   1.105      _lowest_non_clean_chunk_size[i] = 0;
   1.106      _last_LNC_resizing_collection[i] = -1;
   1.107 @@ -650,7 +666,7 @@
   1.108                                        jbyte val, bool val_equals) {
   1.109    jbyte* start    = byte_for(mr.start());
   1.110    jbyte* end      = byte_for(mr.last());
   1.111 -  bool   failures = false;
   1.112 +  bool failures = false;
   1.113    for (jbyte* curr = start; curr <= end; ++curr) {
   1.114      jbyte curr_val = *curr;
   1.115      bool failed = (val_equals) ? (curr_val != val) : (curr_val == val);

mercurial