src/share/vm/interpreter/rewriter.cpp

changeset 1957
136b78722a08
parent 1934
e9ff18c4ace7
child 2015
083fde3b838e
     1.1 --- a/src/share/vm/interpreter/rewriter.cpp	Mon Jun 07 14:17:01 2010 -0700
     1.2 +++ b/src/share/vm/interpreter/rewriter.cpp	Wed Jun 09 18:50:45 2010 -0700
     1.3 @@ -38,6 +38,8 @@
     1.4        case JVM_CONSTANT_InterfaceMethodref:
     1.5        case JVM_CONSTANT_Fieldref          : // fall through
     1.6        case JVM_CONSTANT_Methodref         : // fall through
     1.7 +      case JVM_CONSTANT_MethodHandle      : // fall through
     1.8 +      case JVM_CONSTANT_MethodType        : // fall through
     1.9          add_cp_cache_entry(i);
    1.10          break;
    1.11      }
    1.12 @@ -131,6 +133,27 @@
    1.13  }
    1.14  
    1.15  
    1.16 +// Rewrite some ldc bytecodes to _fast_aldc
    1.17 +void Rewriter::maybe_rewrite_ldc(address bcp, int offset, bool is_wide) {
    1.18 +  assert((*bcp) == (is_wide ? Bytecodes::_ldc_w : Bytecodes::_ldc), "");
    1.19 +  address p = bcp + offset;
    1.20 +  int cp_index = is_wide ? Bytes::get_Java_u2(p) : (u1)(*p);
    1.21 +  constantTag tag = _pool->tag_at(cp_index).value();
    1.22 +  if (tag.is_method_handle() || tag.is_method_type()) {
    1.23 +    int cache_index = cp_entry_to_cp_cache(cp_index);
    1.24 +    if (is_wide) {
    1.25 +      (*bcp) = Bytecodes::_fast_aldc_w;
    1.26 +      assert(cache_index == (u2)cache_index, "");
    1.27 +      Bytes::put_native_u2(p, cache_index);
    1.28 +    } else {
    1.29 +      (*bcp) = Bytecodes::_fast_aldc;
    1.30 +      assert(cache_index == (u1)cache_index, "");
    1.31 +      (*p) = (u1)cache_index;
    1.32 +    }
    1.33 +  }
    1.34 +}
    1.35 +
    1.36 +
    1.37  // Rewrites a method given the index_map information
    1.38  void Rewriter::scan_method(methodOop method) {
    1.39  
    1.40 @@ -198,6 +221,12 @@
    1.41          case Bytecodes::_invokedynamic:
    1.42            rewrite_invokedynamic(bcp, prefix_length+1);
    1.43            break;
    1.44 +        case Bytecodes::_ldc:
    1.45 +          maybe_rewrite_ldc(bcp, prefix_length+1, false);
    1.46 +          break;
    1.47 +        case Bytecodes::_ldc_w:
    1.48 +          maybe_rewrite_ldc(bcp, prefix_length+1, true);
    1.49 +          break;
    1.50          case Bytecodes::_jsr            : // fall through
    1.51          case Bytecodes::_jsr_w          : nof_jsrs++;                   break;
    1.52          case Bytecodes::_monitorenter   : // fall through

mercurial