src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp

changeset 2889
fc2b798ab316
parent 2819
c48ad6ab8bdf
child 2891
7d64aa23eb96
     1.1 --- a/src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp	Fri May 06 09:45:18 2011 +0200
     1.2 +++ b/src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp	Tue May 10 00:33:21 2011 -0700
     1.3 @@ -29,13 +29,14 @@
     1.4  #include "memory/sharedHeap.hpp"
     1.5  #include "memory/space.inline.hpp"
     1.6  #include "memory/universe.hpp"
     1.7 +#include "oops/oop.inline.hpp"
     1.8  #include "runtime/java.hpp"
     1.9  #include "runtime/mutexLocker.hpp"
    1.10  #include "runtime/virtualspace.hpp"
    1.11  
    1.12  void CardTableModRefBS::non_clean_card_iterate_parallel_work(Space* sp, MemRegion mr,
    1.13 -                                                             DirtyCardToOopClosure* dcto_cl,
    1.14 -                                                             ClearNoncleanCardWrapper* cl,
    1.15 +                                                             OopsInGenClosure* cl,
    1.16 +                                                             CardTableRS* ct,
    1.17                                                               int n_threads) {
    1.18    assert(n_threads > 0, "Error: expected n_threads > 0");
    1.19    assert((n_threads == 1 && ParallelGCThreads == 0) ||
    1.20 @@ -49,14 +50,14 @@
    1.21                            lowest_non_clean_base_chunk_index,
    1.22                            lowest_non_clean_chunk_size);
    1.23  
    1.24 -  int n_strides = n_threads * StridesPerThread;
    1.25 +  int n_strides = n_threads * ParGCStridesPerThread;
    1.26    SequentialSubTasksDone* pst = sp->par_seq_tasks();
    1.27    pst->set_n_threads(n_threads);
    1.28    pst->set_n_tasks(n_strides);
    1.29  
    1.30    int stride = 0;
    1.31    while (!pst->is_task_claimed(/* reference */ stride)) {
    1.32 -    process_stride(sp, mr, stride, n_strides, dcto_cl, cl,
    1.33 +    process_stride(sp, mr, stride, n_strides, cl, ct,
    1.34                     lowest_non_clean,
    1.35                     lowest_non_clean_base_chunk_index,
    1.36                     lowest_non_clean_chunk_size);
    1.37 @@ -79,13 +80,13 @@
    1.38  process_stride(Space* sp,
    1.39                 MemRegion used,
    1.40                 jint stride, int n_strides,
    1.41 -               DirtyCardToOopClosure* dcto_cl,
    1.42 -               ClearNoncleanCardWrapper* cl,
    1.43 +               OopsInGenClosure* cl,
    1.44 +               CardTableRS* ct,
    1.45                 jbyte** lowest_non_clean,
    1.46                 uintptr_t lowest_non_clean_base_chunk_index,
    1.47                 size_t    lowest_non_clean_chunk_size) {
    1.48 -  // We don't have to go downwards here; it wouldn't help anyway,
    1.49 -  // because of parallelism.
    1.50 +  // We go from higher to lower addresses here; it wouldn't help that much
    1.51 +  // because of the strided parallelism pattern used here.
    1.52  
    1.53    // Find the first card address of the first chunk in the stride that is
    1.54    // at least "bottom" of the used region.
    1.55 @@ -98,25 +99,35 @@
    1.56    if ((uintptr_t)stride >= start_chunk_stride_num) {
    1.57      chunk_card_start = (jbyte*)(start_card +
    1.58                                  (stride - start_chunk_stride_num) *
    1.59 -                                CardsPerStrideChunk);
    1.60 +                                ParGCCardsPerStrideChunk);
    1.61    } else {
    1.62      // Go ahead to the next chunk group boundary, then to the requested stride.
    1.63      chunk_card_start = (jbyte*)(start_card +
    1.64                                  (n_strides - start_chunk_stride_num + stride) *
    1.65 -                                CardsPerStrideChunk);
    1.66 +                                ParGCCardsPerStrideChunk);
    1.67    }
    1.68  
    1.69    while (chunk_card_start < end_card) {
    1.70 -    // We don't have to go downwards here; it wouldn't help anyway,
    1.71 -    // because of parallelism.  (We take care with "min_done"; see below.)
    1.72 +    // Even though we go from lower to higher addresses below, the
    1.73 +    // strided parallelism can interleave the actual processing of the
    1.74 +    // dirty pages in various ways. For a specific chunk within this
    1.75 +    // stride, we take care to avoid double scanning or missing a card
    1.76 +    // by suitably initializing the "min_done" field in process_chunk_boundaries()
    1.77 +    // below, together with the dirty region extension accomplished in
    1.78 +    // DirtyCardToOopClosure::do_MemRegion().
    1.79 +    jbyte*    chunk_card_end = chunk_card_start + ParGCCardsPerStrideChunk;
    1.80      // Invariant: chunk_mr should be fully contained within the "used" region.
    1.81 -    jbyte*    chunk_card_end = chunk_card_start + CardsPerStrideChunk;
    1.82      MemRegion chunk_mr       = MemRegion(addr_for(chunk_card_start),
    1.83                                           chunk_card_end >= end_card ?
    1.84                                             used.end() : addr_for(chunk_card_end));
    1.85      assert(chunk_mr.word_size() > 0, "[chunk_card_start > used_end)");
    1.86      assert(used.contains(chunk_mr), "chunk_mr should be subset of used");
    1.87  
    1.88 +    DirtyCardToOopClosure* dcto_cl = sp->new_dcto_cl(cl, precision(),
    1.89 +                                                     cl->gen_boundary());
    1.90 +    ClearNoncleanCardWrapper clear_cl(dcto_cl, ct);
    1.91 +
    1.92 +
    1.93      // Process the chunk.
    1.94      process_chunk_boundaries(sp,
    1.95                               dcto_cl,
    1.96 @@ -126,17 +137,30 @@
    1.97                               lowest_non_clean_base_chunk_index,
    1.98                               lowest_non_clean_chunk_size);
    1.99  
   1.100 +    // We want the LNC array updates above in process_chunk_boundaries
   1.101 +    // to be visible before any of the card table value changes as a
   1.102 +    // result of the dirty card iteration below.
   1.103 +    OrderAccess::storestore();
   1.104 +
   1.105      // We do not call the non_clean_card_iterate_serial() version because
   1.106 -    // we want to clear the cards, and the ClearNoncleanCardWrapper closure
   1.107 -    // itself does the work of finding contiguous dirty ranges of cards to
   1.108 -    // process (and clear).
   1.109 -    cl->do_MemRegion(chunk_mr);
   1.110 +    // we want to clear the cards: clear_cl here does the work of finding
   1.111 +    // contiguous dirty ranges of cards to process and clear.
   1.112 +    clear_cl.do_MemRegion(chunk_mr);
   1.113  
   1.114      // Find the next chunk of the stride.
   1.115 -    chunk_card_start += CardsPerStrideChunk * n_strides;
   1.116 +    chunk_card_start += ParGCCardsPerStrideChunk * n_strides;
   1.117    }
   1.118  }
   1.119  
   1.120 +
   1.121 +// If you want a talkative process_chunk_boundaries,
   1.122 +// then #define NOISY(x) x
   1.123 +#ifdef NOISY
   1.124 +#error "Encountered a global preprocessor flag, NOISY, which might clash with local definition to follow"
   1.125 +#else
   1.126 +#define NOISY(x)
   1.127 +#endif
   1.128 +
   1.129  void
   1.130  CardTableModRefBS::
   1.131  process_chunk_boundaries(Space* sp,
   1.132 @@ -147,126 +171,232 @@
   1.133                           uintptr_t lowest_non_clean_base_chunk_index,
   1.134                           size_t    lowest_non_clean_chunk_size)
   1.135  {
   1.136 -  // We must worry about the chunk boundaries.
   1.137 +  // We must worry about non-array objects that cross chunk boundaries,
   1.138 +  // because such objects are both precisely and imprecisely marked:
   1.139 +  // .. if the head of such an object is dirty, the entire object
   1.140 +  //    needs to be scanned, under the interpretation that this
   1.141 +  //    was an imprecise mark
   1.142 +  // .. if the head of such an object is not dirty, we can assume
   1.143 +  //    precise marking and it's efficient to scan just the dirty
   1.144 +  //    cards.
   1.145 +  // In either case, each scanned reference must be scanned precisely
   1.146 +  // once so as to avoid cloning of a young referent. For efficiency,
   1.147 +  // our closures depend on this property and do not protect against
   1.148 +  // double scans.
   1.149  
   1.150 -  // First, set our max_to_do:
   1.151 -  HeapWord* max_to_do = NULL;
   1.152    uintptr_t cur_chunk_index = addr_to_chunk_index(chunk_mr.start());
   1.153    cur_chunk_index           = cur_chunk_index - lowest_non_clean_base_chunk_index;
   1.154  
   1.155 +  NOISY(tty->print_cr("===========================================================================");)
   1.156 +  NOISY(tty->print_cr(" process_chunk_boundary: Called with [" PTR_FORMAT "," PTR_FORMAT ")",
   1.157 +                      chunk_mr.start(), chunk_mr.end());)
   1.158 +
   1.159 +  // First, set "our" lowest_non_clean entry, which would be
   1.160 +  // used by the thread scanning an adjoining left chunk with
   1.161 +  // a non-array object straddling the mutual boundary.
   1.162 +  // Find the object that spans our boundary, if one exists.
   1.163 +  // first_block is the block possibly straddling our left boundary.
   1.164 +  HeapWord* first_block = sp->block_start(chunk_mr.start());
   1.165 +  assert((chunk_mr.start() != used.start()) || (first_block == chunk_mr.start()),
   1.166 +         "First chunk should always have a co-initial block");
   1.167 +  // Does the block straddle the chunk's left boundary, and is it
   1.168 +  // a non-array object?
   1.169 +  if (first_block < chunk_mr.start()        // first block straddles left bdry
   1.170 +      && sp->block_is_obj(first_block)      // first block is an object
   1.171 +      && !(oop(first_block)->is_objArray()  // first block is not an array (arrays are precisely dirtied)
   1.172 +           || oop(first_block)->is_typeArray())) {
   1.173 +    // Find our least non-clean card, so that a left neighbour
   1.174 +    // does not scan an object straddling the mutual boundary
   1.175 +    // too far to the right, and attempt to scan a portion of
   1.176 +    // that object twice.
   1.177 +    jbyte* first_dirty_card = NULL;
   1.178 +    jbyte* last_card_of_first_obj =
   1.179 +        byte_for(first_block + sp->block_size(first_block) - 1);
   1.180 +    jbyte* first_card_of_cur_chunk = byte_for(chunk_mr.start());
   1.181 +    jbyte* last_card_of_cur_chunk = byte_for(chunk_mr.last());
   1.182 +    jbyte* last_card_to_check =
   1.183 +      (jbyte*) MIN2((intptr_t) last_card_of_cur_chunk,
   1.184 +                    (intptr_t) last_card_of_first_obj);
   1.185 +    // Note that this does not need to go beyond our last card
   1.186 +    // if our first object completely straddles this chunk.
   1.187 +    for (jbyte* cur = first_card_of_cur_chunk;
   1.188 +         cur <= last_card_to_check; cur++) {
   1.189 +      jbyte val = *cur;
   1.190 +      if (card_will_be_scanned(val)) {
   1.191 +        first_dirty_card = cur; break;
   1.192 +      } else {
   1.193 +        assert(!card_may_have_been_dirty(val), "Error");
   1.194 +      }
   1.195 +    }
   1.196 +    if (first_dirty_card != NULL) {
   1.197 +      NOISY(tty->print_cr(" LNC: Found a dirty card at " PTR_FORMAT " in current chunk",
   1.198 +                    first_dirty_card);)
   1.199 +      assert(0 <= cur_chunk_index && cur_chunk_index < lowest_non_clean_chunk_size,
   1.200 +             "Bounds error.");
   1.201 +      assert(lowest_non_clean[cur_chunk_index] == NULL,
   1.202 +             "Write exactly once : value should be stable hereafter for this round");
   1.203 +      lowest_non_clean[cur_chunk_index] = first_dirty_card;
   1.204 +    } NOISY(else {
   1.205 +      tty->print_cr(" LNC: Found no dirty card in current chunk; leaving LNC entry NULL");
   1.206 +      // In the future, we could have this thread look for a non-NULL value to copy from its
   1.207 +      // right neighbour (up to the end of the first object).
   1.208 +      if (last_card_of_cur_chunk < last_card_of_first_obj) {
   1.209 +        tty->print_cr(" LNC: BEWARE!!! first obj straddles past right end of chunk:\n"
   1.210 +                      "   might be efficient to get value from right neighbour?");
   1.211 +      }
   1.212 +    })
   1.213 +  } else {
   1.214 +    // In this case we can help our neighbour by just asking them
   1.215 +    // to stop at our first card (even though it may not be dirty).
   1.216 +    NOISY(tty->print_cr(" LNC: first block is not a non-array object; setting LNC to first card of current chunk");)
   1.217 +    assert(lowest_non_clean[cur_chunk_index] == NULL, "Write once : value should be stable hereafter");
   1.218 +    jbyte* first_card_of_cur_chunk = byte_for(chunk_mr.start());
   1.219 +    lowest_non_clean[cur_chunk_index] = first_card_of_cur_chunk;
   1.220 +  }
   1.221 +  NOISY(tty->print_cr(" process_chunk_boundary: lowest_non_clean[" INTPTR_FORMAT "] = " PTR_FORMAT
   1.222 +                "   which corresponds to the heap address " PTR_FORMAT,
   1.223 +                cur_chunk_index, lowest_non_clean[cur_chunk_index],
   1.224 +                (lowest_non_clean[cur_chunk_index] != NULL)
   1.225 +                ? addr_for(lowest_non_clean[cur_chunk_index])
   1.226 +                : NULL);)
   1.227 +  NOISY(tty->print_cr("---------------------------------------------------------------------------");)
   1.228 +
   1.229 +  // Next, set our own max_to_do, which will strictly/exclusively bound
   1.230 +  // the highest address that we will scan past the right end of our chunk.
   1.231 +  HeapWord* max_to_do = NULL;
   1.232    if (chunk_mr.end() < used.end()) {
   1.233 -    // This is not the last chunk in the used region.  What is the last
   1.234 -    // object?
   1.235 -    HeapWord* last_block = sp->block_start(chunk_mr.end());
   1.236 +    // This is not the last chunk in the used region.
   1.237 +    // What is our last block? We check the first block of
   1.238 +    // the next (right) chunk rather than strictly check our last block
   1.239 +    // because it's potentially more efficient to do so.
   1.240 +    HeapWord* const last_block = sp->block_start(chunk_mr.end());
   1.241      assert(last_block <= chunk_mr.end(), "In case this property changes.");
   1.242 -    if (last_block == chunk_mr.end()
   1.243 -        || !sp->block_is_obj(last_block)) {
   1.244 +    if ((last_block == chunk_mr.end())     // our last block does not straddle boundary
   1.245 +        || !sp->block_is_obj(last_block)   // last_block isn't an object
   1.246 +        || oop(last_block)->is_objArray()  // last_block is an array (precisely marked)
   1.247 +        || oop(last_block)->is_typeArray()) {
   1.248        max_to_do = chunk_mr.end();
   1.249 -
   1.250 +      NOISY(tty->print_cr(" process_chunk_boundary: Last block on this card is not a non-array object;\n"
   1.251 +                         "   max_to_do left at " PTR_FORMAT, max_to_do);)
   1.252      } else {
   1.253 -      // It is an object and starts before the end of the current chunk.
   1.254 +      assert(last_block < chunk_mr.end(), "Tautology");
   1.255 +      // It is a non-array object that straddles the right boundary of this chunk.
   1.256        // last_obj_card is the card corresponding to the start of the last object
   1.257        // in the chunk.  Note that the last object may not start in
   1.258        // the chunk.
   1.259 -      jbyte* last_obj_card = byte_for(last_block);
   1.260 -      if (!card_may_have_been_dirty(*last_obj_card)) {
   1.261 -        // The card containing the head is not dirty.  Any marks in
   1.262 +      jbyte* const last_obj_card = byte_for(last_block);
   1.263 +      const jbyte val = *last_obj_card;
   1.264 +      if (!card_will_be_scanned(val)) {
   1.265 +        assert(!card_may_have_been_dirty(val), "Error");
   1.266 +        // The card containing the head is not dirty.  Any marks on
   1.267          // subsequent cards still in this chunk must have been made
   1.268 -        // precisely; we can cap processing at the end.
   1.269 +        // precisely; we can cap processing at the end of our chunk.
   1.270          max_to_do = chunk_mr.end();
   1.271 +        NOISY(tty->print_cr(" process_chunk_boundary: Head of last object on this card is not dirty;\n"
   1.272 +                            "   max_to_do left at " PTR_FORMAT,
   1.273 +                            max_to_do);)
   1.274        } else {
   1.275          // The last object must be considered dirty, and extends onto the
   1.276          // following chunk.  Look for a dirty card in that chunk that will
   1.277          // bound our processing.
   1.278          jbyte* limit_card = NULL;
   1.279 -        size_t last_block_size = sp->block_size(last_block);
   1.280 -        jbyte* last_card_of_last_obj =
   1.281 +        const size_t last_block_size = sp->block_size(last_block);
   1.282 +        jbyte* const last_card_of_last_obj =
   1.283            byte_for(last_block + last_block_size - 1);
   1.284 -        jbyte* first_card_of_next_chunk = byte_for(chunk_mr.end());
   1.285 +        jbyte* const first_card_of_next_chunk = byte_for(chunk_mr.end());
   1.286          // This search potentially goes a long distance looking
   1.287 -        // for the next card that will be scanned.  For example,
   1.288 -        // an object that is an array of primitives will not
   1.289 -        // have any cards covering regions interior to the array
   1.290 -        // that will need to be scanned. The scan can be terminated
   1.291 -        // at the last card of the next chunk.  That would leave
   1.292 -        // limit_card as NULL and would result in "max_to_do"
   1.293 -        // being set with the LNC value or with the end
   1.294 -        // of the last block.
   1.295 -        jbyte* last_card_of_next_chunk = first_card_of_next_chunk +
   1.296 -          CardsPerStrideChunk;
   1.297 -        assert(byte_for(chunk_mr.end()) - byte_for(chunk_mr.start())
   1.298 -          == CardsPerStrideChunk, "last card of next chunk may be wrong");
   1.299 -        jbyte* last_card_to_check = (jbyte*) MIN2(last_card_of_last_obj,
   1.300 -                                                  last_card_of_next_chunk);
   1.301 +        // for the next card that will be scanned, terminating
   1.302 +        // at the end of the last_block, if no earlier dirty card
   1.303 +        // is found.
   1.304 +        assert(byte_for(chunk_mr.end()) - byte_for(chunk_mr.start()) == ParGCCardsPerStrideChunk,
   1.305 +               "last card of next chunk may be wrong");
   1.306          for (jbyte* cur = first_card_of_next_chunk;
   1.307 -             cur <= last_card_to_check; cur++) {
   1.308 -          if (card_will_be_scanned(*cur)) {
   1.309 +             cur <= last_card_of_last_obj; cur++) {
   1.310 +          const jbyte val = *cur;
   1.311 +          if (card_will_be_scanned(val)) {
   1.312 +            NOISY(tty->print_cr(" Found a non-clean card " PTR_FORMAT " with value 0x%x",
   1.313 +                                cur, (int)val);)
   1.314              limit_card = cur; break;
   1.315 +          } else {
   1.316 +            assert(!card_may_have_been_dirty(val), "Error: card can't be skipped");
   1.317            }
   1.318          }
   1.319 -        assert(0 <= cur_chunk_index+1 &&
   1.320 -               cur_chunk_index+1 < lowest_non_clean_chunk_size,
   1.321 +        if (limit_card != NULL) {
   1.322 +          max_to_do = addr_for(limit_card);
   1.323 +          assert(limit_card != NULL && max_to_do != NULL, "Error");
   1.324 +          NOISY(tty->print_cr(" process_chunk_boundary: Found a dirty card at " PTR_FORMAT
   1.325 +                        "   max_to_do set at " PTR_FORMAT " which is before end of last block in chunk: "
   1.326 +                        PTR_FORMAT " + " PTR_FORMAT " = " PTR_FORMAT,
   1.327 +                        limit_card, max_to_do, last_block, last_block_size, (last_block+last_block_size));)
   1.328 +        } else {
   1.329 +          // The following is a pessimistic value, because it's possible
   1.330 +          // that a dirty card on a subsequent chunk has been cleared by
   1.331 +          // the time we get to look at it; we'll correct for that further below,
   1.332 +          // using the LNC array which records the least non-clean card
   1.333 +          // before cards were cleared in a particular chunk.
   1.334 +          limit_card = last_card_of_last_obj;
   1.335 +          max_to_do = last_block + last_block_size;
   1.336 +          assert(limit_card != NULL && max_to_do != NULL, "Error");
   1.337 +          NOISY(tty->print_cr(" process_chunk_boundary: Found no dirty card before end of last block in chunk\n"
   1.338 +                              "   Setting limit_card to " PTR_FORMAT
   1.339 +                              " and max_to_do " PTR_FORMAT " + " PTR_FORMAT " = " PTR_FORMAT,
   1.340 +                              limit_card, last_block, last_block_size, max_to_do);)
   1.341 +        }
   1.342 +        assert(0 < cur_chunk_index+1 && cur_chunk_index+1 < lowest_non_clean_chunk_size,
   1.343                 "Bounds error.");
   1.344 -        // LNC for the next chunk
   1.345 -        jbyte* lnc_card = lowest_non_clean[cur_chunk_index+1];
   1.346 -        if (limit_card == NULL) {
   1.347 -          limit_card = lnc_card;
   1.348 +        // It is possible that a dirty card for the last object may have been
   1.349 +        // cleared before we had a chance to examine it. In that case, the value
   1.350 +        // will have been logged in the LNC for that chunk.
   1.351 +        // We need to examine as many chunks to the right as this object
   1.352 +        // covers.
   1.353 +        const uintptr_t last_chunk_index_to_check = addr_to_chunk_index(last_block + last_block_size - 1)
   1.354 +                                                    - lowest_non_clean_base_chunk_index;
   1.355 +        DEBUG_ONLY(const uintptr_t last_chunk_index = addr_to_chunk_index(used.end())
   1.356 +                                                      - lowest_non_clean_base_chunk_index;)
   1.357 +        assert(last_chunk_index_to_check <= last_chunk_index,
   1.358 +               err_msg("Out of bounds: last_chunk_index_to_check " INTPTR_FORMAT
   1.359 +                       " exceeds last_chunk_index " INTPTR_FORMAT,
   1.360 +                       last_chunk_index_to_check, last_chunk_index));
   1.361 +        for (uintptr_t lnc_index = cur_chunk_index + 1;
   1.362 +             lnc_index <= last_chunk_index_to_check;
   1.363 +             lnc_index++) {
   1.364 +          jbyte* lnc_card = lowest_non_clean[lnc_index];
   1.365 +          if (lnc_card != NULL) {
   1.366 +            // we can stop at the first non-NULL entry we find
   1.367 +            if (lnc_card <= limit_card) {
   1.368 +              NOISY(tty->print_cr(" process_chunk_boundary: LNC card " PTR_FORMAT " is lower than limit_card " PTR_FORMAT,
   1.369 +                                  "   max_to_do will be lowered to " PTR_FORMAT " from " PTR_FORMAT,
   1.370 +                                  lnc_card, limit_card, addr_for(lnc_card), max_to_do);)
   1.371 +              limit_card = lnc_card;
   1.372 +              max_to_do = addr_for(limit_card);
   1.373 +              assert(limit_card != NULL && max_to_do != NULL, "Error");
   1.374 +            }
   1.375 +            // In any case, we break now
   1.376 +            break;
   1.377 +          }  // else continue to look for a non-NULL entry if any
   1.378          }
   1.379 -        if (limit_card != NULL) {
   1.380 -          if (lnc_card != NULL) {
   1.381 -            limit_card = (jbyte*)MIN2((intptr_t)limit_card,
   1.382 -                                      (intptr_t)lnc_card);
   1.383 -          }
   1.384 -          max_to_do = addr_for(limit_card);
   1.385 -        } else {
   1.386 -          max_to_do = last_block + last_block_size;
   1.387 -        }
   1.388 +        assert(limit_card != NULL && max_to_do != NULL, "Error");
   1.389        }
   1.390 +      assert(max_to_do != NULL, "OOPS 1 !");
   1.391      }
   1.392 -    assert(max_to_do != NULL, "OOPS!");
   1.393 +    assert(max_to_do != NULL, "OOPS 2!");
   1.394    } else {
   1.395      max_to_do = used.end();
   1.396 +    NOISY(tty->print_cr(" process_chunk_boundary: Last chunk of this space;\n"
   1.397 +                  "   max_to_do left at " PTR_FORMAT,
   1.398 +                  max_to_do);)
   1.399    }
   1.400 +  assert(max_to_do != NULL, "OOPS 3!");
   1.401    // Now we can set the closure we're using so it doesn't to beyond
   1.402    // max_to_do.
   1.403    dcto_cl->set_min_done(max_to_do);
   1.404  #ifndef PRODUCT
   1.405    dcto_cl->set_last_bottom(max_to_do);
   1.406  #endif
   1.407 +  NOISY(tty->print_cr("===========================================================================\n");)
   1.408 +}
   1.409  
   1.410 -  // Now we set *our" lowest_non_clean entry.
   1.411 -  // Find the object that spans our boundary, if one exists.
   1.412 -  // Nothing to do on the first chunk.
   1.413 -  if (chunk_mr.start() > used.start()) {
   1.414 -    // first_block is the block possibly spanning the chunk start
   1.415 -    HeapWord* first_block = sp->block_start(chunk_mr.start());
   1.416 -    // Does the block span the start of the chunk and is it
   1.417 -    // an object?
   1.418 -    if (first_block < chunk_mr.start() &&
   1.419 -        sp->block_is_obj(first_block)) {
   1.420 -      jbyte* first_dirty_card = NULL;
   1.421 -      jbyte* last_card_of_first_obj =
   1.422 -          byte_for(first_block + sp->block_size(first_block) - 1);
   1.423 -      jbyte* first_card_of_cur_chunk = byte_for(chunk_mr.start());
   1.424 -      jbyte* last_card_of_cur_chunk = byte_for(chunk_mr.last());
   1.425 -      jbyte* last_card_to_check =
   1.426 -        (jbyte*) MIN2((intptr_t) last_card_of_cur_chunk,
   1.427 -                      (intptr_t) last_card_of_first_obj);
   1.428 -      for (jbyte* cur = first_card_of_cur_chunk;
   1.429 -           cur <= last_card_to_check; cur++) {
   1.430 -        if (card_will_be_scanned(*cur)) {
   1.431 -          first_dirty_card = cur; break;
   1.432 -        }
   1.433 -      }
   1.434 -      if (first_dirty_card != NULL) {
   1.435 -        assert(0 <= cur_chunk_index &&
   1.436 -                 cur_chunk_index < lowest_non_clean_chunk_size,
   1.437 -               "Bounds error.");
   1.438 -        lowest_non_clean[cur_chunk_index] = first_dirty_card;
   1.439 -      }
   1.440 -    }
   1.441 -  }
   1.442 -}
   1.443 +#undef NOISY
   1.444  
   1.445  void
   1.446  CardTableModRefBS::
   1.447 @@ -283,8 +413,8 @@
   1.448    // LNC array for the covered region.  Any later expansion can't affect
   1.449    // the used_at_save_marks region.
   1.450    // (I observed a bug in which the first thread to execute this would
   1.451 -  // resize, and then it would cause "expand_and_allocates" that would
   1.452 -  // Increase the number of chunks in the covered region.  Then a second
   1.453 +  // resize, and then it would cause "expand_and_allocate" that would
   1.454 +  // increase the number of chunks in the covered region.  Then a second
   1.455    // thread would come and execute this, see that the size didn't match,
   1.456    // and free and allocate again.  So the first thread would be using a
   1.457    // freed "_lowest_non_clean" array.)

mercurial