Top


定義場所(file name)

hotspot/src/share/vm/interpreter/interpreterRuntime.cpp

名前(function name)

IRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* thread, jint* first_size_address))

本体部(body)

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

      // We may want to pass in more arguments - could make this slightly faster
      constantPoolOop constants = method(thread)->constants();
      int          i = get_index_u2(thread, Bytecodes::_multianewarray);

  {- -------------------------------------------
  (1) constantPoolOopDesc::klass_at() を呼んで, 対象のクラス(klassOop)を取得する.
        (この際, 対象クラスが constantPoolOopDesc 中でまだ解決されてなければ解決も行われる)
      ---------------------------------------- -}

      klassOop klass = constants->klass_at(i, CHECK);

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

      int   nof_dims = number_of_dimensions(thread);

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

      assert(oop(klass)->is_klass(), "not a class");
      assert(nof_dims >= 1, "multianewarray rank must be nonzero");

  {- -------------------------------------------
  (1) (変数宣言など)
      (dims は, arrayKlass::multi_allocate() の引数として使う配列)
      ---------------------------------------- -}

      // We must create an array of jints to pass to multi_allocate.
      ResourceMark rm(thread);
      const int small_dims = 10;
      jint dim_array[small_dims];
      jint *dims = &dim_array[0];
      if (nof_dims > small_dims) {
        dims = (jint*) NEW_RESOURCE_ARRAY(jint, nof_dims);
      }
      for (int index = 0; index < nof_dims; index++) {
        // offset from first_size_address is addressed as local[index]
        int n = Interpreter::local_offset_in_bytes(index)/jintSize;
        dims[index] = first_size_address[n];
      }

  {- -------------------------------------------
  (1) objArrayKlass::multi_allocate() または typeArrayKlass::multi_allocate() でメモリの確保を行う.
        (確保した結果は, JavaThread::set_vm_result() で JavaThread 内に格納してリターン)
      ---------------------------------------- -}

      oop obj = arrayKlass::cast(klass)->multi_allocate(nof_dims, dims, CHECK);
      thread->set_vm_result(obj);
    IRT_END

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