Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/sharedRuntime.cpp @ 6275:957c266d8bc5
Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 21 Aug 2012 10:39:19 +0200 |
parents | a432e6d43aa1 93c71eb28866 |
children | e522a00b91aa |
comparison
equal
deleted
inserted
replaced
5891:fd8832ae511d | 6275:957c266d8bc5 |
---|---|
86 RuntimeStub* SharedRuntime::_resolve_opt_virtual_call_blob; | 86 RuntimeStub* SharedRuntime::_resolve_opt_virtual_call_blob; |
87 RuntimeStub* SharedRuntime::_resolve_virtual_call_blob; | 87 RuntimeStub* SharedRuntime::_resolve_virtual_call_blob; |
88 RuntimeStub* SharedRuntime::_resolve_static_call_blob; | 88 RuntimeStub* SharedRuntime::_resolve_static_call_blob; |
89 | 89 |
90 DeoptimizationBlob* SharedRuntime::_deopt_blob; | 90 DeoptimizationBlob* SharedRuntime::_deopt_blob; |
91 RicochetBlob* SharedRuntime::_ricochet_blob; | |
92 | |
93 SafepointBlob* SharedRuntime::_polling_page_safepoint_handler_blob; | 91 SafepointBlob* SharedRuntime::_polling_page_safepoint_handler_blob; |
94 SafepointBlob* SharedRuntime::_polling_page_return_handler_blob; | 92 SafepointBlob* SharedRuntime::_polling_page_return_handler_blob; |
95 | 93 |
96 #ifdef COMPILER2 | 94 #ifdef COMPILER2 |
97 UncommonTrapBlob* SharedRuntime::_uncommon_trap_blob; | 95 UncommonTrapBlob* SharedRuntime::_uncommon_trap_blob; |
107 _resolve_static_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_static_call_C), "resolve_static_call"); | 105 _resolve_static_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_static_call_C), "resolve_static_call"); |
108 | 106 |
109 _polling_page_safepoint_handler_blob = generate_handler_blob(CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception), false); | 107 _polling_page_safepoint_handler_blob = generate_handler_blob(CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception), false); |
110 _polling_page_return_handler_blob = generate_handler_blob(CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception), true); | 108 _polling_page_return_handler_blob = generate_handler_blob(CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception), true); |
111 | 109 |
112 generate_ricochet_blob(); | |
113 generate_deopt_blob(); | 110 generate_deopt_blob(); |
114 | 111 |
115 #ifdef COMPILER2 | 112 #ifdef COMPILER2 |
116 generate_uncommon_trap_blob(); | 113 generate_uncommon_trap_blob(); |
117 #endif // COMPILER2 | 114 #endif // COMPILER2 |
118 } | 115 } |
119 | |
120 //----------------------------generate_ricochet_blob--------------------------- | |
121 void SharedRuntime::generate_ricochet_blob() { | |
122 if (!EnableInvokeDynamic) return; // leave it as a null | |
123 | |
124 // allocate space for the code | |
125 ResourceMark rm; | |
126 // setup code generation tools | |
127 CodeBuffer buffer("ricochet_blob", 256 LP64_ONLY(+ 256), 256); // XXX x86 LP64L: 512, 512 | |
128 MacroAssembler* masm = new MacroAssembler(&buffer); | |
129 | |
130 int bounce_offset = -1, exception_offset = -1, frame_size_in_words = -1; | |
131 MethodHandles::RicochetFrame::generate_ricochet_blob(masm, &bounce_offset, &exception_offset, &frame_size_in_words); | |
132 | |
133 // ------------- | |
134 // make sure all code is generated | |
135 masm->flush(); | |
136 | |
137 // failed to generate? | |
138 if (bounce_offset < 0 || exception_offset < 0 || frame_size_in_words < 0) { | |
139 assert(false, "bad ricochet blob"); | |
140 return; | |
141 } | |
142 | |
143 _ricochet_blob = RicochetBlob::create(&buffer, bounce_offset, exception_offset, frame_size_in_words); | |
144 } | |
145 | |
146 | 116 |
147 #include <math.h> | 117 #include <math.h> |
148 | 118 |
149 #ifndef USDT2 | 119 #ifndef USDT2 |
150 HS_DTRACE_PROBE_DECL4(hotspot, object__alloc, Thread*, char*, int, size_t); | 120 HS_DTRACE_PROBE_DECL4(hotspot, object__alloc, Thread*, char*, int, size_t); |
524 return StubRoutines::catch_exception_entry(); | 494 return StubRoutines::catch_exception_entry(); |
525 } | 495 } |
526 // Interpreted code | 496 // Interpreted code |
527 if (Interpreter::contains(return_address)) { | 497 if (Interpreter::contains(return_address)) { |
528 return Interpreter::rethrow_exception_entry(); | 498 return Interpreter::rethrow_exception_entry(); |
529 } | |
530 // Ricochet frame unwind code | |
531 if (SharedRuntime::ricochet_blob() != NULL && SharedRuntime::ricochet_blob()->returns_to_bounce_addr(return_address)) { | |
532 return SharedRuntime::ricochet_blob()->exception_addr(); | |
533 } | 499 } |
534 | 500 |
535 guarantee(blob == NULL || !blob->is_runtime_stub(), "caller should have skipped stub"); | 501 guarantee(blob == NULL || !blob->is_runtime_stub(), "caller should have skipped stub"); |
536 guarantee(!VtableStubs::contains(return_address), "NULL exceptions in vtables should have been handled already!"); | 502 guarantee(!VtableStubs::contains(return_address), "NULL exceptions in vtables should have been handled already!"); |
537 | 503 |
799 thread->_ScratchB = Deoptimization::make_trap_request((Deoptimization::DeoptReason)deopt_reason, Deoptimization::Action_reinterpret); | 765 thread->_ScratchB = Deoptimization::make_trap_request((Deoptimization::DeoptReason)deopt_reason, Deoptimization::Action_reinterpret); |
800 return (SharedRuntime::deopt_blob()->implicit_exception_uncommon_trap()); | 766 return (SharedRuntime::deopt_blob()->implicit_exception_uncommon_trap()); |
801 } | 767 } |
802 #endif | 768 #endif |
803 | 769 |
804 JRT_ENTRY(void, SharedRuntime::throw_WrongMethodTypeException(JavaThread* thread, oopDesc* required, oopDesc* actual)) | |
805 assert(thread == JavaThread::current() && required->is_oop() && actual->is_oop(), "bad args"); | |
806 ResourceMark rm; | |
807 char* message = SharedRuntime::generate_wrong_method_type_message(thread, required, actual); | |
808 throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_invoke_WrongMethodTypeException(), message); | |
809 JRT_END | |
810 | |
811 address SharedRuntime::continuation_for_implicit_exception(JavaThread* thread, | 770 address SharedRuntime::continuation_for_implicit_exception(JavaThread* thread, |
812 address pc, | 771 address pc, |
813 SharedRuntime::ImplicitExceptionKind exception_kind) | 772 SharedRuntime::ImplicitExceptionKind exception_kind) |
814 { | 773 { |
815 address target_pc = NULL; | 774 address target_pc = NULL; |
888 // caller => don't push another return address | 847 // caller => don't push another return address |
889 Events::log_exception(thread, "NullPointerException in IC check " INTPTR_FORMAT, pc); | 848 Events::log_exception(thread, "NullPointerException in IC check " INTPTR_FORMAT, pc); |
890 return StubRoutines::throw_NullPointerException_at_call_entry(); | 849 return StubRoutines::throw_NullPointerException_at_call_entry(); |
891 } | 850 } |
892 | 851 |
852 if (nm->method()->is_method_handle_intrinsic()) { | |
853 // exception happened inside MH dispatch code, similar to a vtable stub | |
854 Events::log_exception(thread, "NullPointerException in MH adapter " INTPTR_FORMAT, pc); | |
855 return StubRoutines::throw_NullPointerException_at_call_entry(); | |
856 } | |
857 | |
893 #ifndef PRODUCT | 858 #ifndef PRODUCT |
894 _implicit_null_throws++; | 859 _implicit_null_throws++; |
895 #endif | 860 #endif |
896 #ifdef GRAAL | 861 #ifdef GRAAL |
897 target_pc = deoptimize_for_implicit_exception(thread, pc, nm, Deoptimization::Reason_null_check); | 862 target_pc = deoptimize_for_implicit_exception(thread, pc, nm, Deoptimization::Reason_null_check); |
951 { | 916 { |
952 THROW(vmSymbols::java_lang_UnsatisfiedLinkError()); | 917 THROW(vmSymbols::java_lang_UnsatisfiedLinkError()); |
953 } | 918 } |
954 JNI_END | 919 JNI_END |
955 | 920 |
921 JNI_ENTRY(void, throw_unsupported_operation_exception(JNIEnv* env, ...)) | |
922 { | |
923 THROW(vmSymbols::java_lang_UnsupportedOperationException()); | |
924 } | |
925 JNI_END | |
956 | 926 |
957 address SharedRuntime::native_method_throw_unsatisfied_link_error_entry() { | 927 address SharedRuntime::native_method_throw_unsatisfied_link_error_entry() { |
958 return CAST_FROM_FN_PTR(address, &throw_unsatisfied_link_error); | 928 return CAST_FROM_FN_PTR(address, &throw_unsatisfied_link_error); |
929 } | |
930 | |
931 address SharedRuntime::native_method_throw_unsupported_operation_exception_entry() { | |
932 return CAST_FROM_FN_PTR(address, &throw_unsupported_operation_exception); | |
959 } | 933 } |
960 | 934 |
961 | 935 |
962 #ifndef PRODUCT | 936 #ifndef PRODUCT |
963 JRT_ENTRY(intptr_t, SharedRuntime::trace_bytecode(JavaThread* thread, intptr_t preserve_this_value, intptr_t tos, intptr_t tos2)) | 937 JRT_ENTRY(intptr_t, SharedRuntime::trace_bytecode(JavaThread* thread, intptr_t preserve_this_value, intptr_t tos, intptr_t tos2)) |
1087 Handle nullHandle; //create a handy null handle for exception returns | 1061 Handle nullHandle; //create a handy null handle for exception returns |
1088 | 1062 |
1089 assert(!vfst.at_end(), "Java frame must exist"); | 1063 assert(!vfst.at_end(), "Java frame must exist"); |
1090 | 1064 |
1091 // Find caller and bci from vframe | 1065 // Find caller and bci from vframe |
1092 methodHandle caller (THREAD, vfst.method()); | 1066 methodHandle caller(THREAD, vfst.method()); |
1093 int bci = vfst.bci(); | 1067 int bci = vfst.bci(); |
1094 | 1068 |
1095 // Find bytecode | 1069 // Find bytecode |
1096 Bytecode_invoke bytecode(caller, bci); | 1070 Bytecode_invoke bytecode(caller, bci); |
1097 bc = bytecode.java_code(); | 1071 bc = bytecode.invoke_code(); |
1098 int bytecode_index = bytecode.index(); | 1072 int bytecode_index = bytecode.index(); |
1099 | 1073 |
1100 // Find receiver for non-static call | 1074 // Find receiver for non-static call |
1101 if (bc != Bytecodes::_invokestatic) { | 1075 if (bc != Bytecodes::_invokestatic && |
1076 bc != Bytecodes::_invokedynamic) { | |
1102 // This register map must be update since we need to find the receiver for | 1077 // This register map must be update since we need to find the receiver for |
1103 // compiled frames. The receiver might be in a register. | 1078 // compiled frames. The receiver might be in a register. |
1104 RegisterMap reg_map2(thread); | 1079 RegisterMap reg_map2(thread); |
1105 frame stubFrame = thread->last_frame(); | 1080 frame stubFrame = thread->last_frame(); |
1106 // Caller-frame is a compiled frame | 1081 // Caller-frame is a compiled frame |
1117 THROW_(vmSymbols::java_lang_NullPointerException(), nullHandle); | 1092 THROW_(vmSymbols::java_lang_NullPointerException(), nullHandle); |
1118 } | 1093 } |
1119 } | 1094 } |
1120 | 1095 |
1121 // Resolve method. This is parameterized by bytecode. | 1096 // Resolve method. This is parameterized by bytecode. |
1122 constantPoolHandle constants (THREAD, caller->constants()); | 1097 constantPoolHandle constants(THREAD, caller->constants()); |
1123 assert (receiver.is_null() || receiver->is_oop(), "wrong receiver"); | 1098 assert(receiver.is_null() || receiver->is_oop(), "wrong receiver"); |
1124 LinkResolver::resolve_invoke(callinfo, receiver, constants, bytecode_index, bc, CHECK_(nullHandle)); | 1099 LinkResolver::resolve_invoke(callinfo, receiver, constants, bytecode_index, bc, CHECK_(nullHandle)); |
1125 | 1100 |
1126 #ifdef ASSERT | 1101 #ifdef ASSERT |
1127 // Check that the receiver klass is of the right subtype and that it is initialized for virtual calls | 1102 // Check that the receiver klass is of the right subtype and that it is initialized for virtual calls |
1128 if (bc != Bytecodes::_invokestatic && bc != Bytecodes::_invokedynamic) { | 1103 if (bc != Bytecodes::_invokestatic && bc != Bytecodes::_invokedynamic) { |
1129 assert(receiver.not_null(), "should have thrown exception"); | 1104 assert(receiver.not_null(), "should have thrown exception"); |
1130 KlassHandle receiver_klass (THREAD, receiver->klass()); | 1105 KlassHandle receiver_klass(THREAD, receiver->klass()); |
1131 klassOop rk = constants->klass_ref_at(bytecode_index, CHECK_(nullHandle)); | 1106 klassOop rk = constants->klass_ref_at(bytecode_index, CHECK_(nullHandle)); |
1132 // klass is already loaded | 1107 // klass is already loaded |
1133 KlassHandle static_receiver_klass (THREAD, rk); | 1108 KlassHandle static_receiver_klass(THREAD, rk); |
1134 assert(receiver_klass->is_subtype_of(static_receiver_klass()), "actual receiver must be subclass of static receiver klass"); | 1109 // Method handle invokes might have been optimized to a direct call |
1110 // so don't check for the receiver class. | |
1111 // FIXME this weakens the assert too much | |
1112 methodHandle callee = callinfo.selected_method(); | |
1113 assert(receiver_klass->is_subtype_of(static_receiver_klass()) || | |
1114 callee->is_method_handle_intrinsic() || | |
1115 callee->is_compiled_lambda_form(), | |
1116 "actual receiver must be subclass of static receiver klass"); | |
1135 if (receiver_klass->oop_is_instance()) { | 1117 if (receiver_klass->oop_is_instance()) { |
1136 if (instanceKlass::cast(receiver_klass())->is_not_initialized()) { | 1118 if (instanceKlass::cast(receiver_klass())->is_not_initialized()) { |
1137 tty->print_cr("ERROR: Klass not yet initialized!!"); | 1119 tty->print_cr("ERROR: Klass not yet initialized!!"); |
1138 receiver_klass.print(); | 1120 receiver_klass.print(); |
1139 } | 1121 } |
1140 assert (!instanceKlass::cast(receiver_klass())->is_not_initialized(), "receiver_klass must be initialized"); | 1122 assert(!instanceKlass::cast(receiver_klass())->is_not_initialized(), "receiver_klass must be initialized"); |
1141 } | 1123 } |
1142 } | 1124 } |
1143 #endif | 1125 #endif |
1144 | 1126 |
1145 return receiver; | 1127 return receiver; |
1228 Bytecodes::Code invoke_code = Bytecodes::_illegal; | 1210 Bytecodes::Code invoke_code = Bytecodes::_illegal; |
1229 Handle receiver = find_callee_info(thread, invoke_code, | 1211 Handle receiver = find_callee_info(thread, invoke_code, |
1230 call_info, CHECK_(methodHandle())); | 1212 call_info, CHECK_(methodHandle())); |
1231 methodHandle callee_method = call_info.selected_method(); | 1213 methodHandle callee_method = call_info.selected_method(); |
1232 | 1214 |
1233 assert((!is_virtual && invoke_code == Bytecodes::_invokestatic) || | 1215 assert((!is_virtual && invoke_code == Bytecodes::_invokestatic ) || |
1234 ( is_virtual && invoke_code != Bytecodes::_invokestatic), "inconsistent bytecode"); | 1216 (!is_virtual && invoke_code == Bytecodes::_invokehandle ) || |
1217 (!is_virtual && invoke_code == Bytecodes::_invokedynamic) || | |
1218 ( is_virtual && invoke_code != Bytecodes::_invokestatic ), "inconsistent bytecode"); | |
1235 | 1219 |
1236 #ifndef PRODUCT | 1220 #ifndef PRODUCT |
1237 // tracing/debugging/statistics | 1221 // tracing/debugging/statistics |
1238 int *addr = (is_optimized) ? (&_resolve_opt_virtual_ctr) : | 1222 int *addr = (is_optimized) ? (&_resolve_opt_virtual_ctr) : |
1239 (is_virtual) ? (&_resolve_virtual_ctr) : | 1223 (is_virtual) ? (&_resolve_virtual_ctr) : |
1244 ResourceMark rm(thread); | 1228 ResourceMark rm(thread); |
1245 tty->print("resolving %s%s (%s) call to", | 1229 tty->print("resolving %s%s (%s) call to", |
1246 (is_optimized) ? "optimized " : "", (is_virtual) ? "virtual" : "static", | 1230 (is_optimized) ? "optimized " : "", (is_virtual) ? "virtual" : "static", |
1247 Bytecodes::name(invoke_code)); | 1231 Bytecodes::name(invoke_code)); |
1248 callee_method->print_short_name(tty); | 1232 callee_method->print_short_name(tty); |
1249 tty->print_cr(" code: " INTPTR_FORMAT, callee_method->code()); | 1233 tty->print_cr(" at pc: " INTPTR_FORMAT " to code: " INTPTR_FORMAT, caller_frame.pc(), callee_method->code()); |
1250 } | 1234 } |
1251 #endif | 1235 #endif |
1252 | 1236 |
1253 // JSR 292 | 1237 // JSR 292 key invariant: |
1254 // If the resolved method is a MethodHandle invoke target the call | 1238 // If the resolved method is a MethodHandle invoke target the call |
1255 // site must be a MethodHandle call site. | 1239 // site must be a MethodHandle call site, because the lambda form might tail-call |
1256 if (callee_method->is_method_handle_invoke()) { | 1240 // leaving the stack in a state unknown to either caller or callee |
1257 assert(caller_nm->is_method_handle_return(caller_frame.pc()), "must be MH call site"); | 1241 // TODO detune for now but we might need it again |
1258 } | 1242 // assert(!callee_method->is_compiled_lambda_form() || |
1243 // caller_nm->is_method_handle_return(caller_frame.pc()), "must be MH call site"); | |
1259 | 1244 |
1260 // Compute entry points. This might require generation of C2I converter | 1245 // Compute entry points. This might require generation of C2I converter |
1261 // frames, so we cannot be holding any locks here. Furthermore, the | 1246 // frames, so we cannot be holding any locks here. Furthermore, the |
1262 // computation of the entry points is independent of patching the call. We | 1247 // computation of the entry points is independent of patching the call. We |
1263 // always return the entry-point, but we only patch the stub if the call has | 1248 // always return the entry-point, but we only patch the stub if the call has |
1326 RegisterMap reg_map(thread, false); | 1311 RegisterMap reg_map(thread, false); |
1327 frame stub_frame = thread->last_frame(); | 1312 frame stub_frame = thread->last_frame(); |
1328 assert(stub_frame.is_runtime_frame(), "sanity check"); | 1313 assert(stub_frame.is_runtime_frame(), "sanity check"); |
1329 frame caller_frame = stub_frame.sender(®_map); | 1314 frame caller_frame = stub_frame.sender(®_map); |
1330 assert(!caller_frame.is_interpreted_frame() && !caller_frame.is_entry_frame(), "unexpected frame"); | 1315 assert(!caller_frame.is_interpreted_frame() && !caller_frame.is_entry_frame(), "unexpected frame"); |
1331 assert(!caller_frame.is_ricochet_frame(), "unexpected frame"); | |
1332 #endif /* ASSERT */ | 1316 #endif /* ASSERT */ |
1333 | 1317 |
1334 methodHandle callee_method; | 1318 methodHandle callee_method; |
1335 JRT_BLOCK | 1319 JRT_BLOCK |
1336 callee_method = SharedRuntime::handle_ic_miss_helper(thread, CHECK_NULL); | 1320 callee_method = SharedRuntime::handle_ic_miss_helper(thread, CHECK_NULL); |
1362 // MethodHandle invokes don't have a CompiledIC and should always | 1346 // MethodHandle invokes don't have a CompiledIC and should always |
1363 // simply redispatch to the callee_target. | 1347 // simply redispatch to the callee_target. |
1364 address sender_pc = caller_frame.pc(); | 1348 address sender_pc = caller_frame.pc(); |
1365 CodeBlob* sender_cb = caller_frame.cb(); | 1349 CodeBlob* sender_cb = caller_frame.cb(); |
1366 nmethod* sender_nm = sender_cb->as_nmethod_or_null(); | 1350 nmethod* sender_nm = sender_cb->as_nmethod_or_null(); |
1367 bool is_mh_invoke_via_adapter = false; // Direct c2c call or via adapter? | |
1368 if (sender_nm != NULL && sender_nm->is_method_handle_return(sender_pc)) { | |
1369 // If the callee_target is set, then we have come here via an i2c | |
1370 // adapter. | |
1371 methodOop callee = thread->callee_target(); | |
1372 if (callee != NULL) { | |
1373 assert(callee->is_method(), "sanity"); | |
1374 is_mh_invoke_via_adapter = true; | |
1375 } | |
1376 } | |
1377 | 1351 |
1378 if (caller_frame.is_interpreted_frame() || | 1352 if (caller_frame.is_interpreted_frame() || |
1379 caller_frame.is_entry_frame() || | 1353 caller_frame.is_entry_frame()) { |
1380 caller_frame.is_ricochet_frame() || | |
1381 is_mh_invoke_via_adapter) { | |
1382 methodOop callee = thread->callee_target(); | 1354 methodOop callee = thread->callee_target(); |
1383 guarantee(callee != NULL && callee->is_method(), "bad handshake"); | 1355 guarantee(callee != NULL && callee->is_method(), "bad handshake"); |
1384 thread->set_vm_result(callee); | 1356 thread->set_vm_result(callee); |
1385 thread->set_callee_target(NULL); | 1357 thread->set_callee_target(NULL); |
1386 return callee->get_c2i_entry(); | 1358 return callee->get_c2i_entry(); |
1720 nmethod* nm = cb->as_nmethod_or_null(); | 1692 nmethod* nm = cb->as_nmethod_or_null(); |
1721 assert(nm, "must be"); | 1693 assert(nm, "must be"); |
1722 | 1694 |
1723 // Get the return PC for the passed caller PC. | 1695 // Get the return PC for the passed caller PC. |
1724 address return_pc = caller_pc + frame::pc_return_offset; | 1696 address return_pc = caller_pc + frame::pc_return_offset; |
1725 | |
1726 // Don't fixup method handle call sites as the executed method | |
1727 // handle adapters are doing the required MethodHandle chain work. | |
1728 if (nm->is_method_handle_return(return_pc)) { | |
1729 return; | |
1730 } | |
1731 | 1697 |
1732 // There is a benign race here. We could be attempting to patch to a compiled | 1698 // There is a benign race here. We could be attempting to patch to a compiled |
1733 // entry point at the same time the callee is being deoptimized. If that is | 1699 // entry point at the same time the callee is being deoptimized. If that is |
1734 // the case then entry_point may in fact point to a c2i and we'd patch the | 1700 // the case then entry_point may in fact point to a c2i and we'd patch the |
1735 // call site with the same old data. clear_code will set code() to NULL | 1701 // call site with the same old data. clear_code will set code() to NULL |
1832 Klass* targetKlass = Klass::cast(vfst.method()->constants()->klass_at( | 1798 Klass* targetKlass = Klass::cast(vfst.method()->constants()->klass_at( |
1833 cc.index(), thread)); | 1799 cc.index(), thread)); |
1834 return generate_class_cast_message(objName, targetKlass->external_name()); | 1800 return generate_class_cast_message(objName, targetKlass->external_name()); |
1835 } | 1801 } |
1836 | 1802 |
1837 char* SharedRuntime::generate_wrong_method_type_message(JavaThread* thread, | |
1838 oopDesc* required, | |
1839 oopDesc* actual) { | |
1840 if (TraceMethodHandles) { | |
1841 tty->print_cr("WrongMethodType thread="PTR_FORMAT" req="PTR_FORMAT" act="PTR_FORMAT"", | |
1842 thread, required, actual); | |
1843 } | |
1844 assert(EnableInvokeDynamic, ""); | |
1845 oop singleKlass = wrong_method_type_is_for_single_argument(thread, required); | |
1846 char* message = NULL; | |
1847 if (singleKlass != NULL) { | |
1848 const char* objName = "argument or return value"; | |
1849 if (actual != NULL) { | |
1850 // be flexible about the junk passed in: | |
1851 klassOop ak = (actual->is_klass() | |
1852 ? (klassOop)actual | |
1853 : actual->klass()); | |
1854 objName = Klass::cast(ak)->external_name(); | |
1855 } | |
1856 Klass* targetKlass = Klass::cast(required->is_klass() | |
1857 ? (klassOop)required | |
1858 : java_lang_Class::as_klassOop(required)); | |
1859 message = generate_class_cast_message(objName, targetKlass->external_name()); | |
1860 } else { | |
1861 // %%% need to get the MethodType string, without messing around too much | |
1862 const char* desc = NULL; | |
1863 // Get a signature from the invoke instruction | |
1864 const char* mhName = "method handle"; | |
1865 const char* targetType = "the required signature"; | |
1866 int targetArity = -1, mhArity = -1; | |
1867 vframeStream vfst(thread, true); | |
1868 if (!vfst.at_end()) { | |
1869 Bytecode_invoke call(vfst.method(), vfst.bci()); | |
1870 methodHandle target; | |
1871 { | |
1872 EXCEPTION_MARK; | |
1873 target = call.static_target(THREAD); | |
1874 if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; } | |
1875 } | |
1876 if (target.not_null() | |
1877 && target->is_method_handle_invoke() | |
1878 && required == target->method_handle_type()) { | |
1879 targetType = target->signature()->as_C_string(); | |
1880 targetArity = ArgumentCount(target->signature()).size(); | |
1881 } | |
1882 } | |
1883 KlassHandle kignore; int dmf_flags = 0; | |
1884 methodHandle actual_method = MethodHandles::decode_method(actual, kignore, dmf_flags); | |
1885 if ((dmf_flags & ~(MethodHandles::_dmf_has_receiver | | |
1886 MethodHandles::_dmf_does_dispatch | | |
1887 MethodHandles::_dmf_from_interface)) != 0) | |
1888 actual_method = methodHandle(); // MH does extra binds, drops, etc. | |
1889 bool has_receiver = ((dmf_flags & MethodHandles::_dmf_has_receiver) != 0); | |
1890 if (actual_method.not_null()) { | |
1891 mhName = actual_method->signature()->as_C_string(); | |
1892 mhArity = ArgumentCount(actual_method->signature()).size(); | |
1893 if (!actual_method->is_static()) mhArity += 1; | |
1894 } else if (java_lang_invoke_MethodHandle::is_instance(actual)) { | |
1895 oopDesc* mhType = java_lang_invoke_MethodHandle::type(actual); | |
1896 mhArity = java_lang_invoke_MethodType::ptype_count(mhType); | |
1897 stringStream st; | |
1898 java_lang_invoke_MethodType::print_signature(mhType, &st); | |
1899 mhName = st.as_string(); | |
1900 } | |
1901 if (targetArity != -1 && targetArity != mhArity) { | |
1902 if (has_receiver && targetArity == mhArity-1) | |
1903 desc = " cannot be called without a receiver argument as "; | |
1904 else | |
1905 desc = " cannot be called with a different arity as "; | |
1906 } | |
1907 message = generate_class_cast_message(mhName, targetType, | |
1908 desc != NULL ? desc : | |
1909 " cannot be called as "); | |
1910 } | |
1911 if (TraceMethodHandles) { | |
1912 tty->print_cr("WrongMethodType => message=%s", message); | |
1913 } | |
1914 return message; | |
1915 } | |
1916 | |
1917 oop SharedRuntime::wrong_method_type_is_for_single_argument(JavaThread* thr, | |
1918 oopDesc* required) { | |
1919 if (required == NULL) return NULL; | |
1920 if (required->klass() == SystemDictionary::Class_klass()) | |
1921 return required; | |
1922 if (required->is_klass()) | |
1923 return Klass::cast(klassOop(required))->java_mirror(); | |
1924 return NULL; | |
1925 } | |
1926 | |
1927 | |
1928 char* SharedRuntime::generate_class_cast_message( | 1803 char* SharedRuntime::generate_class_cast_message( |
1929 const char* objName, const char* targetKlassName, const char* desc) { | 1804 const char* objName, const char* targetKlassName, const char* desc) { |
1930 size_t msglen = strlen(objName) + strlen(desc) + strlen(targetKlassName) + 1; | 1805 size_t msglen = strlen(objName) + strlen(desc) + strlen(targetKlassName) + 1; |
1931 | 1806 |
1932 char* message = NEW_RESOURCE_ARRAY(char, msglen); | 1807 char* message = NEW_RESOURCE_ARRAY(char, msglen); |
2161 #endif | 2036 #endif |
2162 | 2037 |
2163 | 2038 |
2164 // A simple wrapper class around the calling convention information | 2039 // A simple wrapper class around the calling convention information |
2165 // that allows sharing of adapters for the same calling convention. | 2040 // that allows sharing of adapters for the same calling convention. |
2166 class AdapterFingerPrint : public CHeapObj { | 2041 class AdapterFingerPrint : public CHeapObj<mtCode> { |
2167 private: | 2042 private: |
2043 enum { | |
2044 _basic_type_bits = 4, | |
2045 _basic_type_mask = right_n_bits(_basic_type_bits), | |
2046 _basic_types_per_int = BitsPerInt / _basic_type_bits, | |
2047 _compact_int_count = 3 | |
2048 }; | |
2049 // TO DO: Consider integrating this with a more global scheme for compressing signatures. | |
2050 // For now, 4 bits per components (plus T_VOID gaps after double/long) is not excessive. | |
2051 | |
2168 union { | 2052 union { |
2169 int _compact[3]; | 2053 int _compact[_compact_int_count]; |
2170 int* _fingerprint; | 2054 int* _fingerprint; |
2171 } _value; | 2055 } _value; |
2172 int _length; // A negative length indicates the fingerprint is in the compact form, | 2056 int _length; // A negative length indicates the fingerprint is in the compact form, |
2173 // Otherwise _value._fingerprint is the array. | 2057 // Otherwise _value._fingerprint is the array. |
2174 | 2058 |
2175 // Remap BasicTypes that are handled equivalently by the adapters. | 2059 // Remap BasicTypes that are handled equivalently by the adapters. |
2176 // These are correct for the current system but someday it might be | 2060 // These are correct for the current system but someday it might be |
2177 // necessary to make this mapping platform dependent. | 2061 // necessary to make this mapping platform dependent. |
2178 static BasicType adapter_encoding(BasicType in) { | 2062 static int adapter_encoding(BasicType in) { |
2179 assert((~0xf & in) == 0, "must fit in 4 bits"); | |
2180 switch(in) { | 2063 switch(in) { |
2181 case T_BOOLEAN: | 2064 case T_BOOLEAN: |
2182 case T_BYTE: | 2065 case T_BYTE: |
2183 case T_SHORT: | 2066 case T_SHORT: |
2184 case T_CHAR: | 2067 case T_CHAR: |
2185 // There are all promoted to T_INT in the calling convention | 2068 // There are all promoted to T_INT in the calling convention |
2186 return T_INT; | 2069 return T_INT; |
2187 | 2070 |
2188 case T_OBJECT: | 2071 case T_OBJECT: |
2189 case T_ARRAY: | 2072 case T_ARRAY: |
2073 // In other words, we assume that any register good enough for | |
2074 // an int or long is good enough for a managed pointer. | |
2190 #ifdef _LP64 | 2075 #ifdef _LP64 |
2191 return T_LONG; | 2076 return T_LONG; |
2192 #else | 2077 #else |
2193 return T_INT; | 2078 return T_INT; |
2194 #endif | 2079 #endif |
2209 public: | 2094 public: |
2210 AdapterFingerPrint(int total_args_passed, BasicType* sig_bt) { | 2095 AdapterFingerPrint(int total_args_passed, BasicType* sig_bt) { |
2211 // The fingerprint is based on the BasicType signature encoded | 2096 // The fingerprint is based on the BasicType signature encoded |
2212 // into an array of ints with eight entries per int. | 2097 // into an array of ints with eight entries per int. |
2213 int* ptr; | 2098 int* ptr; |
2214 int len = (total_args_passed + 7) >> 3; | 2099 int len = (total_args_passed + (_basic_types_per_int-1)) / _basic_types_per_int; |
2215 if (len <= (int)(sizeof(_value._compact) / sizeof(int))) { | 2100 if (len <= _compact_int_count) { |
2101 assert(_compact_int_count == 3, "else change next line"); | |
2216 _value._compact[0] = _value._compact[1] = _value._compact[2] = 0; | 2102 _value._compact[0] = _value._compact[1] = _value._compact[2] = 0; |
2217 // Storing the signature encoded as signed chars hits about 98% | 2103 // Storing the signature encoded as signed chars hits about 98% |
2218 // of the time. | 2104 // of the time. |
2219 _length = -len; | 2105 _length = -len; |
2220 ptr = _value._compact; | 2106 ptr = _value._compact; |
2221 } else { | 2107 } else { |
2222 _length = len; | 2108 _length = len; |
2223 _value._fingerprint = NEW_C_HEAP_ARRAY(int, _length); | 2109 _value._fingerprint = NEW_C_HEAP_ARRAY(int, _length, mtCode); |
2224 ptr = _value._fingerprint; | 2110 ptr = _value._fingerprint; |
2225 } | 2111 } |
2226 | 2112 |
2227 // Now pack the BasicTypes with 8 per int | 2113 // Now pack the BasicTypes with 8 per int |
2228 int sig_index = 0; | 2114 int sig_index = 0; |
2229 for (int index = 0; index < len; index++) { | 2115 for (int index = 0; index < len; index++) { |
2230 int value = 0; | 2116 int value = 0; |
2231 for (int byte = 0; byte < 8; byte++) { | 2117 for (int byte = 0; byte < _basic_types_per_int; byte++) { |
2232 if (sig_index < total_args_passed) { | 2118 int bt = ((sig_index < total_args_passed) |
2233 value = (value << 4) | adapter_encoding(sig_bt[sig_index++]); | 2119 ? adapter_encoding(sig_bt[sig_index++]) |
2234 } | 2120 : 0); |
2121 assert((bt & _basic_type_mask) == bt, "must fit in 4 bits"); | |
2122 value = (value << _basic_type_bits) | bt; | |
2235 } | 2123 } |
2236 ptr[index] = value; | 2124 ptr[index] = value; |
2237 } | 2125 } |
2238 } | 2126 } |
2239 | 2127 |
2240 ~AdapterFingerPrint() { | 2128 ~AdapterFingerPrint() { |
2241 if (_length > 0) { | 2129 if (_length > 0) { |
2242 FREE_C_HEAP_ARRAY(int, _value._fingerprint); | 2130 FREE_C_HEAP_ARRAY(int, _value._fingerprint, mtCode); |
2243 } | 2131 } |
2244 } | 2132 } |
2245 | 2133 |
2246 int value(int index) { | 2134 int value(int index) { |
2247 if (_length < 0) { | 2135 if (_length < 0) { |
2279 bool equals(AdapterFingerPrint* other) { | 2167 bool equals(AdapterFingerPrint* other) { |
2280 if (other->_length != _length) { | 2168 if (other->_length != _length) { |
2281 return false; | 2169 return false; |
2282 } | 2170 } |
2283 if (_length < 0) { | 2171 if (_length < 0) { |
2172 assert(_compact_int_count == 3, "else change next line"); | |
2284 return _value._compact[0] == other->_value._compact[0] && | 2173 return _value._compact[0] == other->_value._compact[0] && |
2285 _value._compact[1] == other->_value._compact[1] && | 2174 _value._compact[1] == other->_value._compact[1] && |
2286 _value._compact[2] == other->_value._compact[2]; | 2175 _value._compact[2] == other->_value._compact[2]; |
2287 } else { | 2176 } else { |
2288 for (int i = 0; i < _length; i++) { | 2177 for (int i = 0; i < _length; i++) { |
2295 } | 2184 } |
2296 }; | 2185 }; |
2297 | 2186 |
2298 | 2187 |
2299 // A hashtable mapping from AdapterFingerPrints to AdapterHandlerEntries | 2188 // A hashtable mapping from AdapterFingerPrints to AdapterHandlerEntries |
2300 class AdapterHandlerTable : public BasicHashtable { | 2189 class AdapterHandlerTable : public BasicHashtable<mtCode> { |
2301 friend class AdapterHandlerTableIterator; | 2190 friend class AdapterHandlerTableIterator; |
2302 | 2191 |
2303 private: | 2192 private: |
2304 | 2193 |
2305 #ifndef PRODUCT | 2194 #ifndef PRODUCT |
2309 static int _hits; // number of successful lookups | 2198 static int _hits; // number of successful lookups |
2310 static int _compact; // number of equals calls with compact signature | 2199 static int _compact; // number of equals calls with compact signature |
2311 #endif | 2200 #endif |
2312 | 2201 |
2313 AdapterHandlerEntry* bucket(int i) { | 2202 AdapterHandlerEntry* bucket(int i) { |
2314 return (AdapterHandlerEntry*)BasicHashtable::bucket(i); | 2203 return (AdapterHandlerEntry*)BasicHashtable<mtCode>::bucket(i); |
2315 } | 2204 } |
2316 | 2205 |
2317 public: | 2206 public: |
2318 AdapterHandlerTable() | 2207 AdapterHandlerTable() |
2319 : BasicHashtable(293, sizeof(AdapterHandlerEntry)) { } | 2208 : BasicHashtable<mtCode>(293, sizeof(AdapterHandlerEntry)) { } |
2320 | 2209 |
2321 // Create a new entry suitable for insertion in the table | 2210 // Create a new entry suitable for insertion in the table |
2322 AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry) { | 2211 AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry) { |
2323 AdapterHandlerEntry* entry = (AdapterHandlerEntry*)BasicHashtable::new_entry(fingerprint->compute_hash()); | 2212 AdapterHandlerEntry* entry = (AdapterHandlerEntry*)BasicHashtable<mtCode>::new_entry(fingerprint->compute_hash()); |
2324 entry->init(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry); | 2213 entry->init(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry); |
2325 return entry; | 2214 return entry; |
2326 } | 2215 } |
2327 | 2216 |
2328 // Insert an entry into the table | 2217 // Insert an entry into the table |
2331 add_entry(index, entry); | 2220 add_entry(index, entry); |
2332 } | 2221 } |
2333 | 2222 |
2334 void free_entry(AdapterHandlerEntry* entry) { | 2223 void free_entry(AdapterHandlerEntry* entry) { |
2335 entry->deallocate(); | 2224 entry->deallocate(); |
2336 BasicHashtable::free_entry(entry); | 2225 BasicHashtable<mtCode>::free_entry(entry); |
2337 } | 2226 } |
2338 | 2227 |
2339 // Find a entry with the same fingerprint if it exists | 2228 // Find a entry with the same fingerprint if it exists |
2340 AdapterHandlerEntry* lookup(int total_args_passed, BasicType* sig_bt) { | 2229 AdapterHandlerEntry* lookup(int total_args_passed, BasicType* sig_bt) { |
2341 NOT_PRODUCT(_lookups++); | 2230 NOT_PRODUCT(_lookups++); |
2575 return NULL; // Out of CodeCache space | 2464 return NULL; // Out of CodeCache space |
2576 } | 2465 } |
2577 entry->relocate(B->content_begin()); | 2466 entry->relocate(B->content_begin()); |
2578 #ifndef PRODUCT | 2467 #ifndef PRODUCT |
2579 // debugging suppport | 2468 // debugging suppport |
2580 if (PrintAdapterHandlers) { | 2469 if (PrintAdapterHandlers || PrintStubCode) { |
2581 tty->cr(); | 2470 entry->print_adapter_on(tty); |
2582 tty->print_cr("i2c argument handler #%d for: %s %s (fingerprint = %s, %d bytes generated)", | 2471 tty->print_cr("i2c argument handler #%d for: %s %s (%d bytes generated)", |
2583 _adapters->number_of_entries(), (method->is_static() ? "static" : "receiver"), | 2472 _adapters->number_of_entries(), (method->is_static() ? "static" : "receiver"), |
2584 method->signature()->as_C_string(), fingerprint->as_string(), insts_size ); | 2473 method->signature()->as_C_string(), insts_size); |
2585 tty->print_cr("c2i argument handler starts at %p",entry->get_c2i_entry()); | 2474 tty->print_cr("c2i argument handler starts at %p",entry->get_c2i_entry()); |
2586 Disassembler::decode(entry->get_i2c_entry(), entry->get_i2c_entry() + insts_size); | 2475 if (Verbose || PrintStubCode) { |
2476 address first_pc = entry->base_address(); | |
2477 if (first_pc != NULL) | |
2478 Disassembler::decode(first_pc, first_pc + insts_size); | |
2479 } | |
2587 } | 2480 } |
2588 #endif | 2481 #endif |
2589 | 2482 |
2590 _adapters->add(entry); | 2483 _adapters->add(entry); |
2591 } | 2484 } |
2605 } | 2498 } |
2606 } | 2499 } |
2607 return entry; | 2500 return entry; |
2608 } | 2501 } |
2609 | 2502 |
2503 address AdapterHandlerEntry::base_address() { | |
2504 address base = _i2c_entry; | |
2505 if (base == NULL) base = _c2i_entry; | |
2506 assert(base <= _c2i_entry || _c2i_entry == NULL, ""); | |
2507 assert(base <= _c2i_unverified_entry || _c2i_unverified_entry == NULL, ""); | |
2508 return base; | |
2509 } | |
2510 | |
2610 void AdapterHandlerEntry::relocate(address new_base) { | 2511 void AdapterHandlerEntry::relocate(address new_base) { |
2611 ptrdiff_t delta = new_base - _i2c_entry; | 2512 address old_base = base_address(); |
2513 assert(old_base != NULL, ""); | |
2514 ptrdiff_t delta = new_base - old_base; | |
2515 if (_i2c_entry != NULL) | |
2612 _i2c_entry += delta; | 2516 _i2c_entry += delta; |
2517 if (_c2i_entry != NULL) | |
2613 _c2i_entry += delta; | 2518 _c2i_entry += delta; |
2519 if (_c2i_unverified_entry != NULL) | |
2614 _c2i_unverified_entry += delta; | 2520 _c2i_unverified_entry += delta; |
2521 assert(base_address() == new_base, ""); | |
2615 } | 2522 } |
2616 | 2523 |
2617 | 2524 |
2618 void AdapterHandlerEntry::deallocate() { | 2525 void AdapterHandlerEntry::deallocate() { |
2619 delete _fingerprint; | 2526 delete _fingerprint; |
2620 #ifdef ASSERT | 2527 #ifdef ASSERT |
2621 if (_saved_code) FREE_C_HEAP_ARRAY(unsigned char, _saved_code); | 2528 if (_saved_code) FREE_C_HEAP_ARRAY(unsigned char, _saved_code, mtCode); |
2622 if (_saved_sig) FREE_C_HEAP_ARRAY(Basictype, _saved_sig); | 2529 if (_saved_sig) FREE_C_HEAP_ARRAY(Basictype, _saved_sig, mtCode); |
2623 #endif | 2530 #endif |
2624 } | 2531 } |
2625 | 2532 |
2626 | 2533 |
2627 #ifdef ASSERT | 2534 #ifdef ASSERT |
2628 // Capture the code before relocation so that it can be compared | 2535 // Capture the code before relocation so that it can be compared |
2629 // against other versions. If the code is captured after relocation | 2536 // against other versions. If the code is captured after relocation |
2630 // then relative instructions won't be equivalent. | 2537 // then relative instructions won't be equivalent. |
2631 void AdapterHandlerEntry::save_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) { | 2538 void AdapterHandlerEntry::save_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) { |
2632 _saved_code = NEW_C_HEAP_ARRAY(unsigned char, length); | 2539 _saved_code = NEW_C_HEAP_ARRAY(unsigned char, length, mtCode); |
2633 _code_length = length; | 2540 _code_length = length; |
2634 memcpy(_saved_code, buffer, length); | 2541 memcpy(_saved_code, buffer, length); |
2635 _total_args_passed = total_args_passed; | 2542 _total_args_passed = total_args_passed; |
2636 _saved_sig = NEW_C_HEAP_ARRAY(BasicType, _total_args_passed); | 2543 _saved_sig = NEW_C_HEAP_ARRAY(BasicType, _total_args_passed, mtCode); |
2637 memcpy(_saved_sig, sig_bt, _total_args_passed * sizeof(BasicType)); | 2544 memcpy(_saved_sig, sig_bt, _total_args_passed * sizeof(BasicType)); |
2638 } | 2545 } |
2639 | 2546 |
2640 | 2547 |
2641 bool AdapterHandlerEntry::compare_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) { | 2548 bool AdapterHandlerEntry::compare_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) { |
2658 // back to java blocking if a safepoint is in progress. | 2565 // back to java blocking if a safepoint is in progress. |
2659 nmethod *AdapterHandlerLibrary::create_native_wrapper(methodHandle method, int compile_id) { | 2566 nmethod *AdapterHandlerLibrary::create_native_wrapper(methodHandle method, int compile_id) { |
2660 ResourceMark rm; | 2567 ResourceMark rm; |
2661 nmethod* nm = NULL; | 2568 nmethod* nm = NULL; |
2662 | 2569 |
2663 assert(method->has_native_function(), "must have something valid to call!"); | 2570 assert(method->is_native(), "must be native"); |
2571 assert(method->is_method_handle_intrinsic() || | |
2572 method->has_native_function(), "must have something valid to call!"); | |
2664 | 2573 |
2665 { | 2574 { |
2666 // perform the work while holding the lock, but perform any printing outside the lock | 2575 // perform the work while holding the lock, but perform any printing outside the lock |
2667 MutexLocker mu(AdapterHandlerLibrary_lock); | 2576 MutexLocker mu(AdapterHandlerLibrary_lock); |
2668 // See if somebody beat us to it | 2577 // See if somebody beat us to it |
2695 sig_bt[i++] = T_VOID; // Longs & doubles take 2 Java slots | 2604 sig_bt[i++] = T_VOID; // Longs & doubles take 2 Java slots |
2696 } | 2605 } |
2697 assert( i==total_args_passed, "" ); | 2606 assert( i==total_args_passed, "" ); |
2698 BasicType ret_type = ss.type(); | 2607 BasicType ret_type = ss.type(); |
2699 | 2608 |
2700 // Now get the compiled-Java layout as input arguments | 2609 // Now get the compiled-Java layout as input (or output) arguments. |
2701 int comp_args_on_stack; | 2610 // NOTE: Stubs for compiled entry points of method handle intrinsics |
2702 comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false); | 2611 // are just trampolines so the argument registers must be outgoing ones. |
2612 const bool is_outgoing = method->is_method_handle_intrinsic(); | |
2613 int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, is_outgoing); | |
2703 | 2614 |
2704 // Generate the compiled-to-native wrapper code | 2615 // Generate the compiled-to-native wrapper code |
2705 nm = SharedRuntime::generate_native_wrapper(&_masm, | 2616 nm = SharedRuntime::generate_native_wrapper(&_masm, |
2706 method, | 2617 method, |
2707 compile_id, | 2618 compile_id, |
2937 | 2848 |
2938 methodOop moop = fr.interpreter_frame_method(); | 2849 methodOop moop = fr.interpreter_frame_method(); |
2939 int max_locals = moop->max_locals(); | 2850 int max_locals = moop->max_locals(); |
2940 // Allocate temp buffer, 1 word per local & 2 per active monitor | 2851 // Allocate temp buffer, 1 word per local & 2 per active monitor |
2941 int buf_size_words = max_locals + active_monitor_count*2; | 2852 int buf_size_words = max_locals + active_monitor_count*2; |
2942 intptr_t *buf = NEW_C_HEAP_ARRAY(intptr_t,buf_size_words); | 2853 intptr_t *buf = NEW_C_HEAP_ARRAY(intptr_t,buf_size_words, mtCode); |
2943 | 2854 |
2944 // Copy the locals. Order is preserved so that loading of longs works. | 2855 // Copy the locals. Order is preserved so that loading of longs works. |
2945 // Since there's no GC I can copy the oops blindly. | 2856 // Since there's no GC I can copy the oops blindly. |
2946 assert( sizeof(HeapWord)==sizeof(intptr_t), "fix this code"); | 2857 assert( sizeof(HeapWord)==sizeof(intptr_t), "fix this code"); |
2947 Copy::disjoint_words((HeapWord*)fr.interpreter_frame_local_at(max_locals-1), | 2858 Copy::disjoint_words((HeapWord*)fr.interpreter_frame_local_at(max_locals-1), |
2967 | 2878 |
2968 return buf; | 2879 return buf; |
2969 JRT_END | 2880 JRT_END |
2970 | 2881 |
2971 JRT_LEAF(void, SharedRuntime::OSR_migration_end( intptr_t* buf) ) | 2882 JRT_LEAF(void, SharedRuntime::OSR_migration_end( intptr_t* buf) ) |
2972 FREE_C_HEAP_ARRAY(intptr_t,buf); | 2883 FREE_C_HEAP_ARRAY(intptr_t,buf, mtCode); |
2973 JRT_END | 2884 JRT_END |
2974 | 2885 |
2975 bool AdapterHandlerLibrary::contains(CodeBlob* b) { | 2886 bool AdapterHandlerLibrary::contains(CodeBlob* b) { |
2976 AdapterHandlerTableIterator iter(_adapters); | 2887 AdapterHandlerTableIterator iter(_adapters); |
2977 while (iter.has_next()) { | 2888 while (iter.has_next()) { |
2983 | 2894 |
2984 void AdapterHandlerLibrary::print_handler_on(outputStream* st, CodeBlob* b) { | 2895 void AdapterHandlerLibrary::print_handler_on(outputStream* st, CodeBlob* b) { |
2985 AdapterHandlerTableIterator iter(_adapters); | 2896 AdapterHandlerTableIterator iter(_adapters); |
2986 while (iter.has_next()) { | 2897 while (iter.has_next()) { |
2987 AdapterHandlerEntry* a = iter.next(); | 2898 AdapterHandlerEntry* a = iter.next(); |
2988 if ( b == CodeCache::find_blob(a->get_i2c_entry()) ) { | 2899 if (b == CodeCache::find_blob(a->get_i2c_entry())) { |
2989 st->print("Adapter for signature: "); | 2900 st->print("Adapter for signature: "); |
2990 st->print_cr("%s i2c: " INTPTR_FORMAT " c2i: " INTPTR_FORMAT " c2iUV: " INTPTR_FORMAT, | 2901 a->print_adapter_on(tty); |
2991 a->fingerprint()->as_string(), | |
2992 a->get_i2c_entry(), a->get_c2i_entry(), a->get_c2i_unverified_entry()); | |
2993 | |
2994 return; | 2902 return; |
2995 } | 2903 } |
2996 } | 2904 } |
2997 assert(false, "Should have found handler"); | 2905 assert(false, "Should have found handler"); |
2906 } | |
2907 | |
2908 void AdapterHandlerEntry::print_adapter_on(outputStream* st) const { | |
2909 st->print_cr("AHE@" INTPTR_FORMAT ": %s i2c: " INTPTR_FORMAT " c2i: " INTPTR_FORMAT " c2iUV: " INTPTR_FORMAT, | |
2910 (intptr_t) this, fingerprint()->as_string(), | |
2911 get_i2c_entry(), get_c2i_entry(), get_c2i_unverified_entry()); | |
2912 | |
2998 } | 2913 } |
2999 | 2914 |
3000 #ifndef PRODUCT | 2915 #ifndef PRODUCT |
3001 | 2916 |
3002 void AdapterHandlerLibrary::print_statistics() { | 2917 void AdapterHandlerLibrary::print_statistics() { |