Fri, 18 Feb 2011 10:07:34 -0800
7020042: G1: Partially remove fix for 6994628
Summary: Disable reference discovery and processing during concurrent marking by disabling fix for 6994628.
Reviewed-by: tonyp, ysr
ysr@777 | 1 | /* |
tonyp@2472 | 2 | * Copyright (c) 2001, 2011, 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" |
stefank@2314 | 26 | #include "classfile/javaClasses.hpp" |
stefank@2314 | 27 | #include "classfile/symbolTable.hpp" |
stefank@2314 | 28 | #include "classfile/systemDictionary.hpp" |
stefank@2314 | 29 | #include "classfile/vmSymbols.hpp" |
stefank@2314 | 30 | #include "code/codeCache.hpp" |
stefank@2314 | 31 | #include "code/icBuffer.hpp" |
stefank@2314 | 32 | #include "gc_implementation/g1/g1MarkSweep.hpp" |
stefank@2314 | 33 | #include "memory/gcLocker.hpp" |
stefank@2314 | 34 | #include "memory/genCollectedHeap.hpp" |
stefank@2314 | 35 | #include "memory/modRefBarrierSet.hpp" |
stefank@2314 | 36 | #include "memory/referencePolicy.hpp" |
stefank@2314 | 37 | #include "memory/space.hpp" |
stefank@2314 | 38 | #include "oops/instanceRefKlass.hpp" |
stefank@2314 | 39 | #include "oops/oop.inline.hpp" |
stefank@2314 | 40 | #include "prims/jvmtiExport.hpp" |
stefank@2314 | 41 | #include "runtime/aprofiler.hpp" |
stefank@2314 | 42 | #include "runtime/biasedLocking.hpp" |
stefank@2314 | 43 | #include "runtime/fprofiler.hpp" |
stefank@2314 | 44 | #include "runtime/synchronizer.hpp" |
stefank@2314 | 45 | #include "runtime/thread.hpp" |
stefank@2314 | 46 | #include "runtime/vmThread.hpp" |
stefank@2314 | 47 | #include "utilities/copy.hpp" |
stefank@2314 | 48 | #include "utilities/events.hpp" |
ysr@777 | 49 | |
ysr@777 | 50 | class HeapRegion; |
ysr@777 | 51 | |
ysr@777 | 52 | void G1MarkSweep::invoke_at_safepoint(ReferenceProcessor* rp, |
ysr@777 | 53 | bool clear_all_softrefs) { |
ysr@777 | 54 | assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); |
ysr@777 | 55 | |
jmasa@1822 | 56 | SharedHeap* sh = SharedHeap::heap(); |
jmasa@1822 | 57 | #ifdef ASSERT |
jmasa@1822 | 58 | if (sh->collector_policy()->should_clear_all_soft_refs()) { |
jmasa@1822 | 59 | assert(clear_all_softrefs, "Policy should have been checked earler"); |
jmasa@1822 | 60 | } |
jmasa@1822 | 61 | #endif |
ysr@777 | 62 | // hook up weak ref data so it can be used during Mark-Sweep |
ysr@777 | 63 | assert(GenMarkSweep::ref_processor() == NULL, "no stomping"); |
ysr@888 | 64 | assert(rp != NULL, "should be non-NULL"); |
ysr@777 | 65 | GenMarkSweep::_ref_processor = rp; |
ysr@892 | 66 | rp->setup_policy(clear_all_softrefs); |
ysr@777 | 67 | |
ysr@777 | 68 | // When collecting the permanent generation methodOops may be moving, |
ysr@777 | 69 | // so we either have to flush all bcp data or convert it into bci. |
ysr@777 | 70 | CodeCache::gc_prologue(); |
ysr@777 | 71 | Threads::gc_prologue(); |
ysr@777 | 72 | |
ysr@777 | 73 | // Increment the invocation count for the permanent generation, since it is |
ysr@777 | 74 | // implicitly collected whenever we do a full mark sweep collection. |
ysr@777 | 75 | sh->perm_gen()->stat_record()->invocations++; |
ysr@777 | 76 | |
ysr@777 | 77 | bool marked_for_unloading = false; |
ysr@777 | 78 | |
ysr@777 | 79 | allocate_stacks(); |
ysr@777 | 80 | |
iveresov@793 | 81 | // We should save the marks of the currently locked biased monitors. |
iveresov@793 | 82 | // The marking doesn't preserve the marks of biased objects. |
iveresov@793 | 83 | BiasedLocking::preserve_marks(); |
iveresov@793 | 84 | |
ysr@777 | 85 | mark_sweep_phase1(marked_for_unloading, clear_all_softrefs); |
ysr@777 | 86 | |
johnc@1186 | 87 | if (VerifyDuringGC) { |
ysr@777 | 88 | G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
ysr@777 | 89 | g1h->checkConcurrentMark(); |
ysr@777 | 90 | } |
ysr@777 | 91 | |
ysr@777 | 92 | mark_sweep_phase2(); |
ysr@777 | 93 | |
ysr@777 | 94 | // Don't add any more derived pointers during phase3 |
ysr@777 | 95 | COMPILER2_PRESENT(DerivedPointerTable::set_active(false)); |
ysr@777 | 96 | |
ysr@777 | 97 | mark_sweep_phase3(); |
ysr@777 | 98 | |
ysr@777 | 99 | mark_sweep_phase4(); |
ysr@777 | 100 | |
ysr@777 | 101 | GenMarkSweep::restore_marks(); |
iveresov@793 | 102 | BiasedLocking::restore_marks(); |
ysr@777 | 103 | GenMarkSweep::deallocate_stacks(); |
ysr@777 | 104 | |
ysr@777 | 105 | // We must invalidate the perm-gen rs, so that it gets rebuilt. |
ysr@777 | 106 | GenRemSet* rs = sh->rem_set(); |
ysr@777 | 107 | rs->invalidate(sh->perm_gen()->used_region(), true /*whole_heap*/); |
ysr@777 | 108 | |
ysr@777 | 109 | // "free at last gc" is calculated from these. |
ysr@777 | 110 | // CHF: cheating for now!!! |
ysr@777 | 111 | // Universe::set_heap_capacity_at_last_gc(Universe::heap()->capacity()); |
ysr@777 | 112 | // Universe::set_heap_used_at_last_gc(Universe::heap()->used()); |
ysr@777 | 113 | |
ysr@777 | 114 | Threads::gc_epilogue(); |
ysr@777 | 115 | CodeCache::gc_epilogue(); |
kamg@2467 | 116 | JvmtiExport::gc_epilogue(); |
ysr@777 | 117 | |
ysr@777 | 118 | // refs processing: clean slate |
ysr@777 | 119 | GenMarkSweep::_ref_processor = NULL; |
ysr@777 | 120 | } |
ysr@777 | 121 | |
ysr@777 | 122 | |
ysr@777 | 123 | void G1MarkSweep::allocate_stacks() { |
ysr@777 | 124 | GenMarkSweep::_preserved_count_max = 0; |
ysr@777 | 125 | GenMarkSweep::_preserved_marks = NULL; |
ysr@777 | 126 | GenMarkSweep::_preserved_count = 0; |
ysr@777 | 127 | } |
ysr@777 | 128 | |
ysr@777 | 129 | void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading, |
ysr@777 | 130 | bool clear_all_softrefs) { |
ysr@777 | 131 | // Recursively traverse all live objects and mark them |
ysr@777 | 132 | EventMark m("1 mark object"); |
ysr@777 | 133 | TraceTime tm("phase 1", PrintGC && Verbose, true, gclog_or_tty); |
ysr@777 | 134 | GenMarkSweep::trace(" 1"); |
ysr@777 | 135 | |
ysr@777 | 136 | SharedHeap* sh = SharedHeap::heap(); |
ysr@777 | 137 | |
jrose@1424 | 138 | sh->process_strong_roots(true, // activeate StrongRootsScope |
jrose@1424 | 139 | true, // Collecting permanent generation. |
ysr@777 | 140 | SharedHeap::SO_SystemClasses, |
ysr@777 | 141 | &GenMarkSweep::follow_root_closure, |
jrose@1424 | 142 | &GenMarkSweep::follow_code_root_closure, |
ysr@777 | 143 | &GenMarkSweep::follow_root_closure); |
ysr@777 | 144 | |
ysr@777 | 145 | // Process reference objects found during marking |
ysr@888 | 146 | ReferenceProcessor* rp = GenMarkSweep::ref_processor(); |
ysr@892 | 147 | rp->setup_policy(clear_all_softrefs); |
ysr@888 | 148 | rp->process_discovered_references(&GenMarkSweep::is_alive, |
ysr@888 | 149 | &GenMarkSweep::keep_alive, |
ysr@888 | 150 | &GenMarkSweep::follow_stack_closure, |
ysr@888 | 151 | NULL); |
ysr@777 | 152 | |
ysr@777 | 153 | // Follow system dictionary roots and unload classes |
ysr@777 | 154 | bool purged_class = SystemDictionary::do_unloading(&GenMarkSweep::is_alive); |
jcoomes@2191 | 155 | assert(GenMarkSweep::_marking_stack.is_empty(), |
ysr@777 | 156 | "stack should be empty by now"); |
ysr@777 | 157 | |
ysr@777 | 158 | // Follow code cache roots (has to be done after system dictionary, |
ysr@777 | 159 | // assumes all live klasses are marked) |
ysr@777 | 160 | CodeCache::do_unloading(&GenMarkSweep::is_alive, |
ysr@777 | 161 | &GenMarkSweep::keep_alive, |
ysr@777 | 162 | purged_class); |
ysr@1376 | 163 | GenMarkSweep::follow_stack(); |
ysr@777 | 164 | |
ysr@777 | 165 | // Update subklass/sibling/implementor links of live klasses |
ysr@777 | 166 | GenMarkSweep::follow_weak_klass_links(); |
jcoomes@2191 | 167 | assert(GenMarkSweep::_marking_stack.is_empty(), |
ysr@777 | 168 | "stack should be empty by now"); |
ysr@777 | 169 | |
ysr@1376 | 170 | // Visit memoized MDO's and clear any unmarked weak refs |
ysr@1376 | 171 | GenMarkSweep::follow_mdo_weak_refs(); |
jcoomes@2191 | 172 | assert(GenMarkSweep::_marking_stack.is_empty(), "just drained"); |
ysr@1376 | 173 | |
ysr@1376 | 174 | |
coleenp@2497 | 175 | // Visit interned string tables and delete unmarked oops |
ysr@777 | 176 | StringTable::unlink(&GenMarkSweep::is_alive); |
coleenp@2497 | 177 | // Clean up unreferenced symbols in symbol table. |
coleenp@2497 | 178 | SymbolTable::unlink(); |
ysr@777 | 179 | |
jcoomes@2191 | 180 | assert(GenMarkSweep::_marking_stack.is_empty(), |
ysr@777 | 181 | "stack should be empty by now"); |
ysr@777 | 182 | } |
ysr@777 | 183 | |
ysr@777 | 184 | class G1PrepareCompactClosure: public HeapRegionClosure { |
tonyp@2472 | 185 | G1CollectedHeap* _g1h; |
ysr@777 | 186 | ModRefBarrierSet* _mrbs; |
ysr@777 | 187 | CompactPoint _cp; |
tonyp@2472 | 188 | HumongousRegionSet _humongous_proxy_set; |
ysr@777 | 189 | |
ysr@777 | 190 | void free_humongous_region(HeapRegion* hr) { |
ysr@777 | 191 | HeapWord* end = hr->end(); |
tonyp@2643 | 192 | size_t dummy_pre_used; |
tonyp@2643 | 193 | FreeRegionList dummy_free_list("Dummy Free List for G1MarkSweep"); |
tonyp@2643 | 194 | |
ysr@777 | 195 | assert(hr->startsHumongous(), |
ysr@777 | 196 | "Only the start of a humongous region should be freed."); |
tonyp@2643 | 197 | _g1h->free_humongous_region(hr, &dummy_pre_used, &dummy_free_list, |
tonyp@2472 | 198 | &_humongous_proxy_set, false /* par */); |
ysr@777 | 199 | hr->prepare_for_compaction(&_cp); |
ysr@777 | 200 | // Also clear the part of the card table that will be unused after |
ysr@777 | 201 | // compaction. |
tonyp@2472 | 202 | _mrbs->clear(MemRegion(hr->compaction_top(), end)); |
tonyp@2643 | 203 | dummy_free_list.remove_all(); |
ysr@777 | 204 | } |
ysr@777 | 205 | |
ysr@777 | 206 | public: |
tonyp@2472 | 207 | G1PrepareCompactClosure(CompactibleSpace* cs) |
tonyp@2472 | 208 | : _g1h(G1CollectedHeap::heap()), |
tonyp@2472 | 209 | _mrbs(G1CollectedHeap::heap()->mr_bs()), |
ysr@777 | 210 | _cp(NULL, cs, cs->initialize_threshold()), |
tonyp@2472 | 211 | _humongous_proxy_set("G1MarkSweep Humongous Proxy Set") { } |
tonyp@2472 | 212 | |
tonyp@2472 | 213 | void update_sets() { |
tonyp@2472 | 214 | // We'll recalculate total used bytes and recreate the free list |
tonyp@2472 | 215 | // at the end of the GC, so no point in updating those values here. |
tonyp@2472 | 216 | _g1h->update_sets_after_freeing_regions(0, /* pre_used */ |
tonyp@2472 | 217 | NULL, /* free_list */ |
tonyp@2472 | 218 | &_humongous_proxy_set, |
tonyp@2472 | 219 | false /* par */); |
tonyp@2472 | 220 | } |
tonyp@2472 | 221 | |
ysr@777 | 222 | bool doHeapRegion(HeapRegion* hr) { |
ysr@777 | 223 | if (hr->isHumongous()) { |
ysr@777 | 224 | if (hr->startsHumongous()) { |
ysr@777 | 225 | oop obj = oop(hr->bottom()); |
ysr@777 | 226 | if (obj->is_gc_marked()) { |
ysr@777 | 227 | obj->forward_to(obj); |
ysr@777 | 228 | } else { |
ysr@777 | 229 | free_humongous_region(hr); |
ysr@777 | 230 | } |
ysr@777 | 231 | } else { |
ysr@777 | 232 | assert(hr->continuesHumongous(), "Invalid humongous."); |
ysr@777 | 233 | } |
ysr@777 | 234 | } else { |
ysr@777 | 235 | hr->prepare_for_compaction(&_cp); |
ysr@777 | 236 | // Also clear the part of the card table that will be unused after |
ysr@777 | 237 | // compaction. |
ysr@777 | 238 | _mrbs->clear(MemRegion(hr->compaction_top(), hr->end())); |
ysr@777 | 239 | } |
ysr@777 | 240 | return false; |
ysr@777 | 241 | } |
ysr@777 | 242 | }; |
apetrusenko@1112 | 243 | |
apetrusenko@1112 | 244 | // Finds the first HeapRegion. |
ysr@777 | 245 | class FindFirstRegionClosure: public HeapRegionClosure { |
ysr@777 | 246 | HeapRegion* _a_region; |
ysr@777 | 247 | public: |
apetrusenko@1112 | 248 | FindFirstRegionClosure() : _a_region(NULL) {} |
ysr@777 | 249 | bool doHeapRegion(HeapRegion* r) { |
apetrusenko@1112 | 250 | _a_region = r; |
apetrusenko@1112 | 251 | return true; |
ysr@777 | 252 | } |
ysr@777 | 253 | HeapRegion* result() { return _a_region; } |
ysr@777 | 254 | }; |
ysr@777 | 255 | |
ysr@777 | 256 | void G1MarkSweep::mark_sweep_phase2() { |
ysr@777 | 257 | // Now all live objects are marked, compute the new object addresses. |
ysr@777 | 258 | |
ysr@777 | 259 | // It is imperative that we traverse perm_gen LAST. If dead space is |
ysr@777 | 260 | // allowed a range of dead object may get overwritten by a dead int |
ysr@777 | 261 | // array. If perm_gen is not traversed last a klassOop may get |
ysr@777 | 262 | // overwritten. This is fine since it is dead, but if the class has dead |
ysr@777 | 263 | // instances we have to skip them, and in order to find their size we |
ysr@777 | 264 | // need the klassOop! |
ysr@777 | 265 | // |
ysr@777 | 266 | // It is not required that we traverse spaces in the same order in |
ysr@777 | 267 | // phase2, phase3 and phase4, but the ValidateMarkSweep live oops |
ysr@777 | 268 | // tracking expects us to do so. See comment under phase4. |
ysr@777 | 269 | |
ysr@777 | 270 | G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
ysr@777 | 271 | Generation* pg = g1h->perm_gen(); |
ysr@777 | 272 | |
ysr@777 | 273 | EventMark m("2 compute new addresses"); |
ysr@777 | 274 | TraceTime tm("phase 2", PrintGC && Verbose, true, gclog_or_tty); |
ysr@777 | 275 | GenMarkSweep::trace("2"); |
ysr@777 | 276 | |
apetrusenko@1112 | 277 | FindFirstRegionClosure cl; |
ysr@777 | 278 | g1h->heap_region_iterate(&cl); |
ysr@777 | 279 | HeapRegion *r = cl.result(); |
ysr@777 | 280 | CompactibleSpace* sp = r; |
ysr@777 | 281 | if (r->isHumongous() && oop(r->bottom())->is_gc_marked()) { |
ysr@777 | 282 | sp = r->next_compaction_space(); |
ysr@777 | 283 | } |
ysr@777 | 284 | |
apetrusenko@1112 | 285 | G1PrepareCompactClosure blk(sp); |
ysr@777 | 286 | g1h->heap_region_iterate(&blk); |
tonyp@2472 | 287 | blk.update_sets(); |
ysr@777 | 288 | |
ysr@777 | 289 | CompactPoint perm_cp(pg, NULL, NULL); |
ysr@777 | 290 | pg->prepare_for_compaction(&perm_cp); |
ysr@777 | 291 | } |
ysr@777 | 292 | |
ysr@777 | 293 | class G1AdjustPointersClosure: public HeapRegionClosure { |
ysr@777 | 294 | public: |
ysr@777 | 295 | bool doHeapRegion(HeapRegion* r) { |
ysr@777 | 296 | if (r->isHumongous()) { |
ysr@777 | 297 | if (r->startsHumongous()) { |
ysr@777 | 298 | // We must adjust the pointers on the single H object. |
ysr@777 | 299 | oop obj = oop(r->bottom()); |
ysr@777 | 300 | debug_only(GenMarkSweep::track_interior_pointers(obj)); |
ysr@777 | 301 | // point all the oops to the new location |
ysr@777 | 302 | obj->adjust_pointers(); |
ysr@777 | 303 | debug_only(GenMarkSweep::check_interior_pointers()); |
ysr@777 | 304 | } |
ysr@777 | 305 | } else { |
ysr@777 | 306 | // This really ought to be "as_CompactibleSpace"... |
ysr@777 | 307 | r->adjust_pointers(); |
ysr@777 | 308 | } |
ysr@777 | 309 | return false; |
ysr@777 | 310 | } |
ysr@777 | 311 | }; |
ysr@777 | 312 | |
ysr@777 | 313 | void G1MarkSweep::mark_sweep_phase3() { |
ysr@777 | 314 | G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
ysr@777 | 315 | Generation* pg = g1h->perm_gen(); |
ysr@777 | 316 | |
ysr@777 | 317 | // Adjust the pointers to reflect the new locations |
ysr@777 | 318 | EventMark m("3 adjust pointers"); |
ysr@777 | 319 | TraceTime tm("phase 3", PrintGC && Verbose, true, gclog_or_tty); |
ysr@777 | 320 | GenMarkSweep::trace("3"); |
ysr@777 | 321 | |
ysr@777 | 322 | SharedHeap* sh = SharedHeap::heap(); |
ysr@777 | 323 | |
jrose@1424 | 324 | sh->process_strong_roots(true, // activate StrongRootsScope |
jrose@1424 | 325 | true, // Collecting permanent generation. |
ysr@777 | 326 | SharedHeap::SO_AllClasses, |
ysr@777 | 327 | &GenMarkSweep::adjust_root_pointer_closure, |
jrose@1424 | 328 | NULL, // do not touch code cache here |
ysr@777 | 329 | &GenMarkSweep::adjust_pointer_closure); |
ysr@777 | 330 | |
ysr@777 | 331 | g1h->ref_processor()->weak_oops_do(&GenMarkSweep::adjust_root_pointer_closure); |
ysr@777 | 332 | |
ysr@777 | 333 | // Now adjust pointers in remaining weak roots. (All of which should |
ysr@777 | 334 | // have been cleared if they pointed to non-surviving objects.) |
ysr@777 | 335 | g1h->g1_process_weak_roots(&GenMarkSweep::adjust_root_pointer_closure, |
ysr@777 | 336 | &GenMarkSweep::adjust_pointer_closure); |
ysr@777 | 337 | |
ysr@777 | 338 | GenMarkSweep::adjust_marks(); |
ysr@777 | 339 | |
ysr@777 | 340 | G1AdjustPointersClosure blk; |
ysr@777 | 341 | g1h->heap_region_iterate(&blk); |
ysr@777 | 342 | pg->adjust_pointers(); |
ysr@777 | 343 | } |
ysr@777 | 344 | |
ysr@777 | 345 | class G1SpaceCompactClosure: public HeapRegionClosure { |
ysr@777 | 346 | public: |
ysr@777 | 347 | G1SpaceCompactClosure() {} |
ysr@777 | 348 | |
ysr@777 | 349 | bool doHeapRegion(HeapRegion* hr) { |
ysr@777 | 350 | if (hr->isHumongous()) { |
ysr@777 | 351 | if (hr->startsHumongous()) { |
ysr@777 | 352 | oop obj = oop(hr->bottom()); |
ysr@777 | 353 | if (obj->is_gc_marked()) { |
ysr@777 | 354 | obj->init_mark(); |
ysr@777 | 355 | } else { |
ysr@777 | 356 | assert(hr->is_empty(), "Should have been cleared in phase 2."); |
ysr@777 | 357 | } |
ysr@777 | 358 | hr->reset_during_compaction(); |
ysr@777 | 359 | } |
ysr@777 | 360 | } else { |
ysr@777 | 361 | hr->compact(); |
ysr@777 | 362 | } |
ysr@777 | 363 | return false; |
ysr@777 | 364 | } |
ysr@777 | 365 | }; |
ysr@777 | 366 | |
ysr@777 | 367 | void G1MarkSweep::mark_sweep_phase4() { |
ysr@777 | 368 | // All pointers are now adjusted, move objects accordingly |
ysr@777 | 369 | |
ysr@777 | 370 | // It is imperative that we traverse perm_gen first in phase4. All |
ysr@777 | 371 | // classes must be allocated earlier than their instances, and traversing |
ysr@777 | 372 | // perm_gen first makes sure that all klassOops have moved to their new |
ysr@777 | 373 | // location before any instance does a dispatch through it's klass! |
ysr@777 | 374 | |
ysr@777 | 375 | // The ValidateMarkSweep live oops tracking expects us to traverse spaces |
ysr@777 | 376 | // in the same order in phase2, phase3 and phase4. We don't quite do that |
ysr@777 | 377 | // here (perm_gen first rather than last), so we tell the validate code |
ysr@777 | 378 | // to use a higher index (saved from phase2) when verifying perm_gen. |
ysr@777 | 379 | G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
ysr@777 | 380 | Generation* pg = g1h->perm_gen(); |
ysr@777 | 381 | |
ysr@777 | 382 | EventMark m("4 compact heap"); |
ysr@777 | 383 | TraceTime tm("phase 4", PrintGC && Verbose, true, gclog_or_tty); |
ysr@777 | 384 | GenMarkSweep::trace("4"); |
ysr@777 | 385 | |
ysr@777 | 386 | pg->compact(); |
ysr@777 | 387 | |
ysr@777 | 388 | G1SpaceCompactClosure blk; |
ysr@777 | 389 | g1h->heap_region_iterate(&blk); |
ysr@777 | 390 | |
ysr@777 | 391 | } |
ysr@777 | 392 | |
ysr@777 | 393 | // Local Variables: *** |
ysr@777 | 394 | // c-indentation-style: gnu *** |
ysr@777 | 395 | // End: *** |