1.1 --- a/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp Fri Jul 16 21:33:21 2010 -0700 1.2 +++ b/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp Mon Jul 19 11:06:34 2010 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2001, 2009, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2001, 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 @@ -271,21 +271,16 @@ 1.11 if (cas_res == prev_epoch_entry) { 1.12 // We successfully updated the card num value in the epoch entry 1.13 count_ptr->_count = 0; // initialize counter for new card num 1.14 + jbyte* old_card_ptr = card_num_2_ptr(old_card_num); 1.15 1.16 // Even though the region containg the card at old_card_num was not 1.17 // in the young list when old_card_num was recorded in the epoch 1.18 // cache it could have been added to the free list and subsequently 1.19 - // added to the young list in the intervening time. If the evicted 1.20 - // card is in a young region just return the card_ptr and the evicted 1.21 - // card will not be cleaned. See CR 6817995. 1.22 - 1.23 - jbyte* old_card_ptr = card_num_2_ptr(old_card_num); 1.24 - if (is_young_card(old_card_ptr)) { 1.25 - *count = 0; 1.26 - // We can defer the processing of card_ptr 1.27 - *defer = true; 1.28 - return card_ptr; 1.29 - } 1.30 + // added to the young list in the intervening time. See CR 6817995. 1.31 + // We do not deal with this case here - it will be handled in 1.32 + // HeapRegion::oops_on_card_seq_iterate_careful after it has been 1.33 + // determined that the region containing the card has been allocated 1.34 + // to, and it's safe to check the young type of the region. 1.35 1.36 // We do not want to defer processing of card_ptr in this case 1.37 // (we need to refine old_card_ptr and card_ptr) 1.38 @@ -301,22 +296,22 @@ 1.39 jbyte* cached_ptr = add_card_count(card_ptr, &count, defer); 1.40 assert(cached_ptr != NULL, "bad cached card ptr"); 1.41 1.42 - if (is_young_card(cached_ptr)) { 1.43 - // The region containing cached_ptr has been freed during a clean up 1.44 - // pause, reallocated, and tagged as young. 1.45 - assert(cached_ptr != card_ptr, "shouldn't be"); 1.46 + // We've just inserted a card pointer into the card count cache 1.47 + // and got back the card that we just inserted or (evicted) the 1.48 + // previous contents of that count slot. 1.49 1.50 - // We've just inserted a new old-gen card pointer into the card count 1.51 - // cache and evicted the previous contents of that count slot. 1.52 - // The evicted card pointer has been determined to be in a young region 1.53 - // and so cannot be the newly inserted card pointer (that will be 1.54 - // in an old region). 1.55 - // The count for newly inserted card will be set to zero during the 1.56 - // insertion, so we don't want to defer the cleaning of the newly 1.57 - // inserted card pointer. 1.58 - assert(*defer == false, "deferring non-hot card"); 1.59 - return NULL; 1.60 - } 1.61 + // The card we got back could be in a young region. When the 1.62 + // returned card (if evicted) was originally inserted, we had 1.63 + // determined that its containing region was not young. However 1.64 + // it is possible for the region to be freed during a cleanup 1.65 + // pause, then reallocated and tagged as young which will result 1.66 + // in the returned card residing in a young region. 1.67 + // 1.68 + // We do not deal with this case here - the change from non-young 1.69 + // to young could be observed at any time - it will be handled in 1.70 + // HeapRegion::oops_on_card_seq_iterate_careful after it has been 1.71 + // determined that the region containing the card has been allocated 1.72 + // to. 1.73 1.74 // The card pointer we obtained from card count cache is not hot 1.75 // so do not store it in the cache; return it for immediate 1.76 @@ -325,7 +320,7 @@ 1.77 return cached_ptr; 1.78 } 1.79 1.80 - // Otherwise, the pointer we got from the _card_counts is hot. 1.81 + // Otherwise, the pointer we got from the _card_counts cache is hot. 1.82 jbyte* res = NULL; 1.83 MutexLockerEx x(HotCardCache_lock, Mutex::_no_safepoint_check_flag); 1.84 if (_n_hot == _hot_cache_size) { 1.85 @@ -338,17 +333,8 @@ 1.86 if (_hot_cache_idx == _hot_cache_size) _hot_cache_idx = 0; 1.87 _n_hot++; 1.88 1.89 - if (res != NULL) { 1.90 - // Even though the region containg res was not in the young list 1.91 - // when it was recorded in the hot cache it could have been added 1.92 - // to the free list and subsequently added to the young list in 1.93 - // the intervening time. If res is in a young region, return NULL 1.94 - // so that res is not cleaned. See CR 6817995. 1.95 - 1.96 - if (is_young_card(res)) { 1.97 - res = NULL; 1.98 - } 1.99 - } 1.100 + // The card obtained from the hot card cache could be in a young 1.101 + // region. See above on how this can happen. 1.102 1.103 return res; 1.104 }