hotspot/src/share/vm/gc_implementation/shared/markSweep.inline.hpp
template <class T> inline void MarkSweep::follow_root(T* p) {
  {- -------------------------------------------
  (1) (assert)
      ---------------------------------------- -}
      assert(!Universe::heap()->is_in_reserved(p),
             "roots shouldn't be things within the heap");
  {- -------------------------------------------
  (1) (verify)
      ---------------------------------------- -}
    #ifdef VALIDATE_MARK_SWEEP
      if (ValidateMarkSweep) {
        guarantee(!_root_refs_stack->contains(p), "should only be in here once");
        _root_refs_stack->push(p);
      }
    #endif
  {- -------------------------------------------
  (1) 処理対象のオブジェクトが NULL ではなく未だマークもされていなければ, 
      mark_object() でそのオブジェクトにマークを付け, 
      oopDesc::follow_contents() でそのオブジェクトが参照している先のオブジェクトを marking stack にプッシュする.
      ---------------------------------------- -}
      T heap_oop = oopDesc::load_heap_oop(p);
      if (!oopDesc::is_null(heap_oop)) {
        oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
        if (!obj->mark()->is_marked()) {
          mark_object(obj);
          obj->follow_contents();
        }
      }
  {- -------------------------------------------
  (1) MarkSweep::follow_stack() で, 
      marking stack に溜まったポインタから辿れる範囲を, 再帰的に全て辿って処理する.
      ---------------------------------------- -}
      follow_stack();
    }
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.