Top


定義場所(file name)

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

名前(function name)

inline DiscoveredList* ReferenceProcessor::get_discovered_list(ReferenceType rt) {

本体部(body)

  {- -------------------------------------------
  (1) 適当なスレッドIDを取得する.
      (もし参照オブジェクトの発見処理自体がマルチスレッドで実行されていれば, 
       この関数(ReferenceProcessor::get_discovered_list())を呼び出したスレッドの ID を使う.

       もし発見処理はシングルスレッド実行でも, 参照オブジェクトの処理はマルチスレッドで行う場合, 
       ラウンドロビン方式で順繰りに ID を使用する.

       もしどちらもシングルスレッド実行なら, スレッドIDは 0 とする.)
      ---------------------------------------- -}

      int id = 0;
      // Determine the queue index to use for this object.
      if (_discovery_is_mt) {
        // During a multi-threaded discovery phase,
        // each thread saves to its "own" list.
        Thread* thr = Thread::current();
        id = thr->as_Worker_thread()->id();
      } else {
        // single-threaded discovery, we save in round-robin
        // fashion to each of the lists.
        if (_processing_is_mt) {
          id = next_id();
        }
      }

  {- -------------------------------------------
  (1) (assert)
      ---------------------------------------- -}

      assert(0 <= id && id < _max_num_q, "Id is out-of-bounds (call Freud?)");

  {- -------------------------------------------
  (1) さっき求めたスレッドIDと参照オブジェクトの種別に基づき, 
      参照オブジェクトをつなぐための適切なリストを取得する.

      * soft referece の場合
        ReferenceProcessor::_discoveredSoftRefs[id]
      * weak reference 
        ReferenceProcessor::_discoveredWeakRefs[id]
      * final reference
        ReferenceProcessor::_discoveredFinalRefs[id]
      * phantom reference
        ReferenceProcessor::_discoveredPhantomRefs[id]
      ---------------------------------------- -}

      // Get the discovered queue to which we will add
      DiscoveredList* list = NULL;
      switch (rt) {
        case REF_OTHER:
          // Unknown reference type, no special treatment
          break;
        case REF_SOFT:
          list = &_discoveredSoftRefs[id];
          break;
        case REF_WEAK:
          list = &_discoveredWeakRefs[id];
          break;
        case REF_FINAL:
          list = &_discoveredFinalRefs[id];
          break;
        case REF_PHANTOM:
          list = &_discoveredPhantomRefs[id];
          break;
        case REF_NONE:
          // we should not reach here if we are an instanceRefKlass
        default:
          ShouldNotReachHere();
      }

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

      if (TraceReferenceGC && PrintGCDetails) {
        gclog_or_tty->print_cr("Thread %d gets list " INTPTR_FORMAT, id, list);
      }

  {- -------------------------------------------
  (1) 結果をリターンする.
      ---------------------------------------- -}

      return list;
    }

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