Top


定義場所(file name)

hotspot/src/share/vm/compiler/compileBroker.cpp

説明(description)

// ------------------------------------------------------------------
// CompileBroker::compilation_init
//
// Initialize the Compilation object

名前(function name)

void CompileBroker::compilation_init() {

本体部(body)

  {- -------------------------------------------
  (1) (フィールドの初期化)
      ---------------------------------------- -}

      _last_method_compiled[0] = '\0';

  {- -------------------------------------------
  (1) コンパイラオブジェクト (AbstractCompilerのサブクラスのインスタンス) を生成する.

      なお, 生成するコンパイラオブジェクトのクラスは HotSpot のビルド時の定義によって決まる.
      * (#ifndef SHARK かつ) #ifdef COMPILER1 の場合:
        Compiler クラス
      * (#ifndef SHARK かつ) #ifdef COMPILER1 の場合:
        C2Compiler クラス
      * #ifdef SHARK の場合:
        SharkCompiler クラス

      また, 以下で定義している局所変数 c1_count 及び c2_count は
      生成する CompilerThread の数を示す.
      ---------------------------------------- -}

    #ifndef SHARK
      // Set the interface to the current compiler(s).
      int c1_count = CompilationPolicy::policy()->compiler_count(CompLevel_simple);
      int c2_count = CompilationPolicy::policy()->compiler_count(CompLevel_full_optimization);

    {- -------------------------------------------
  (1.1) (以下は #ifndef SHARK かつ #ifdef COMPILER1 の場合)
        Compiler オブジェクトを生成し, フィールドに格納.
        ---------------------------------------- -}

    #ifdef COMPILER1
      if (c1_count > 0) {
        _compilers[0] = new Compiler();
      }
    #endif // COMPILER1

    {- -------------------------------------------
  (1.1) (以下は #ifndef SHARK かつ #ifdef COMPILER2 の場合)
        C2Compiler オブジェクトを生成し, フィールドに格納.
        ---------------------------------------- -}

    #ifdef COMPILER2
      if (c2_count > 0) {
        _compilers[1] = new C2Compiler();
      }
    #endif // COMPILER2

    {- -------------------------------------------
  (1.1) (以下は #ifdef SHARK の場合)
        SharkCompiler オブジェクトを生成し, フィールドに格納.
        ---------------------------------------- -}

    #else // SHARK
      int c1_count = 0;
      int c2_count = 1;

      _compilers[1] = new SharkCompiler();
    #endif // SHARK

  {- -------------------------------------------
  (1) (フィールドの初期化)
      ---------------------------------------- -}

      // Initialize the CompileTask free list
      _task_free_list = NULL;

  {- -------------------------------------------
  (1) CompileBroker::init_compiler_threads() を呼んで, 
      CompilerThread を生成し実行を開始させる.
      ---------------------------------------- -}

      // Start the CompilerThreads
      init_compiler_threads(c1_count, c2_count);

  {- -------------------------------------------
  (1) (プロファイル情報取得用の初期化処理) ("java.ci.totalTime") (See: PerfTraceTime)

      (なお, このカウンタは java.lang.management.CompilationMBean の実装内で必要なため常に生成する, とのこと)
      ---------------------------------------- -}

      // totalTime performance counter is always created as it is required
      // by the implementation of java.lang.management.CompilationMBean.
      {
        EXCEPTION_MARK;
        _perf_total_compilation =
                     PerfDataManager::create_counter(JAVA_CI, "totalTime",
                                                     PerfData::U_Ticks, CHECK);
      }


  {- -------------------------------------------
  (1) (プロファイル情報取得用の初期化処理) (See: PerfTraceTime)

      (なお, ここで生成されている Perf データにはそれぞれ以下の名前でアクセス可能.
       * sun.ci.osrTime
       * sun.ci.standardTime
       * sun.ci.totalBailouts
       * sun.ci.totalInvalidates
       * sun.ci.totalCompiles
       * sun.ci.osrCompiles
       * sun.ci.standardCompiles
       * sun.ci.osrBytes
       * sun.ci.standardBytes
       * sun.ci.nmethodSize
       * sun.ci.nmethodCodeSize
       * sun.ci.lastMethod
       * sun.ci.lastFailedMethod
       * sun.ci.lastInvalidatedMethod
       * sun.ci.lastType
       * sun.ci.lastSize
       * sun.ci.lastFailedType
       * sun.ci.lastInvalidatedType
      )
      ---------------------------------------- -}

      if (UsePerfData) {

        EXCEPTION_MARK;

        // create the jvmstat performance counters
        _perf_osr_compilation =
                     PerfDataManager::create_counter(SUN_CI, "osrTime",
                                                     PerfData::U_Ticks, CHECK);

        _perf_standard_compilation =
                     PerfDataManager::create_counter(SUN_CI, "standardTime",
                                                     PerfData::U_Ticks, CHECK);

        _perf_total_bailout_count =
                     PerfDataManager::create_counter(SUN_CI, "totalBailouts",
                                                     PerfData::U_Events, CHECK);

        _perf_total_invalidated_count =
                     PerfDataManager::create_counter(SUN_CI, "totalInvalidates",
                                                     PerfData::U_Events, CHECK);

        _perf_total_compile_count =
                     PerfDataManager::create_counter(SUN_CI, "totalCompiles",
                                                     PerfData::U_Events, CHECK);
        _perf_total_osr_compile_count =
                     PerfDataManager::create_counter(SUN_CI, "osrCompiles",
                                                     PerfData::U_Events, CHECK);

        _perf_total_standard_compile_count =
                     PerfDataManager::create_counter(SUN_CI, "standardCompiles",
                                                     PerfData::U_Events, CHECK);

        _perf_sum_osr_bytes_compiled =
                     PerfDataManager::create_counter(SUN_CI, "osrBytes",
                                                     PerfData::U_Bytes, CHECK);

        _perf_sum_standard_bytes_compiled =
                     PerfDataManager::create_counter(SUN_CI, "standardBytes",
                                                     PerfData::U_Bytes, CHECK);

        _perf_sum_nmethod_size =
                     PerfDataManager::create_counter(SUN_CI, "nmethodSize",
                                                     PerfData::U_Bytes, CHECK);

        _perf_sum_nmethod_code_size =
                     PerfDataManager::create_counter(SUN_CI, "nmethodCodeSize",
                                                     PerfData::U_Bytes, CHECK);

        _perf_last_method =
                     PerfDataManager::create_string_variable(SUN_CI, "lastMethod",
                                           CompilerCounters::cmname_buffer_length,
                                           "", CHECK);

        _perf_last_failed_method =
                PerfDataManager::create_string_variable(SUN_CI, "lastFailedMethod",
                                           CompilerCounters::cmname_buffer_length,
                                           "", CHECK);

        _perf_last_invalidated_method =
            PerfDataManager::create_string_variable(SUN_CI, "lastInvalidatedMethod",
                                         CompilerCounters::cmname_buffer_length,
                                         "", CHECK);

        _perf_last_compile_type =
                 PerfDataManager::create_variable(SUN_CI, "lastType",
                                                  PerfData::U_None,
                                                  (jlong)CompileBroker::no_compile,
                                                  CHECK);

        _perf_last_compile_size =
                 PerfDataManager::create_variable(SUN_CI, "lastSize",
                                                  PerfData::U_Bytes,
                                                  (jlong)CompileBroker::no_compile,
                                                  CHECK);


        _perf_last_failed_type =
                 PerfDataManager::create_variable(SUN_CI, "lastFailedType",
                                                  PerfData::U_None,
                                                  (jlong)CompileBroker::no_compile,
                                                  CHECK);

        _perf_last_invalidated_type =
             PerfDataManager::create_variable(SUN_CI, "lastInvalidatedType",
                                              PerfData::U_None,
                                              (jlong)CompileBroker::no_compile,
                                              CHECK);
      }

  {- -------------------------------------------
  (1) 初期化済みである印を付ける.
      ---------------------------------------- -}

      _initialized = true;
    }

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