hotspot/src/share/vm/prims/methodHandles.hpp
author sspitsyn
Thu, 23 May 2013 23:04:33 -0700
changeset 17828 17131ab4b3b5
parent 17029 9ff8d7c0ed79
child 20017 81eba62e9048
permissions -rw-r--r--
8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes Summary: The fix of perf regression is to use method_idnum() for direct indexing into NMT Reviewed-by: twisti, kvn, coleenp, dholmes Contributed-by: serguei.spitsyn@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     1
/*
17828
17131ab4b3b5 8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes
sspitsyn
parents: 17029
diff changeset
     2
 * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     4
 *
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     7
 * published by the Free Software Foundation.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     8
 *
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    13
 * accompanied this code).
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    14
 *
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5420
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5420
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5420
diff changeset
    21
 * questions.
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    22
 *
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    23
 */
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    25
#ifndef SHARE_VM_PRIMS_METHODHANDLES_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    26
#define SHARE_VM_PRIMS_METHODHANDLES_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    28
#include "classfile/javaClasses.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    29
#include "classfile/vmSymbols.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    30
#include "runtime/frame.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    31
#include "runtime/globals.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    32
#include "runtime/interfaceSupport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    33
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    34
class MacroAssembler;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    35
class Label;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    36
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    37
class MethodHandles: AllStatic {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    38
  // JVM support for MethodHandle, MethodType, and related types
8676
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    39
  // in java.lang.invoke and sun.invoke.
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    40
  // See also  javaClasses for layouts java_lang_invoke_Method{Handle,Type,Type::Form}.
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    41
 public:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    42
 public:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    43
  static bool enabled()                         { return _enabled; }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    44
  static void set_enabled(bool z);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    45
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    46
 private:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    47
  static bool _enabled;
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
    48
5050
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
    49
  // Adapters.
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
    50
  static MethodHandlesAdapterBlob* _adapter_code;
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
    51
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    52
 public:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    53
  // working with member names
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    54
  static Handle resolve_MemberName(Handle mname, TRAPS); // compute vmtarget/vmindex from name/type
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    55
  static void expand_MemberName(Handle mname, int suppress, TRAPS);  // expand defc/name/type if missing
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
    56
  static Handle new_MemberName(TRAPS);  // must be followed by init_MemberName
17029
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
    57
  static oop init_MemberName(Handle mname_h, Handle target_h); // compute vmtarget/vmindex from target
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
    58
  static oop init_method_MemberName(Handle mname_h, Method* m, bool do_dispatch,
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
    59
                                    KlassHandle receiver_limit_h);
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
    60
  static oop init_field_MemberName(Handle mname_h, KlassHandle field_holder_h,
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    61
                                   AccessFlags mods, oop type, oop name,
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    62
                                   intptr_t offset, bool is_setter = false);
17029
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
    63
  static Handle init_method_MemberName(Handle mname_h, CallInfo& info, TRAPS);
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
    64
  static Handle init_field_MemberName(Handle mname_h, FieldAccessInfo& info, TRAPS);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    65
  static int method_ref_kind(Method* m, bool do_dispatch_if_possible = true);
17029
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
    66
  static int find_MemberNames(KlassHandle k, Symbol* name, Symbol* sig,
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
    67
                              int mflags, KlassHandle caller,
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
    68
                              int skip, objArrayHandle results);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    69
  // bit values for suppress argument to expand_MemberName:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    70
  enum { _suppress_defc = 1, _suppress_name = 2, _suppress_type = 4 };
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    71
5050
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
    72
  // Generate MethodHandles adapters.
17029
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
    73
                              static void generate_adapters();
5050
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
    74
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    75
  // Called from MethodHandlesAdapterGenerator.
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    76
  static address generate_method_handle_interpreter_entry(MacroAssembler* _masm, vmIntrinsics::ID iid);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    77
  static void generate_method_handle_dispatch(MacroAssembler* _masm,
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    78
                                              vmIntrinsics::ID iid,
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    79
                                              Register receiver_reg,
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    80
                                              Register member_reg,
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    81
                                              bool for_compiler_entry);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    82
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    83
  // Queries
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    84
  static bool is_signature_polymorphic(vmIntrinsics::ID iid) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    85
    return (iid >= vmIntrinsics::FIRST_MH_SIG_POLY &&
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    86
            iid <= vmIntrinsics::LAST_MH_SIG_POLY);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    87
  }
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    88
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    89
  static bool is_signature_polymorphic_intrinsic(vmIntrinsics::ID iid) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    90
    assert(is_signature_polymorphic(iid), "");
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    91
    // Most sig-poly methods are intrinsics which do not require an
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    92
    // appeal to Java for adapter code.
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    93
    return (iid != vmIntrinsics::_invokeGeneric);
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
    94
  }
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
    95
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    96
  static bool is_signature_polymorphic_static(vmIntrinsics::ID iid) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    97
    assert(is_signature_polymorphic(iid), "");
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    98
    return (iid >= vmIntrinsics::FIRST_MH_STATIC &&
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    99
            iid <= vmIntrinsics::LAST_MH_SIG_POLY);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   100
  }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   101
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   102
  static bool has_member_arg(vmIntrinsics::ID iid) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   103
    assert(is_signature_polymorphic(iid), "");
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   104
    return (iid >= vmIntrinsics::_linkToVirtual &&
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   105
            iid <= vmIntrinsics::_linkToInterface);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   106
  }
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   107
  static bool has_member_arg(Symbol* klass, Symbol* name) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   108
    if ((klass == vmSymbols::java_lang_invoke_MethodHandle()) &&
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   109
        is_signature_polymorphic_name(name)) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   110
      vmIntrinsics::ID iid = signature_polymorphic_name_id(name);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   111
      return has_member_arg(iid);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   112
    }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   113
    return false;
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   114
  }
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   115
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   116
  static Symbol* signature_polymorphic_intrinsic_name(vmIntrinsics::ID iid);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   117
  static int signature_polymorphic_intrinsic_ref_kind(vmIntrinsics::ID iid);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   118
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   119
  static vmIntrinsics::ID signature_polymorphic_name_id(Klass* klass, Symbol* name);
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   120
  static vmIntrinsics::ID signature_polymorphic_name_id(Symbol* name);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   121
  static bool is_signature_polymorphic_name(Symbol* name) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   122
    return signature_polymorphic_name_id(name) != vmIntrinsics::_none;
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   123
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   124
  static bool is_method_handle_invoke_name(Klass* klass, Symbol* name);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   125
  static bool is_signature_polymorphic_name(Klass* klass, Symbol* name) {
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   126
    return signature_polymorphic_name_id(klass, name) != vmIntrinsics::_none;
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   127
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   128
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   129
  enum {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   130
    // format of query to getConstant:
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   131
    GC_COUNT_GWT = 4,
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   132
    GC_LAMBDA_SUPPORT = 5
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   133
  };
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   134
  static int get_named_constant(int which, Handle name_box, TRAPS);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   135
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   136
public:
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   137
  static Symbol* lookup_signature(oop type_str, bool polymorphic, TRAPS);  // use TempNewSymbol
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   138
  static Symbol* lookup_basic_type_signature(Symbol* sig, bool keep_last_arg, TRAPS);  // use TempNewSymbol
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   139
  static Symbol* lookup_basic_type_signature(Symbol* sig, TRAPS) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   140
    return lookup_basic_type_signature(sig, false, THREAD);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   141
  }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   142
  static bool is_basic_type_signature(Symbol* sig);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   143
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   144
  static Symbol* lookup_method_type(Symbol* msig, Handle mtype, TRAPS);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   145
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   146
  static void print_as_method_type_on(outputStream* st, Symbol* sig) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   147
    print_as_basic_type_signature_on(st, sig, true, true);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   148
  }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   149
  static void print_as_basic_type_signature_on(outputStream* st, Symbol* sig, bool keep_arrays = false, bool keep_basic_names = false);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   150
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   151
  // decoding CONSTANT_MethodHandle constants
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   152
  enum { JVM_REF_MIN = JVM_REF_getField, JVM_REF_MAX = JVM_REF_invokeInterface };
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   153
  static bool ref_kind_is_valid(int ref_kind) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   154
    return (ref_kind >= JVM_REF_MIN && ref_kind <= JVM_REF_MAX);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   155
  }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   156
  static bool ref_kind_is_field(int ref_kind) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   157
    assert(ref_kind_is_valid(ref_kind), "");
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   158
    return (ref_kind <= JVM_REF_putStatic);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   159
  }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   160
  static bool ref_kind_is_getter(int ref_kind) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   161
    assert(ref_kind_is_valid(ref_kind), "");
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   162
    return (ref_kind <= JVM_REF_getStatic);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   163
  }
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   164
  static bool ref_kind_is_setter(int ref_kind) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   165
    return ref_kind_is_field(ref_kind) && !ref_kind_is_getter(ref_kind);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   166
  }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   167
  static bool ref_kind_is_method(int ref_kind) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   168
    return !ref_kind_is_field(ref_kind) && (ref_kind != JVM_REF_newInvokeSpecial);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   169
  }
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   170
  static bool ref_kind_has_receiver(int ref_kind) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   171
    assert(ref_kind_is_valid(ref_kind), "");
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   172
    return (ref_kind & 1) != 0;
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   173
  }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   174
  static bool ref_kind_is_static(int ref_kind) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   175
    return !ref_kind_has_receiver(ref_kind) && (ref_kind != JVM_REF_newInvokeSpecial);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   176
  }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   177
  static bool ref_kind_does_dispatch(int ref_kind) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   178
    return (ref_kind == JVM_REF_invokeVirtual ||
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   179
            ref_kind == JVM_REF_invokeInterface);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   180
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   181
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   182
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   183
#ifdef TARGET_ARCH_x86
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   184
# include "methodHandles_x86.hpp"
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   185
#endif
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   186
#ifdef TARGET_ARCH_sparc
9976
6fef34e63df1 7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents: 9967
diff changeset
   187
# include "methodHandles_sparc.hpp"
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   188
#endif
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   189
#ifdef TARGET_ARCH_zero
9976
6fef34e63df1 7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents: 9967
diff changeset
   190
# include "methodHandles_zero.hpp"
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   191
#endif
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   192
#ifdef TARGET_ARCH_arm
9943
a9aea2b8010f 7045515: ARM assembly code for JSR 292 ricochet frames
bdelsart
parents: 9638
diff changeset
   193
# include "methodHandles_arm.hpp"
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   194
#endif
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   195
#ifdef TARGET_ARCH_ppc
9943
a9aea2b8010f 7045515: ARM assembly code for JSR 292 ricochet frames
bdelsart
parents: 9638
diff changeset
   196
# include "methodHandles_ppc.hpp"
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   197
#endif
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   198
13968
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   199
  // Tracing
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   200
  static void trace_method_handle(MacroAssembler* _masm, const char* adaptername) PRODUCT_RETURN;
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   201
  static void trace_method_handle_interpreter_entry(MacroAssembler* _masm, vmIntrinsics::ID iid) {
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   202
    if (TraceMethodHandles) {
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   203
      const char* name = vmIntrinsics::name_at(iid);
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   204
      if (*name == '_')  name += 1;
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   205
      const size_t len = strlen(name) + 50;
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   206
      char* qname = NEW_C_HEAP_ARRAY(char, len, mtInternal);
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   207
      const char* suffix = "";
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   208
      if (is_signature_polymorphic(iid)) {
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   209
        if (is_signature_polymorphic_static(iid))
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   210
          suffix = "/static";
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   211
        else
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   212
          suffix = "/private";
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   213
      }
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   214
      jio_snprintf(qname, len, "MethodHandle::interpreter_entry::%s%s", name, suffix);
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   215
      trace_method_handle(_masm, qname);
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   216
      // Note:  Don't free the allocated char array because it's used
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   217
      // during runtime.
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   218
    }
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   219
  }
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   220
};
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   221
5050
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   222
//------------------------------------------------------------------------------
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   223
// MethodHandlesAdapterGenerator
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   224
//
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   225
class MethodHandlesAdapterGenerator : public StubCodeGenerator {
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   226
public:
9980
a330de5dea17 7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents: 9976
diff changeset
   227
  MethodHandlesAdapterGenerator(CodeBuffer* code) : StubCodeGenerator(code, PrintMethodHandleStubs) {}
5050
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   228
7887
7aa0354cbf25 7010180: JSR 292 InvokeDynamicPrintArgs fails with: assert(_adapter == NULL) failed: init'd to NULL
twisti
parents: 7712
diff changeset
   229
  void generate();
5050
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   230
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
   231
17029
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   232
//------------------------------------------------------------------------------
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   233
// MemberNameTable
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   234
//
17828
17131ab4b3b5 8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes
sspitsyn
parents: 17029
diff changeset
   235
17029
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   236
class MemberNameTable : public GrowableArray<jweak> {
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   237
 public:
17828
17131ab4b3b5 8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes
sspitsyn
parents: 17029
diff changeset
   238
  MemberNameTable(int methods_cnt);
17029
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   239
  ~MemberNameTable();
17828
17131ab4b3b5 8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes
sspitsyn
parents: 17029
diff changeset
   240
  void add_member_name(int index, jweak mem_name_ref);
17131ab4b3b5 8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes
sspitsyn
parents: 17029
diff changeset
   241
  oop  get_member_name(int index);
17029
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   242
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   243
#if INCLUDE_JVMTI
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   244
 public:
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   245
  // RedefineClasses() API support:
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   246
  // If a MemberName refers to old_method then update it
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   247
  // to refer to new_method.
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   248
  void adjust_method_entries(Method** old_methods, Method** new_methods,
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   249
                             int methods_length, bool *trace_name_printed);
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   250
 private:
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   251
  oop find_member_name_by_method(Method* old_method);
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   252
#endif // INCLUDE_JVMTI
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   253
};
9ff8d7c0ed79 8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents: 13968
diff changeset
   254
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
   255
#endif // SHARE_VM_PRIMS_METHODHANDLES_HPP