src/share/vm/memory/blockOffsetTable.cpp

changeset 2071
be3f9c242c9d
parent 1907
c18cbe5936b8
child 2314
f95d63e2154a
     1.1 --- a/src/share/vm/memory/blockOffsetTable.cpp	Sat Aug 14 00:47:52 2010 -0700
     1.2 +++ b/src/share/vm/memory/blockOffsetTable.cpp	Mon Aug 16 15:58:42 2010 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -103,13 +103,13 @@
    1.11  //////////////////////////////////////////////////////////////////////
    1.12  
    1.13  BlockOffsetArray::BlockOffsetArray(BlockOffsetSharedArray* array,
    1.14 -                                   MemRegion mr, bool init_to_zero) :
    1.15 +                                   MemRegion mr, bool init_to_zero_) :
    1.16    BlockOffsetTable(mr.start(), mr.end()),
    1.17 -  _array(array),
    1.18 -  _init_to_zero(init_to_zero)
    1.19 +  _array(array)
    1.20  {
    1.21    assert(_bottom <= _end, "arguments out of order");
    1.22 -  if (!_init_to_zero) {
    1.23 +  set_init_to_zero(init_to_zero_);
    1.24 +  if (!init_to_zero_) {
    1.25      // initialize cards to point back to mr.start()
    1.26      set_remainder_to_point_to_start(mr.start() + N_words, mr.end());
    1.27      _array->set_offset_array(0, 0);  // set first card to 0
    1.28 @@ -121,8 +121,9 @@
    1.29  // a right-open interval: [start, end)
    1.30  void
    1.31  BlockOffsetArray::
    1.32 -set_remainder_to_point_to_start(HeapWord* start, HeapWord* end) {
    1.33 +set_remainder_to_point_to_start(HeapWord* start, HeapWord* end, bool reducing) {
    1.34  
    1.35 +  check_reducing_assertion(reducing);
    1.36    if (start >= end) {
    1.37      // The start address is equal to the end address (or to
    1.38      // the right of the end address) so there are not cards
    1.39 @@ -167,7 +168,7 @@
    1.40    size_t end_card = _array->index_for(end-1);
    1.41    assert(start ==_array->address_for_index(start_card), "Precondition");
    1.42    assert(end ==_array->address_for_index(end_card)+N_words, "Precondition");
    1.43 -  set_remainder_to_point_to_start_incl(start_card, end_card); // closed interval
    1.44 +  set_remainder_to_point_to_start_incl(start_card, end_card, reducing); // closed interval
    1.45  }
    1.46  
    1.47  
    1.48 @@ -175,7 +176,9 @@
    1.49  // a closed, inclusive interval: [start_card, end_card], cf set_remainder_to_point_to_start()
    1.50  // above.
    1.51  void
    1.52 -BlockOffsetArray::set_remainder_to_point_to_start_incl(size_t start_card, size_t end_card) {
    1.53 +BlockOffsetArray::set_remainder_to_point_to_start_incl(size_t start_card, size_t end_card, bool reducing) {
    1.54 +
    1.55 +  check_reducing_assertion(reducing);
    1.56    if (start_card > end_card) {
    1.57      return;
    1.58    }
    1.59 @@ -191,11 +194,11 @@
    1.60      size_t reach = start_card - 1 + (power_to_cards_back(i+1) - 1);
    1.61      offset = N_words + i;
    1.62      if (reach >= end_card) {
    1.63 -      _array->set_offset_array(start_card_for_region, end_card, offset);
    1.64 +      _array->set_offset_array(start_card_for_region, end_card, offset, reducing);
    1.65        start_card_for_region = reach + 1;
    1.66        break;
    1.67      }
    1.68 -    _array->set_offset_array(start_card_for_region, reach, offset);
    1.69 +    _array->set_offset_array(start_card_for_region, reach, offset, reducing);
    1.70      start_card_for_region = reach + 1;
    1.71    }
    1.72    assert(start_card_for_region > end_card, "Sanity check");
    1.73 @@ -211,8 +214,10 @@
    1.74      return;
    1.75    }
    1.76    guarantee(_array->offset_array(start_card) == N_words, "Wrong value in second card");
    1.77 +  u_char last_entry = N_words;
    1.78    for (size_t c = start_card + 1; c <= end_card; c++ /* yeah! */) {
    1.79      u_char entry = _array->offset_array(c);
    1.80 +    guarantee(entry >= last_entry, "Monotonicity");
    1.81      if (c - start_card > power_to_cards_back(1)) {
    1.82        guarantee(entry > N_words, "Should be in logarithmic region");
    1.83      }
    1.84 @@ -220,11 +225,13 @@
    1.85      size_t landing_card = c - backskip;
    1.86      guarantee(landing_card >= (start_card - 1), "Inv");
    1.87      if (landing_card >= start_card) {
    1.88 -      guarantee(_array->offset_array(landing_card) <= entry, "monotonicity");
    1.89 +      guarantee(_array->offset_array(landing_card) <= entry, "Monotonicity");
    1.90      } else {
    1.91 -      guarantee(landing_card == start_card - 1, "Tautology");
    1.92 +      guarantee(landing_card == (start_card - 1), "Tautology");
    1.93 +      // Note that N_words is the maximum offset value
    1.94        guarantee(_array->offset_array(landing_card) <= N_words, "Offset value");
    1.95      }
    1.96 +    last_entry = entry;  // remember for monotonicity test
    1.97    }
    1.98  }
    1.99  
   1.100 @@ -243,7 +250,7 @@
   1.101  void
   1.102  BlockOffsetArray::do_block_internal(HeapWord* blk_start,
   1.103                                      HeapWord* blk_end,
   1.104 -                                    Action action) {
   1.105 +                                    Action action, bool reducing) {
   1.106    assert(Universe::heap()->is_in_reserved(blk_start),
   1.107           "reference must be into the heap");
   1.108    assert(Universe::heap()->is_in_reserved(blk_end-1),
   1.109 @@ -275,18 +282,18 @@
   1.110      switch (action) {
   1.111        case Action_mark: {
   1.112          if (init_to_zero()) {
   1.113 -          _array->set_offset_array(start_index, boundary, blk_start);
   1.114 +          _array->set_offset_array(start_index, boundary, blk_start, reducing);
   1.115            break;
   1.116          } // Else fall through to the next case
   1.117        }
   1.118        case Action_single: {
   1.119 -        _array->set_offset_array(start_index, boundary, blk_start);
   1.120 +        _array->set_offset_array(start_index, boundary, blk_start, reducing);
   1.121          // We have finished marking the "offset card". We need to now
   1.122          // mark the subsequent cards that this blk spans.
   1.123          if (start_index < end_index) {
   1.124            HeapWord* rem_st = _array->address_for_index(start_index) + N_words;
   1.125            HeapWord* rem_end = _array->address_for_index(end_index) + N_words;
   1.126 -          set_remainder_to_point_to_start(rem_st, rem_end);
   1.127 +          set_remainder_to_point_to_start(rem_st, rem_end, reducing);
   1.128          }
   1.129          break;
   1.130        }
   1.131 @@ -395,7 +402,7 @@
   1.132    // Indices for starts of prefix block and suffix block.
   1.133    size_t pref_index = _array->index_for(pref_addr);
   1.134    if (_array->address_for_index(pref_index) != pref_addr) {
   1.135 -    // pref_addr deos not begin pref_index
   1.136 +    // pref_addr does not begin pref_index
   1.137      pref_index++;
   1.138    }
   1.139  
   1.140 @@ -430,18 +437,18 @@
   1.141    if (num_suff_cards > 0) {
   1.142      HeapWord* boundary = _array->address_for_index(suff_index);
   1.143      // Set the offset card for suffix block
   1.144 -    _array->set_offset_array(suff_index, boundary, suff_addr);
   1.145 +    _array->set_offset_array(suff_index, boundary, suff_addr, true /* reducing */);
   1.146      // Change any further cards that need changing in the suffix
   1.147      if (num_pref_cards > 0) {
   1.148        if (num_pref_cards >= num_suff_cards) {
   1.149          // Unilaterally fix all of the suffix cards: closed card
   1.150          // index interval in args below.
   1.151 -        set_remainder_to_point_to_start_incl(suff_index + 1, end_index - 1);
   1.152 +        set_remainder_to_point_to_start_incl(suff_index + 1, end_index - 1, true /* reducing */);
   1.153        } else {
   1.154          // Unilaterally fix the first (num_pref_cards - 1) following
   1.155          // the "offset card" in the suffix block.
   1.156          set_remainder_to_point_to_start_incl(suff_index + 1,
   1.157 -          suff_index + num_pref_cards - 1);
   1.158 +          suff_index + num_pref_cards - 1, true /* reducing */);
   1.159          // Fix the appropriate cards in the remainder of the
   1.160          // suffix block -- these are the last num_pref_cards
   1.161          // cards in each power block of the "new" range plumbed
   1.162 @@ -461,7 +468,7 @@
   1.163              // is non-null.
   1.164              if (left_index <= right_index) {
   1.165                _array->set_offset_array(left_index, right_index,
   1.166 -                                     N_words + i - 1);
   1.167 +                                     N_words + i - 1, true /* reducing */);
   1.168              } else {
   1.169                more = false; // we are done
   1.170              }
   1.171 @@ -482,7 +489,7 @@
   1.172              more  = false;
   1.173            }
   1.174            assert(left_index <= right_index, "Error");
   1.175 -          _array->set_offset_array(left_index, right_index, N_words + i - 1);
   1.176 +          _array->set_offset_array(left_index, right_index, N_words + i - 1, true /* reducing */);
   1.177            i++;
   1.178          }
   1.179        }
   1.180 @@ -501,14 +508,13 @@
   1.181  // any cards subsequent to the first one.
   1.182  void
   1.183  BlockOffsetArrayNonContigSpace::mark_block(HeapWord* blk_start,
   1.184 -                                           HeapWord* blk_end) {
   1.185 -  do_block_internal(blk_start, blk_end, Action_mark);
   1.186 +                                           HeapWord* blk_end, bool reducing) {
   1.187 +  do_block_internal(blk_start, blk_end, Action_mark, reducing);
   1.188  }
   1.189  
   1.190  HeapWord* BlockOffsetArrayNonContigSpace::block_start_unsafe(
   1.191    const void* addr) const {
   1.192    assert(_array->offset_array(0) == 0, "objects can't cross covered areas");
   1.193 -
   1.194    assert(_bottom <= addr && addr < _end,
   1.195           "addr must be covered by this Array");
   1.196    // Must read this exactly once because it can be modified by parallel
   1.197 @@ -542,9 +548,10 @@
   1.198      debug_only(HeapWord* last = q);   // for debugging
   1.199      q = n;
   1.200      n += _sp->block_size(n);
   1.201 +    assert(n > q, err_msg("Looping at: " INTPTR_FORMAT, n));
   1.202    }
   1.203 -  assert(q <= addr, "wrong order for current and arg");
   1.204 -  assert(addr <= n, "wrong order for arg and next");
   1.205 +  assert(q <= addr, err_msg("wrong order for current (" INTPTR_FORMAT ") <= arg (" INTPTR_FORMAT ")", q, addr));
   1.206 +  assert(addr <= n, err_msg("wrong order for arg (" INTPTR_FORMAT ") <= next (" INTPTR_FORMAT ")", addr, n));
   1.207    return q;
   1.208  }
   1.209  
   1.210 @@ -727,9 +734,8 @@
   1.211    _next_offset_index = end_index + 1;
   1.212    // Calculate _next_offset_threshold this way because end_index
   1.213    // may be the last valid index in the covered region.
   1.214 -  _next_offset_threshold = _array->address_for_index(end_index) +
   1.215 -    N_words;
   1.216 -  assert(_next_offset_threshold >= blk_end, "Incorrent offset threshold");
   1.217 +  _next_offset_threshold = _array->address_for_index(end_index) + N_words;
   1.218 +  assert(_next_offset_threshold >= blk_end, "Incorrect offset threshold");
   1.219  
   1.220  #ifdef ASSERT
   1.221    // The offset can be 0 if the block starts on a boundary.  That

mercurial