src/share/vm/interpreter/interpreterRuntime.cpp

changeset 3969
1d7922586cf6
parent 3931
dd785aabe02b
child 4037
da91efe96a93
     1.1 --- a/src/share/vm/interpreter/interpreterRuntime.cpp	Mon Jul 23 13:04:59 2012 -0700
     1.2 +++ b/src/share/vm/interpreter/interpreterRuntime.cpp	Tue Jul 24 10:51:00 2012 -0700
     1.3 @@ -145,7 +145,7 @@
     1.4      // The bytecode wrappers aren't GC-safe so construct a new one
     1.5      Bytecode_loadconstant ldc2(m, bci(thread));
     1.6      ConstantPoolCacheEntry* cpce = m->constants()->cache()->entry_at(ldc2.cache_index());
     1.7 -    assert(result == cpce->f1(), "expected result for assembly code");
     1.8 +    assert(result == cpce->f1_as_instance(), "expected result for assembly code");
     1.9    }
    1.10  #endif
    1.11  }
    1.12 @@ -656,7 +656,7 @@
    1.13    JvmtiExport::post_raw_breakpoint(thread, method, bcp);
    1.14  IRT_END
    1.15  
    1.16 -IRT_ENTRY(void, InterpreterRuntime::resolve_invoke(JavaThread* thread, Bytecodes::Code bytecode))
    1.17 +IRT_ENTRY(void, InterpreterRuntime::resolve_invoke(JavaThread* thread, Bytecodes::Code bytecode)) {
    1.18    // extract receiver from the outgoing argument list if necessary
    1.19    Handle receiver(thread, NULL);
    1.20    if (bytecode == Bytecodes::_invokevirtual || bytecode == Bytecodes::_invokeinterface) {
    1.21 @@ -724,86 +724,54 @@
    1.22        info.resolved_method(),
    1.23        info.vtable_index());
    1.24    }
    1.25 +}
    1.26 +IRT_END
    1.27 +
    1.28 +
    1.29 +// First time execution:  Resolve symbols, create a permanent MethodType object.
    1.30 +IRT_ENTRY(void, InterpreterRuntime::resolve_invokehandle(JavaThread* thread)) {
    1.31 +  assert(EnableInvokeDynamic, "");
    1.32 +  const Bytecodes::Code bytecode = Bytecodes::_invokehandle;
    1.33 +
    1.34 +  // resolve method
    1.35 +  CallInfo info;
    1.36 +  constantPoolHandle pool(thread, method(thread)->constants());
    1.37 +
    1.38 +  {
    1.39 +    JvmtiHideSingleStepping jhss(thread);
    1.40 +    LinkResolver::resolve_invoke(info, Handle(), pool,
    1.41 +                                 get_index_u2_cpcache(thread, bytecode), bytecode, CHECK);
    1.42 +  } // end JvmtiHideSingleStepping
    1.43 +
    1.44 +  cache_entry(thread)->set_method_handle(
    1.45 +      info.resolved_method(),
    1.46 +      info.resolved_appendix());
    1.47 +}
    1.48  IRT_END
    1.49  
    1.50  
    1.51  // First time execution:  Resolve symbols, create a permanent CallSite object.
    1.52  IRT_ENTRY(void, InterpreterRuntime::resolve_invokedynamic(JavaThread* thread)) {
    1.53 -  ResourceMark rm(thread);
    1.54 -
    1.55    assert(EnableInvokeDynamic, "");
    1.56 -
    1.57    const Bytecodes::Code bytecode = Bytecodes::_invokedynamic;
    1.58  
    1.59 -  methodHandle caller_method(thread, method(thread));
    1.60 +  //TO DO: consider passing BCI to Java.
    1.61 +  //  int caller_bci = method(thread)->bci_from(bcp(thread));
    1.62  
    1.63 -  constantPoolHandle pool(thread, caller_method->constants());
    1.64 -  pool->set_invokedynamic();    // mark header to flag active call sites
    1.65 +  // resolve method
    1.66 +  CallInfo info;
    1.67 +  constantPoolHandle pool(thread, method(thread)->constants());
    1.68 +  int index = get_index_u4(thread, bytecode);
    1.69  
    1.70 -  int caller_bci = 0;
    1.71 -  int site_index = 0;
    1.72 -  { address caller_bcp = bcp(thread);
    1.73 -    caller_bci = caller_method->bci_from(caller_bcp);
    1.74 -    site_index = Bytes::get_native_u4(caller_bcp+1);
    1.75 -  }
    1.76 -  assert(site_index == InterpreterRuntime::bytecode(thread).get_index_u4(bytecode), "");
    1.77 -  assert(constantPoolCacheOopDesc::is_secondary_index(site_index), "proper format");
    1.78 -  // there is a second CPC entries that is of interest; it caches signature info:
    1.79 -  int main_index = pool->cache()->secondary_entry_at(site_index)->main_entry_index();
    1.80 -  int pool_index = pool->cache()->entry_at(main_index)->constant_pool_index();
    1.81 +  {
    1.82 +    JvmtiHideSingleStepping jhss(thread);
    1.83 +    LinkResolver::resolve_invoke(info, Handle(), pool,
    1.84 +                                 index, bytecode, CHECK);
    1.85 +  } // end JvmtiHideSingleStepping
    1.86  
    1.87 -  // first resolve the signature to a MH.invoke methodOop
    1.88 -  if (!pool->cache()->entry_at(main_index)->is_resolved(bytecode)) {
    1.89 -    JvmtiHideSingleStepping jhss(thread);
    1.90 -    CallInfo callinfo;
    1.91 -    LinkResolver::resolve_invoke(callinfo, Handle(), pool,
    1.92 -                                 site_index, bytecode, CHECK);
    1.93 -    // The main entry corresponds to a JVM_CONSTANT_InvokeDynamic, and serves
    1.94 -    // as a common reference point for all invokedynamic call sites with
    1.95 -    // that exact call descriptor.  We will link it in the CP cache exactly
    1.96 -    // as if it were an invokevirtual of MethodHandle.invoke.
    1.97 -    pool->cache()->entry_at(main_index)->set_method(
    1.98 -      bytecode,
    1.99 -      callinfo.resolved_method(),
   1.100 -      callinfo.vtable_index());
   1.101 -  }
   1.102 -
   1.103 -  // The method (f2 entry) of the main entry is the MH.invoke for the
   1.104 -  // invokedynamic target call signature.
   1.105 -  oop f1_value = pool->cache()->entry_at(main_index)->f1();
   1.106 -  methodHandle signature_invoker(THREAD, (methodOop) f1_value);
   1.107 -  assert(signature_invoker.not_null() && signature_invoker->is_method() && signature_invoker->is_method_handle_invoke(),
   1.108 -         "correct result from LinkResolver::resolve_invokedynamic");
   1.109 -
   1.110 -  Handle info;  // optional argument(s) in JVM_CONSTANT_InvokeDynamic
   1.111 -  Handle bootm = SystemDictionary::find_bootstrap_method(caller_method, caller_bci,
   1.112 -                                                         main_index, info, CHECK);
   1.113 -  if (!java_lang_invoke_MethodHandle::is_instance(bootm())) {
   1.114 -    THROW_MSG(vmSymbols::java_lang_IllegalStateException(),
   1.115 -              "no bootstrap method found for invokedynamic");
   1.116 -  }
   1.117 -
   1.118 -  // Short circuit if CallSite has been bound already:
   1.119 -  if (!pool->cache()->secondary_entry_at(site_index)->is_f1_null())
   1.120 -    return;
   1.121 -
   1.122 -  Symbol*  call_site_name = pool->name_ref_at(site_index);
   1.123 -
   1.124 -  Handle call_site
   1.125 -    = SystemDictionary::make_dynamic_call_site(bootm,
   1.126 -                                               // Callee information:
   1.127 -                                               call_site_name,
   1.128 -                                               signature_invoker,
   1.129 -                                               info,
   1.130 -                                               // Caller information:
   1.131 -                                               caller_method,
   1.132 -                                               caller_bci,
   1.133 -                                               CHECK);
   1.134 -
   1.135 -  // In the secondary entry, the f1 field is the call site, and the f2 (index)
   1.136 -  // field is some data about the invoke site.  Currently, it is just the BCI.
   1.137 -  // Later, it might be changed to help manage inlining dependencies.
   1.138 -  pool->cache()->secondary_entry_at(site_index)->set_dynamic_call(call_site, signature_invoker);
   1.139 +  pool->cache()->secondary_entry_at(index)->set_dynamic_call(
   1.140 +      info.resolved_method(),
   1.141 +      info.resolved_appendix());
   1.142  }
   1.143  IRT_END
   1.144  
   1.145 @@ -975,7 +943,7 @@
   1.146  
   1.147    // check the access_flags for the field in the klass
   1.148  
   1.149 -  instanceKlass* ik = instanceKlass::cast(java_lang_Class::as_klassOop(cp_entry->f1()));
   1.150 +  instanceKlass* ik = instanceKlass::cast(java_lang_Class::as_klassOop(cp_entry->f1_as_klass_mirror()));
   1.151    int index = cp_entry->field_index();
   1.152    if ((ik->field_access_flags(index) & JVM_ACC_FIELD_ACCESS_WATCHED) == 0) return;
   1.153  
   1.154 @@ -998,15 +966,15 @@
   1.155      // non-static field accessors have an object, but we need a handle
   1.156      h_obj = Handle(thread, obj);
   1.157    }
   1.158 -  instanceKlassHandle h_cp_entry_f1(thread, java_lang_Class::as_klassOop(cp_entry->f1()));
   1.159 -  jfieldID fid = jfieldIDWorkaround::to_jfieldID(h_cp_entry_f1, cp_entry->f2(), is_static);
   1.160 +  instanceKlassHandle h_cp_entry_f1(thread, java_lang_Class::as_klassOop(cp_entry->f1_as_klass_mirror()));
   1.161 +  jfieldID fid = jfieldIDWorkaround::to_jfieldID(h_cp_entry_f1, cp_entry->f2_as_index(), is_static);
   1.162    JvmtiExport::post_field_access(thread, method(thread), bcp(thread), h_cp_entry_f1, h_obj, fid);
   1.163  IRT_END
   1.164  
   1.165  IRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread *thread,
   1.166    oopDesc* obj, ConstantPoolCacheEntry *cp_entry, jvalue *value))
   1.167  
   1.168 -  klassOop k = java_lang_Class::as_klassOop(cp_entry->f1());
   1.169 +  klassOop k = java_lang_Class::as_klassOop(cp_entry->f1_as_klass_mirror());
   1.170  
   1.171    // check the access_flags for the field in the klass
   1.172    instanceKlass* ik = instanceKlass::cast(k);
   1.173 @@ -1031,7 +999,7 @@
   1.174  
   1.175    HandleMark hm(thread);
   1.176    instanceKlassHandle h_klass(thread, k);
   1.177 -  jfieldID fid = jfieldIDWorkaround::to_jfieldID(h_klass, cp_entry->f2(), is_static);
   1.178 +  jfieldID fid = jfieldIDWorkaround::to_jfieldID(h_klass, cp_entry->f2_as_index(), is_static);
   1.179    jvalue fvalue;
   1.180  #ifdef _LP64
   1.181    fvalue = *value;

mercurial