Top


定義場所(file name)

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

説明(description)

// Rewrite some ldc bytecodes to _fast_aldc

名前(function name)

void Rewriter::maybe_rewrite_ldc(address bcp, int offset, bool is_wide,
                                 bool reverse) {

本体部(body)

  {- -------------------------------------------
  (1) reverse 引数が false の場合には, 
      ロード対象が method handle あるいは method type であれば
      Bytecodes::_fast_aldc 命令や Bytecodes::_fast_aldc_w 命令に置き換える (どちらも HotSpot 独自のバイトコード命令).
      ロード対象がそれ以外の定数の場合は, 何もしない.

      reverse 引数が true の場合には, 逆に元に戻す処理が行われる.
      ---------------------------------------- -}

      if (!reverse) {
        assert((*bcp) == (is_wide ? Bytecodes::_ldc_w : Bytecodes::_ldc), "not ldc bytecode");
        address p = bcp + offset;
        int cp_index = is_wide ? Bytes::get_Java_u2(p) : (u1)(*p);
        constantTag tag = _pool->tag_at(cp_index).value();
        if (tag.is_method_handle() || tag.is_method_type()) {
          int cache_index = cp_entry_to_cp_cache(cp_index);
          if (is_wide) {
            (*bcp) = Bytecodes::_fast_aldc_w;
            assert(cache_index == (u2)cache_index, "index overflow");
            Bytes::put_native_u2(p, cache_index);
          } else {
            (*bcp) = Bytecodes::_fast_aldc;
            assert(cache_index == (u1)cache_index, "index overflow");
            (*p) = (u1)cache_index;
          }
        }
      } else {
        Bytecodes::Code rewritten_bc =
                  (is_wide ? Bytecodes::_fast_aldc_w : Bytecodes::_fast_aldc);
        if ((*bcp) == rewritten_bc) {
          address p = bcp + offset;
          int cache_index = is_wide ? Bytes::get_native_u2(p) : (u1)(*p);
          int pool_index = cp_cache_entry_pool_index(cache_index);
          if (is_wide) {
            (*bcp) = Bytecodes::_ldc_w;
            assert(pool_index == (u2)pool_index, "index overflow");
            Bytes::put_Java_u2(p, pool_index);
          } else {
            (*bcp) = Bytecodes::_ldc;
            assert(pool_index == (u1)pool_index, "index overflow");
            (*p) = (u1)pool_index;
          }
        }
      }
    }

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