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); 60 static oop field_signature_type_or_null(Symbol* s); 61 62 public: 63 // working with member names 64 static Handle resolve_MemberName(Handle mname, Klass* caller, TRAPS); // compute vmtarget/vmindex from name/type 65 static void expand_MemberName(Handle mname, int suppress, TRAPS); // expand defc/name/type if missing 66 static oop init_MemberName(Handle mname_h, Handle target_h, TRAPS); // compute vmtarget/vmindex from target 67 static oop init_field_MemberName(Handle mname_h, fieldDescriptor& fd, bool is_setter = false); 68 static oop init_method_MemberName(Handle mname_h, CallInfo& info); 69 static int method_ref_kind(Method* m, bool do_dispatch_if_possible = true); 70 static int find_MemberNames(Klass* k, Symbol* name, Symbol* sig, 71 int mflags, Klass* caller, 72 int skip, objArrayHandle results, TRAPS); 73 // bit values for suppress argument to expand_MemberName: 74 enum { _suppress_defc = 1, _suppress_name = 2, _suppress_type = 4 }; 75 76 // CallSite support 77 static void add_dependent_nmethod(oop call_site, nmethod* nm); 78 static void remove_dependent_nmethod(oop call_site, nmethod* nm); 79 80 static void flush_dependent_nmethods(Handle call_site, Handle target); 81 82 // Generate MethodHandles adapters. 83 static void generate_adapters(); 84 85 // Called from MethodHandlesAdapterGenerator. 86 static address generate_method_handle_interpreter_entry(MacroAssembler* _masm, vmIntrinsics::ID iid); 87 static void generate_method_handle_dispatch(MacroAssembler* _masm, 88 vmIntrinsics::ID iid, 89 Register receiver_reg, 90 Register member_reg, 91 bool for_compiler_entry); 92 174 return (ref_kind <= JVM_REF_getStatic); 175 } 176 static bool ref_kind_is_setter(int ref_kind) { 177 return ref_kind_is_field(ref_kind) && !ref_kind_is_getter(ref_kind); 178 } 179 static bool ref_kind_is_method(int ref_kind) { 180 return !ref_kind_is_field(ref_kind) && (ref_kind != JVM_REF_newInvokeSpecial); 181 } 182 static bool ref_kind_has_receiver(int ref_kind) { 183 assert(ref_kind_is_valid(ref_kind), ""); 184 return (ref_kind & 1) != 0; 185 } 186 static bool ref_kind_is_static(int ref_kind) { 187 return !ref_kind_has_receiver(ref_kind) && (ref_kind != JVM_REF_newInvokeSpecial); 188 } 189 static bool ref_kind_does_dispatch(int ref_kind) { 190 return (ref_kind == JVM_REF_invokeVirtual || 191 ref_kind == JVM_REF_invokeInterface); 192 } 193 194 #include CPU_HEADER(methodHandles) 195 196 // Tracing 197 static void trace_method_handle(MacroAssembler* _masm, const char* adaptername) PRODUCT_RETURN; 198 static void trace_method_handle_interpreter_entry(MacroAssembler* _masm, vmIntrinsics::ID iid); 199 }; 200 201 //------------------------------------------------------------------------------ 202 // MethodHandlesAdapterGenerator 203 // 204 class MethodHandlesAdapterGenerator : public StubCodeGenerator { 205 public: 206 MethodHandlesAdapterGenerator(CodeBuffer* code) : StubCodeGenerator(code, PrintMethodHandleStubs) {} 207 208 void generate(); 209 }; 210 211 #endif // SHARE_VM_PRIMS_METHODHANDLES_HPP | 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); 60 static oop field_signature_type_or_null(Symbol* s); 61 62 public: 63 // working with member names 64 static Handle resolve_MemberName(Handle mname, Klass* caller, TRAPS); // compute vmtarget/vmindex from name/type 65 static void expand_MemberName(Handle mname, int suppress, TRAPS); // expand defc/name/type if missing 66 static oop init_MemberName(Handle mname_h, Handle target_h, TRAPS); // compute vmtarget/vmindex from target 67 static oop init_field_MemberName(Handle mname_h, fieldDescriptor& fd, bool is_setter = false); 68 static oop init_method_MemberName(Handle mname_h, CallInfo& info); 69 static int method_ref_kind(Method* m, bool do_dispatch_if_possible = true); 70 static int find_MemberNames(Klass* k, Symbol* name, Symbol* sig, 71 int mflags, Klass* caller, 72 int skip, objArrayHandle results, TRAPS); 73 static Handle resolve_MemberName_type(Handle mname, Klass* caller, TRAPS); 74 75 // bit values for suppress argument to expand_MemberName: 76 enum { _suppress_defc = 1, _suppress_name = 2, _suppress_type = 4 }; 77 78 // CallSite support 79 static void add_dependent_nmethod(oop call_site, nmethod* nm); 80 static void remove_dependent_nmethod(oop call_site, nmethod* nm); 81 82 static void flush_dependent_nmethods(Handle call_site, Handle target); 83 84 // Generate MethodHandles adapters. 85 static void generate_adapters(); 86 87 // Called from MethodHandlesAdapterGenerator. 88 static address generate_method_handle_interpreter_entry(MacroAssembler* _masm, vmIntrinsics::ID iid); 89 static void generate_method_handle_dispatch(MacroAssembler* _masm, 90 vmIntrinsics::ID iid, 91 Register receiver_reg, 92 Register member_reg, 93 bool for_compiler_entry); 94 176 return (ref_kind <= JVM_REF_getStatic); 177 } 178 static bool ref_kind_is_setter(int ref_kind) { 179 return ref_kind_is_field(ref_kind) && !ref_kind_is_getter(ref_kind); 180 } 181 static bool ref_kind_is_method(int ref_kind) { 182 return !ref_kind_is_field(ref_kind) && (ref_kind != JVM_REF_newInvokeSpecial); 183 } 184 static bool ref_kind_has_receiver(int ref_kind) { 185 assert(ref_kind_is_valid(ref_kind), ""); 186 return (ref_kind & 1) != 0; 187 } 188 static bool ref_kind_is_static(int ref_kind) { 189 return !ref_kind_has_receiver(ref_kind) && (ref_kind != JVM_REF_newInvokeSpecial); 190 } 191 static bool ref_kind_does_dispatch(int ref_kind) { 192 return (ref_kind == JVM_REF_invokeVirtual || 193 ref_kind == JVM_REF_invokeInterface); 194 } 195 196 static int ref_kind_to_flags(int ref_kind); 197 198 #include CPU_HEADER(methodHandles) 199 200 // Tracing 201 static void trace_method_handle(MacroAssembler* _masm, const char* adaptername) PRODUCT_RETURN; 202 static void trace_method_handle_interpreter_entry(MacroAssembler* _masm, vmIntrinsics::ID iid); 203 }; 204 205 //------------------------------------------------------------------------------ 206 // MethodHandlesAdapterGenerator 207 // 208 class MethodHandlesAdapterGenerator : public StubCodeGenerator { 209 public: 210 MethodHandlesAdapterGenerator(CodeBuffer* code) : StubCodeGenerator(code, PrintMethodHandleStubs) {} 211 212 void generate(); 213 }; 214 215 #endif // SHARE_VM_PRIMS_METHODHANDLES_HPP |