src/share/vm/oops/methodOop.cpp

changeset 1870
ef1a1d051971
parent 1853
77261afdc5f2
parent 1862
cd5dbf694d45
child 1907
c18cbe5936b8
     1.1 --- a/src/share/vm/oops/methodOop.cpp	Tue May 11 17:41:11 2010 -0700
     1.2 +++ b/src/share/vm/oops/methodOop.cpp	Wed May 12 22:06:02 2010 -0700
     1.3 @@ -306,7 +306,7 @@
     1.4  
     1.5  int methodOopDesc::extra_stack_words() {
     1.6    // not an inline function, to avoid a header dependency on Interpreter
     1.7 -  return extra_stack_entries() * Interpreter::stackElementSize();
     1.8 +  return extra_stack_entries() * Interpreter::stackElementSize;
     1.9  }
    1.10  
    1.11  
    1.12 @@ -807,9 +807,19 @@
    1.13    return false;
    1.14  }
    1.15  
    1.16 +bool methodOopDesc::is_method_handle_invoke_name(vmSymbols::SID name_sid) {
    1.17 +  switch (name_sid) {
    1.18 +  case vmSymbols::VM_SYMBOL_ENUM_NAME(invoke_name):  // FIXME: remove this transitional form
    1.19 +  case vmSymbols::VM_SYMBOL_ENUM_NAME(invokeExact_name):
    1.20 +  case vmSymbols::VM_SYMBOL_ENUM_NAME(invokeGeneric_name):
    1.21 +    return true;
    1.22 +  }
    1.23 +  return false;
    1.24 +}
    1.25 +
    1.26  // Constant pool structure for invoke methods:
    1.27  enum {
    1.28 -  _imcp_invoke_name = 1,        // utf8: 'invoke'
    1.29 +  _imcp_invoke_name = 1,        // utf8: 'invokeExact' or 'invokeGeneric'
    1.30    _imcp_invoke_signature,       // utf8: (variable symbolOop)
    1.31    _imcp_method_type_value,      // string: (variable java/dyn/MethodType, sic)
    1.32    _imcp_limit
    1.33 @@ -839,14 +849,15 @@
    1.34  //
    1.35  // Tests if this method is an internal adapter frame from the
    1.36  // MethodHandleCompiler.
    1.37 +// Must be consistent with MethodHandleCompiler::get_method_oop().
    1.38  bool methodOopDesc::is_method_handle_adapter() const {
    1.39 -  return ((name() == vmSymbols::invoke_name() &&
    1.40 -           method_holder() == SystemDictionary::MethodHandle_klass())
    1.41 -          ||
    1.42 -          method_holder() == SystemDictionary::InvokeDynamic_klass());
    1.43 +  return (is_method_handle_invoke_name(name()) &&
    1.44 +          is_synthetic() &&
    1.45 +          MethodHandleCompiler::klass_is_method_handle_adapter_holder(method_holder()));
    1.46  }
    1.47  
    1.48  methodHandle methodOopDesc::make_invoke_method(KlassHandle holder,
    1.49 +                                               symbolHandle name,
    1.50                                                 symbolHandle signature,
    1.51                                                 Handle method_type, TRAPS) {
    1.52    methodHandle empty;
    1.53 @@ -865,7 +876,7 @@
    1.54      constantPoolOop cp_oop = oopFactory::new_constantPool(_imcp_limit, IsSafeConc, CHECK_(empty));
    1.55      cp = constantPoolHandle(THREAD, cp_oop);
    1.56    }
    1.57 -  cp->symbol_at_put(_imcp_invoke_name,       vmSymbols::invoke_name());
    1.58 +  cp->symbol_at_put(_imcp_invoke_name,       name());
    1.59    cp->symbol_at_put(_imcp_invoke_signature,  signature());
    1.60    cp->string_at_put(_imcp_method_type_value, vmSymbols::void_signature());
    1.61    cp->set_pool_holder(holder());
    1.62 @@ -882,7 +893,7 @@
    1.63    m->set_constants(cp());
    1.64    m->set_name_index(_imcp_invoke_name);
    1.65    m->set_signature_index(_imcp_invoke_signature);
    1.66 -  assert(m->name() == vmSymbols::invoke_name(), "");
    1.67 +  assert(is_method_handle_invoke_name(m->name()), "");
    1.68    assert(m->signature() == signature(), "");
    1.69  #ifdef CC_INTERP
    1.70    ResultTypeFinder rtf(signature());
    1.71 @@ -1033,6 +1044,24 @@
    1.72        id = vmIntrinsics::find_id(klass_id, name_id, sig_id, flags);
    1.73        break;
    1.74      }
    1.75 +    break;
    1.76 +
    1.77 +  // Signature-polymorphic methods: MethodHandle.invoke*, InvokeDynamic.*.
    1.78 +  case vmSymbols::VM_SYMBOL_ENUM_NAME(java_dyn_MethodHandle):
    1.79 +    if (is_static() || !is_native())  break;
    1.80 +    switch (name_id) {
    1.81 +    case vmSymbols::VM_SYMBOL_ENUM_NAME(invokeGeneric_name):
    1.82 +      id = vmIntrinsics::_invokeGeneric; break;
    1.83 +    default:
    1.84 +      if (is_method_handle_invoke_name(name()))
    1.85 +        id = vmIntrinsics::_invokeExact;
    1.86 +      break;
    1.87 +    }
    1.88 +    break;
    1.89 +  case vmSymbols::VM_SYMBOL_ENUM_NAME(java_dyn_InvokeDynamic):
    1.90 +    if (!is_static() || !is_native())  break;
    1.91 +    id = vmIntrinsics::_invokeDynamic;
    1.92 +    break;
    1.93    }
    1.94  
    1.95    if (id != vmIntrinsics::_none) {

mercurial