< prev index next >

src/share/vm/compiler/compileBroker.cpp

Print this page
rev 9941 : 8147432: JVMCI should report bailouts in PrintCompilation output


1777     // accidentally be referenced once the thread transitions to
1778     // native.  The NoHandleMark before the transition should catch
1779     // any cases where this occurs in the future.
1780     methodHandle method(thread, task->method());
1781     assert(!method->is_native(), "no longer compile natives");
1782 
1783     // Look up matching directives
1784     directive = DirectivesStack::getMatchingDirective(method, compiler(task_level));
1785 
1786     // Save information about this method in case of failure.
1787     set_last_compile(thread, method, is_osr, task_level);
1788 
1789     DTRACE_METHOD_COMPILE_BEGIN_PROBE(method, compiler_name(task_level));
1790   }
1791 
1792   should_break = directive->BreakAtExecuteOption || task->check_break_at_flags();
1793   if (should_log && !directive->LogOption) {
1794     should_log = false;
1795   }
1796 
1797   // Allocate a new set of JNI handles.
1798   push_jni_handle_block();
1799   Method* target_handle = task->method();
1800   int compilable = ciEnv::MethodCompilable;


1801   AbstractCompiler *comp = compiler(task_level);
1802 
1803   int system_dictionary_modification_counter;
1804   {
1805     MutexLocker locker(Compile_lock, thread);
1806     system_dictionary_modification_counter = SystemDictionary::number_of_modifications();
1807   }
1808 #if INCLUDE_JVMCI
1809   if (UseJVMCICompiler && comp != NULL && comp->is_jvmci()) {
1810     JVMCICompiler* jvmci = (JVMCICompiler*) comp;
1811 
1812     TraceTime t1("compilation", &time);
1813     EventCompilation event;
1814 
1815     JVMCIEnv env(task, system_dictionary_modification_counter);
1816     methodHandle method(thread, target_handle);
1817     jvmci->compile_method(method, osr_bci, &env);
1818 
1819     post_compile(thread, task, event, task->code() != NULL, NULL);







1820   } else
1821 #endif // INCLUDE_JVMCI
1822   {


1823 
1824     NoHandleMark  nhm;
1825     ThreadToNativeFromVM ttn(thread);
1826 
1827     ciEnv ci_env(task, system_dictionary_modification_counter);
1828     if (should_break) {
1829       ci_env.set_break_at_compile(true);
1830     }
1831     if (should_log) {
1832       ci_env.set_log(thread->log());
1833     }
1834     assert(thread->env() == &ci_env, "set by ci_env");
1835     // The thread-env() field is cleared in ~CompileTaskWrapper.
1836 
1837     // Cache Jvmti state
1838     ci_env.cache_jvmti_state();
1839 
1840     // Cache DTrace flags
1841     ci_env.cache_dtrace_flags();
1842 


1851       if (WhiteBoxAPI && WhiteBox::compilation_locked) {
1852         MonitorLockerEx locker(Compilation_lock, Mutex::_no_safepoint_check_flag);
1853         while (WhiteBox::compilation_locked) {
1854           locker.wait(Mutex::_no_safepoint_check_flag);
1855         }
1856       }
1857       comp->compile_method(&ci_env, target, osr_bci, directive);
1858     }
1859 
1860     if (!ci_env.failing() && task->code() == NULL) {
1861       //assert(false, "compiler should always document failure");
1862       // The compiler elected, without comment, not to register a result.
1863       // Do not attempt further compilations of this method.
1864       ci_env.record_method_not_compilable("compile failed", !TieredCompilation);
1865     }
1866 
1867     // Copy this bit to the enclosing block:
1868     compilable = ci_env.compilable();
1869 
1870     if (ci_env.failing()) {
1871       task->set_failure_reason(ci_env.failure_reason());

1872       ci_env.report_failure(ci_env.failure_reason());
1873       const char* retry_message = ci_env.retry_message();








1874       if (_compilation_log != NULL) {
1875         _compilation_log->log_failure(thread, task, ci_env.failure_reason(), retry_message);
1876       }
1877       if (PrintCompilation) {
1878         FormatBufferResource msg = retry_message != NULL ?
1879             FormatBufferResource("COMPILE SKIPPED: %s (%s)", ci_env.failure_reason(), retry_message) :
1880             FormatBufferResource("COMPILE SKIPPED: %s",      ci_env.failure_reason());
1881         task->print(tty, msg);
1882       }
1883     }
1884 
1885     post_compile(thread, task, event, !ci_env.failing(), &ci_env);
1886   }
1887   pop_jni_handle_block();
1888 
1889   methodHandle method(thread, task->method());
1890 
1891   DTRACE_METHOD_COMPILE_END_PROBE(method, compiler_name(task_level), task->is_success());
1892 
1893   collect_statistics(thread, time, task);
1894 
1895   bool printnmethods = directive->PrintAssemblyOption || directive->PrintNMethodsOption;
1896   if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) {
1897     nmethod* nm = task->code();
1898     if (nm != NULL) {
1899       nm->print_nmethod(printnmethods);
1900     }
1901   }
1902   DirectivesStack::release(directive);
1903 
1904   if (PrintCompilation && PrintCompilation2) {
1905     tty->print("%7d ", (int) tty->time_stamp().milliseconds());  // print timestamp
1906     tty->print("%4d ", compile_id);    // print compilation number
1907     tty->print("%s ", (is_osr ? "%" : " "));
1908     if (task->code() != NULL) {




1777     // accidentally be referenced once the thread transitions to
1778     // native.  The NoHandleMark before the transition should catch
1779     // any cases where this occurs in the future.
1780     methodHandle method(thread, task->method());
1781     assert(!method->is_native(), "no longer compile natives");
1782 
1783     // Look up matching directives
1784     directive = DirectivesStack::getMatchingDirective(method, compiler(task_level));
1785 
1786     // Save information about this method in case of failure.
1787     set_last_compile(thread, method, is_osr, task_level);
1788 
1789     DTRACE_METHOD_COMPILE_BEGIN_PROBE(method, compiler_name(task_level));
1790   }
1791 
1792   should_break = directive->BreakAtExecuteOption || task->check_break_at_flags();
1793   if (should_log && !directive->LogOption) {
1794     should_log = false;
1795   }
1796 


1797   Method* target_handle = task->method();
1798   int compilable = ciEnv::MethodCompilable;
1799   const char* failure_reason = NULL;
1800   const char* retry_message = NULL;
1801   AbstractCompiler *comp = compiler(task_level);
1802 
1803   int system_dictionary_modification_counter;
1804   {
1805     MutexLocker locker(Compile_lock, thread);
1806     system_dictionary_modification_counter = SystemDictionary::number_of_modifications();
1807   }
1808 #if INCLUDE_JVMCI
1809   if (UseJVMCICompiler && comp != NULL && comp->is_jvmci()) {
1810     JVMCICompiler* jvmci = (JVMCICompiler*) comp;
1811 
1812     TraceTime t1("compilation", &time);
1813     EventCompilation event;
1814 
1815     JVMCIEnv env(task, system_dictionary_modification_counter);
1816     methodHandle method(thread, target_handle);
1817     jvmci->compile_method(method, osr_bci, &env);
1818 
1819     post_compile(thread, task, event, task->code() != NULL, NULL);
1820 
1821     failure_reason = env.failure_reason();
1822     if (!env.retryable()) {
1823       retry_message = "not retryable";
1824       compilable = ciEnv::MethodCompilable_not_at_tier;
1825     }
1826 
1827   } else
1828 #endif // INCLUDE_JVMCI
1829   {
1830     // Allocate a new set of JNI handles.
1831     push_jni_handle_block();
1832 
1833     NoHandleMark  nhm;
1834     ThreadToNativeFromVM ttn(thread);
1835 
1836     ciEnv ci_env(task, system_dictionary_modification_counter);
1837     if (should_break) {
1838       ci_env.set_break_at_compile(true);
1839     }
1840     if (should_log) {
1841       ci_env.set_log(thread->log());
1842     }
1843     assert(thread->env() == &ci_env, "set by ci_env");
1844     // The thread-env() field is cleared in ~CompileTaskWrapper.
1845 
1846     // Cache Jvmti state
1847     ci_env.cache_jvmti_state();
1848 
1849     // Cache DTrace flags
1850     ci_env.cache_dtrace_flags();
1851 


1860       if (WhiteBoxAPI && WhiteBox::compilation_locked) {
1861         MonitorLockerEx locker(Compilation_lock, Mutex::_no_safepoint_check_flag);
1862         while (WhiteBox::compilation_locked) {
1863           locker.wait(Mutex::_no_safepoint_check_flag);
1864         }
1865       }
1866       comp->compile_method(&ci_env, target, osr_bci, directive);
1867     }
1868 
1869     if (!ci_env.failing() && task->code() == NULL) {
1870       //assert(false, "compiler should always document failure");
1871       // The compiler elected, without comment, not to register a result.
1872       // Do not attempt further compilations of this method.
1873       ci_env.record_method_not_compilable("compile failed", !TieredCompilation);
1874     }
1875 
1876     // Copy this bit to the enclosing block:
1877     compilable = ci_env.compilable();
1878 
1879     if (ci_env.failing()) {
1880       failure_reason = ci_env.failure_reason();
1881       retry_message = ci_env.retry_message();
1882       ci_env.report_failure(ci_env.failure_reason());
1883     }
1884 
1885     post_compile(thread, task, event, !ci_env.failing(), &ci_env);
1886 
1887     pop_jni_handle_block();
1888   }
1889 
1890   if (failure_reason != NULL) {
1891     task->set_failure_reason(failure_reason);
1892     if (_compilation_log != NULL) {
1893       _compilation_log->log_failure(thread, task, failure_reason, retry_message);
1894     }
1895     if (PrintCompilation) {
1896       FormatBufferResource msg = retry_message != NULL ?
1897         FormatBufferResource("COMPILE SKIPPED: %s (%s)", failure_reason, retry_message) :
1898         FormatBufferResource("COMPILE SKIPPED: %s",      failure_reason);
1899       task->print(tty, msg);
1900     }
1901   }
1902 




1903   methodHandle method(thread, task->method());
1904 
1905   DTRACE_METHOD_COMPILE_END_PROBE(method, compiler_name(task_level), task->is_success());
1906 
1907   collect_statistics(thread, time, task);
1908 
1909   bool printnmethods = directive->PrintAssemblyOption || directive->PrintNMethodsOption;
1910   if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) {
1911     nmethod* nm = task->code();
1912     if (nm != NULL) {
1913       nm->print_nmethod(printnmethods);
1914     }
1915   }
1916   DirectivesStack::release(directive);
1917 
1918   if (PrintCompilation && PrintCompilation2) {
1919     tty->print("%7d ", (int) tty->time_stamp().milliseconds());  // print timestamp
1920     tty->print("%4d ", compile_id);    // print compilation number
1921     tty->print("%s ", (is_osr ? "%" : " "));
1922     if (task->code() != NULL) {


< prev index next >