src/hotspot/share/prims/methodHandles.hpp
author coleenp
Thu, 10 Jan 2019 15:13:51 -0500
changeset 53244 9807daeb47c4
parent 52781 436097b038a1
child 53547 9d1a788dea3d
permissions -rw-r--r--
8216167: Update include guards to reflect correct directories Summary: Use script and some manual fixup to fix directores names in include guards. Reviewed-by: lfoltan, eosterlund, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52781
diff changeset
     2
 * Copyright (c) 2008, 2019, 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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52781
diff changeset
    25
#ifndef SHARE_PRIMS_METHODHANDLES_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52781
diff changeset
    26
#define SHARE_PRIMS_METHODHANDLES_HPP
7397
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"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49449
diff changeset
    30
#include "runtime/frame.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    31
#include "runtime/globals.hpp"
40010
e32d5e545789 8161258: Simplify including platform files.
goetz
parents: 39289
diff changeset
    32
#include "utilities/macros.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    33
40010
e32d5e545789 8161258: Simplify including platform files.
goetz
parents: 39289
diff changeset
    34
#ifdef ZERO
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 31037
diff changeset
    35
# include "entry_zero.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49449
diff changeset
    36
# include "interpreter/interpreter.hpp"
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 31037
diff changeset
    37
#endif
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 31037
diff changeset
    38
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 31037
diff changeset
    39
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    40
class MacroAssembler;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    41
class Label;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    42
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    43
class MethodHandles: AllStatic {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    44
  // 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
    45
  // 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
    46
  // 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
    47
 public:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    48
 public:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    49
  static bool enabled()                         { return _enabled; }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    50
  static void set_enabled(bool z);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    51
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    52
 private:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    53
  static bool _enabled;
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
    54
5050
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
    55
  // Adapters.
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
    56
  static MethodHandlesAdapterBlob* _adapter_code;
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
    57
20017
81eba62e9048 8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents: 17828
diff changeset
    58
  // utility functions for reifying names and types
81eba62e9048 8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents: 17828
diff changeset
    59
  static oop field_name_or_null(Symbol* s);
81eba62e9048 8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents: 17828
diff changeset
    60
  static oop field_signature_type_or_null(Symbol* s);
81eba62e9048 8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents: 17828
diff changeset
    61
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    62
 public:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    63
  // working with member names
49641
2ad3212a7dd9 8200238: Reduce number of exceptions created when calling MemberName$Factory::resolveOrNull
redestad
parents: 49480
diff changeset
    64
  static Handle resolve_MemberName(Handle mname, Klass* caller,
2ad3212a7dd9 8200238: Reduce number of exceptions created when calling MemberName$Factory::resolveOrNull
redestad
parents: 49480
diff changeset
    65
                                   bool speculative_resolve, TRAPS); // compute vmtarget/vmindex from name/type
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    66
  static void expand_MemberName(Handle mname, int suppress, TRAPS);  // expand defc/name/type if missing
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents: 46329
diff changeset
    67
  static oop init_MemberName(Handle mname_h, Handle target_h, TRAPS); // compute vmtarget/vmindex from target
20017
81eba62e9048 8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents: 17828
diff changeset
    68
  static oop init_field_MemberName(Handle mname_h, fieldDescriptor& fd, bool is_setter = false);
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents: 46329
diff changeset
    69
  static oop init_method_MemberName(Handle mname_h, CallInfo& info);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    70
  static int method_ref_kind(Method* m, bool do_dispatch_if_possible = true);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43929
diff changeset
    71
  static int find_MemberNames(Klass* k, Symbol* name, Symbol* sig,
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43929
diff changeset
    72
                              int mflags, Klass* caller,
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents: 46329
diff changeset
    73
                              int skip, objArrayHandle results, TRAPS);
48514
9608f7f41c4e 8188145: MethodHandle resolution should follow JVMS sequence of lookup by name & type before type descriptor resolution
vlivanov
parents: 48157
diff changeset
    74
  static Handle resolve_MemberName_type(Handle mname, Klass* caller, TRAPS);
9608f7f41c4e 8188145: MethodHandle resolution should follow JVMS sequence of lookup by name & type before type descriptor resolution
vlivanov
parents: 48157
diff changeset
    75
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    76
  // bit values for suppress argument to expand_MemberName:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    77
  enum { _suppress_defc = 1, _suppress_name = 2, _suppress_type = 4 };
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    78
30296
95baefac8485 8057967: CallSite dependency tracking scales devastatingly poorly
vlivanov
parents: 30224
diff changeset
    79
  // CallSite support
31037
01a5c5fa5681 8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents: 30310
diff changeset
    80
  static void add_dependent_nmethod(oop call_site, nmethod* nm);
01a5c5fa5681 8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents: 30310
diff changeset
    81
  static void remove_dependent_nmethod(oop call_site, nmethod* nm);
52781
436097b038a1 8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents: 50771
diff changeset
    82
  static void clean_dependency_context(oop call_site);
31037
01a5c5fa5681 8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents: 30310
diff changeset
    83
01a5c5fa5681 8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents: 30310
diff changeset
    84
  static void flush_dependent_nmethods(Handle call_site, Handle target);
30296
95baefac8485 8057967: CallSite dependency tracking scales devastatingly poorly
vlivanov
parents: 30224
diff changeset
    85
5050
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
    86
  // Generate MethodHandles adapters.
36074
11263906664c 8138922: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list
vlivanov
parents: 35232
diff changeset
    87
  static void generate_adapters();
5050
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
    88
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    89
  // Called from MethodHandlesAdapterGenerator.
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    90
  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
    91
  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
    92
                                              vmIntrinsics::ID iid,
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    93
                                              Register receiver_reg,
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    94
                                              Register member_reg,
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    95
                                              bool for_compiler_entry);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    96
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    97
  // Queries
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
    98
  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
    99
    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
   100
            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
   101
  }
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   102
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 31037
diff changeset
   103
  static bool is_signature_polymorphic_method(Method* m) {
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 31037
diff changeset
   104
    return is_signature_polymorphic(m->intrinsic_id());
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 31037
diff changeset
   105
  }
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 31037
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 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
   108
    assert(is_signature_polymorphic(iid), "");
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   109
    // 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
   110
    // 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
   111
    return (iid != vmIntrinsics::_invokeGeneric);
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   112
  }
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   113
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   114
  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
   115
    assert(is_signature_polymorphic(iid), "");
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   116
    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
   117
            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
   118
  }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   119
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   120
  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
   121
    assert(is_signature_polymorphic(iid), "");
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   122
    return (iid >= vmIntrinsics::_linkToVirtual &&
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   123
            iid <= vmIntrinsics::_linkToInterface);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   124
  }
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   125
  static bool has_member_arg(Symbol* klass, Symbol* name) {
36819
bca375d368ed 8149644: Integrate VarHandles
psandoz
parents: 36074
diff changeset
   126
    if ((klass == vmSymbols::java_lang_invoke_MethodHandle() ||
bca375d368ed 8149644: Integrate VarHandles
psandoz
parents: 36074
diff changeset
   127
         klass == vmSymbols::java_lang_invoke_VarHandle()) &&
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   128
        is_signature_polymorphic_name(name)) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   129
      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
   130
      return has_member_arg(iid);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   131
    }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   132
    return false;
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   133
  }
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   134
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   135
  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
   136
  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
   137
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   138
  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
   139
  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
   140
  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
   141
    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
   142
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   143
  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
   144
  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
   145
    return signature_polymorphic_name_id(klass, name) != vmIntrinsics::_none;
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   146
  }
50771
9ca95539747d 8195650: Method references to VarHandle accessors
psandoz
parents: 49641
diff changeset
   147
  static bool is_signature_polymorphic_public_name(Klass* klass, Symbol* name);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   148
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 31037
diff changeset
   149
  static Bytecodes::Code signature_polymorphic_intrinsic_bytecode(vmIntrinsics::ID id);
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 31037
diff changeset
   150
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   151
  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
   152
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   153
public:
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   154
  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
   155
  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
   156
  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
   157
    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
   158
  }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   159
  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
   160
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   161
  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
   162
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   163
  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
   164
    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
   165
  }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   166
  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
   167
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   168
  // decoding CONSTANT_MethodHandle constants
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   169
  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
   170
  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
   171
    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
   172
  }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   173
  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
   174
    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
   175
    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
   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_is_getter(int ref_kind) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   178
    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
   179
    return (ref_kind <= JVM_REF_getStatic);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   180
  }
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   181
  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
   182
    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
   183
  }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   184
  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
   185
    return !ref_kind_is_field(ref_kind) && (ref_kind != JVM_REF_newInvokeSpecial);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   186
  }
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   187
  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
   188
    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
   189
    return (ref_kind & 1) != 0;
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   190
  }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   191
  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
   192
    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
   193
  }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11487
diff changeset
   194
  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
   195
    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
   196
            ref_kind == JVM_REF_invokeInterface);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   197
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   198
48514
9608f7f41c4e 8188145: MethodHandle resolution should follow JVMS sequence of lookup by name & type before type descriptor resolution
vlivanov
parents: 48157
diff changeset
   199
  static int ref_kind_to_flags(int ref_kind);
9608f7f41c4e 8188145: MethodHandle resolution should follow JVMS sequence of lookup by name & type before type descriptor resolution
vlivanov
parents: 48157
diff changeset
   200
40010
e32d5e545789 8161258: Simplify including platform files.
goetz
parents: 39289
diff changeset
   201
#include CPU_HEADER(methodHandles)
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   202
13968
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   203
  // Tracing
8c9029c01470 8000263: JSR 292: signature types may appear to be unloaded
twisti
parents: 13728
diff changeset
   204
  static void trace_method_handle(MacroAssembler* _masm, const char* adaptername) PRODUCT_RETURN;
48157
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
   205
  static void trace_method_handle_interpreter_entry(MacroAssembler* _masm, vmIntrinsics::ID iid);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   206
};
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   207
5050
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   208
//------------------------------------------------------------------------------
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   209
// MethodHandlesAdapterGenerator
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   210
//
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   211
class MethodHandlesAdapterGenerator : public StubCodeGenerator {
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   212
public:
9980
a330de5dea17 7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents: 9976
diff changeset
   213
  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
   214
7887
7aa0354cbf25 7010180: JSR 292 InvokeDynamicPrintArgs fails with: assert(_adapter == NULL) failed: init'd to NULL
twisti
parents: 7712
diff changeset
   215
  void generate();
5050
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   216
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
   217
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52781
diff changeset
   218
#endif // SHARE_PRIMS_METHODHANDLES_HPP