Thu, 26 Sep 2013 10:25:02 -0400
7195622: CheckUnhandledOops has limited usefulness now
Summary: Enable CHECK_UNHANDLED_OOPS in fastdebug builds across all supported platforms.
Reviewed-by: coleenp, hseigel, dholmes, stefank, twisti, ihse, rdurbin
Contributed-by: lois.foltan@oracle.com
ysr@777 | 1 | /* |
tschatzl@5701 | 2 | * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. |
ysr@777 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ysr@777 | 4 | * |
ysr@777 | 5 | * This code is free software; you can redistribute it and/or modify it |
ysr@777 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ysr@777 | 7 | * published by the Free Software Foundation. |
ysr@777 | 8 | * |
ysr@777 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
ysr@777 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ysr@777 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ysr@777 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
ysr@777 | 13 | * accompanied this code). |
ysr@777 | 14 | * |
ysr@777 | 15 | * You should have received a copy of the GNU General Public License version |
ysr@777 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
ysr@777 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ysr@777 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
ysr@777 | 22 | * |
ysr@777 | 23 | */ |
ysr@777 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
johnc@5548 | 26 | #include "code/nmethod.hpp" |
stefank@2314 | 27 | #include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp" |
stefank@2314 | 28 | #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
stefank@2314 | 29 | #include "gc_implementation/g1/g1OopClosures.inline.hpp" |
stefank@2314 | 30 | #include "gc_implementation/g1/heapRegion.inline.hpp" |
stefank@2314 | 31 | #include "gc_implementation/g1/heapRegionRemSet.hpp" |
stefank@2314 | 32 | #include "gc_implementation/g1/heapRegionSeq.inline.hpp" |
stefank@2314 | 33 | #include "memory/genOopClosures.inline.hpp" |
stefank@2314 | 34 | #include "memory/iterator.hpp" |
stefank@2314 | 35 | #include "oops/oop.inline.hpp" |
ysr@777 | 36 | |
johnc@3182 | 37 | int HeapRegion::LogOfHRGrainBytes = 0; |
johnc@3182 | 38 | int HeapRegion::LogOfHRGrainWords = 0; |
johnc@3182 | 39 | size_t HeapRegion::GrainBytes = 0; |
johnc@3182 | 40 | size_t HeapRegion::GrainWords = 0; |
johnc@3182 | 41 | size_t HeapRegion::CardsPerRegion = 0; |
tonyp@1377 | 42 | |
ysr@777 | 43 | HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1, |
coleenp@4037 | 44 | HeapRegion* hr, ExtendedOopClosure* cl, |
ysr@777 | 45 | CardTableModRefBS::PrecisionStyle precision, |
ysr@777 | 46 | FilterKind fk) : |
ysr@777 | 47 | ContiguousSpaceDCTOC(hr, cl, precision, NULL), |
tonyp@3957 | 48 | _hr(hr), _fk(fk), _g1(g1) { } |
ysr@777 | 49 | |
ysr@777 | 50 | FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r, |
ysr@777 | 51 | OopClosure* oc) : |
tonyp@3957 | 52 | _r_bottom(r->bottom()), _r_end(r->end()), _oc(oc) { } |
ysr@777 | 53 | |
ysr@777 | 54 | template<class ClosureType> |
ysr@777 | 55 | HeapWord* walk_mem_region_loop(ClosureType* cl, G1CollectedHeap* g1h, |
ysr@777 | 56 | HeapRegion* hr, |
ysr@777 | 57 | HeapWord* cur, HeapWord* top) { |
ysr@777 | 58 | oop cur_oop = oop(cur); |
ysr@777 | 59 | int oop_size = cur_oop->size(); |
ysr@777 | 60 | HeapWord* next_obj = cur + oop_size; |
ysr@777 | 61 | while (next_obj < top) { |
ysr@777 | 62 | // Keep filtering the remembered set. |
ysr@777 | 63 | if (!g1h->is_obj_dead(cur_oop, hr)) { |
ysr@777 | 64 | // Bottom lies entirely below top, so we can call the |
ysr@777 | 65 | // non-memRegion version of oop_iterate below. |
ysr@777 | 66 | cur_oop->oop_iterate(cl); |
ysr@777 | 67 | } |
ysr@777 | 68 | cur = next_obj; |
ysr@777 | 69 | cur_oop = oop(cur); |
ysr@777 | 70 | oop_size = cur_oop->size(); |
ysr@777 | 71 | next_obj = cur + oop_size; |
ysr@777 | 72 | } |
ysr@777 | 73 | return cur; |
ysr@777 | 74 | } |
ysr@777 | 75 | |
ysr@777 | 76 | void HeapRegionDCTOC::walk_mem_region_with_cl(MemRegion mr, |
ysr@777 | 77 | HeapWord* bottom, |
ysr@777 | 78 | HeapWord* top, |
coleenp@4037 | 79 | ExtendedOopClosure* cl) { |
ysr@777 | 80 | G1CollectedHeap* g1h = _g1; |
johnc@3179 | 81 | int oop_size; |
coleenp@4037 | 82 | ExtendedOopClosure* cl2 = NULL; |
ysr@777 | 83 | |
johnc@3179 | 84 | FilterIntoCSClosure intoCSFilt(this, g1h, cl); |
ysr@777 | 85 | FilterOutOfRegionClosure outOfRegionFilt(_hr, cl); |
johnc@3175 | 86 | |
ysr@777 | 87 | switch (_fk) { |
johnc@3179 | 88 | case NoFilterKind: cl2 = cl; break; |
ysr@777 | 89 | case IntoCSFilterKind: cl2 = &intoCSFilt; break; |
ysr@777 | 90 | case OutOfRegionFilterKind: cl2 = &outOfRegionFilt; break; |
johnc@3179 | 91 | default: ShouldNotReachHere(); |
ysr@777 | 92 | } |
ysr@777 | 93 | |
ysr@777 | 94 | // Start filtering what we add to the remembered set. If the object is |
ysr@777 | 95 | // not considered dead, either because it is marked (in the mark bitmap) |
ysr@777 | 96 | // or it was allocated after marking finished, then we add it. Otherwise |
ysr@777 | 97 | // we can safely ignore the object. |
ysr@777 | 98 | if (!g1h->is_obj_dead(oop(bottom), _hr)) { |
ysr@777 | 99 | oop_size = oop(bottom)->oop_iterate(cl2, mr); |
ysr@777 | 100 | } else { |
ysr@777 | 101 | oop_size = oop(bottom)->size(); |
ysr@777 | 102 | } |
ysr@777 | 103 | |
ysr@777 | 104 | bottom += oop_size; |
ysr@777 | 105 | |
ysr@777 | 106 | if (bottom < top) { |
ysr@777 | 107 | // We replicate the loop below for several kinds of possible filters. |
ysr@777 | 108 | switch (_fk) { |
ysr@777 | 109 | case NoFilterKind: |
ysr@777 | 110 | bottom = walk_mem_region_loop(cl, g1h, _hr, bottom, top); |
ysr@777 | 111 | break; |
johnc@3175 | 112 | |
ysr@777 | 113 | case IntoCSFilterKind: { |
johnc@3179 | 114 | FilterIntoCSClosure filt(this, g1h, cl); |
ysr@777 | 115 | bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top); |
ysr@777 | 116 | break; |
ysr@777 | 117 | } |
johnc@3175 | 118 | |
ysr@777 | 119 | case OutOfRegionFilterKind: { |
ysr@777 | 120 | FilterOutOfRegionClosure filt(_hr, cl); |
ysr@777 | 121 | bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top); |
ysr@777 | 122 | break; |
ysr@777 | 123 | } |
johnc@3175 | 124 | |
ysr@777 | 125 | default: |
ysr@777 | 126 | ShouldNotReachHere(); |
ysr@777 | 127 | } |
ysr@777 | 128 | |
ysr@777 | 129 | // Last object. Need to do dead-obj filtering here too. |
ysr@777 | 130 | if (!g1h->is_obj_dead(oop(bottom), _hr)) { |
ysr@777 | 131 | oop(bottom)->oop_iterate(cl2, mr); |
ysr@777 | 132 | } |
ysr@777 | 133 | } |
ysr@777 | 134 | } |
ysr@777 | 135 | |
tonyp@1377 | 136 | // Minimum region size; we won't go lower than that. |
tonyp@1377 | 137 | // We might want to decrease this in the future, to deal with small |
tonyp@1377 | 138 | // heaps a bit more efficiently. |
tonyp@1377 | 139 | #define MIN_REGION_SIZE ( 1024 * 1024 ) |
tonyp@1377 | 140 | |
tonyp@1377 | 141 | // Maximum region size; we don't go higher than that. There's a good |
tonyp@1377 | 142 | // reason for having an upper bound. We don't want regions to get too |
tonyp@1377 | 143 | // large, otherwise cleanup's effectiveness would decrease as there |
tonyp@1377 | 144 | // will be fewer opportunities to find totally empty regions after |
tonyp@1377 | 145 | // marking. |
tonyp@1377 | 146 | #define MAX_REGION_SIZE ( 32 * 1024 * 1024 ) |
tonyp@1377 | 147 | |
tonyp@1377 | 148 | // The automatic region size calculation will try to have around this |
tonyp@1377 | 149 | // many regions in the heap (based on the min heap size). |
tonyp@1377 | 150 | #define TARGET_REGION_NUMBER 2048 |
tonyp@1377 | 151 | |
tschatzl@5701 | 152 | size_t HeapRegion::max_region_size() { |
tschatzl@5701 | 153 | return (size_t)MAX_REGION_SIZE; |
tschatzl@5701 | 154 | } |
tschatzl@5701 | 155 | |
brutisso@5646 | 156 | void HeapRegion::setup_heap_region_size(size_t initial_heap_size, size_t max_heap_size) { |
tonyp@1377 | 157 | uintx region_size = G1HeapRegionSize; |
tonyp@1377 | 158 | if (FLAG_IS_DEFAULT(G1HeapRegionSize)) { |
brutisso@5646 | 159 | size_t average_heap_size = (initial_heap_size + max_heap_size) / 2; |
brutisso@5646 | 160 | region_size = MAX2(average_heap_size / TARGET_REGION_NUMBER, |
tonyp@1377 | 161 | (uintx) MIN_REGION_SIZE); |
tonyp@1377 | 162 | } |
tonyp@1377 | 163 | |
tonyp@1377 | 164 | int region_size_log = log2_long((jlong) region_size); |
tonyp@1377 | 165 | // Recalculate the region size to make sure it's a power of |
tonyp@1377 | 166 | // 2. This means that region_size is the largest power of 2 that's |
tonyp@1377 | 167 | // <= what we've calculated so far. |
prr@1840 | 168 | region_size = ((uintx)1 << region_size_log); |
tonyp@1377 | 169 | |
tonyp@1377 | 170 | // Now make sure that we don't go over or under our limits. |
tonyp@1377 | 171 | if (region_size < MIN_REGION_SIZE) { |
tonyp@1377 | 172 | region_size = MIN_REGION_SIZE; |
tonyp@1377 | 173 | } else if (region_size > MAX_REGION_SIZE) { |
tonyp@1377 | 174 | region_size = MAX_REGION_SIZE; |
tonyp@1377 | 175 | } |
tonyp@1377 | 176 | |
brutisso@5464 | 177 | if (region_size != G1HeapRegionSize) { |
brutisso@5464 | 178 | // Update the flag to make sure that PrintFlagsFinal logs the correct value |
brutisso@5464 | 179 | FLAG_SET_ERGO(uintx, G1HeapRegionSize, region_size); |
brutisso@5464 | 180 | } |
brutisso@5464 | 181 | |
tonyp@1377 | 182 | // And recalculate the log. |
tonyp@1377 | 183 | region_size_log = log2_long((jlong) region_size); |
tonyp@1377 | 184 | |
tonyp@1377 | 185 | // Now, set up the globals. |
tonyp@1377 | 186 | guarantee(LogOfHRGrainBytes == 0, "we should only set it once"); |
tonyp@1377 | 187 | LogOfHRGrainBytes = region_size_log; |
tonyp@1377 | 188 | |
tonyp@1377 | 189 | guarantee(LogOfHRGrainWords == 0, "we should only set it once"); |
tonyp@1377 | 190 | LogOfHRGrainWords = LogOfHRGrainBytes - LogHeapWordSize; |
tonyp@1377 | 191 | |
tonyp@1377 | 192 | guarantee(GrainBytes == 0, "we should only set it once"); |
tonyp@1377 | 193 | // The cast to int is safe, given that we've bounded region_size by |
tonyp@1377 | 194 | // MIN_REGION_SIZE and MAX_REGION_SIZE. |
johnc@3182 | 195 | GrainBytes = (size_t)region_size; |
tonyp@1377 | 196 | |
tonyp@1377 | 197 | guarantee(GrainWords == 0, "we should only set it once"); |
tonyp@1377 | 198 | GrainWords = GrainBytes >> LogHeapWordSize; |
tonyp@3713 | 199 | guarantee((size_t) 1 << LogOfHRGrainWords == GrainWords, "sanity"); |
tonyp@1377 | 200 | |
tonyp@1377 | 201 | guarantee(CardsPerRegion == 0, "we should only set it once"); |
tonyp@1377 | 202 | CardsPerRegion = GrainBytes >> CardTableModRefBS::card_shift; |
tonyp@1377 | 203 | } |
tonyp@1377 | 204 | |
ysr@777 | 205 | void HeapRegion::reset_after_compaction() { |
ysr@777 | 206 | G1OffsetTableContigSpace::reset_after_compaction(); |
ysr@777 | 207 | // After a compaction the mark bitmap is invalid, so we must |
ysr@777 | 208 | // treat all objects as being inside the unmarked area. |
ysr@777 | 209 | zero_marked_bytes(); |
ysr@777 | 210 | init_top_at_mark_start(); |
ysr@777 | 211 | } |
ysr@777 | 212 | |
ysr@777 | 213 | void HeapRegion::hr_clear(bool par, bool clear_space) { |
tonyp@2472 | 214 | assert(_humongous_type == NotHumongous, |
tonyp@2472 | 215 | "we should have already filtered out humongous regions"); |
tonyp@2472 | 216 | assert(_humongous_start_region == NULL, |
tonyp@2472 | 217 | "we should have already filtered out humongous regions"); |
tonyp@2472 | 218 | assert(_end == _orig_end, |
tonyp@2472 | 219 | "we should have already filtered out humongous regions"); |
tonyp@2472 | 220 | |
ysr@777 | 221 | _in_collection_set = false; |
ysr@777 | 222 | |
ysr@777 | 223 | set_young_index_in_cset(-1); |
ysr@777 | 224 | uninstall_surv_rate_group(); |
ysr@777 | 225 | set_young_type(NotYoung); |
tonyp@2715 | 226 | reset_pre_dummy_top(); |
ysr@777 | 227 | |
ysr@777 | 228 | if (!par) { |
ysr@777 | 229 | // If this is parallel, this will be done later. |
ysr@777 | 230 | HeapRegionRemSet* hrrs = rem_set(); |
johnc@5548 | 231 | hrrs->clear(); |
tonyp@790 | 232 | _claimed = InitialClaimValue; |
ysr@777 | 233 | } |
ysr@777 | 234 | zero_marked_bytes(); |
ysr@777 | 235 | |
ysr@777 | 236 | _offsets.resize(HeapRegion::GrainWords); |
ysr@777 | 237 | init_top_at_mark_start(); |
tonyp@791 | 238 | if (clear_space) clear(SpaceDecorator::Mangle); |
ysr@777 | 239 | } |
ysr@777 | 240 | |
tonyp@2849 | 241 | void HeapRegion::par_clear() { |
tonyp@2849 | 242 | assert(used() == 0, "the region should have been already cleared"); |
johnc@3182 | 243 | assert(capacity() == HeapRegion::GrainBytes, "should be back to normal"); |
tonyp@2849 | 244 | HeapRegionRemSet* hrrs = rem_set(); |
tonyp@2849 | 245 | hrrs->clear(); |
tonyp@2849 | 246 | CardTableModRefBS* ct_bs = |
tonyp@2849 | 247 | (CardTableModRefBS*)G1CollectedHeap::heap()->barrier_set(); |
tonyp@2849 | 248 | ct_bs->clear(MemRegion(bottom(), end())); |
tonyp@2849 | 249 | } |
tonyp@2849 | 250 | |
ysr@777 | 251 | void HeapRegion::calc_gc_efficiency() { |
johnc@3998 | 252 | // GC efficiency is the ratio of how much space would be |
johnc@3998 | 253 | // reclaimed over how long we predict it would take to reclaim it. |
ysr@777 | 254 | G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
tonyp@3539 | 255 | G1CollectorPolicy* g1p = g1h->g1_policy(); |
johnc@3998 | 256 | |
johnc@3998 | 257 | // Retrieve a prediction of the elapsed time for this region for |
johnc@3998 | 258 | // a mixed gc because the region will only be evacuated during a |
johnc@3998 | 259 | // mixed gc. |
johnc@3998 | 260 | double region_elapsed_time_ms = |
johnc@3998 | 261 | g1p->predict_region_elapsed_time_ms(this, false /* for_young_gc */); |
johnc@3998 | 262 | _gc_efficiency = (double) reclaimable_bytes() / region_elapsed_time_ms; |
ysr@777 | 263 | } |
ysr@777 | 264 | |
tonyp@2453 | 265 | void HeapRegion::set_startsHumongous(HeapWord* new_top, HeapWord* new_end) { |
tonyp@2472 | 266 | assert(!isHumongous(), "sanity / pre-condition"); |
tonyp@2241 | 267 | assert(end() == _orig_end, |
tonyp@2241 | 268 | "Should be normal before the humongous object allocation"); |
tonyp@2241 | 269 | assert(top() == bottom(), "should be empty"); |
tonyp@2453 | 270 | assert(bottom() <= new_top && new_top <= new_end, "pre-condition"); |
tonyp@2241 | 271 | |
tonyp@790 | 272 | _humongous_type = StartsHumongous; |
ysr@777 | 273 | _humongous_start_region = this; |
tonyp@2241 | 274 | |
tonyp@2241 | 275 | set_end(new_end); |
tonyp@2453 | 276 | _offsets.set_for_starts_humongous(new_top); |
tonyp@2241 | 277 | } |
tonyp@2241 | 278 | |
tonyp@2453 | 279 | void HeapRegion::set_continuesHumongous(HeapRegion* first_hr) { |
tonyp@2472 | 280 | assert(!isHumongous(), "sanity / pre-condition"); |
tonyp@2241 | 281 | assert(end() == _orig_end, |
tonyp@2241 | 282 | "Should be normal before the humongous object allocation"); |
tonyp@2241 | 283 | assert(top() == bottom(), "should be empty"); |
tonyp@2453 | 284 | assert(first_hr->startsHumongous(), "pre-condition"); |
tonyp@2241 | 285 | |
tonyp@2241 | 286 | _humongous_type = ContinuesHumongous; |
tonyp@2453 | 287 | _humongous_start_region = first_hr; |
ysr@777 | 288 | } |
ysr@777 | 289 | |
tonyp@2472 | 290 | void HeapRegion::set_notHumongous() { |
tonyp@2472 | 291 | assert(isHumongous(), "pre-condition"); |
tonyp@2472 | 292 | |
tonyp@2472 | 293 | if (startsHumongous()) { |
tonyp@2472 | 294 | assert(top() <= end(), "pre-condition"); |
tonyp@2472 | 295 | set_end(_orig_end); |
tonyp@2472 | 296 | if (top() > end()) { |
tonyp@2472 | 297 | // at least one "continues humongous" region after it |
tonyp@2472 | 298 | set_top(end()); |
tonyp@2472 | 299 | } |
tonyp@2472 | 300 | } else { |
tonyp@2472 | 301 | // continues humongous |
tonyp@2472 | 302 | assert(end() == _orig_end, "sanity"); |
tonyp@2472 | 303 | } |
tonyp@2472 | 304 | |
johnc@3182 | 305 | assert(capacity() == HeapRegion::GrainBytes, "pre-condition"); |
tonyp@2472 | 306 | _humongous_type = NotHumongous; |
tonyp@2472 | 307 | _humongous_start_region = NULL; |
tonyp@2472 | 308 | } |
tonyp@2472 | 309 | |
ysr@777 | 310 | bool HeapRegion::claimHeapRegion(jint claimValue) { |
ysr@777 | 311 | jint current = _claimed; |
ysr@777 | 312 | if (current != claimValue) { |
ysr@777 | 313 | jint res = Atomic::cmpxchg(claimValue, &_claimed, current); |
ysr@777 | 314 | if (res == current) { |
ysr@777 | 315 | return true; |
ysr@777 | 316 | } |
ysr@777 | 317 | } |
ysr@777 | 318 | return false; |
ysr@777 | 319 | } |
ysr@777 | 320 | |
ysr@777 | 321 | HeapWord* HeapRegion::next_block_start_careful(HeapWord* addr) { |
ysr@777 | 322 | HeapWord* low = addr; |
ysr@777 | 323 | HeapWord* high = end(); |
ysr@777 | 324 | while (low < high) { |
ysr@777 | 325 | size_t diff = pointer_delta(high, low); |
ysr@777 | 326 | // Must add one below to bias toward the high amount. Otherwise, if |
ysr@777 | 327 | // "high" were at the desired value, and "low" were one less, we |
ysr@777 | 328 | // would not converge on "high". This is not symmetric, because |
ysr@777 | 329 | // we set "high" to a block start, which might be the right one, |
ysr@777 | 330 | // which we don't do for "low". |
ysr@777 | 331 | HeapWord* middle = low + (diff+1)/2; |
ysr@777 | 332 | if (middle == high) return high; |
ysr@777 | 333 | HeapWord* mid_bs = block_start_careful(middle); |
ysr@777 | 334 | if (mid_bs < addr) { |
ysr@777 | 335 | low = middle; |
ysr@777 | 336 | } else { |
ysr@777 | 337 | high = mid_bs; |
ysr@777 | 338 | } |
ysr@777 | 339 | } |
ysr@777 | 340 | assert(low == high && low >= addr, "Didn't work."); |
ysr@777 | 341 | return low; |
ysr@777 | 342 | } |
ysr@777 | 343 | |
ysr@777 | 344 | #ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away |
ysr@777 | 345 | #pragma warning( disable:4355 ) // 'this' : used in base member initializer list |
ysr@777 | 346 | #endif // _MSC_VER |
ysr@777 | 347 | |
ysr@777 | 348 | |
tonyp@3713 | 349 | HeapRegion::HeapRegion(uint hrs_index, |
tonyp@3713 | 350 | G1BlockOffsetSharedArray* sharedOffsetArray, |
johnc@4065 | 351 | MemRegion mr) : |
johnc@4065 | 352 | G1OffsetTableContigSpace(sharedOffsetArray, mr), |
johnc@3175 | 353 | _hrs_index(hrs_index), |
tonyp@790 | 354 | _humongous_type(NotHumongous), _humongous_start_region(NULL), |
tonyp@3028 | 355 | _in_collection_set(false), |
ysr@777 | 356 | _next_in_special_set(NULL), _orig_end(NULL), |
tonyp@790 | 357 | _claimed(InitialClaimValue), _evacuation_failed(false), |
tonyp@3714 | 358 | _prev_marked_bytes(0), _next_marked_bytes(0), _gc_efficiency(0.0), |
ysr@777 | 359 | _young_type(NotYoung), _next_young_region(NULL), |
tonyp@2472 | 360 | _next_dirty_cards_region(NULL), _next(NULL), _pending_removal(false), |
tonyp@2472 | 361 | #ifdef ASSERT |
tonyp@2472 | 362 | _containing_set(NULL), |
tonyp@2472 | 363 | #endif // ASSERT |
tonyp@2472 | 364 | _young_index_in_cset(-1), _surv_rate_group(NULL), _age_index(-1), |
tonyp@2472 | 365 | _rem_set(NULL), _recorded_rs_length(0), _predicted_elapsed_time_ms(0), |
johnc@1829 | 366 | _predicted_bytes_to_copy(0) |
ysr@777 | 367 | { |
johnc@5548 | 368 | _rem_set = new HeapRegionRemSet(sharedOffsetArray, this); |
ysr@777 | 369 | _orig_end = mr.end(); |
ysr@777 | 370 | // Note that initialize() will set the start of the unmarked area of the |
ysr@777 | 371 | // region. |
johnc@4065 | 372 | hr_clear(false /*par*/, false /*clear_space*/); |
tonyp@791 | 373 | set_top(bottom()); |
tonyp@791 | 374 | set_saved_mark(); |
ysr@777 | 375 | |
ysr@777 | 376 | assert(HeapRegionRemSet::num_par_rem_sets() > 0, "Invariant."); |
ysr@777 | 377 | } |
ysr@777 | 378 | |
tonyp@3957 | 379 | CompactibleSpace* HeapRegion::next_compaction_space() const { |
tonyp@3957 | 380 | // We're not using an iterator given that it will wrap around when |
tonyp@3957 | 381 | // it reaches the last region and this is not what we want here. |
tonyp@3957 | 382 | G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
tonyp@3957 | 383 | uint index = hrs_index() + 1; |
tonyp@3957 | 384 | while (index < g1h->n_regions()) { |
tonyp@3957 | 385 | HeapRegion* hr = g1h->region_at(index); |
tonyp@3957 | 386 | if (!hr->isHumongous()) { |
tonyp@3957 | 387 | return hr; |
ysr@777 | 388 | } |
tonyp@3957 | 389 | index += 1; |
ysr@777 | 390 | } |
tonyp@3957 | 391 | return NULL; |
ysr@777 | 392 | } |
ysr@777 | 393 | |
ysr@777 | 394 | void HeapRegion::save_marks() { |
ysr@777 | 395 | set_saved_mark(); |
ysr@777 | 396 | } |
ysr@777 | 397 | |
coleenp@4037 | 398 | void HeapRegion::oops_in_mr_iterate(MemRegion mr, ExtendedOopClosure* cl) { |
ysr@777 | 399 | HeapWord* p = mr.start(); |
ysr@777 | 400 | HeapWord* e = mr.end(); |
ysr@777 | 401 | oop obj; |
ysr@777 | 402 | while (p < e) { |
ysr@777 | 403 | obj = oop(p); |
ysr@777 | 404 | p += obj->oop_iterate(cl); |
ysr@777 | 405 | } |
ysr@777 | 406 | assert(p == e, "bad memregion: doesn't end on obj boundary"); |
ysr@777 | 407 | } |
ysr@777 | 408 | |
ysr@777 | 409 | #define HeapRegion_OOP_SINCE_SAVE_MARKS_DEFN(OopClosureType, nv_suffix) \ |
ysr@777 | 410 | void HeapRegion::oop_since_save_marks_iterate##nv_suffix(OopClosureType* cl) { \ |
ysr@777 | 411 | ContiguousSpace::oop_since_save_marks_iterate##nv_suffix(cl); \ |
ysr@777 | 412 | } |
ysr@777 | 413 | SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(HeapRegion_OOP_SINCE_SAVE_MARKS_DEFN) |
ysr@777 | 414 | |
ysr@777 | 415 | |
coleenp@4037 | 416 | void HeapRegion::oop_before_save_marks_iterate(ExtendedOopClosure* cl) { |
ysr@777 | 417 | oops_in_mr_iterate(MemRegion(bottom(), saved_mark_word()), cl); |
ysr@777 | 418 | } |
ysr@777 | 419 | |
tonyp@3416 | 420 | void HeapRegion::note_self_forwarding_removal_start(bool during_initial_mark, |
tonyp@3416 | 421 | bool during_conc_mark) { |
tonyp@3416 | 422 | // We always recreate the prev marking info and we'll explicitly |
tonyp@3416 | 423 | // mark all objects we find to be self-forwarded on the prev |
tonyp@3416 | 424 | // bitmap. So all objects need to be below PTAMS. |
tonyp@3416 | 425 | _prev_top_at_mark_start = top(); |
tonyp@3416 | 426 | _prev_marked_bytes = 0; |
tonyp@3416 | 427 | |
tonyp@3416 | 428 | if (during_initial_mark) { |
tonyp@3416 | 429 | // During initial-mark, we'll also explicitly mark all objects |
tonyp@3416 | 430 | // we find to be self-forwarded on the next bitmap. So all |
tonyp@3416 | 431 | // objects need to be below NTAMS. |
tonyp@3416 | 432 | _next_top_at_mark_start = top(); |
tonyp@3416 | 433 | _next_marked_bytes = 0; |
tonyp@3416 | 434 | } else if (during_conc_mark) { |
tonyp@3416 | 435 | // During concurrent mark, all objects in the CSet (including |
tonyp@3416 | 436 | // the ones we find to be self-forwarded) are implicitly live. |
tonyp@3416 | 437 | // So all objects need to be above NTAMS. |
tonyp@3416 | 438 | _next_top_at_mark_start = bottom(); |
tonyp@3416 | 439 | _next_marked_bytes = 0; |
tonyp@3416 | 440 | } |
tonyp@3416 | 441 | } |
tonyp@3416 | 442 | |
tonyp@3416 | 443 | void HeapRegion::note_self_forwarding_removal_end(bool during_initial_mark, |
tonyp@3416 | 444 | bool during_conc_mark, |
tonyp@3416 | 445 | size_t marked_bytes) { |
tonyp@3416 | 446 | assert(0 <= marked_bytes && marked_bytes <= used(), |
tonyp@3416 | 447 | err_msg("marked: "SIZE_FORMAT" used: "SIZE_FORMAT, |
tonyp@3416 | 448 | marked_bytes, used())); |
tonyp@3416 | 449 | _prev_marked_bytes = marked_bytes; |
tonyp@3416 | 450 | } |
tonyp@3416 | 451 | |
ysr@777 | 452 | HeapWord* |
ysr@777 | 453 | HeapRegion::object_iterate_mem_careful(MemRegion mr, |
ysr@777 | 454 | ObjectClosure* cl) { |
ysr@777 | 455 | G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
ysr@777 | 456 | // We used to use "block_start_careful" here. But we're actually happy |
ysr@777 | 457 | // to update the BOT while we do this... |
ysr@777 | 458 | HeapWord* cur = block_start(mr.start()); |
ysr@777 | 459 | mr = mr.intersection(used_region()); |
ysr@777 | 460 | if (mr.is_empty()) return NULL; |
ysr@777 | 461 | // Otherwise, find the obj that extends onto mr.start(). |
ysr@777 | 462 | |
ysr@777 | 463 | assert(cur <= mr.start() |
ysr@1280 | 464 | && (oop(cur)->klass_or_null() == NULL || |
ysr@777 | 465 | cur + oop(cur)->size() > mr.start()), |
ysr@777 | 466 | "postcondition of block_start"); |
ysr@777 | 467 | oop obj; |
ysr@777 | 468 | while (cur < mr.end()) { |
ysr@777 | 469 | obj = oop(cur); |
ysr@1280 | 470 | if (obj->klass_or_null() == NULL) { |
ysr@777 | 471 | // Ran into an unparseable point. |
ysr@777 | 472 | return cur; |
ysr@777 | 473 | } else if (!g1h->is_obj_dead(obj)) { |
ysr@777 | 474 | cl->do_object(obj); |
ysr@777 | 475 | } |
ysr@777 | 476 | if (cl->abort()) return cur; |
ysr@777 | 477 | // The check above must occur before the operation below, since an |
ysr@777 | 478 | // abort might invalidate the "size" operation. |
ysr@777 | 479 | cur += obj->size(); |
ysr@777 | 480 | } |
ysr@777 | 481 | return NULL; |
ysr@777 | 482 | } |
ysr@777 | 483 | |
ysr@777 | 484 | HeapWord* |
ysr@777 | 485 | HeapRegion:: |
ysr@777 | 486 | oops_on_card_seq_iterate_careful(MemRegion mr, |
johnc@2021 | 487 | FilterOutOfRegionClosure* cl, |
tonyp@2849 | 488 | bool filter_young, |
tonyp@2849 | 489 | jbyte* card_ptr) { |
tonyp@2849 | 490 | // Currently, we should only have to clean the card if filter_young |
tonyp@2849 | 491 | // is true and vice versa. |
tonyp@2849 | 492 | if (filter_young) { |
tonyp@2849 | 493 | assert(card_ptr != NULL, "pre-condition"); |
tonyp@2849 | 494 | } else { |
tonyp@2849 | 495 | assert(card_ptr == NULL, "pre-condition"); |
tonyp@2849 | 496 | } |
ysr@777 | 497 | G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
ysr@777 | 498 | |
ysr@777 | 499 | // If we're within a stop-world GC, then we might look at a card in a |
ysr@777 | 500 | // GC alloc region that extends onto a GC LAB, which may not be |
ysr@777 | 501 | // parseable. Stop such at the "saved_mark" of the region. |
johnc@3466 | 502 | if (g1h->is_gc_active()) { |
ysr@777 | 503 | mr = mr.intersection(used_region_at_save_marks()); |
ysr@777 | 504 | } else { |
ysr@777 | 505 | mr = mr.intersection(used_region()); |
ysr@777 | 506 | } |
ysr@777 | 507 | if (mr.is_empty()) return NULL; |
ysr@777 | 508 | // Otherwise, find the obj that extends onto mr.start(). |
ysr@777 | 509 | |
johnc@2021 | 510 | // The intersection of the incoming mr (for the card) and the |
johnc@2021 | 511 | // allocated part of the region is non-empty. This implies that |
johnc@2021 | 512 | // we have actually allocated into this region. The code in |
johnc@2021 | 513 | // G1CollectedHeap.cpp that allocates a new region sets the |
johnc@2021 | 514 | // is_young tag on the region before allocating. Thus we |
johnc@2021 | 515 | // safely know if this region is young. |
johnc@2021 | 516 | if (is_young() && filter_young) { |
johnc@2021 | 517 | return NULL; |
johnc@2021 | 518 | } |
johnc@2021 | 519 | |
johnc@2060 | 520 | assert(!is_young(), "check value of filter_young"); |
johnc@2060 | 521 | |
tonyp@2849 | 522 | // We can only clean the card here, after we make the decision that |
tonyp@2849 | 523 | // the card is not young. And we only clean the card if we have been |
tonyp@2849 | 524 | // asked to (i.e., card_ptr != NULL). |
tonyp@2849 | 525 | if (card_ptr != NULL) { |
tonyp@2849 | 526 | *card_ptr = CardTableModRefBS::clean_card_val(); |
tonyp@2849 | 527 | // We must complete this write before we do any of the reads below. |
tonyp@2849 | 528 | OrderAccess::storeload(); |
tonyp@2849 | 529 | } |
tonyp@2849 | 530 | |
johnc@3466 | 531 | // Cache the boundaries of the memory region in some const locals |
johnc@3466 | 532 | HeapWord* const start = mr.start(); |
johnc@3466 | 533 | HeapWord* const end = mr.end(); |
johnc@3466 | 534 | |
ysr@777 | 535 | // We used to use "block_start_careful" here. But we're actually happy |
ysr@777 | 536 | // to update the BOT while we do this... |
johnc@3466 | 537 | HeapWord* cur = block_start(start); |
johnc@3466 | 538 | assert(cur <= start, "Postcondition"); |
ysr@777 | 539 | |
johnc@3466 | 540 | oop obj; |
johnc@3466 | 541 | |
johnc@3466 | 542 | HeapWord* next = cur; |
johnc@3466 | 543 | while (next <= start) { |
johnc@3466 | 544 | cur = next; |
johnc@3466 | 545 | obj = oop(cur); |
johnc@3466 | 546 | if (obj->klass_or_null() == NULL) { |
ysr@777 | 547 | // Ran into an unparseable point. |
ysr@777 | 548 | return cur; |
ysr@777 | 549 | } |
ysr@777 | 550 | // Otherwise... |
johnc@3466 | 551 | next = (cur + obj->size()); |
ysr@777 | 552 | } |
johnc@3466 | 553 | |
johnc@3466 | 554 | // If we finish the above loop...We have a parseable object that |
johnc@3466 | 555 | // begins on or before the start of the memory region, and ends |
johnc@3466 | 556 | // inside or spans the entire region. |
johnc@3466 | 557 | |
johnc@3466 | 558 | assert(obj == oop(cur), "sanity"); |
johnc@3466 | 559 | assert(cur <= start && |
johnc@3466 | 560 | obj->klass_or_null() != NULL && |
johnc@3466 | 561 | (cur + obj->size()) > start, |
ysr@777 | 562 | "Loop postcondition"); |
johnc@3466 | 563 | |
ysr@777 | 564 | if (!g1h->is_obj_dead(obj)) { |
ysr@777 | 565 | obj->oop_iterate(cl, mr); |
ysr@777 | 566 | } |
ysr@777 | 567 | |
johnc@3466 | 568 | while (cur < end) { |
ysr@777 | 569 | obj = oop(cur); |
ysr@1280 | 570 | if (obj->klass_or_null() == NULL) { |
ysr@777 | 571 | // Ran into an unparseable point. |
ysr@777 | 572 | return cur; |
ysr@777 | 573 | }; |
johnc@3466 | 574 | |
ysr@777 | 575 | // Otherwise: |
ysr@777 | 576 | next = (cur + obj->size()); |
johnc@3466 | 577 | |
ysr@777 | 578 | if (!g1h->is_obj_dead(obj)) { |
johnc@3466 | 579 | if (next < end || !obj->is_objArray()) { |
johnc@3466 | 580 | // This object either does not span the MemRegion |
johnc@3466 | 581 | // boundary, or if it does it's not an array. |
johnc@3466 | 582 | // Apply closure to whole object. |
ysr@777 | 583 | obj->oop_iterate(cl); |
ysr@777 | 584 | } else { |
johnc@3466 | 585 | // This obj is an array that spans the boundary. |
johnc@3466 | 586 | // Stop at the boundary. |
johnc@3466 | 587 | obj->oop_iterate(cl, mr); |
ysr@777 | 588 | } |
ysr@777 | 589 | } |
ysr@777 | 590 | cur = next; |
ysr@777 | 591 | } |
ysr@777 | 592 | return NULL; |
ysr@777 | 593 | } |
ysr@777 | 594 | |
johnc@5548 | 595 | // Code roots support |
johnc@5548 | 596 | |
johnc@5548 | 597 | void HeapRegion::add_strong_code_root(nmethod* nm) { |
johnc@5548 | 598 | HeapRegionRemSet* hrrs = rem_set(); |
johnc@5548 | 599 | hrrs->add_strong_code_root(nm); |
johnc@5548 | 600 | } |
johnc@5548 | 601 | |
johnc@5548 | 602 | void HeapRegion::remove_strong_code_root(nmethod* nm) { |
johnc@5548 | 603 | HeapRegionRemSet* hrrs = rem_set(); |
johnc@5548 | 604 | hrrs->remove_strong_code_root(nm); |
johnc@5548 | 605 | } |
johnc@5548 | 606 | |
johnc@5548 | 607 | void HeapRegion::migrate_strong_code_roots() { |
johnc@5548 | 608 | assert(in_collection_set(), "only collection set regions"); |
johnc@5548 | 609 | assert(!isHumongous(), "not humongous regions"); |
johnc@5548 | 610 | |
johnc@5548 | 611 | HeapRegionRemSet* hrrs = rem_set(); |
johnc@5548 | 612 | hrrs->migrate_strong_code_roots(); |
johnc@5548 | 613 | } |
johnc@5548 | 614 | |
johnc@5548 | 615 | void HeapRegion::strong_code_roots_do(CodeBlobClosure* blk) const { |
johnc@5548 | 616 | HeapRegionRemSet* hrrs = rem_set(); |
johnc@5548 | 617 | hrrs->strong_code_roots_do(blk); |
johnc@5548 | 618 | } |
johnc@5548 | 619 | |
johnc@5548 | 620 | class VerifyStrongCodeRootOopClosure: public OopClosure { |
johnc@5548 | 621 | const HeapRegion* _hr; |
johnc@5548 | 622 | nmethod* _nm; |
johnc@5548 | 623 | bool _failures; |
johnc@5548 | 624 | bool _has_oops_in_region; |
johnc@5548 | 625 | |
johnc@5548 | 626 | template <class T> void do_oop_work(T* p) { |
johnc@5548 | 627 | T heap_oop = oopDesc::load_heap_oop(p); |
johnc@5548 | 628 | if (!oopDesc::is_null(heap_oop)) { |
johnc@5548 | 629 | oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); |
johnc@5548 | 630 | |
johnc@5548 | 631 | // Note: not all the oops embedded in the nmethod are in the |
johnc@5548 | 632 | // current region. We only look at those which are. |
johnc@5548 | 633 | if (_hr->is_in(obj)) { |
johnc@5548 | 634 | // Object is in the region. Check that its less than top |
johnc@5548 | 635 | if (_hr->top() <= (HeapWord*)obj) { |
johnc@5548 | 636 | // Object is above top |
johnc@5548 | 637 | gclog_or_tty->print_cr("Object "PTR_FORMAT" in region " |
johnc@5548 | 638 | "["PTR_FORMAT", "PTR_FORMAT") is above " |
johnc@5548 | 639 | "top "PTR_FORMAT, |
hseigel@5784 | 640 | (void *)obj, _hr->bottom(), _hr->end(), _hr->top()); |
johnc@5548 | 641 | _failures = true; |
johnc@5548 | 642 | return; |
johnc@5548 | 643 | } |
johnc@5548 | 644 | // Nmethod has at least one oop in the current region |
johnc@5548 | 645 | _has_oops_in_region = true; |
johnc@5548 | 646 | } |
johnc@5548 | 647 | } |
johnc@5548 | 648 | } |
johnc@5548 | 649 | |
johnc@5548 | 650 | public: |
johnc@5548 | 651 | VerifyStrongCodeRootOopClosure(const HeapRegion* hr, nmethod* nm): |
johnc@5548 | 652 | _hr(hr), _failures(false), _has_oops_in_region(false) {} |
johnc@5548 | 653 | |
johnc@5548 | 654 | void do_oop(narrowOop* p) { do_oop_work(p); } |
johnc@5548 | 655 | void do_oop(oop* p) { do_oop_work(p); } |
johnc@5548 | 656 | |
johnc@5548 | 657 | bool failures() { return _failures; } |
johnc@5548 | 658 | bool has_oops_in_region() { return _has_oops_in_region; } |
johnc@5548 | 659 | }; |
johnc@5548 | 660 | |
johnc@5548 | 661 | class VerifyStrongCodeRootCodeBlobClosure: public CodeBlobClosure { |
johnc@5548 | 662 | const HeapRegion* _hr; |
johnc@5548 | 663 | bool _failures; |
johnc@5548 | 664 | public: |
johnc@5548 | 665 | VerifyStrongCodeRootCodeBlobClosure(const HeapRegion* hr) : |
johnc@5548 | 666 | _hr(hr), _failures(false) {} |
johnc@5548 | 667 | |
johnc@5548 | 668 | void do_code_blob(CodeBlob* cb) { |
johnc@5548 | 669 | nmethod* nm = (cb == NULL) ? NULL : cb->as_nmethod_or_null(); |
johnc@5548 | 670 | if (nm != NULL) { |
johnc@5548 | 671 | // Verify that the nemthod is live |
johnc@5548 | 672 | if (!nm->is_alive()) { |
johnc@5548 | 673 | gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] has dead nmethod " |
johnc@5548 | 674 | PTR_FORMAT" in its strong code roots", |
johnc@5548 | 675 | _hr->bottom(), _hr->end(), nm); |
johnc@5548 | 676 | _failures = true; |
johnc@5548 | 677 | } else { |
johnc@5548 | 678 | VerifyStrongCodeRootOopClosure oop_cl(_hr, nm); |
johnc@5548 | 679 | nm->oops_do(&oop_cl); |
johnc@5548 | 680 | if (!oop_cl.has_oops_in_region()) { |
johnc@5548 | 681 | gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] has nmethod " |
johnc@5548 | 682 | PTR_FORMAT" in its strong code roots " |
johnc@5548 | 683 | "with no pointers into region", |
johnc@5548 | 684 | _hr->bottom(), _hr->end(), nm); |
johnc@5548 | 685 | _failures = true; |
johnc@5548 | 686 | } else if (oop_cl.failures()) { |
johnc@5548 | 687 | gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] has other " |
johnc@5548 | 688 | "failures for nmethod "PTR_FORMAT, |
johnc@5548 | 689 | _hr->bottom(), _hr->end(), nm); |
johnc@5548 | 690 | _failures = true; |
johnc@5548 | 691 | } |
johnc@5548 | 692 | } |
johnc@5548 | 693 | } |
johnc@5548 | 694 | } |
johnc@5548 | 695 | |
johnc@5548 | 696 | bool failures() { return _failures; } |
johnc@5548 | 697 | }; |
johnc@5548 | 698 | |
johnc@5548 | 699 | void HeapRegion::verify_strong_code_roots(VerifyOption vo, bool* failures) const { |
johnc@5548 | 700 | if (!G1VerifyHeapRegionCodeRoots) { |
johnc@5548 | 701 | // We're not verifying code roots. |
johnc@5548 | 702 | return; |
johnc@5548 | 703 | } |
johnc@5548 | 704 | if (vo == VerifyOption_G1UseMarkWord) { |
johnc@5548 | 705 | // Marking verification during a full GC is performed after class |
johnc@5548 | 706 | // unloading, code cache unloading, etc so the strong code roots |
johnc@5548 | 707 | // attached to each heap region are in an inconsistent state. They won't |
johnc@5548 | 708 | // be consistent until the strong code roots are rebuilt after the |
johnc@5548 | 709 | // actual GC. Skip verifying the strong code roots in this particular |
johnc@5548 | 710 | // time. |
johnc@5548 | 711 | assert(VerifyDuringGC, "only way to get here"); |
johnc@5548 | 712 | return; |
johnc@5548 | 713 | } |
johnc@5548 | 714 | |
johnc@5548 | 715 | HeapRegionRemSet* hrrs = rem_set(); |
johnc@5548 | 716 | int strong_code_roots_length = hrrs->strong_code_roots_list_length(); |
johnc@5548 | 717 | |
johnc@5548 | 718 | // if this region is empty then there should be no entries |
johnc@5548 | 719 | // on its strong code root list |
johnc@5548 | 720 | if (is_empty()) { |
johnc@5548 | 721 | if (strong_code_roots_length > 0) { |
johnc@5548 | 722 | gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] is empty " |
johnc@5548 | 723 | "but has "INT32_FORMAT" code root entries", |
johnc@5548 | 724 | bottom(), end(), strong_code_roots_length); |
johnc@5548 | 725 | *failures = true; |
johnc@5548 | 726 | } |
johnc@5548 | 727 | return; |
johnc@5548 | 728 | } |
johnc@5548 | 729 | |
johnc@5548 | 730 | // An H-region should have an empty strong code root list |
johnc@5548 | 731 | if (isHumongous()) { |
johnc@5548 | 732 | if (strong_code_roots_length > 0) { |
johnc@5548 | 733 | gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] is humongous " |
johnc@5548 | 734 | "but has "INT32_FORMAT" code root entries", |
johnc@5548 | 735 | bottom(), end(), strong_code_roots_length); |
johnc@5548 | 736 | *failures = true; |
johnc@5548 | 737 | } |
johnc@5548 | 738 | return; |
johnc@5548 | 739 | } |
johnc@5548 | 740 | |
johnc@5548 | 741 | VerifyStrongCodeRootCodeBlobClosure cb_cl(this); |
johnc@5548 | 742 | strong_code_roots_do(&cb_cl); |
johnc@5548 | 743 | |
johnc@5548 | 744 | if (cb_cl.failures()) { |
johnc@5548 | 745 | *failures = true; |
johnc@5548 | 746 | } |
johnc@5548 | 747 | } |
johnc@5548 | 748 | |
ysr@777 | 749 | void HeapRegion::print() const { print_on(gclog_or_tty); } |
ysr@777 | 750 | void HeapRegion::print_on(outputStream* st) const { |
ysr@777 | 751 | if (isHumongous()) { |
ysr@777 | 752 | if (startsHumongous()) |
ysr@777 | 753 | st->print(" HS"); |
ysr@777 | 754 | else |
ysr@777 | 755 | st->print(" HC"); |
ysr@777 | 756 | } else { |
ysr@777 | 757 | st->print(" "); |
ysr@777 | 758 | } |
ysr@777 | 759 | if (in_collection_set()) |
ysr@777 | 760 | st->print(" CS"); |
ysr@777 | 761 | else |
ysr@777 | 762 | st->print(" "); |
ysr@777 | 763 | if (is_young()) |
johnc@1829 | 764 | st->print(is_survivor() ? " SU" : " Y "); |
ysr@777 | 765 | else |
ysr@777 | 766 | st->print(" "); |
ysr@777 | 767 | if (is_empty()) |
ysr@777 | 768 | st->print(" F"); |
ysr@777 | 769 | else |
ysr@777 | 770 | st->print(" "); |
tonyp@3269 | 771 | st->print(" TS %5d", _gc_time_stamp); |
tonyp@1823 | 772 | st->print(" PTAMS "PTR_FORMAT" NTAMS "PTR_FORMAT, |
tonyp@1823 | 773 | prev_top_at_mark_start(), next_top_at_mark_start()); |
ysr@777 | 774 | G1OffsetTableContigSpace::print_on(st); |
ysr@777 | 775 | } |
ysr@777 | 776 | |
johnc@5548 | 777 | class VerifyLiveClosure: public OopClosure { |
johnc@5548 | 778 | private: |
johnc@5548 | 779 | G1CollectedHeap* _g1h; |
johnc@5548 | 780 | CardTableModRefBS* _bs; |
johnc@5548 | 781 | oop _containing_obj; |
johnc@5548 | 782 | bool _failures; |
johnc@5548 | 783 | int _n_failures; |
johnc@5548 | 784 | VerifyOption _vo; |
johnc@5548 | 785 | public: |
johnc@5548 | 786 | // _vo == UsePrevMarking -> use "prev" marking information, |
johnc@5548 | 787 | // _vo == UseNextMarking -> use "next" marking information, |
johnc@5548 | 788 | // _vo == UseMarkWord -> use mark word from object header. |
johnc@5548 | 789 | VerifyLiveClosure(G1CollectedHeap* g1h, VerifyOption vo) : |
johnc@5548 | 790 | _g1h(g1h), _bs(NULL), _containing_obj(NULL), |
johnc@5548 | 791 | _failures(false), _n_failures(0), _vo(vo) |
johnc@5548 | 792 | { |
johnc@5548 | 793 | BarrierSet* bs = _g1h->barrier_set(); |
johnc@5548 | 794 | if (bs->is_a(BarrierSet::CardTableModRef)) |
johnc@5548 | 795 | _bs = (CardTableModRefBS*)bs; |
johnc@5548 | 796 | } |
johnc@5548 | 797 | |
johnc@5548 | 798 | void set_containing_obj(oop obj) { |
johnc@5548 | 799 | _containing_obj = obj; |
johnc@5548 | 800 | } |
johnc@5548 | 801 | |
johnc@5548 | 802 | bool failures() { return _failures; } |
johnc@5548 | 803 | int n_failures() { return _n_failures; } |
johnc@5548 | 804 | |
johnc@5548 | 805 | virtual void do_oop(narrowOop* p) { do_oop_work(p); } |
johnc@5548 | 806 | virtual void do_oop( oop* p) { do_oop_work(p); } |
johnc@5548 | 807 | |
johnc@5548 | 808 | void print_object(outputStream* out, oop obj) { |
johnc@5548 | 809 | #ifdef PRODUCT |
johnc@5548 | 810 | Klass* k = obj->klass(); |
johnc@5548 | 811 | const char* class_name = InstanceKlass::cast(k)->external_name(); |
johnc@5548 | 812 | out->print_cr("class name %s", class_name); |
johnc@5548 | 813 | #else // PRODUCT |
johnc@5548 | 814 | obj->print_on(out); |
johnc@5548 | 815 | #endif // PRODUCT |
johnc@5548 | 816 | } |
johnc@5548 | 817 | |
johnc@5548 | 818 | template <class T> |
johnc@5548 | 819 | void do_oop_work(T* p) { |
johnc@5548 | 820 | assert(_containing_obj != NULL, "Precondition"); |
johnc@5548 | 821 | assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo), |
johnc@5548 | 822 | "Precondition"); |
johnc@5548 | 823 | T heap_oop = oopDesc::load_heap_oop(p); |
johnc@5548 | 824 | if (!oopDesc::is_null(heap_oop)) { |
johnc@5548 | 825 | oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); |
johnc@5548 | 826 | bool failed = false; |
johnc@5548 | 827 | if (!_g1h->is_in_closed_subset(obj) || _g1h->is_obj_dead_cond(obj, _vo)) { |
johnc@5548 | 828 | MutexLockerEx x(ParGCRareEvent_lock, |
johnc@5548 | 829 | Mutex::_no_safepoint_check_flag); |
johnc@5548 | 830 | |
johnc@5548 | 831 | if (!_failures) { |
johnc@5548 | 832 | gclog_or_tty->print_cr(""); |
johnc@5548 | 833 | gclog_or_tty->print_cr("----------"); |
johnc@5548 | 834 | } |
johnc@5548 | 835 | if (!_g1h->is_in_closed_subset(obj)) { |
johnc@5548 | 836 | HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p); |
johnc@5548 | 837 | gclog_or_tty->print_cr("Field "PTR_FORMAT |
johnc@5548 | 838 | " of live obj "PTR_FORMAT" in region " |
johnc@5548 | 839 | "["PTR_FORMAT", "PTR_FORMAT")", |
johnc@5548 | 840 | p, (void*) _containing_obj, |
johnc@5548 | 841 | from->bottom(), from->end()); |
johnc@5548 | 842 | print_object(gclog_or_tty, _containing_obj); |
johnc@5548 | 843 | gclog_or_tty->print_cr("points to obj "PTR_FORMAT" not in the heap", |
johnc@5548 | 844 | (void*) obj); |
johnc@5548 | 845 | } else { |
johnc@5548 | 846 | HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p); |
johnc@5548 | 847 | HeapRegion* to = _g1h->heap_region_containing((HeapWord*)obj); |
johnc@5548 | 848 | gclog_or_tty->print_cr("Field "PTR_FORMAT |
johnc@5548 | 849 | " of live obj "PTR_FORMAT" in region " |
johnc@5548 | 850 | "["PTR_FORMAT", "PTR_FORMAT")", |
johnc@5548 | 851 | p, (void*) _containing_obj, |
johnc@5548 | 852 | from->bottom(), from->end()); |
johnc@5548 | 853 | print_object(gclog_or_tty, _containing_obj); |
johnc@5548 | 854 | gclog_or_tty->print_cr("points to dead obj "PTR_FORMAT" in region " |
johnc@5548 | 855 | "["PTR_FORMAT", "PTR_FORMAT")", |
johnc@5548 | 856 | (void*) obj, to->bottom(), to->end()); |
johnc@5548 | 857 | print_object(gclog_or_tty, obj); |
johnc@5548 | 858 | } |
johnc@5548 | 859 | gclog_or_tty->print_cr("----------"); |
johnc@5548 | 860 | gclog_or_tty->flush(); |
johnc@5548 | 861 | _failures = true; |
johnc@5548 | 862 | failed = true; |
johnc@5548 | 863 | _n_failures++; |
johnc@5548 | 864 | } |
johnc@5548 | 865 | |
johnc@5548 | 866 | if (!_g1h->full_collection() || G1VerifyRSetsDuringFullGC) { |
johnc@5548 | 867 | HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p); |
johnc@5548 | 868 | HeapRegion* to = _g1h->heap_region_containing(obj); |
johnc@5548 | 869 | if (from != NULL && to != NULL && |
johnc@5548 | 870 | from != to && |
johnc@5548 | 871 | !to->isHumongous()) { |
johnc@5548 | 872 | jbyte cv_obj = *_bs->byte_for_const(_containing_obj); |
johnc@5548 | 873 | jbyte cv_field = *_bs->byte_for_const(p); |
johnc@5548 | 874 | const jbyte dirty = CardTableModRefBS::dirty_card_val(); |
johnc@5548 | 875 | |
johnc@5548 | 876 | bool is_bad = !(from->is_young() |
johnc@5548 | 877 | || to->rem_set()->contains_reference(p) |
johnc@5548 | 878 | || !G1HRRSFlushLogBuffersOnVerify && // buffers were not flushed |
johnc@5548 | 879 | (_containing_obj->is_objArray() ? |
johnc@5548 | 880 | cv_field == dirty |
johnc@5548 | 881 | : cv_obj == dirty || cv_field == dirty)); |
johnc@5548 | 882 | if (is_bad) { |
johnc@5548 | 883 | MutexLockerEx x(ParGCRareEvent_lock, |
johnc@5548 | 884 | Mutex::_no_safepoint_check_flag); |
johnc@5548 | 885 | |
johnc@5548 | 886 | if (!_failures) { |
johnc@5548 | 887 | gclog_or_tty->print_cr(""); |
johnc@5548 | 888 | gclog_or_tty->print_cr("----------"); |
johnc@5548 | 889 | } |
johnc@5548 | 890 | gclog_or_tty->print_cr("Missing rem set entry:"); |
johnc@5548 | 891 | gclog_or_tty->print_cr("Field "PTR_FORMAT" " |
johnc@5548 | 892 | "of obj "PTR_FORMAT", " |
johnc@5548 | 893 | "in region "HR_FORMAT, |
johnc@5548 | 894 | p, (void*) _containing_obj, |
johnc@5548 | 895 | HR_FORMAT_PARAMS(from)); |
johnc@5548 | 896 | _containing_obj->print_on(gclog_or_tty); |
johnc@5548 | 897 | gclog_or_tty->print_cr("points to obj "PTR_FORMAT" " |
johnc@5548 | 898 | "in region "HR_FORMAT, |
johnc@5548 | 899 | (void*) obj, |
johnc@5548 | 900 | HR_FORMAT_PARAMS(to)); |
johnc@5548 | 901 | obj->print_on(gclog_or_tty); |
johnc@5548 | 902 | gclog_or_tty->print_cr("Obj head CTE = %d, field CTE = %d.", |
johnc@5548 | 903 | cv_obj, cv_field); |
johnc@5548 | 904 | gclog_or_tty->print_cr("----------"); |
johnc@5548 | 905 | gclog_or_tty->flush(); |
johnc@5548 | 906 | _failures = true; |
johnc@5548 | 907 | if (!failed) _n_failures++; |
johnc@5548 | 908 | } |
johnc@5548 | 909 | } |
johnc@5548 | 910 | } |
johnc@5548 | 911 | } |
johnc@5548 | 912 | } |
johnc@5548 | 913 | }; |
tonyp@1246 | 914 | |
ysr@777 | 915 | // This really ought to be commoned up into OffsetTableContigSpace somehow. |
ysr@777 | 916 | // We would need a mechanism to make that code skip dead objects. |
ysr@777 | 917 | |
brutisso@3711 | 918 | void HeapRegion::verify(VerifyOption vo, |
tonyp@1455 | 919 | bool* failures) const { |
ysr@777 | 920 | G1CollectedHeap* g1 = G1CollectedHeap::heap(); |
tonyp@1455 | 921 | *failures = false; |
ysr@777 | 922 | HeapWord* p = bottom(); |
ysr@777 | 923 | HeapWord* prev_p = NULL; |
johnc@2969 | 924 | VerifyLiveClosure vl_cl(g1, vo); |
tonyp@2073 | 925 | bool is_humongous = isHumongous(); |
tonyp@2453 | 926 | bool do_bot_verify = !is_young(); |
tonyp@2073 | 927 | size_t object_num = 0; |
ysr@777 | 928 | while (p < top()) { |
tonyp@2453 | 929 | oop obj = oop(p); |
tonyp@2453 | 930 | size_t obj_size = obj->size(); |
tonyp@2453 | 931 | object_num += 1; |
tonyp@2453 | 932 | |
tonyp@2453 | 933 | if (is_humongous != g1->isHumongous(obj_size)) { |
tonyp@2073 | 934 | gclog_or_tty->print_cr("obj "PTR_FORMAT" is of %shumongous size (" |
tonyp@2073 | 935 | SIZE_FORMAT" words) in a %shumongous region", |
tonyp@2453 | 936 | p, g1->isHumongous(obj_size) ? "" : "non-", |
tonyp@2453 | 937 | obj_size, is_humongous ? "" : "non-"); |
tonyp@2073 | 938 | *failures = true; |
tonyp@2453 | 939 | return; |
tonyp@2073 | 940 | } |
tonyp@2453 | 941 | |
tonyp@2453 | 942 | // If it returns false, verify_for_object() will output the |
tonyp@2453 | 943 | // appropriate messasge. |
tonyp@2453 | 944 | if (do_bot_verify && !_offsets.verify_for_object(p, obj_size)) { |
tonyp@2453 | 945 | *failures = true; |
tonyp@2453 | 946 | return; |
tonyp@2453 | 947 | } |
tonyp@2453 | 948 | |
johnc@2969 | 949 | if (!g1->is_obj_dead_cond(obj, this, vo)) { |
tonyp@2453 | 950 | if (obj->is_oop()) { |
coleenp@4037 | 951 | Klass* klass = obj->klass(); |
coleenp@5307 | 952 | if (!klass->is_metaspace_object()) { |
tonyp@2453 | 953 | gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" " |
hseigel@5784 | 954 | "not metadata", klass, (void *)obj); |
tonyp@2453 | 955 | *failures = true; |
tonyp@2453 | 956 | return; |
tonyp@2453 | 957 | } else if (!klass->is_klass()) { |
tonyp@2453 | 958 | gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" " |
hseigel@5784 | 959 | "not a klass", klass, (void *)obj); |
tonyp@2453 | 960 | *failures = true; |
tonyp@2453 | 961 | return; |
tonyp@2453 | 962 | } else { |
tonyp@2453 | 963 | vl_cl.set_containing_obj(obj); |
coleenp@4037 | 964 | obj->oop_iterate_no_header(&vl_cl); |
tonyp@2453 | 965 | if (vl_cl.failures()) { |
tonyp@2453 | 966 | *failures = true; |
tonyp@2453 | 967 | } |
tonyp@2453 | 968 | if (G1MaxVerifyFailures >= 0 && |
tonyp@2453 | 969 | vl_cl.n_failures() >= G1MaxVerifyFailures) { |
tonyp@2453 | 970 | return; |
tonyp@2453 | 971 | } |
tonyp@2453 | 972 | } |
tonyp@2453 | 973 | } else { |
hseigel@5784 | 974 | gclog_or_tty->print_cr(PTR_FORMAT" no an oop", (void *)obj); |
tonyp@1455 | 975 | *failures = true; |
tonyp@1455 | 976 | return; |
tonyp@1455 | 977 | } |
ysr@777 | 978 | } |
ysr@777 | 979 | prev_p = p; |
tonyp@2453 | 980 | p += obj_size; |
ysr@777 | 981 | } |
tonyp@2453 | 982 | |
tonyp@2453 | 983 | if (p != top()) { |
tonyp@2453 | 984 | gclog_or_tty->print_cr("end of last object "PTR_FORMAT" " |
tonyp@2453 | 985 | "does not match top "PTR_FORMAT, p, top()); |
tonyp@2453 | 986 | *failures = true; |
tonyp@2453 | 987 | return; |
tonyp@2453 | 988 | } |
tonyp@2453 | 989 | |
tonyp@2453 | 990 | HeapWord* the_end = end(); |
tonyp@2453 | 991 | assert(p == top(), "it should still hold"); |
tonyp@2453 | 992 | // Do some extra BOT consistency checking for addresses in the |
tonyp@2453 | 993 | // range [top, end). BOT look-ups in this range should yield |
tonyp@2453 | 994 | // top. No point in doing that if top == end (there's nothing there). |
tonyp@2453 | 995 | if (p < the_end) { |
tonyp@2453 | 996 | // Look up top |
tonyp@2453 | 997 | HeapWord* addr_1 = p; |
tonyp@2453 | 998 | HeapWord* b_start_1 = _offsets.block_start_const(addr_1); |
tonyp@2453 | 999 | if (b_start_1 != p) { |
tonyp@2453 | 1000 | gclog_or_tty->print_cr("BOT look up for top: "PTR_FORMAT" " |
tonyp@2453 | 1001 | " yielded "PTR_FORMAT", expecting "PTR_FORMAT, |
tonyp@2453 | 1002 | addr_1, b_start_1, p); |
tonyp@2453 | 1003 | *failures = true; |
tonyp@2453 | 1004 | return; |
tonyp@2453 | 1005 | } |
tonyp@2453 | 1006 | |
tonyp@2453 | 1007 | // Look up top + 1 |
tonyp@2453 | 1008 | HeapWord* addr_2 = p + 1; |
tonyp@2453 | 1009 | if (addr_2 < the_end) { |
tonyp@2453 | 1010 | HeapWord* b_start_2 = _offsets.block_start_const(addr_2); |
tonyp@2453 | 1011 | if (b_start_2 != p) { |
tonyp@2453 | 1012 | gclog_or_tty->print_cr("BOT look up for top + 1: "PTR_FORMAT" " |
tonyp@2453 | 1013 | " yielded "PTR_FORMAT", expecting "PTR_FORMAT, |
tonyp@2453 | 1014 | addr_2, b_start_2, p); |
tonyp@1455 | 1015 | *failures = true; |
tonyp@1455 | 1016 | return; |
tonyp@2453 | 1017 | } |
tonyp@2453 | 1018 | } |
tonyp@2453 | 1019 | |
tonyp@2453 | 1020 | // Look up an address between top and end |
tonyp@2453 | 1021 | size_t diff = pointer_delta(the_end, p) / 2; |
tonyp@2453 | 1022 | HeapWord* addr_3 = p + diff; |
tonyp@2453 | 1023 | if (addr_3 < the_end) { |
tonyp@2453 | 1024 | HeapWord* b_start_3 = _offsets.block_start_const(addr_3); |
tonyp@2453 | 1025 | if (b_start_3 != p) { |
tonyp@2453 | 1026 | gclog_or_tty->print_cr("BOT look up for top + diff: "PTR_FORMAT" " |
tonyp@2453 | 1027 | " yielded "PTR_FORMAT", expecting "PTR_FORMAT, |
tonyp@2453 | 1028 | addr_3, b_start_3, p); |
tonyp@2453 | 1029 | *failures = true; |
tonyp@2453 | 1030 | return; |
tonyp@2453 | 1031 | } |
tonyp@2453 | 1032 | } |
tonyp@2453 | 1033 | |
tonyp@2453 | 1034 | // Loook up end - 1 |
tonyp@2453 | 1035 | HeapWord* addr_4 = the_end - 1; |
tonyp@2453 | 1036 | HeapWord* b_start_4 = _offsets.block_start_const(addr_4); |
tonyp@2453 | 1037 | if (b_start_4 != p) { |
tonyp@2453 | 1038 | gclog_or_tty->print_cr("BOT look up for end - 1: "PTR_FORMAT" " |
tonyp@2453 | 1039 | " yielded "PTR_FORMAT", expecting "PTR_FORMAT, |
tonyp@2453 | 1040 | addr_4, b_start_4, p); |
tonyp@2453 | 1041 | *failures = true; |
tonyp@2453 | 1042 | return; |
tonyp@1455 | 1043 | } |
ysr@777 | 1044 | } |
tonyp@1455 | 1045 | |
tonyp@2073 | 1046 | if (is_humongous && object_num > 1) { |
tonyp@2073 | 1047 | gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] is humongous " |
tonyp@2073 | 1048 | "but has "SIZE_FORMAT", objects", |
tonyp@2073 | 1049 | bottom(), end(), object_num); |
tonyp@2073 | 1050 | *failures = true; |
tonyp@1455 | 1051 | return; |
ysr@777 | 1052 | } |
johnc@5548 | 1053 | |
johnc@5548 | 1054 | verify_strong_code_roots(vo, failures); |
johnc@5548 | 1055 | } |
johnc@5548 | 1056 | |
johnc@5548 | 1057 | void HeapRegion::verify() const { |
johnc@5548 | 1058 | bool dummy = false; |
johnc@5548 | 1059 | verify(VerifyOption_G1UsePrevMarking, /* failures */ &dummy); |
ysr@777 | 1060 | } |
ysr@777 | 1061 | |
ysr@777 | 1062 | // G1OffsetTableContigSpace code; copied from space.cpp. Hope this can go |
ysr@777 | 1063 | // away eventually. |
ysr@777 | 1064 | |
tonyp@791 | 1065 | void G1OffsetTableContigSpace::clear(bool mangle_space) { |
tonyp@791 | 1066 | ContiguousSpace::clear(mangle_space); |
ysr@777 | 1067 | _offsets.zero_bottom_entry(); |
ysr@777 | 1068 | _offsets.initialize_threshold(); |
ysr@777 | 1069 | } |
ysr@777 | 1070 | |
ysr@777 | 1071 | void G1OffsetTableContigSpace::set_bottom(HeapWord* new_bottom) { |
ysr@777 | 1072 | Space::set_bottom(new_bottom); |
ysr@777 | 1073 | _offsets.set_bottom(new_bottom); |
ysr@777 | 1074 | } |
ysr@777 | 1075 | |
ysr@777 | 1076 | void G1OffsetTableContigSpace::set_end(HeapWord* new_end) { |
ysr@777 | 1077 | Space::set_end(new_end); |
ysr@777 | 1078 | _offsets.resize(new_end - bottom()); |
ysr@777 | 1079 | } |
ysr@777 | 1080 | |
ysr@777 | 1081 | void G1OffsetTableContigSpace::print() const { |
ysr@777 | 1082 | print_short(); |
ysr@777 | 1083 | gclog_or_tty->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " |
ysr@777 | 1084 | INTPTR_FORMAT ", " INTPTR_FORMAT ")", |
ysr@777 | 1085 | bottom(), top(), _offsets.threshold(), end()); |
ysr@777 | 1086 | } |
ysr@777 | 1087 | |
ysr@777 | 1088 | HeapWord* G1OffsetTableContigSpace::initialize_threshold() { |
ysr@777 | 1089 | return _offsets.initialize_threshold(); |
ysr@777 | 1090 | } |
ysr@777 | 1091 | |
ysr@777 | 1092 | HeapWord* G1OffsetTableContigSpace::cross_threshold(HeapWord* start, |
ysr@777 | 1093 | HeapWord* end) { |
ysr@777 | 1094 | _offsets.alloc_block(start, end); |
ysr@777 | 1095 | return _offsets.threshold(); |
ysr@777 | 1096 | } |
ysr@777 | 1097 | |
ysr@777 | 1098 | HeapWord* G1OffsetTableContigSpace::saved_mark_word() const { |
ysr@777 | 1099 | G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
ysr@777 | 1100 | assert( _gc_time_stamp <= g1h->get_gc_time_stamp(), "invariant" ); |
ysr@777 | 1101 | if (_gc_time_stamp < g1h->get_gc_time_stamp()) |
ysr@777 | 1102 | return top(); |
ysr@777 | 1103 | else |
ysr@777 | 1104 | return ContiguousSpace::saved_mark_word(); |
ysr@777 | 1105 | } |
ysr@777 | 1106 | |
ysr@777 | 1107 | void G1OffsetTableContigSpace::set_saved_mark() { |
ysr@777 | 1108 | G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
ysr@777 | 1109 | unsigned curr_gc_time_stamp = g1h->get_gc_time_stamp(); |
ysr@777 | 1110 | |
ysr@777 | 1111 | if (_gc_time_stamp < curr_gc_time_stamp) { |
ysr@777 | 1112 | // The order of these is important, as another thread might be |
ysr@777 | 1113 | // about to start scanning this region. If it does so after |
ysr@777 | 1114 | // set_saved_mark and before _gc_time_stamp = ..., then the latter |
ysr@777 | 1115 | // will be false, and it will pick up top() as the high water mark |
ysr@777 | 1116 | // of region. If it does so after _gc_time_stamp = ..., then it |
ysr@777 | 1117 | // will pick up the right saved_mark_word() as the high water mark |
ysr@777 | 1118 | // of the region. Either way, the behaviour will be correct. |
ysr@777 | 1119 | ContiguousSpace::set_saved_mark(); |
ysr@1280 | 1120 | OrderAccess::storestore(); |
iveresov@788 | 1121 | _gc_time_stamp = curr_gc_time_stamp; |
tonyp@2715 | 1122 | // No need to do another barrier to flush the writes above. If |
tonyp@2715 | 1123 | // this is called in parallel with other threads trying to |
tonyp@2715 | 1124 | // allocate into the region, the caller should call this while |
tonyp@2715 | 1125 | // holding a lock and when the lock is released the writes will be |
tonyp@2715 | 1126 | // flushed. |
ysr@777 | 1127 | } |
ysr@777 | 1128 | } |
ysr@777 | 1129 | |
ysr@777 | 1130 | G1OffsetTableContigSpace:: |
ysr@777 | 1131 | G1OffsetTableContigSpace(G1BlockOffsetSharedArray* sharedOffsetArray, |
johnc@4065 | 1132 | MemRegion mr) : |
ysr@777 | 1133 | _offsets(sharedOffsetArray, mr), |
ysr@777 | 1134 | _par_alloc_lock(Mutex::leaf, "OffsetTableContigSpace par alloc lock", true), |
ysr@777 | 1135 | _gc_time_stamp(0) |
ysr@777 | 1136 | { |
ysr@777 | 1137 | _offsets.set_space(this); |
johnc@4065 | 1138 | // false ==> we'll do the clearing if there's clearing to be done. |
johnc@4065 | 1139 | ContiguousSpace::initialize(mr, false, SpaceDecorator::Mangle); |
johnc@4065 | 1140 | _offsets.zero_bottom_entry(); |
johnc@4065 | 1141 | _offsets.initialize_threshold(); |
ysr@777 | 1142 | } |