Top


定義場所(file name)

hotspot/src/share/vm/oops/arrayKlass.cpp

名前(function name)

arrayKlassHandle arrayKlass::base_create_array_klass(
const Klass_vtbl& cplusplus_vtbl, int header_size, KlassHandle klass, TRAPS) {

本体部(body)

  {- -------------------------------------------
  (1) (assert)
      (コメントによると, 
      vtable の位置を全ての klass で合わせるため arrayKlass にはパディングを入れている.
      もし以下の assert が失敗したら instanceKlass とずれているので調整すること.
      とのこと)
      ---------------------------------------- -}

      // Allocation
      // Note: because the Java vtable must start at the same offset in all klasses,
      // we must insert filler fields into arrayKlass to make it the same size as instanceKlass.
      // If this assert fails, add filler to instanceKlass to make it bigger.
      assert(header_size <= instanceKlass::header_size(),
             "array klasses must be same size as instanceKlass");

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

      header_size = instanceKlass::header_size();
      // Arrays don't add any new methods, so their vtable is the same size as
      // the vtable of klass Object.
      int vtable_size = Universe::base_vtable_size();
      arrayKlassHandle k;

  {- -------------------------------------------
  (1) Klass::base_create_klass() を呼んで, 配列クラスを表す Klass オブジェクトを生成する
      ---------------------------------------- -}

      KlassHandle base_klass = Klass::base_create_klass(klass,
                                                     header_size + vtable_size,
                                                     cplusplus_vtbl, CHECK_(k));

  {- -------------------------------------------
  (1) (No_Safepoint_Verifier)(= このブロック内では Safepoint 停止は起こらないはず)
      ---------------------------------------- -}

      // No safepoint should be possible until the handle's
      // target below becomes parsable
      No_Safepoint_Verifier no_safepoint;

  {- -------------------------------------------
  (1) 生成した配列クラスのフィールドを初期化する
      ---------------------------------------- -}

      k = arrayKlassHandle(THREAD, base_klass());

      assert(!k()->is_parsable(), "not expecting parsability yet.");
      k->set_super(Universe::is_bootstrapping() ? (klassOop)NULL : SystemDictionary::Object_klass());
      k->set_layout_helper(Klass::_lh_neutral_value);
      k->set_dimension(1);
      k->set_higher_dimension(NULL);
      k->set_lower_dimension(NULL);
      k->set_component_mirror(NULL);
      k->set_vtable_length(vtable_size);
      k->set_is_cloneable(); // All arrays are considered to be cloneable (See JLS 20.1.5)

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

      assert(k()->is_parsable(), "should be parsable here.");
      // Make sure size calculation is right
      assert(k()->size() == align_object_size(header_size + vtable_size), "wrong size for object");

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

      return k;
    }

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