예제 #1
0
void G1MarkSweep::mark_sweep_phase3() {
  G1CollectedHeap* g1h = G1CollectedHeap::heap();
  Generation* pg = g1h->perm_gen();

  // Adjust the pointers to reflect the new locations
  EventMark m("3 adjust pointers");
  TraceTime tm("phase 3", PrintGC && Verbose, true, gclog_or_tty);
  GenMarkSweep::trace("3");

  SharedHeap* sh = SharedHeap::heap();

  sh->process_strong_roots(true,  // activate StrongRootsScope
                           true,  // Collecting permanent generation.
                           SharedHeap::SO_AllClasses,
                           &GenMarkSweep::adjust_root_pointer_closure,
                           NULL,  // do not touch code cache here
                           &GenMarkSweep::adjust_pointer_closure);

  g1h->ref_processor()->weak_oops_do(&GenMarkSweep::adjust_root_pointer_closure);

  // Now adjust pointers in remaining weak roots.  (All of which should
  // have been cleared if they pointed to non-surviving objects.)
  g1h->g1_process_weak_roots(&GenMarkSweep::adjust_root_pointer_closure,
                             &GenMarkSweep::adjust_pointer_closure);

  GenMarkSweep::adjust_marks();

  G1AdjustPointersClosure blk;
  g1h->heap_region_iterate(&blk);
  pg->adjust_pointers();
}