13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_PRIMS_METHODHANDLES_HPP
26 #define SHARE_VM_PRIMS_METHODHANDLES_HPP
27
28 #include "classfile/javaClasses.hpp"
29 #include "classfile/vmSymbols.hpp"
30 #include "runtime/frame.inline.hpp"
31 #include "runtime/globals.hpp"
32 #include "runtime/interfaceSupport.hpp"
33
34 #ifdef TARGET_ARCH_zero
35 # include "entry_zero.hpp"
36 #endif
37
38
39
40 class MacroAssembler;
41 class Label;
42
43 class MethodHandles: AllStatic {
44 // JVM support for MethodHandle, MethodType, and related types
45 // in java.lang.invoke and sun.invoke.
46 // See also javaClasses for layouts java_lang_invoke_Method{Handle,Type,Type::Form}.
47 public:
48 public:
49 static bool enabled() { return _enabled; }
50 static void set_enabled(bool z);
51
52 private:
53 static bool _enabled;
54
55 // Adapters.
56 static MethodHandlesAdapterBlob* _adapter_code;
57
58 // utility functions for reifying names and types
59 static oop field_name_or_null(Symbol* s);
175 return (ref_kind <= JVM_REF_getStatic);
176 }
177 static bool ref_kind_is_setter(int ref_kind) {
178 return ref_kind_is_field(ref_kind) && !ref_kind_is_getter(ref_kind);
179 }
180 static bool ref_kind_is_method(int ref_kind) {
181 return !ref_kind_is_field(ref_kind) && (ref_kind != JVM_REF_newInvokeSpecial);
182 }
183 static bool ref_kind_has_receiver(int ref_kind) {
184 assert(ref_kind_is_valid(ref_kind), "");
185 return (ref_kind & 1) != 0;
186 }
187 static bool ref_kind_is_static(int ref_kind) {
188 return !ref_kind_has_receiver(ref_kind) && (ref_kind != JVM_REF_newInvokeSpecial);
189 }
190 static bool ref_kind_does_dispatch(int ref_kind) {
191 return (ref_kind == JVM_REF_invokeVirtual ||
192 ref_kind == JVM_REF_invokeInterface);
193 }
194
195
196 #ifdef TARGET_ARCH_x86
197 # include "methodHandles_x86.hpp"
198 #endif
199 #ifdef TARGET_ARCH_sparc
200 # include "methodHandles_sparc.hpp"
201 #endif
202 #ifdef TARGET_ARCH_zero
203 # include "methodHandles_zero.hpp"
204 #endif
205 #ifdef TARGET_ARCH_arm
206 # include "methodHandles_arm.hpp"
207 #endif
208 #ifdef TARGET_ARCH_ppc
209 # include "methodHandles_ppc.hpp"
210 #endif
211 #ifdef TARGET_ARCH_aarch64
212 # include "methodHandles_aarch64.hpp"
213 #endif
214
215 // Tracing
216 static void trace_method_handle(MacroAssembler* _masm, const char* adaptername) PRODUCT_RETURN;
217 static void trace_method_handle_interpreter_entry(MacroAssembler* _masm, vmIntrinsics::ID iid) {
218 if (TraceMethodHandles) {
219 const char* name = vmIntrinsics::name_at(iid);
220 if (*name == '_') name += 1;
221 const size_t len = strlen(name) + 50;
222 char* qname = NEW_C_HEAP_ARRAY(char, len, mtInternal);
223 const char* suffix = "";
224 if (is_signature_polymorphic(iid)) {
225 if (is_signature_polymorphic_static(iid))
226 suffix = "/static";
227 else
228 suffix = "/private";
229 }
230 jio_snprintf(qname, len, "MethodHandle::interpreter_entry::%s%s", name, suffix);
231 trace_method_handle(_masm, qname);
232 // Note: Don't free the allocated char array because it's used
233 // during runtime.
|
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_PRIMS_METHODHANDLES_HPP
26 #define SHARE_VM_PRIMS_METHODHANDLES_HPP
27
28 #include "classfile/javaClasses.hpp"
29 #include "classfile/vmSymbols.hpp"
30 #include "runtime/frame.inline.hpp"
31 #include "runtime/globals.hpp"
32 #include "runtime/interfaceSupport.hpp"
33 #include "utilities/macros.hpp"
34
35 #ifdef ZERO
36 # include "entry_zero.hpp"
37 #endif
38
39
40 class MacroAssembler;
41 class Label;
42
43 class MethodHandles: AllStatic {
44 // JVM support for MethodHandle, MethodType, and related types
45 // in java.lang.invoke and sun.invoke.
46 // See also javaClasses for layouts java_lang_invoke_Method{Handle,Type,Type::Form}.
47 public:
48 public:
49 static bool enabled() { return _enabled; }
50 static void set_enabled(bool z);
51
52 private:
53 static bool _enabled;
54
55 // Adapters.
56 static MethodHandlesAdapterBlob* _adapter_code;
57
58 // utility functions for reifying names and types
59 static oop field_name_or_null(Symbol* s);
175 return (ref_kind <= JVM_REF_getStatic);
176 }
177 static bool ref_kind_is_setter(int ref_kind) {
178 return ref_kind_is_field(ref_kind) && !ref_kind_is_getter(ref_kind);
179 }
180 static bool ref_kind_is_method(int ref_kind) {
181 return !ref_kind_is_field(ref_kind) && (ref_kind != JVM_REF_newInvokeSpecial);
182 }
183 static bool ref_kind_has_receiver(int ref_kind) {
184 assert(ref_kind_is_valid(ref_kind), "");
185 return (ref_kind & 1) != 0;
186 }
187 static bool ref_kind_is_static(int ref_kind) {
188 return !ref_kind_has_receiver(ref_kind) && (ref_kind != JVM_REF_newInvokeSpecial);
189 }
190 static bool ref_kind_does_dispatch(int ref_kind) {
191 return (ref_kind == JVM_REF_invokeVirtual ||
192 ref_kind == JVM_REF_invokeInterface);
193 }
194
195 #include CPU_HEADER(methodHandles)
196
197 // Tracing
198 static void trace_method_handle(MacroAssembler* _masm, const char* adaptername) PRODUCT_RETURN;
199 static void trace_method_handle_interpreter_entry(MacroAssembler* _masm, vmIntrinsics::ID iid) {
200 if (TraceMethodHandles) {
201 const char* name = vmIntrinsics::name_at(iid);
202 if (*name == '_') name += 1;
203 const size_t len = strlen(name) + 50;
204 char* qname = NEW_C_HEAP_ARRAY(char, len, mtInternal);
205 const char* suffix = "";
206 if (is_signature_polymorphic(iid)) {
207 if (is_signature_polymorphic_static(iid))
208 suffix = "/static";
209 else
210 suffix = "/private";
211 }
212 jio_snprintf(qname, len, "MethodHandle::interpreter_entry::%s%s", name, suffix);
213 trace_method_handle(_masm, qname);
214 // Note: Don't free the allocated char array because it's used
215 // during runtime.
|