src/share/vm/interpreter/bytecode.cpp

changeset 1957
136b78722a08
parent 1934
e9ff18c4ace7
child 2314
f95d63e2154a
     1.1 --- a/src/share/vm/interpreter/bytecode.cpp	Mon Jun 07 14:17:01 2010 -0700
     1.2 +++ b/src/share/vm/interpreter/bytecode.cpp	Wed Jun 09 18:50:45 2010 -0700
     1.3 @@ -136,25 +136,24 @@
     1.4  // Implementation of Bytecode_invoke
     1.5  
     1.6  void Bytecode_invoke::verify() const {
     1.7 -  Bytecodes::Code bc = adjusted_invoke_code();
     1.8    assert(is_valid(), "check invoke");
     1.9    assert(method()->constants()->cache() != NULL, "do not call this from verifier or rewriter");
    1.10  }
    1.11  
    1.12  
    1.13 -symbolOop Bytecode_invoke::signature() const {
    1.14 +symbolOop Bytecode_member_ref::signature() const {
    1.15    constantPoolOop constants = method()->constants();
    1.16    return constants->signature_ref_at(index());
    1.17  }
    1.18  
    1.19  
    1.20 -symbolOop Bytecode_invoke::name() const {
    1.21 +symbolOop Bytecode_member_ref::name() const {
    1.22    constantPoolOop constants = method()->constants();
    1.23    return constants->name_ref_at(index());
    1.24  }
    1.25  
    1.26  
    1.27 -BasicType Bytecode_invoke::result_type(Thread *thread) const {
    1.28 +BasicType Bytecode_member_ref::result_type(Thread *thread) const {
    1.29    symbolHandle sh(thread, signature());
    1.30    ResultTypeFinder rts(sh);
    1.31    rts.iterate();
    1.32 @@ -167,9 +166,9 @@
    1.33    KlassHandle resolved_klass;
    1.34    constantPoolHandle constants(THREAD, _method->constants());
    1.35  
    1.36 -  if (adjusted_invoke_code() == Bytecodes::_invokedynamic) {
    1.37 +  if (java_code() == Bytecodes::_invokedynamic) {
    1.38      LinkResolver::resolve_dynamic_method(m, resolved_klass, constants, index(), CHECK_(methodHandle()));
    1.39 -  } else if (adjusted_invoke_code() != Bytecodes::_invokeinterface) {
    1.40 +  } else if (java_code() != Bytecodes::_invokeinterface) {
    1.41      LinkResolver::resolve_method(m, resolved_klass, constants, index(), CHECK_(methodHandle()));
    1.42    } else {
    1.43      LinkResolver::resolve_interface_method(m, resolved_klass, constants, index(), CHECK_(methodHandle()));
    1.44 @@ -178,51 +177,68 @@
    1.45  }
    1.46  
    1.47  
    1.48 -int Bytecode_invoke::index() const {
    1.49 +int Bytecode_member_ref::index() const {
    1.50    // Note:  Rewriter::rewrite changes the Java_u2 of an invokedynamic to a native_u4,
    1.51    // at the same time it allocates per-call-site CP cache entries.
    1.52 -  Bytecodes::Code stdc = Bytecodes::java_code(code());
    1.53 -  Bytecode* invoke = Bytecode_at(bcp());
    1.54 -  if (invoke->has_index_u4(stdc))
    1.55 -    return invoke->get_index_u4(stdc);
    1.56 +  Bytecodes::Code rawc = code();
    1.57 +  Bytecode* invoke = bytecode();
    1.58 +  if (invoke->has_index_u4(rawc))
    1.59 +    return invoke->get_index_u4(rawc);
    1.60    else
    1.61 -    return invoke->get_index_u2_cpcache(stdc);
    1.62 +    return invoke->get_index_u2_cpcache(rawc);
    1.63  }
    1.64  
    1.65 +int Bytecode_member_ref::pool_index() const {
    1.66 +  int index = this->index();
    1.67 +  DEBUG_ONLY({
    1.68 +      if (!bytecode()->has_index_u4(code()))
    1.69 +        index -= constantPoolOopDesc::CPCACHE_INDEX_TAG;
    1.70 +    });
    1.71 +  return _method->constants()->cache()->entry_at(index)->constant_pool_index();
    1.72 +}
    1.73  
    1.74  // Implementation of Bytecode_field
    1.75  
    1.76  void Bytecode_field::verify() const {
    1.77 -  Bytecodes::Code stdc = Bytecodes::java_code(code());
    1.78 -  assert(stdc == Bytecodes::_putstatic || stdc == Bytecodes::_getstatic ||
    1.79 -         stdc == Bytecodes::_putfield  || stdc == Bytecodes::_getfield, "check field");
    1.80 +  assert(is_valid(), "check field");
    1.81  }
    1.82  
    1.83  
    1.84 -bool Bytecode_field::is_static() const {
    1.85 -  Bytecodes::Code stdc = Bytecodes::java_code(code());
    1.86 -  return stdc == Bytecodes::_putstatic || stdc == Bytecodes::_getstatic;
    1.87 +// Implementation of Bytecode_loadconstant
    1.88 +
    1.89 +int Bytecode_loadconstant::raw_index() const {
    1.90 +  Bytecode* bcp = bytecode();
    1.91 +  Bytecodes::Code rawc = bcp->code();
    1.92 +  assert(rawc != Bytecodes::_wide, "verifier prevents this");
    1.93 +  if (Bytecodes::java_code(rawc) == Bytecodes::_ldc)
    1.94 +    return bcp->get_index_u1(rawc);
    1.95 +  else
    1.96 +    return bcp->get_index_u2(rawc, false);
    1.97  }
    1.98  
    1.99 -
   1.100 -int Bytecode_field::index() const {
   1.101 -  Bytecode* invoke = Bytecode_at(bcp());
   1.102 -  return invoke->get_index_u2_cpcache(Bytecodes::_getfield);
   1.103 +int Bytecode_loadconstant::pool_index() const {
   1.104 +  int index = raw_index();
   1.105 +  if (has_cache_index()) {
   1.106 +    return _method->constants()->cache()->entry_at(index)->constant_pool_index();
   1.107 +  }
   1.108 +  return index;
   1.109  }
   1.110  
   1.111 +BasicType Bytecode_loadconstant::result_type() const {
   1.112 +  int index = pool_index();
   1.113 +  constantTag tag = _method->constants()->tag_at(index);
   1.114 +  return tag.basic_type();
   1.115 +}
   1.116  
   1.117 -// Implementation of Bytecodes loac constant
   1.118 -
   1.119 -int Bytecode_loadconstant::index() const {
   1.120 -  Bytecodes::Code stdc = Bytecodes::java_code(code());
   1.121 -  if (stdc != Bytecodes::_wide) {
   1.122 -    if (Bytecodes::java_code(stdc) == Bytecodes::_ldc)
   1.123 -      return get_index_u1(stdc);
   1.124 -    else
   1.125 -      return get_index_u2(stdc, false);
   1.126 +oop Bytecode_loadconstant::resolve_constant(TRAPS) const {
   1.127 +  assert(_method.not_null(), "must supply method to resolve constant");
   1.128 +  int index = raw_index();
   1.129 +  constantPoolOop constants = _method->constants();
   1.130 +  if (has_cache_index()) {
   1.131 +    return constants->resolve_cached_constant_at(index, THREAD);
   1.132 +  } else {
   1.133 +    return constants->resolve_constant_at(index, THREAD);
   1.134    }
   1.135 -  stdc = Bytecodes::code_at(addr_at(1));
   1.136 -  return get_index_u2(stdc, true);
   1.137  }
   1.138  
   1.139  //------------------------------------------------------------------------------

mercurial