comparison src/share/vm/runtime/sharedRuntime.cpp @ 6948:e522a00b91aa

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
author Doug Simon <doug.simon@oracle.com>
date Mon, 12 Nov 2012 23:14:12 +0100
parents 957c266d8bc5 d8ce2825b193
children 2cb439954abf
comparison
equal deleted inserted replaced
6711:ae13cc658b80 6948:e522a00b91aa
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 SafepointBlob* SharedRuntime::_polling_page_vectors_safepoint_handler_blob;
91 SafepointBlob* SharedRuntime::_polling_page_safepoint_handler_blob; 92 SafepointBlob* SharedRuntime::_polling_page_safepoint_handler_blob;
92 SafepointBlob* SharedRuntime::_polling_page_return_handler_blob; 93 SafepointBlob* SharedRuntime::_polling_page_return_handler_blob;
93 94
94 #ifdef COMPILER2 95 #ifdef COMPILER2
95 UncommonTrapBlob* SharedRuntime::_uncommon_trap_blob; 96 UncommonTrapBlob* SharedRuntime::_uncommon_trap_blob;
102 _ic_miss_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method_ic_miss), "ic_miss_stub"); 103 _ic_miss_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method_ic_miss), "ic_miss_stub");
103 _resolve_opt_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_opt_virtual_call_C), "resolve_opt_virtual_call"); 104 _resolve_opt_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_opt_virtual_call_C), "resolve_opt_virtual_call");
104 _resolve_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_virtual_call_C), "resolve_virtual_call"); 105 _resolve_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_virtual_call_C), "resolve_virtual_call");
105 _resolve_static_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_static_call_C), "resolve_static_call"); 106 _resolve_static_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_static_call_C), "resolve_static_call");
106 107
107 _polling_page_safepoint_handler_blob = generate_handler_blob(CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception), false); 108 #ifdef COMPILER2
108 _polling_page_return_handler_blob = generate_handler_blob(CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception), true); 109 // Vectors are generated only by C2.
110 if (is_wide_vector(MaxVectorSize)) {
111 _polling_page_vectors_safepoint_handler_blob = generate_handler_blob(CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception), POLL_AT_VECTOR_LOOP);
112 }
113 #endif // COMPILER2
114 _polling_page_safepoint_handler_blob = generate_handler_blob(CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception), POLL_AT_LOOP);
115 _polling_page_return_handler_blob = generate_handler_blob(CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception), POLL_AT_RETURN);
109 116
110 generate_deopt_blob(); 117 generate_deopt_blob();
111 118
112 #ifdef COMPILER2 119 #ifdef COMPILER2
113 generate_uncommon_trap_blob(); 120 generate_uncommon_trap_blob();
533 540
534 assert( ((NativeInstruction*)pc)->is_safepoint_poll(), 541 assert( ((NativeInstruction*)pc)->is_safepoint_poll(),
535 "Only polling locations are used for safepoint"); 542 "Only polling locations are used for safepoint");
536 543
537 bool at_poll_return = ((nmethod*)cb)->is_at_poll_return(pc); 544 bool at_poll_return = ((nmethod*)cb)->is_at_poll_return(pc);
545 bool has_wide_vectors = ((nmethod*)cb)->has_wide_vectors();
538 if (at_poll_return) { 546 if (at_poll_return) {
539 assert(SharedRuntime::polling_page_return_handler_blob() != NULL, 547 assert(SharedRuntime::polling_page_return_handler_blob() != NULL,
540 "polling page return stub not created yet"); 548 "polling page return stub not created yet");
541 stub = SharedRuntime::polling_page_return_handler_blob()->entry_point(); 549 stub = SharedRuntime::polling_page_return_handler_blob()->entry_point();
550 } else if (has_wide_vectors) {
551 assert(SharedRuntime::polling_page_vectors_safepoint_handler_blob() != NULL,
552 "polling page vectors safepoint stub not created yet");
553 stub = SharedRuntime::polling_page_vectors_safepoint_handler_blob()->entry_point();
542 } else { 554 } else {
543 assert(SharedRuntime::polling_page_safepoint_handler_blob() != NULL, 555 assert(SharedRuntime::polling_page_safepoint_handler_blob() != NULL,
544 "polling page safepoint stub not created yet"); 556 "polling page safepoint stub not created yet");
545 stub = SharedRuntime::polling_page_safepoint_handler_blob()->entry_point(); 557 stub = SharedRuntime::polling_page_safepoint_handler_blob()->entry_point();
546 } 558 }
588 // called/generated when TraceRedefineClasses has the right bits 600 // called/generated when TraceRedefineClasses has the right bits
589 // set. Since obsolete methods are never compiled, we don't have 601 // set. Since obsolete methods are never compiled, we don't have
590 // to modify the compilers to generate calls to this function. 602 // to modify the compilers to generate calls to this function.
591 // 603 //
592 JRT_LEAF(int, SharedRuntime::rc_trace_method_entry( 604 JRT_LEAF(int, SharedRuntime::rc_trace_method_entry(
593 JavaThread* thread, methodOopDesc* method)) 605 JavaThread* thread, Method* method))
594 assert(RC_TRACE_IN_RANGE(0x00001000, 0x00002000), "wrong call"); 606 assert(RC_TRACE_IN_RANGE(0x00001000, 0x00002000), "wrong call");
595 607
596 if (method->is_obsolete()) { 608 if (method->is_obsolete()) {
597 // We are calling an obsolete method, but this is not necessarily 609 // We are calling an obsolete method, but this is not necessarily
598 // an error. Our method could have been redefined just after we 610 // an error. Our method could have been redefined just after we
599 // fetched the methodOop from the constant pool. 611 // fetched the Method* from the constant pool.
600 612
601 // RC_TRACE macro has an embedded ResourceMark 613 // RC_TRACE macro has an embedded ResourceMark
602 RC_TRACE_WITH_THREAD(0x00001000, thread, 614 RC_TRACE_WITH_THREAD(0x00001000, thread,
603 ("calling obsolete method '%s'", 615 ("calling obsolete method '%s'",
604 method->name_and_sig_as_C_string())); 616 method->name_and_sig_as_C_string()));
744 JRT_END 756 JRT_END
745 757
746 JRT_ENTRY(void, SharedRuntime::throw_StackOverflowError(JavaThread* thread)) 758 JRT_ENTRY(void, SharedRuntime::throw_StackOverflowError(JavaThread* thread))
747 // We avoid using the normal exception construction in this case because 759 // We avoid using the normal exception construction in this case because
748 // it performs an upcall to Java, and we're already out of stack space. 760 // it performs an upcall to Java, and we're already out of stack space.
749 klassOop k = SystemDictionary::StackOverflowError_klass(); 761 Klass* k = SystemDictionary::StackOverflowError_klass();
750 oop exception_oop = instanceKlass::cast(k)->allocate_instance(CHECK); 762 oop exception_oop = InstanceKlass::cast(k)->allocate_instance(CHECK);
751 Handle exception (thread, exception_oop); 763 Handle exception (thread, exception_oop);
752 if (StackTraceInThrowable) { 764 if (StackTraceInThrowable) {
753 java_lang_Throwable::fill_in_stack_trace(exception); 765 java_lang_Throwable::fill_in_stack_trace(exception);
754 } 766 }
755 throw_and_post_jvmti_exception(thread, exception); 767 throw_and_post_jvmti_exception(thread, exception);
951 JRT_END 963 JRT_END
952 964
953 965
954 JRT_ENTRY_NO_ASYNC(void, SharedRuntime::register_finalizer(JavaThread* thread, oopDesc* obj)) 966 JRT_ENTRY_NO_ASYNC(void, SharedRuntime::register_finalizer(JavaThread* thread, oopDesc* obj))
955 assert(obj->is_oop(), "must be a valid oop"); 967 assert(obj->is_oop(), "must be a valid oop");
956 assert(obj->klass()->klass_part()->has_finalizer(), "shouldn't be here otherwise"); 968 assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
957 instanceKlass::register_finalizer(instanceOop(obj), CHECK); 969 InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
958 JRT_END 970 JRT_END
959 971
960 972
961 jlong SharedRuntime::get_java_tid(Thread* thread) { 973 jlong SharedRuntime::get_java_tid(Thread* thread) {
962 if (thread != NULL) { 974 if (thread != NULL) {
977 return dtrace_object_alloc_base(Thread::current(), o); 989 return dtrace_object_alloc_base(Thread::current(), o);
978 } 990 }
979 991
980 int SharedRuntime::dtrace_object_alloc_base(Thread* thread, oopDesc* o) { 992 int SharedRuntime::dtrace_object_alloc_base(Thread* thread, oopDesc* o) {
981 assert(DTraceAllocProbes, "wrong call"); 993 assert(DTraceAllocProbes, "wrong call");
982 Klass* klass = o->blueprint(); 994 Klass* klass = o->klass();
983 int size = o->size(); 995 int size = o->size();
984 Symbol* name = klass->name(); 996 Symbol* name = klass->name();
985 #ifndef USDT2 997 #ifndef USDT2
986 HS_DTRACE_PROBE4(hotspot, object__alloc, get_java_tid(thread), 998 HS_DTRACE_PROBE4(hotspot, object__alloc, get_java_tid(thread),
987 name->bytes(), name->utf8_length(), size * HeapWordSize); 999 name->bytes(), name->utf8_length(), size * HeapWordSize);
992 #endif /* USDT2 */ 1004 #endif /* USDT2 */
993 return 0; 1005 return 0;
994 } 1006 }
995 1007
996 JRT_LEAF(int, SharedRuntime::dtrace_method_entry( 1008 JRT_LEAF(int, SharedRuntime::dtrace_method_entry(
997 JavaThread* thread, methodOopDesc* method)) 1009 JavaThread* thread, Method* method))
998 assert(DTraceMethodProbes, "wrong call"); 1010 assert(DTraceMethodProbes, "wrong call");
999 Symbol* kname = method->klass_name(); 1011 Symbol* kname = method->klass_name();
1000 Symbol* name = method->name(); 1012 Symbol* name = method->name();
1001 Symbol* sig = method->signature(); 1013 Symbol* sig = method->signature();
1002 #ifndef USDT2 1014 #ifndef USDT2
1013 #endif /* USDT2 */ 1025 #endif /* USDT2 */
1014 return 0; 1026 return 0;
1015 JRT_END 1027 JRT_END
1016 1028
1017 JRT_LEAF(int, SharedRuntime::dtrace_method_exit( 1029 JRT_LEAF(int, SharedRuntime::dtrace_method_exit(
1018 JavaThread* thread, methodOopDesc* method)) 1030 JavaThread* thread, Method* method))
1019 assert(DTraceMethodProbes, "wrong call"); 1031 assert(DTraceMethodProbes, "wrong call");
1020 Symbol* kname = method->klass_name(); 1032 Symbol* kname = method->klass_name();
1021 Symbol* name = method->name(); 1033 Symbol* name = method->name();
1022 Symbol* sig = method->signature(); 1034 Symbol* sig = method->signature();
1023 #ifndef USDT2 1035 #ifndef USDT2
1101 #ifdef ASSERT 1113 #ifdef ASSERT
1102 // Check that the receiver klass is of the right subtype and that it is initialized for virtual calls 1114 // Check that the receiver klass is of the right subtype and that it is initialized for virtual calls
1103 if (bc != Bytecodes::_invokestatic && bc != Bytecodes::_invokedynamic) { 1115 if (bc != Bytecodes::_invokestatic && bc != Bytecodes::_invokedynamic) {
1104 assert(receiver.not_null(), "should have thrown exception"); 1116 assert(receiver.not_null(), "should have thrown exception");
1105 KlassHandle receiver_klass(THREAD, receiver->klass()); 1117 KlassHandle receiver_klass(THREAD, receiver->klass());
1106 klassOop rk = constants->klass_ref_at(bytecode_index, CHECK_(nullHandle)); 1118 Klass* rk = constants->klass_ref_at(bytecode_index, CHECK_(nullHandle));
1107 // klass is already loaded 1119 // klass is already loaded
1108 KlassHandle static_receiver_klass(THREAD, rk); 1120 KlassHandle static_receiver_klass(THREAD, rk);
1109 // Method handle invokes might have been optimized to a direct call 1121 // Method handle invokes might have been optimized to a direct call
1110 // so don't check for the receiver class. 1122 // so don't check for the receiver class.
1111 // FIXME this weakens the assert too much 1123 // FIXME this weakens the assert too much
1113 assert(receiver_klass->is_subtype_of(static_receiver_klass()) || 1125 assert(receiver_klass->is_subtype_of(static_receiver_klass()) ||
1114 callee->is_method_handle_intrinsic() || 1126 callee->is_method_handle_intrinsic() ||
1115 callee->is_compiled_lambda_form(), 1127 callee->is_compiled_lambda_form(),
1116 "actual receiver must be subclass of static receiver klass"); 1128 "actual receiver must be subclass of static receiver klass");
1117 if (receiver_klass->oop_is_instance()) { 1129 if (receiver_klass->oop_is_instance()) {
1118 if (instanceKlass::cast(receiver_klass())->is_not_initialized()) { 1130 if (InstanceKlass::cast(receiver_klass())->is_not_initialized()) {
1119 tty->print_cr("ERROR: Klass not yet initialized!!"); 1131 tty->print_cr("ERROR: Klass not yet initialized!!");
1120 receiver_klass.print(); 1132 receiver_klass()->print();
1121 } 1133 }
1122 assert(!instanceKlass::cast(receiver_klass())->is_not_initialized(), "receiver_klass must be initialized"); 1134 assert(!InstanceKlass::cast(receiver_klass())->is_not_initialized(), "receiver_klass must be initialized");
1123 } 1135 }
1124 } 1136 }
1125 #endif 1137 #endif
1126 1138
1127 return receiver; 1139 return receiver;
1275 1287
1276 // grab lock, check for deoptimization and potentially patch caller 1288 // grab lock, check for deoptimization and potentially patch caller
1277 { 1289 {
1278 MutexLocker ml_patch(CompiledIC_lock); 1290 MutexLocker ml_patch(CompiledIC_lock);
1279 1291
1280 // Now that we are ready to patch if the methodOop was redefined then 1292 // Now that we are ready to patch if the Method* was redefined then
1281 // don't update call site and let the caller retry. 1293 // don't update call site and let the caller retry.
1282 1294
1283 if (!callee_method->is_old()) { 1295 if (!callee_method->is_old()) {
1284 #ifdef ASSERT 1296 #ifdef ASSERT
1285 // We must not try to patch to jump to an already unloaded method. 1297 // We must not try to patch to jump to an already unloaded method.
1287 assert(CodeCache::find_blob(dest_entry_point) != NULL, 1299 assert(CodeCache::find_blob(dest_entry_point) != NULL,
1288 "should not unload nmethod while locked"); 1300 "should not unload nmethod while locked");
1289 } 1301 }
1290 #endif 1302 #endif
1291 if (is_virtual) { 1303 if (is_virtual) {
1292 CompiledIC* inline_cache = CompiledIC_before(caller_frame.pc()); 1304 nmethod* nm = callee_nm;
1305 if (nm == NULL) CodeCache::find_blob(caller_frame.pc());
1306 CompiledIC* inline_cache = CompiledIC_before(caller_nm, caller_frame.pc());
1293 if (inline_cache->is_clean()) { 1307 if (inline_cache->is_clean()) {
1294 inline_cache->set_to_monomorphic(virtual_call_info); 1308 inline_cache->set_to_monomorphic(virtual_call_info);
1295 } 1309 }
1296 } else { 1310 } else {
1297 CompiledStaticCall* ssc = compiledStaticCall_before(caller_frame.pc()); 1311 CompiledStaticCall* ssc = compiledStaticCall_before(caller_frame.pc());
1316 #endif /* ASSERT */ 1330 #endif /* ASSERT */
1317 1331
1318 methodHandle callee_method; 1332 methodHandle callee_method;
1319 JRT_BLOCK 1333 JRT_BLOCK
1320 callee_method = SharedRuntime::handle_ic_miss_helper(thread, CHECK_NULL); 1334 callee_method = SharedRuntime::handle_ic_miss_helper(thread, CHECK_NULL);
1321 // Return methodOop through TLS 1335 // Return Method* through TLS
1322 thread->set_vm_result(callee_method()); 1336 thread->set_vm_result_2(callee_method());
1323 JRT_BLOCK_END 1337 JRT_BLOCK_END
1324 // return compiled code entry point after potential safepoints 1338 // return compiled code entry point after potential safepoints
1325 assert(callee_method->verified_code_entry() != NULL, " Jump to zero!"); 1339 assert(callee_method->verified_code_entry() != NULL, " Jump to zero!");
1326 return callee_method->verified_code_entry(); 1340 return callee_method->verified_code_entry();
1327 JRT_END 1341 JRT_END
1349 CodeBlob* sender_cb = caller_frame.cb(); 1363 CodeBlob* sender_cb = caller_frame.cb();
1350 nmethod* sender_nm = sender_cb->as_nmethod_or_null(); 1364 nmethod* sender_nm = sender_cb->as_nmethod_or_null();
1351 1365
1352 if (caller_frame.is_interpreted_frame() || 1366 if (caller_frame.is_interpreted_frame() ||
1353 caller_frame.is_entry_frame()) { 1367 caller_frame.is_entry_frame()) {
1354 methodOop callee = thread->callee_target(); 1368 Method* callee = thread->callee_target();
1355 guarantee(callee != NULL && callee->is_method(), "bad handshake"); 1369 guarantee(callee != NULL && callee->is_method(), "bad handshake");
1356 thread->set_vm_result(callee); 1370 thread->set_vm_result_2(callee);
1357 thread->set_callee_target(NULL); 1371 thread->set_callee_target(NULL);
1358 return callee->get_c2i_entry(); 1372 return callee->get_c2i_entry();
1359 } 1373 }
1360 1374
1361 // Must be compiled to compiled path which is safe to stackwalk 1375 // Must be compiled to compiled path which is safe to stackwalk
1362 methodHandle callee_method; 1376 methodHandle callee_method;
1363 JRT_BLOCK 1377 JRT_BLOCK
1364 // Force resolving of caller (if we called from compiled frame) 1378 // Force resolving of caller (if we called from compiled frame)
1365 callee_method = SharedRuntime::reresolve_call_site(thread, CHECK_NULL); 1379 callee_method = SharedRuntime::reresolve_call_site(thread, CHECK_NULL);
1366 thread->set_vm_result(callee_method()); 1380 thread->set_vm_result_2(callee_method());
1367 JRT_BLOCK_END 1381 JRT_BLOCK_END
1368 // return compiled code entry point after potential safepoints 1382 // return compiled code entry point after potential safepoints
1369 assert(callee_method->verified_code_entry() != NULL, " Jump to zero!"); 1383 assert(callee_method->verified_code_entry() != NULL, " Jump to zero!");
1370 return callee_method->verified_code_entry(); 1384 return callee_method->verified_code_entry();
1371 JRT_END 1385 JRT_END
1374 // resolve a static call and patch code 1388 // resolve a static call and patch code
1375 JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_static_call_C(JavaThread *thread )) 1389 JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_static_call_C(JavaThread *thread ))
1376 methodHandle callee_method; 1390 methodHandle callee_method;
1377 JRT_BLOCK 1391 JRT_BLOCK
1378 callee_method = SharedRuntime::resolve_helper(thread, false, false, CHECK_NULL); 1392 callee_method = SharedRuntime::resolve_helper(thread, false, false, CHECK_NULL);
1379 thread->set_vm_result(callee_method()); 1393 thread->set_vm_result_2(callee_method());
1380 JRT_BLOCK_END 1394 JRT_BLOCK_END
1381 // return compiled code entry point after potential safepoints 1395 // return compiled code entry point after potential safepoints
1382 assert(callee_method->verified_code_entry() != NULL, " Jump to zero!"); 1396 assert(callee_method->verified_code_entry() != NULL, " Jump to zero!");
1383 return callee_method->verified_code_entry(); 1397 return callee_method->verified_code_entry();
1384 JRT_END 1398 JRT_END
1387 // resolve virtual call and update inline cache to monomorphic 1401 // resolve virtual call and update inline cache to monomorphic
1388 JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_virtual_call_C(JavaThread *thread )) 1402 JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_virtual_call_C(JavaThread *thread ))
1389 methodHandle callee_method; 1403 methodHandle callee_method;
1390 JRT_BLOCK 1404 JRT_BLOCK
1391 callee_method = SharedRuntime::resolve_helper(thread, true, false, CHECK_NULL); 1405 callee_method = SharedRuntime::resolve_helper(thread, true, false, CHECK_NULL);
1392 thread->set_vm_result(callee_method()); 1406 thread->set_vm_result_2(callee_method());
1393 JRT_BLOCK_END 1407 JRT_BLOCK_END
1394 // return compiled code entry point after potential safepoints 1408 // return compiled code entry point after potential safepoints
1395 assert(callee_method->verified_code_entry() != NULL, " Jump to zero!"); 1409 assert(callee_method->verified_code_entry() != NULL, " Jump to zero!");
1396 return callee_method->verified_code_entry(); 1410 return callee_method->verified_code_entry();
1397 JRT_END 1411 JRT_END
1401 // monomorphic, so it has no inline cache). Patch code to resolved target. 1415 // monomorphic, so it has no inline cache). Patch code to resolved target.
1402 JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_opt_virtual_call_C(JavaThread *thread)) 1416 JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_opt_virtual_call_C(JavaThread *thread))
1403 methodHandle callee_method; 1417 methodHandle callee_method;
1404 JRT_BLOCK 1418 JRT_BLOCK
1405 callee_method = SharedRuntime::resolve_helper(thread, true, true, CHECK_NULL); 1419 callee_method = SharedRuntime::resolve_helper(thread, true, true, CHECK_NULL);
1406 thread->set_vm_result(callee_method()); 1420 thread->set_vm_result_2(callee_method());
1407 JRT_BLOCK_END 1421 JRT_BLOCK_END
1408 // return compiled code entry point after potential safepoints 1422 // return compiled code entry point after potential safepoints
1409 assert(callee_method->verified_code_entry() != NULL, " Jump to zero!"); 1423 assert(callee_method->verified_code_entry() != NULL, " Jump to zero!");
1410 return callee_method->verified_code_entry(); 1424 return callee_method->verified_code_entry();
1411 JRT_END 1425 JRT_END
1484 RegisterMap reg_map(thread, false); 1498 RegisterMap reg_map(thread, false);
1485 frame caller_frame = thread->last_frame().sender(&reg_map); 1499 frame caller_frame = thread->last_frame().sender(&reg_map);
1486 CodeBlob* cb = caller_frame.cb(); 1500 CodeBlob* cb = caller_frame.cb();
1487 if (cb->is_nmethod() && ((nmethod*)cb)->is_in_use()) { 1501 if (cb->is_nmethod() && ((nmethod*)cb)->is_in_use()) {
1488 // Not a non-entrant nmethod, so find inline_cache 1502 // Not a non-entrant nmethod, so find inline_cache
1489 CompiledIC* inline_cache = CompiledIC_before(caller_frame.pc()); 1503 CompiledIC* inline_cache = CompiledIC_before(((nmethod*)cb), caller_frame.pc());
1490 bool should_be_mono = false; 1504 bool should_be_mono = false;
1491 if (inline_cache->is_optimized()) { 1505 if (inline_cache->is_optimized()) {
1492 if (TraceCallFixup) { 1506 if (TraceCallFixup) {
1493 ResourceMark rm(thread); 1507 ResourceMark rm(thread);
1494 tty->print("OPTIMIZED IC miss (%s) call to", Bytecodes::name(bc)); 1508 tty->print("OPTIMIZED IC miss (%s) call to", Bytecodes::name(bc));
1495 callee_method->print_short_name(tty); 1509 callee_method->print_short_name(tty);
1496 tty->print_cr(" code: " INTPTR_FORMAT, callee_method->code()); 1510 tty->print_cr(" code: " INTPTR_FORMAT, callee_method->code());
1497 } 1511 }
1498 should_be_mono = true; 1512 should_be_mono = true;
1499 } else { 1513 } else if (inline_cache->is_icholder_call()) {
1500 compiledICHolderOop ic_oop = (compiledICHolderOop) inline_cache->cached_oop(); 1514 CompiledICHolder* ic_oop = inline_cache->cached_icholder();
1501 if ( ic_oop != NULL && ic_oop->is_compiledICHolder()) { 1515 if ( ic_oop != NULL) {
1502 1516
1503 if (receiver()->klass() == ic_oop->holder_klass()) { 1517 if (receiver()->klass() == ic_oop->holder_klass()) {
1504 // This isn't a real miss. We must have seen that compiled code 1518 // This isn't a real miss. We must have seen that compiled code
1505 // is now available and we want the call site converted to a 1519 // is now available and we want the call site converted to a
1506 // monomorphic compiled call site. 1520 // monomorphic compiled call site.
1633 if (is_static_call) { 1647 if (is_static_call) {
1634 CompiledStaticCall* ssc= compiledStaticCall_at(call_addr); 1648 CompiledStaticCall* ssc= compiledStaticCall_at(call_addr);
1635 ssc->set_to_clean(); 1649 ssc->set_to_clean();
1636 } else { 1650 } else {
1637 // compiled, dispatched call (which used to call an interpreted method) 1651 // compiled, dispatched call (which used to call an interpreted method)
1638 CompiledIC* inline_cache = CompiledIC_at(call_addr); 1652 CompiledIC* inline_cache = CompiledIC_at(caller_nm, call_addr);
1639 inline_cache->set_to_clean(); 1653 inline_cache->set_to_clean();
1640 } 1654 }
1641 } 1655 }
1642 } 1656 }
1643 1657
1657 } 1671 }
1658 #endif 1672 #endif
1659 1673
1660 return callee_method; 1674 return callee_method;
1661 } 1675 }
1676
1677 #ifdef ASSERT
1678 void SharedRuntime::check_member_name_argument_is_last_argument(methodHandle method,
1679 const BasicType* sig_bt,
1680 const VMRegPair* regs) {
1681 ResourceMark rm;
1682 const int total_args_passed = method->size_of_parameters();
1683 const VMRegPair* regs_with_member_name = regs;
1684 VMRegPair* regs_without_member_name = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed - 1);
1685
1686 const int member_arg_pos = total_args_passed - 1;
1687 assert(member_arg_pos >= 0 && member_arg_pos < total_args_passed, "oob");
1688 assert(sig_bt[member_arg_pos] == T_OBJECT, "dispatch argument must be an object");
1689
1690 const bool is_outgoing = method->is_method_handle_intrinsic();
1691 int comp_args_on_stack = java_calling_convention(sig_bt, regs_without_member_name, total_args_passed - 1, is_outgoing);
1692
1693 for (int i = 0; i < member_arg_pos; i++) {
1694 VMReg a = regs_with_member_name[i].first();
1695 VMReg b = regs_without_member_name[i].first();
1696 assert(a->value() == b->value(), err_msg_res("register allocation mismatch: a=%d, b=%d", a->value(), b->value()));
1697 }
1698 assert(regs_with_member_name[member_arg_pos].first()->is_valid(), "bad member arg");
1699 }
1700 #endif
1662 1701
1663 // --------------------------------------------------------------------------- 1702 // ---------------------------------------------------------------------------
1664 // We are calling the interpreter via a c2i. Normally this would mean that 1703 // We are calling the interpreter via a c2i. Normally this would mean that
1665 // we were called by a compiled method. However we could have lost a race 1704 // we were called by a compiled method. However we could have lost a race
1666 // where we went int -> i2c -> c2i and so the caller could in fact be 1705 // where we went int -> i2c -> c2i and so the caller could in fact be
1667 // interpreted. If the caller is compiled we attempt to patch the caller 1706 // interpreted. If the caller is compiled we attempt to patch the caller
1668 // so he no longer calls into the interpreter. 1707 // so he no longer calls into the interpreter.
1669 IRT_LEAF(void, SharedRuntime::fixup_callers_callsite(methodOopDesc* method, address caller_pc)) 1708 IRT_LEAF(void, SharedRuntime::fixup_callers_callsite(Method* method, address caller_pc))
1670 methodOop moop(method); 1709 Method* moop(method);
1671
1672 assert(moop->is_oop(false) && moop->is_method(), "method oop from call site is invalid");
1673 1710
1674 address entry_point = moop->from_compiled_entry(); 1711 address entry_point = moop->from_compiled_entry();
1675 1712
1676 // It's possible that deoptimization can occur at a call site which hasn't 1713 // It's possible that deoptimization can occur at a call site which hasn't
1677 // been resolved yet, in which case this function will be called from 1714 // been resolved yet, in which case this function will be called from
1678 // an nmethod that has been patched for deopt and we can ignore the 1715 // an nmethod that has been patched for deopt and we can ignore the
1679 // request for a fixup. 1716 // request for a fixup.
1680 // Also it is possible that we lost a race in that from_compiled_entry 1717 // Also it is possible that we lost a race in that from_compiled_entry
1681 // is now back to the i2c in that case we don't need to patch and if 1718 // is now back to the i2c in that case we don't need to patch and if
1682 // we did we'd leap into space because the callsite needs to use 1719 // we did we'd leap into space because the callsite needs to use
1683 // "to interpreter" stub in order to load up the methodOop. Don't 1720 // "to interpreter" stub in order to load up the Method*. Don't
1684 // ask me how I know this... 1721 // ask me how I know this...
1685 1722
1686 CodeBlob* cb = CodeCache::find_blob(caller_pc); 1723 CodeBlob* cb = CodeCache::find_blob(caller_pc);
1687 if (!cb->is_nmethod() || entry_point == moop->get_c2i_entry()) { 1724 if (!cb->is_nmethod() || entry_point == moop->get_c2i_entry()) {
1688 return; 1725 return;
1951 static int _size_histogram[MAX_ARITY]; // histogram of arg size in words 1988 static int _size_histogram[MAX_ARITY]; // histogram of arg size in words
1952 static int _max_arity; // max. arity seen 1989 static int _max_arity; // max. arity seen
1953 static int _max_size; // max. arg size seen 1990 static int _max_size; // max. arg size seen
1954 1991
1955 static void add_method_to_histogram(nmethod* nm) { 1992 static void add_method_to_histogram(nmethod* nm) {
1956 methodOop m = nm->method(); 1993 Method* m = nm->method();
1957 ArgumentCount args(m->signature()); 1994 ArgumentCount args(m->signature());
1958 int arity = args.size() + (m->is_static() ? 0 : 1); 1995 int arity = args.size() + (m->is_static() ? 0 : 1);
1959 int argsize = m->size_of_parameters(); 1996 int argsize = m->size_of_parameters();
1960 arity = MIN2(arity, MAX_ARITY-1); 1997 arity = MIN2(arity, MAX_ARITY-1);
1961 argsize = MIN2(argsize, MAX_ARITY-1); 1998 argsize = MIN2(argsize, MAX_ARITY-1);
2465 } 2502 }
2466 entry->relocate(B->content_begin()); 2503 entry->relocate(B->content_begin());
2467 #ifndef PRODUCT 2504 #ifndef PRODUCT
2468 // debugging suppport 2505 // debugging suppport
2469 if (PrintAdapterHandlers || PrintStubCode) { 2506 if (PrintAdapterHandlers || PrintStubCode) {
2507 ttyLocker ttyl;
2470 entry->print_adapter_on(tty); 2508 entry->print_adapter_on(tty);
2471 tty->print_cr("i2c argument handler #%d for: %s %s (%d bytes generated)", 2509 tty->print_cr("i2c argument handler #%d for: %s %s (%d bytes generated)",
2472 _adapters->number_of_entries(), (method->is_static() ? "static" : "receiver"), 2510 _adapters->number_of_entries(), (method->is_static() ? "static" : "receiver"),
2473 method->signature()->as_C_string(), insts_size); 2511 method->signature()->as_C_string(), insts_size);
2474 tty->print_cr("c2i argument handler starts at %p",entry->get_c2i_entry()); 2512 tty->print_cr("c2i argument handler starts at %p",entry->get_c2i_entry());
2475 if (Verbose || PrintStubCode) { 2513 if (Verbose || PrintStubCode) {
2476 address first_pc = entry->base_address(); 2514 address first_pc = entry->base_address();
2477 if (first_pc != NULL) 2515 if (first_pc != NULL) {
2478 Disassembler::decode(first_pc, first_pc + insts_size); 2516 Disassembler::decode(first_pc, first_pc + insts_size);
2517 tty->cr();
2518 }
2479 } 2519 }
2480 } 2520 }
2481 #endif 2521 #endif
2482 2522
2483 _adapters->add(entry); 2523 _adapters->add(entry);
2588 double locs_buf[20]; 2628 double locs_buf[20];
2589 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo)); 2629 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo));
2590 MacroAssembler _masm(&buffer); 2630 MacroAssembler _masm(&buffer);
2591 2631
2592 // Fill in the signature array, for the calling-convention call. 2632 // Fill in the signature array, for the calling-convention call.
2593 int total_args_passed = method->size_of_parameters(); 2633 const int total_args_passed = method->size_of_parameters();
2594 2634
2595 BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType,total_args_passed); 2635 BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed);
2596 VMRegPair* regs = NEW_RESOURCE_ARRAY(VMRegPair,total_args_passed); 2636 VMRegPair* regs = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed);
2597 int i=0; 2637 int i=0;
2598 if( !method->is_static() ) // Pass in receiver first 2638 if( !method->is_static() ) // Pass in receiver first
2599 sig_bt[i++] = T_OBJECT; 2639 sig_bt[i++] = T_OBJECT;
2600 SignatureStream ss(method->signature()); 2640 SignatureStream ss(method->signature());
2601 for( ; !ss.at_return_type(); ss.next()) { 2641 for( ; !ss.at_return_type(); ss.next()) {
2602 sig_bt[i++] = ss.type(); // Collect remaining bits of signature 2642 sig_bt[i++] = ss.type(); // Collect remaining bits of signature
2603 if( ss.type() == T_LONG || ss.type() == T_DOUBLE ) 2643 if( ss.type() == T_LONG || ss.type() == T_DOUBLE )
2604 sig_bt[i++] = T_VOID; // Longs & doubles take 2 Java slots 2644 sig_bt[i++] = T_VOID; // Longs & doubles take 2 Java slots
2605 } 2645 }
2606 assert( i==total_args_passed, "" ); 2646 assert(i == total_args_passed, "");
2607 BasicType ret_type = ss.type(); 2647 BasicType ret_type = ss.type();
2608 2648
2609 // Now get the compiled-Java layout as input (or output) arguments. 2649 // Now get the compiled-Java layout as input (or output) arguments.
2610 // NOTE: Stubs for compiled entry points of method handle intrinsics 2650 // NOTE: Stubs for compiled entry points of method handle intrinsics
2611 // are just trampolines so the argument registers must be outgoing ones. 2651 // are just trampolines so the argument registers must be outgoing ones.
2614 2654
2615 // Generate the compiled-to-native wrapper code 2655 // Generate the compiled-to-native wrapper code
2616 nm = SharedRuntime::generate_native_wrapper(&_masm, 2656 nm = SharedRuntime::generate_native_wrapper(&_masm,
2617 method, 2657 method,
2618 compile_id, 2658 compile_id,
2619 total_args_passed, 2659 sig_bt,
2620 comp_args_on_stack, 2660 regs,
2621 sig_bt,regs,
2622 ret_type); 2661 ret_type);
2623 } 2662 }
2624 } 2663 }
2625 2664
2626 // Must unlock before calling set_code 2665 // Must unlock before calling set_code
2708 typeArrayOop jlsValue = java_lang_String::value(src); 2747 typeArrayOop jlsValue = java_lang_String::value(src);
2709 int jlsOffset = java_lang_String::offset(src); 2748 int jlsOffset = java_lang_String::offset(src);
2710 int jlsLen = java_lang_String::length(src); 2749 int jlsLen = java_lang_String::length(src);
2711 jchar* jlsPos = (jlsLen == 0) ? NULL : 2750 jchar* jlsPos = (jlsLen == 0) ? NULL :
2712 jlsValue->char_at_addr(jlsOffset); 2751 jlsValue->char_at_addr(jlsOffset);
2713 assert(typeArrayKlass::cast(jlsValue->klass())->element_type() == T_CHAR, "compressed string"); 2752 assert(TypeArrayKlass::cast(jlsValue->klass())->element_type() == T_CHAR, "compressed string");
2714 (void) UNICODE::as_utf8(jlsPos, jlsLen, (char *)dst, max_dtrace_string_size); 2753 (void) UNICODE::as_utf8(jlsPos, jlsLen, (char *)dst, max_dtrace_string_size);
2715 } 2754 }
2716 #endif // ndef HAVE_DTRACE_H 2755 #endif // ndef HAVE_DTRACE_H
2717 2756
2718 // ------------------------------------------------------------------------- 2757 // -------------------------------------------------------------------------
2844 } 2883 }
2845 2884
2846 // QQQ we could place number of active monitors in the array so that compiled code 2885 // QQQ we could place number of active monitors in the array so that compiled code
2847 // could double check it. 2886 // could double check it.
2848 2887
2849 methodOop moop = fr.interpreter_frame_method(); 2888 Method* moop = fr.interpreter_frame_method();
2850 int max_locals = moop->max_locals(); 2889 int max_locals = moop->max_locals();
2851 // Allocate temp buffer, 1 word per local & 2 per active monitor 2890 // Allocate temp buffer, 1 word per local & 2 per active monitor
2852 int buf_size_words = max_locals + active_monitor_count*2; 2891 int buf_size_words = max_locals + active_monitor_count*2;
2853 intptr_t *buf = NEW_C_HEAP_ARRAY(intptr_t,buf_size_words, mtCode); 2892 intptr_t *buf = NEW_C_HEAP_ARRAY(intptr_t,buf_size_words, mtCode);
2854 2893