comparison src/share/vm/runtime/deoptimization.cpp @ 22298:c28cb37b2e1d

Rename JVMCI to INCLUDE_JVMCI.
author twisti
date Wed, 22 Jul 2015 08:56:03 -0700
parents be896a1983c0
children fd3d534aecca
comparison
equal deleted inserted replaced
22297:571202729bbf 22298:c28cb37b2e1d
90 #endif 90 #endif
91 #endif // COMPILER2 91 #endif // COMPILER2
92 92
93 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC 93 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
94 94
95 #ifdef JVMCI 95 #if INCLUDE_JVMCI
96 #include "jvmci/jvmciRuntime.hpp" 96 #include "jvmci/jvmciRuntime.hpp"
97 #include "jvmci/jvmciJavaAccess.hpp" 97 #include "jvmci/jvmciJavaAccess.hpp"
98 #endif 98 #endif
99 99
100 100
223 assert(vf->is_compiled_frame(), "Wrong frame type"); 223 assert(vf->is_compiled_frame(), "Wrong frame type");
224 chunk->push(compiledVFrame::cast(vf)); 224 chunk->push(compiledVFrame::cast(vf));
225 225
226 bool realloc_failures = false; 226 bool realloc_failures = false;
227 227
228 #if defined(COMPILER2) || defined(JVMCI) 228 #if defined(COMPILER2) || INCLUDE_JVMCI
229 // Reallocate the non-escaping objects and restore their fields. Then 229 // Reallocate the non-escaping objects and restore their fields. Then
230 // relock objects if synchronization on them was eliminated. 230 // relock objects if synchronization on them was eliminated.
231 #ifdef COMPILER2 231 #ifdef COMPILER2
232 if (DoEscapeAnalysis || EliminateNestedLocks) { 232 if (DoEscapeAnalysis || EliminateNestedLocks) {
233 if (EliminateAllocations) { 233 if (EliminateAllocations) {
311 } 311 }
312 #ifdef COMPILER2 312 #ifdef COMPILER2
313 } 313 }
314 } 314 }
315 #endif // COMPILER2 315 #endif // COMPILER2
316 #endif // COMPILER2 || JVMCI 316 #endif // COMPILER2 || INCLUDE_JVMCI
317 317
318 // Ensure that no safepoint is taken after pointers have been stored 318 // Ensure that no safepoint is taken after pointers have been stored
319 // in fields of rematerialized objects. If a safepoint occurs from here on 319 // in fields of rematerialized objects. If a safepoint occurs from here on
320 // out the java state residing in the vframeArray will be missed. 320 // out the java state residing in the vframeArray will be missed.
321 No_Safepoint_Verifier no_safepoint; 321 No_Safepoint_Verifier no_safepoint;
322 322
323 vframeArray* array = create_vframeArray(thread, deoptee, &map, chunk, realloc_failures); 323 vframeArray* array = create_vframeArray(thread, deoptee, &map, chunk, realloc_failures);
324 #if defined(COMPILER2) || defined(JVMCI) 324 #if defined(COMPILER2) || INCLUDE_JVMCI
325 if (realloc_failures) { 325 if (realloc_failures) {
326 pop_frames_failed_reallocs(thread, array); 326 pop_frames_failed_reallocs(thread, array);
327 } 327 }
328 #endif 328 #endif
329 329
774 Threads::deoptimized_wrt_marked_nmethods(); 774 Threads::deoptimized_wrt_marked_nmethods();
775 return 0; 775 return 0;
776 } 776 }
777 777
778 778
779 #if defined(COMPILER2) || defined(JVMCI) 779 #if defined(COMPILER2) || INCLUDE_JVMCI
780 bool Deoptimization::realloc_objects(JavaThread* thread, frame* fr, GrowableArray<ScopeValue*>* objects, TRAPS) { 780 bool Deoptimization::realloc_objects(JavaThread* thread, frame* fr, GrowableArray<ScopeValue*>* objects, TRAPS) {
781 Handle pending_exception(thread->pending_exception()); 781 Handle pending_exception(thread->pending_exception());
782 const char* exception_file = thread->exception_file(); 782 const char* exception_file = thread->exception_file();
783 int exception_line = thread->exception_line(); 783 int exception_line = thread->exception_line();
784 thread->clear_pending_exception(); 784 thread->clear_pending_exception();
1109 k->oop_print_on(obj(), tty); 1109 k->oop_print_on(obj(), tty);
1110 } 1110 }
1111 } 1111 }
1112 } 1112 }
1113 #endif 1113 #endif
1114 #endif // COMPILER2 || JVMCI 1114 #endif // COMPILER2 || INCLUDE_JVMCI
1115 1115
1116 vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures) { 1116 vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures) {
1117 Events::log(thread, "DEOPT PACKING pc=" INTPTR_FORMAT " sp=" INTPTR_FORMAT, fr.pc(), fr.sp()); 1117 Events::log(thread, "DEOPT PACKING pc=" INTPTR_FORMAT " sp=" INTPTR_FORMAT, fr.pc(), fr.sp());
1118 1118
1119 #ifndef PRODUCT 1119 #ifndef PRODUCT
1169 #endif // PRODUCT 1169 #endif // PRODUCT
1170 1170
1171 return array; 1171 return array;
1172 } 1172 }
1173 1173
1174 #if defined(COMPILER2) || defined(JVMCI) 1174 #if defined(COMPILER2) || INCLUDE_JVMCI
1175 void Deoptimization::pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array) { 1175 void Deoptimization::pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array) {
1176 // Reallocation of some scalar replaced objects failed. Record 1176 // Reallocation of some scalar replaced objects failed. Record
1177 // that we need to pop all the interpreter frames for the 1177 // that we need to pop all the interpreter frames for the
1178 // deoptimized compiled frame. 1178 // deoptimized compiled frame.
1179 assert(thread->frames_to_pop_failed_realloc() == 0, "missed frames to pop?"); 1179 assert(thread->frames_to_pop_failed_realloc() == 0, "missed frames to pop?");
1359 thread->popframe_preserve_args(in_ByteSize(bytes_to_save), start_address); 1359 thread->popframe_preserve_args(in_ByteSize(bytes_to_save), start_address);
1360 } 1360 }
1361 JRT_END 1361 JRT_END
1362 1362
1363 1363
1364 #if defined(COMPILER2) || defined(SHARK) || defined(JVMCI) 1364 #if defined(COMPILER2) || defined(SHARK) || INCLUDE_JVMCI
1365 void Deoptimization::load_class_by_index(constantPoolHandle constant_pool, int index, TRAPS) { 1365 void Deoptimization::load_class_by_index(constantPoolHandle constant_pool, int index, TRAPS) {
1366 // in case of an unresolved klass entry, load the class. 1366 // in case of an unresolved klass entry, load the class.
1367 if (constant_pool->tag_at(index).is_unresolved_klass()) { 1367 if (constant_pool->tag_at(index).is_unresolved_klass()) {
1368 Klass* tk = constant_pool->klass_at(index, CHECK); 1368 Klass* tk = constant_pool->klass_at(index, CHECK);
1369 return; 1369 return;
1422 // that can confuse an asynchronous stack walker. This counter is 1422 // that can confuse an asynchronous stack walker. This counter is
1423 // decremented at the end of unpack_frames(). 1423 // decremented at the end of unpack_frames().
1424 thread->inc_in_deopt_handler(); 1424 thread->inc_in_deopt_handler();
1425 1425
1426 // We need to update the map if we have biased locking. 1426 // We need to update the map if we have biased locking.
1427 #ifdef JVMCI 1427 #if INCLUDE_JVMCI
1428 // (lstadler) JVMCI might need to get an exception from the stack, which in turn requires the register map to be valid 1428 // (lstadler) JVMCI might need to get an exception from the stack, which in turn requires the register map to be valid
1429 RegisterMap reg_map(thread, true); 1429 RegisterMap reg_map(thread, true);
1430 #else 1430 #else
1431 RegisterMap reg_map(thread, UseBiasedLocking); 1431 RegisterMap reg_map(thread, UseBiasedLocking);
1432 #endif 1432 #endif
1446 // Revoke biases of any monitors in the frame to ensure we can migrate them 1446 // Revoke biases of any monitors in the frame to ensure we can migrate them
1447 revoke_biases_of_monitors(thread, fr, &reg_map); 1447 revoke_biases_of_monitors(thread, fr, &reg_map);
1448 1448
1449 DeoptReason reason = trap_request_reason(trap_request); 1449 DeoptReason reason = trap_request_reason(trap_request);
1450 DeoptAction action = trap_request_action(trap_request); 1450 DeoptAction action = trap_request_action(trap_request);
1451 #ifdef JVMCI 1451 #if INCLUDE_JVMCI
1452 int debug_id = trap_request_debug_id(trap_request); 1452 int debug_id = trap_request_debug_id(trap_request);
1453 #endif 1453 #endif
1454 jint unloaded_class_index = trap_request_index(trap_request); // CP idx or -1 1454 jint unloaded_class_index = trap_request_index(trap_request); // CP idx or -1
1455 1455
1456 vframe* vf = vframe::new_vframe(&fr, &reg_map, thread); 1456 vframe* vf = vframe::new_vframe(&fr, &reg_map, thread);
1461 ScopeDesc* trap_scope = cvf->scope(); 1461 ScopeDesc* trap_scope = cvf->scope();
1462 1462
1463 if (TraceDeoptimization) { 1463 if (TraceDeoptimization) {
1464 ttyLocker ttyl; 1464 ttyLocker ttyl;
1465 tty->print_cr(" bci=%d pc=" INTPTR_FORMAT ", relative_pc=%d, method=%s" JVMCI_ONLY(", debug_id=%d"), trap_scope->bci(), fr.pc(), fr.pc() - nm->code_begin(), trap_scope->method()->name_and_sig_as_C_string() 1465 tty->print_cr(" bci=%d pc=" INTPTR_FORMAT ", relative_pc=%d, method=%s" JVMCI_ONLY(", debug_id=%d"), trap_scope->bci(), fr.pc(), fr.pc() - nm->code_begin(), trap_scope->method()->name_and_sig_as_C_string()
1466 #ifdef JVMCI 1466 #if INCLUDE_JVMCI
1467 , debug_id 1467 , debug_id
1468 #endif 1468 #endif
1469 ); 1469 );
1470 } 1470 }
1471 1471
1472 methodHandle trap_method = trap_scope->method(); 1472 methodHandle trap_method = trap_scope->method();
1473 int trap_bci = trap_scope->bci(); 1473 int trap_bci = trap_scope->bci();
1474 #ifdef JVMCI 1474 #if INCLUDE_JVMCI
1475 oop speculation = thread->pending_failed_speculation(); 1475 oop speculation = thread->pending_failed_speculation();
1476 if (nm->is_compiled_by_jvmci()) { 1476 if (nm->is_compiled_by_jvmci()) {
1477 if (speculation != NULL) { 1477 if (speculation != NULL) {
1478 oop speculation_log = nm->speculation_log(); 1478 oop speculation_log = nm->speculation_log();
1479 if (speculation_log != NULL) { 1479 if (speculation_log != NULL) {
1532 // Ensure that we can record deopt. history: 1532 // Ensure that we can record deopt. history:
1533 // Need MDO to record RTM code generation state. 1533 // Need MDO to record RTM code generation state.
1534 bool create_if_missing = ProfileTraps RTM_OPT_ONLY( || UseRTMLocking ); 1534 bool create_if_missing = ProfileTraps RTM_OPT_ONLY( || UseRTMLocking );
1535 1535
1536 methodHandle profiled_method; 1536 methodHandle profiled_method;
1537 #ifdef JVMCI 1537 #if INCLUDE_JVMCI
1538 if (nm->is_compiled_by_jvmci()) { 1538 if (nm->is_compiled_by_jvmci()) {
1539 profiled_method = nm->method(); 1539 profiled_method = nm->method();
1540 } else { 1540 } else {
1541 profiled_method = trap_method; 1541 profiled_method = trap_method;
1542 } 1542 }
1602 } 1602 }
1603 if (TraceDeoptimization) { // make noise on the tty 1603 if (TraceDeoptimization) { // make noise on the tty
1604 tty->print("Uncommon trap occurred in"); 1604 tty->print("Uncommon trap occurred in");
1605 nm->method()->print_short_name(tty); 1605 nm->method()->print_short_name(tty);
1606 tty->print(" compiler=%s compile_id=%d", nm->compiler() == NULL ? "" : nm->compiler()->name(), nm->compile_id()); 1606 tty->print(" compiler=%s compile_id=%d", nm->compiler() == NULL ? "" : nm->compiler()->name(), nm->compile_id());
1607 #ifdef JVMCI 1607 #if INCLUDE_JVMCI
1608 oop installedCode = nm->jvmci_installed_code(); 1608 oop installedCode = nm->jvmci_installed_code();
1609 if (installedCode != NULL) { 1609 if (installedCode != NULL) {
1610 oop installedCodeName = NULL; 1610 oop installedCodeName = NULL;
1611 if (installedCode->is_a(InstalledCode::klass())) { 1611 if (installedCode->is_a(InstalledCode::klass())) {
1612 installedCodeName = InstalledCode::name(installedCode); 1612 installedCodeName = InstalledCode::name(installedCode);
1617 tty->print(" (JVMCI: installed code has no name) "); 1617 tty->print(" (JVMCI: installed code has no name) ");
1618 } 1618 }
1619 } else if (nm->is_compiled_by_jvmci()) { 1619 } else if (nm->is_compiled_by_jvmci()) {
1620 tty->print(" (JVMCI: no installed code) "); 1620 tty->print(" (JVMCI: no installed code) ");
1621 } 1621 }
1622 #endif //JVMCI 1622 #endif
1623 tty->print(" (@" INTPTR_FORMAT ") thread=" UINTX_FORMAT " reason=%s action=%s unloaded_class_index=%d" JVMCI_ONLY(" debug_id=%d"), 1623 tty->print(" (@" INTPTR_FORMAT ") thread=" UINTX_FORMAT " reason=%s action=%s unloaded_class_index=%d" JVMCI_ONLY(" debug_id=%d"),
1624 fr.pc(), 1624 fr.pc(),
1625 os::current_thread_id(), 1625 os::current_thread_id(),
1626 trap_reason_name(reason), 1626 trap_reason_name(reason),
1627 trap_action_name(action), 1627 trap_action_name(action),
1628 unloaded_class_index 1628 unloaded_class_index
1629 #ifdef JVMCI 1629 #if INCLUDE_JVMCI
1630 , debug_id 1630 , debug_id
1631 #endif 1631 #endif
1632 ); 1632 );
1633 if (class_name != NULL) { 1633 if (class_name != NULL) {
1634 tty->print(unresolved ? " unresolved class: " : " symbol: "); 1634 tty->print(unresolved ? " unresolved class: " : " symbol: ");
1762 assert(trap_mdo == get_method_data(thread, profiled_method, false), "sanity"); 1762 assert(trap_mdo == get_method_data(thread, profiled_method, false), "sanity");
1763 uint this_trap_count = 0; 1763 uint this_trap_count = 0;
1764 bool maybe_prior_trap = false; 1764 bool maybe_prior_trap = false;
1765 bool maybe_prior_recompile = false; 1765 bool maybe_prior_recompile = false;
1766 pdata = query_update_method_data(trap_mdo, trap_bci, reason, true, 1766 pdata = query_update_method_data(trap_mdo, trap_bci, reason, true,
1767 #ifdef JVMCI 1767 #if INCLUDE_JVMCI
1768 nm->is_compiled_by_jvmci() && nm->is_osr_method(), 1768 nm->is_compiled_by_jvmci() && nm->is_osr_method(),
1769 #endif 1769 #endif
1770 nm->method(), 1770 nm->method(),
1771 //outputs: 1771 //outputs:
1772 this_trap_count, 1772 this_trap_count,
1911 ProfileData* 1911 ProfileData*
1912 Deoptimization::query_update_method_data(MethodData* trap_mdo, 1912 Deoptimization::query_update_method_data(MethodData* trap_mdo,
1913 int trap_bci, 1913 int trap_bci,
1914 Deoptimization::DeoptReason reason, 1914 Deoptimization::DeoptReason reason,
1915 bool update_total_trap_count, 1915 bool update_total_trap_count,
1916 #ifdef JVMCI 1916 #if INCLUDE_JVMCI
1917 bool is_osr, 1917 bool is_osr,
1918 #endif 1918 #endif
1919 Method* compiled_method, 1919 Method* compiled_method,
1920 //outputs: 1920 //outputs:
1921 uint& ret_this_trap_count, 1921 uint& ret_this_trap_count,
1924 bool maybe_prior_trap = false; 1924 bool maybe_prior_trap = false;
1925 bool maybe_prior_recompile = false; 1925 bool maybe_prior_recompile = false;
1926 uint this_trap_count = 0; 1926 uint this_trap_count = 0;
1927 if (update_total_trap_count) { 1927 if (update_total_trap_count) {
1928 uint idx = reason; 1928 uint idx = reason;
1929 #ifdef JVMCI 1929 #if INCLUDE_JVMCI
1930 if (is_osr) { 1930 if (is_osr) {
1931 idx += Reason_LIMIT; 1931 idx += Reason_LIMIT;
1932 } 1932 }
1933 #endif 1933 #endif
1934 uint prior_trap_count = trap_mdo->trap_count(idx); 1934 uint prior_trap_count = trap_mdo->trap_count(idx);
2003 // JVMCI uses the total counts to determine if deoptimizations are happening too frequently -> do not adjust total counts 2003 // JVMCI uses the total counts to determine if deoptimizations are happening too frequently -> do not adjust total counts
2004 bool update_total_counts = JVMCI_ONLY(false) NOT_JVMCI(true); 2004 bool update_total_counts = JVMCI_ONLY(false) NOT_JVMCI(true);
2005 query_update_method_data(trap_mdo, trap_bci, 2005 query_update_method_data(trap_mdo, trap_bci,
2006 (DeoptReason)reason, 2006 (DeoptReason)reason,
2007 update_total_counts, 2007 update_total_counts,
2008 #ifdef JVMCI 2008 #if INCLUDE_JVMCI
2009 false, 2009 false,
2010 #endif 2010 #endif
2011 NULL, 2011 NULL,
2012 ignore_this_trap_count, 2012 ignore_this_trap_count,
2013 ignore_maybe_prior_trap, 2013 ignore_maybe_prior_trap,
2140 "predicate", 2140 "predicate",
2141 "loop_limit_check", 2141 "loop_limit_check",
2142 "speculate_class_check", 2142 "speculate_class_check",
2143 "rtm_state_change", 2143 "rtm_state_change",
2144 "unstable_if" 2144 "unstable_if"
2145 #ifdef JVMCI 2145 #if INCLUDE_JVMCI
2146 "aliasing", 2146 "aliasing",
2147 "transfer_to_interpreter", 2147 "transfer_to_interpreter",
2148 "not_compiled_exception_handler", 2148 "not_compiled_exception_handler",
2149 "unresolved", 2149 "unresolved",
2150 "jsr_mismatch" 2150 "jsr_mismatch"
2179 const char* Deoptimization::format_trap_request(char* buf, size_t buflen, 2179 const char* Deoptimization::format_trap_request(char* buf, size_t buflen,
2180 int trap_request) { 2180 int trap_request) {
2181 jint unloaded_class_index = trap_request_index(trap_request); 2181 jint unloaded_class_index = trap_request_index(trap_request);
2182 const char* reason = trap_reason_name(trap_request_reason(trap_request)); 2182 const char* reason = trap_reason_name(trap_request_reason(trap_request));
2183 const char* action = trap_action_name(trap_request_action(trap_request)); 2183 const char* action = trap_action_name(trap_request_action(trap_request));
2184 #ifdef JVMCI 2184 #if INCLUDE_JVMCI
2185 int debug_id = trap_request_debug_id(trap_request); 2185 int debug_id = trap_request_debug_id(trap_request);
2186 #endif 2186 #endif
2187 size_t len; 2187 size_t len;
2188 if (unloaded_class_index < 0) { 2188 if (unloaded_class_index < 0) {
2189 len = jio_snprintf(buf, buflen, "reason='%s' action='%s'" JVMCI_ONLY(" debug_id='%d'"), 2189 len = jio_snprintf(buf, buflen, "reason='%s' action='%s'" JVMCI_ONLY(" debug_id='%d'"),
2190 reason, action 2190 reason, action
2191 #ifdef JVMCI 2191 #if INCLUDE_JVMCI
2192 ,debug_id 2192 ,debug_id
2193 #endif 2193 #endif
2194 ); 2194 );
2195 } else { 2195 } else {
2196 len = jio_snprintf(buf, buflen, "reason='%s' action='%s' index='%d'" JVMCI_ONLY(" debug_id='%d'"), 2196 len = jio_snprintf(buf, buflen, "reason='%s' action='%s' index='%d'" JVMCI_ONLY(" debug_id='%d'"),
2197 reason, action, unloaded_class_index 2197 reason, action, unloaded_class_index
2198 #ifdef JVMCI 2198 #if INCLUDE_JVMCI
2199 ,debug_id 2199 ,debug_id
2200 #endif 2200 #endif
2201 ); 2201 );
2202 } 2202 }
2203 if (len >= buflen) 2203 if (len >= buflen)
2293 } 2293 }
2294 #undef PRINT_STAT_LINE 2294 #undef PRINT_STAT_LINE
2295 if (xtty != NULL) xtty->tail("statistics"); 2295 if (xtty != NULL) xtty->tail("statistics");
2296 } 2296 }
2297 } 2297 }
2298 #else // COMPILER2 || SHARK || JVMCI 2298 #else // COMPILER2 || SHARK || INCLUDE_JVMCI
2299 2299
2300 2300
2301 // Stubs for C1 only system. 2301 // Stubs for C1 only system.
2302 bool Deoptimization::trap_state_is_recompiled(int trap_state) { 2302 bool Deoptimization::trap_state_is_recompiled(int trap_state) {
2303 return false; 2303 return false;
2329 int trap_state) { 2329 int trap_state) {
2330 jio_snprintf(buf, buflen, "#%d", trap_state); 2330 jio_snprintf(buf, buflen, "#%d", trap_state);
2331 return buf; 2331 return buf;
2332 } 2332 }
2333 2333
2334 #endif // COMPILER2 || SHARK || JVMCI 2334 #endif // COMPILER2 || SHARK || INCLUDE_JVMCI