Top


定義場所(file name)

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

名前(function name)

jint universe_init() {

本体部(body)

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

      assert(!Universe::_fully_initialized, "called after initialize_vtables");
      guarantee(1 << LogHeapWordSize == sizeof(HeapWord),
             "LogHeapWordSize is incorrect.");
      guarantee(sizeof(oop) >= sizeof(HeapWord), "HeapWord larger than oop?");
      guarantee(sizeof(oop) % sizeof(HeapWord) == 0,
                "oop size is not not a multiple of HeapWord size");

  {- -------------------------------------------
  (1) (トレース処理)
      ---------------------------------------- -}

      TraceTime timer("Genesis", TraceStartupTime);

  {- -------------------------------------------
  (1) GC_locker を用いて, 初期化中は GC 処理が起こらないようにしておく
      (See: GC_locker)

      (なお, 対応する GC_locker::unlock() は universe_post_init() 内で行われている)
      ---------------------------------------- -}

      GC_locker::lock();  // do not allow gc during bootstrapping

  {- -------------------------------------------
  (1) ?? #TODO
      ---------------------------------------- -}

      JavaClasses::compute_hard_coded_offsets();

  {- -------------------------------------------
  (1) (DumpSharedSpaces オプションが指定されている場合には UseSharedSpaces オプションは明示的に切っておく)
      (See: DumpSharedSpaces, UseSharedSpaces)
      ---------------------------------------- -}

      // Get map info from shared archive file.
      if (DumpSharedSpaces)
        UseSharedSpaces = false;

  {- -------------------------------------------
  (1) UseSharedSpaces オプションが指定されている場合... #TODO
      ---------------------------------------- -}

      FileMapInfo* mapinfo = NULL;
      if (UseSharedSpaces) {
        mapinfo = NEW_C_HEAP_OBJ(FileMapInfo);
        memset(mapinfo, 0, sizeof(FileMapInfo));

        // Open the shared archive file, read and validate the header. If
        // initialization files, shared spaces [UseSharedSpaces] are
        // disabled and the file is closed.

        if (mapinfo->initialize()) {
          FileMapInfo::set_current_info(mapinfo);
        } else {
          assert(!mapinfo->is_open() && !UseSharedSpaces,
                 "archive file not closed or shared spaces not disabled.");
        }
      }

  {- -------------------------------------------
  (1) Universe::initialize_heap() を呼び出して, 
      ヒープ領域の確保やヒープ管理用のオブジェクトの生成を行う.
      ---------------------------------------- -}

      jint status = Universe::initialize_heap();
      if (status != JNI_OK) {
        return status;
      }

  {- -------------------------------------------
  (1) Universe::_finalizer_register_cache, Universe::_loader_addClass_cache 及び 
      Universe::_reflect_invoke_cache フィールドを初期化する.

      (See: LatestMethodOopCache, ActiveMethodOopsCache)
      ---------------------------------------- -}

      // We have a heap so create the methodOop caches before
      // CompactingPermGenGen::initialize_oops() tries to populate them.
      Universe::_finalizer_register_cache = new LatestMethodOopCache();
      Universe::_loader_addClass_cache    = new LatestMethodOopCache();
      Universe::_reflect_invoke_cache     = new ActiveMethodOopsCache();

  {- -------------------------------------------
  (1) SymbolTable オブジェクトや StringTable オブジェクト, PackageHashtable オブジェクトの生成を行う.
      (See: CompactingPermGenGen::initialize_oops(), 
            SymbolTable::create_table(), StringTable::create_table(), ClassLoader::create_package_info_table())

      (UseSharedSpaces オプションが指定されている場合は, 
       CompactingPermGenGen::initialize_oops() でファイルから呼んでくればよい.
       そうでなければ自前で作る.)
      ---------------------------------------- -}

      if (UseSharedSpaces) {

        // Read the data structures supporting the shared spaces (shared
        // system dictionary, symbol table, etc.).  After that, access to
        // the file (other than the mapped regions) is no longer needed, and
        // the file is closed. Closing the file does not affect the
        // currently mapped regions.

        CompactingPermGenGen::initialize_oops();
        mapinfo->close();

      } else {
        SymbolTable::create_table();
        StringTable::create_table();
        ClassLoader::create_package_info_table();
      }

  {- -------------------------------------------
  (1) リターン
      ---------------------------------------- -}

      return JNI_OK;
    }

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