annotate src/share/vm/prims/methodHandles.hpp @ 12355:cefad50507d8

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