Top


定義場所(file name)

hotspot/src/share/vm/memory/genMarkSweep.cpp

名前(function name)

void GenMarkSweep::mark_sweep_phase3(int level) {

本体部(body)

  {- -------------------------------------------
  (1) (変数宣言など)
      ---------------------------------------- -}

      GenCollectedHeap* gch = GenCollectedHeap::heap();
      Generation* pg = gch->perm_gen();

  {- -------------------------------------------
  (1) (トレース出力)
      ---------------------------------------- -}

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

  {- -------------------------------------------
  (1) (verify)
      ---------------------------------------- -}

      VALIDATE_MARK_SWEEP_ONLY(reset_live_oop_tracking(false));

  {- -------------------------------------------
  (1) Generation::pre_adjust_pointers() を呼び出す.
      (オーバーライドされているため, 実際の呼び出し先は CompactingPermGenGen::pre_adjust_pointers())
      ---------------------------------------- -}

      // Needs to be done before the system dictionary is adjusted.
      pg->pre_adjust_pointers();

  {- -------------------------------------------
  (1) 前準備を行う (処理対象の Generation をセット)
      ---------------------------------------- -}

      // Because the two closures below are created statically, cannot
      // use OopsInGenClosure constructor which takes a generation,
      // as the Universe has not been created when the static constructors
      // are run.
      adjust_root_pointer_closure.set_orig_generation(gch->get_gen(level));
      adjust_pointer_closure.set_orig_generation(gch->get_gen(level));

  {- -------------------------------------------
  (1) まず, GenCollectedHeap::gen_process_strong_roots() を呼び出して
      root から参照されているオブジェクト内のポインタ値を修正しておく.
      ---------------------------------------- -}

      gch->gen_process_strong_roots(level,
                                    false, // Younger gens are not roots.
                                    true,  // activate StrongRootsScope
                                    true,  // Collecting permanent generation.
                                    SharedHeap::SO_AllClasses,
                                    &adjust_root_pointer_closure,
                                    false, // do not walk code
                                    &adjust_root_pointer_closure);

  {- -------------------------------------------
  (1) (変数宣言など)
      ---------------------------------------- -}

      // Now adjust pointers in remaining weak roots.  (All of which should
      // have been cleared if they pointed to non-surviving objects.)
      CodeBlobToOopClosure adjust_code_pointer_closure(&adjust_pointer_closure,
                                                       /*do_marking=*/ false);

  {- -------------------------------------------
  (1) 次に, GenCollectedHeap::gen_process_weak_roots() を呼び出して
      ReferenceProcessor や JNI の Weak Global Handle 内のポインタ値を修正しておく.
      ---------------------------------------- -}

      gch->gen_process_weak_roots(&adjust_root_pointer_closure,
                                  &adjust_code_pointer_closure,
                                  &adjust_pointer_closure);

  {- -------------------------------------------
  (1) MarkSweep::adjust_marks() を呼んで, 
      MarkSweep::preserve_mark() で待避された mark 値内のポインタについても, 値を修正しておく.
      (See: PreservedMark)
      ---------------------------------------- -}

      adjust_marks();

  {- -------------------------------------------
  (1) GenCollectedHeap::generation_iterate() で, New/Old 領域のポインタを修正する.
      ---------------------------------------- -}

      GenAdjustPointersClosure blk;
      gch->generation_iterate(&blk, true);

  {- -------------------------------------------
  (1) CompactingPermGenGen::adjust_pointers() で, Perm 領域のポインタを修正する.
      ---------------------------------------- -}

      pg->adjust_pointers();
    }

This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.