Mercurial > hg > truffle
comparison src/share/vm/compiler/compileBroker.cpp @ 8883:b9a918201d47
Merge with hsx25
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Sat, 06 Apr 2013 20:04:06 +0200 |
parents | 2bc6f232f74e 46f6f063b272 |
children | 22851e342f0e |
comparison
equal
deleted
inserted
replaced
8660:d47b52b0ff68 | 8883:b9a918201d47 |
---|---|
66 HS_DTRACE_PROBE_DECL8(hotspot, method__compile__begin, | 66 HS_DTRACE_PROBE_DECL8(hotspot, method__compile__begin, |
67 char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t); | 67 char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t); |
68 HS_DTRACE_PROBE_DECL9(hotspot, method__compile__end, | 68 HS_DTRACE_PROBE_DECL9(hotspot, method__compile__end, |
69 char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t, bool); | 69 char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t, bool); |
70 | 70 |
71 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler, method) \ | 71 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler, method, comp_name) \ |
72 { \ | 72 { \ |
73 char* comp_name = (char*)(compiler)->name(); \ | |
74 Symbol* klass_name = (method)->klass_name(); \ | 73 Symbol* klass_name = (method)->klass_name(); \ |
75 Symbol* name = (method)->name(); \ | 74 Symbol* name = (method)->name(); \ |
76 Symbol* signature = (method)->signature(); \ | 75 Symbol* signature = (method)->signature(); \ |
77 HS_DTRACE_PROBE8(hotspot, method__compile__begin, \ | 76 HS_DTRACE_PROBE8(hotspot, method__compile__begin, \ |
78 comp_name, strlen(comp_name), \ | 77 comp_name, strlen(comp_name), \ |
79 klass_name->bytes(), klass_name->utf8_length(), \ | 78 klass_name->bytes(), klass_name->utf8_length(), \ |
80 name->bytes(), name->utf8_length(), \ | 79 name->bytes(), name->utf8_length(), \ |
81 signature->bytes(), signature->utf8_length()); \ | 80 signature->bytes(), signature->utf8_length()); \ |
82 } | 81 } |
83 | 82 |
84 #define DTRACE_METHOD_COMPILE_END_PROBE(compiler, method, success) \ | 83 #define DTRACE_METHOD_COMPILE_END_PROBE(compiler, method, \ |
84 comp_name, success) \ | |
85 { \ | 85 { \ |
86 char* comp_name = (char*)(compiler)->name(); \ | |
87 Symbol* klass_name = (method)->klass_name(); \ | 86 Symbol* klass_name = (method)->klass_name(); \ |
88 Symbol* name = (method)->name(); \ | 87 Symbol* name = (method)->name(); \ |
89 Symbol* signature = (method)->signature(); \ | 88 Symbol* signature = (method)->signature(); \ |
90 HS_DTRACE_PROBE9(hotspot, method__compile__end, \ | 89 HS_DTRACE_PROBE9(hotspot, method__compile__end, \ |
91 comp_name, strlen(comp_name), \ | 90 comp_name, strlen(comp_name), \ |
94 signature->bytes(), signature->utf8_length(), (success)); \ | 93 signature->bytes(), signature->utf8_length(), (success)); \ |
95 } | 94 } |
96 | 95 |
97 #else /* USDT2 */ | 96 #else /* USDT2 */ |
98 | 97 |
99 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler, method) \ | 98 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler, method, comp_name) \ |
100 { \ | 99 { \ |
101 char* comp_name = (char*)(compiler)->name(); \ | |
102 Symbol* klass_name = (method)->klass_name(); \ | 100 Symbol* klass_name = (method)->klass_name(); \ |
103 Symbol* name = (method)->name(); \ | 101 Symbol* name = (method)->name(); \ |
104 Symbol* signature = (method)->signature(); \ | 102 Symbol* signature = (method)->signature(); \ |
105 HOTSPOT_METHOD_COMPILE_BEGIN( \ | 103 HOTSPOT_METHOD_COMPILE_BEGIN( \ |
106 comp_name, strlen(comp_name), \ | 104 comp_name, strlen(comp_name), \ |
107 (char *) klass_name->bytes(), klass_name->utf8_length(), \ | 105 (char *) klass_name->bytes(), klass_name->utf8_length(), \ |
108 (char *) name->bytes(), name->utf8_length(), \ | 106 (char *) name->bytes(), name->utf8_length(), \ |
109 (char *) signature->bytes(), signature->utf8_length()); \ | 107 (char *) signature->bytes(), signature->utf8_length()); \ |
110 } | 108 } |
111 | 109 |
112 #define DTRACE_METHOD_COMPILE_END_PROBE(compiler, method, success) \ | 110 #define DTRACE_METHOD_COMPILE_END_PROBE(compiler, method, \ |
111 comp_name, success) \ | |
113 { \ | 112 { \ |
114 char* comp_name = (char*)(compiler)->name(); \ | |
115 Symbol* klass_name = (method)->klass_name(); \ | 113 Symbol* klass_name = (method)->klass_name(); \ |
116 Symbol* name = (method)->name(); \ | 114 Symbol* name = (method)->name(); \ |
117 Symbol* signature = (method)->signature(); \ | 115 Symbol* signature = (method)->signature(); \ |
118 HOTSPOT_METHOD_COMPILE_END( \ | 116 HOTSPOT_METHOD_COMPILE_END( \ |
119 comp_name, strlen(comp_name), \ | 117 comp_name, strlen(comp_name), \ |
123 } | 121 } |
124 #endif /* USDT2 */ | 122 #endif /* USDT2 */ |
125 | 123 |
126 #else // ndef DTRACE_ENABLED | 124 #else // ndef DTRACE_ENABLED |
127 | 125 |
128 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler, method) | 126 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler, method, comp_name) |
129 #define DTRACE_METHOD_COMPILE_END_PROBE(compiler, method, success) | 127 #define DTRACE_METHOD_COMPILE_END_PROBE(compiler, method, comp_name, success) |
130 | 128 |
131 #endif // ndef DTRACE_ENABLED | 129 #endif // ndef DTRACE_ENABLED |
132 | 130 |
133 bool CompileBroker::_initialized = false; | 131 bool CompileBroker::_initialized = false; |
134 volatile bool CompileBroker::_should_block = false; | 132 volatile bool CompileBroker::_should_block = false; |
360 // | 358 // |
361 // Otherwise it's the same as CompileTask::print_line() | 359 // Otherwise it's the same as CompileTask::print_line() |
362 // | 360 // |
363 void CompileTask::print_line_on_error(outputStream* st, char* buf, int buflen) { | 361 void CompileTask::print_line_on_error(outputStream* st, char* buf, int buflen) { |
364 // print compiler name | 362 // print compiler name |
365 st->print("%s:", CompileBroker::compiler(comp_level())->name()); | 363 st->print("%s:", CompileBroker::compiler_name(comp_level())); |
366 print_compilation(st); | 364 print_compilation(st); |
367 } | 365 } |
368 | 366 |
369 // ------------------------------------------------------------------ | 367 // ------------------------------------------------------------------ |
370 // CompileTask::print_line | 368 // CompileTask::print_line |
371 void CompileTask::print_line() { | 369 void CompileTask::print_line() { |
372 ttyLocker ttyl; // keep the following output all in one block | 370 ttyLocker ttyl; // keep the following output all in one block |
373 // print compiler name if requested | 371 // print compiler name if requested |
374 if (CIPrintCompilerName) tty->print("%s:", CompileBroker::compiler(comp_level())->name()); | 372 if (CIPrintCompilerName) tty->print("%s:", CompileBroker::compiler_name(comp_level())); |
375 print_compilation(); | 373 print_compilation(); |
376 } | 374 } |
377 | 375 |
378 | 376 |
379 // ------------------------------------------------------------------ | 377 // ------------------------------------------------------------------ |
506 Thread* thread = Thread::current(); | 504 Thread* thread = Thread::current(); |
507 methodHandle method(thread, this->method()); | 505 methodHandle method(thread, this->method()); |
508 ResourceMark rm(thread); | 506 ResourceMark rm(thread); |
509 | 507 |
510 // <task id='9' method='M' osr_bci='X' level='1' blocking='1' stamp='1.234'> | 508 // <task id='9' method='M' osr_bci='X' level='1' blocking='1' stamp='1.234'> |
511 if (_compile_id != 0) log->print(" compile_id='%d'", _compile_id); | 509 log->print(" compile_id='%d'", _compile_id); |
512 if (_osr_bci != CompileBroker::standard_entry_bci) { | 510 if (_osr_bci != CompileBroker::standard_entry_bci) { |
513 log->print(" compile_kind='osr'"); // same as nmethod::compile_kind | 511 log->print(" compile_kind='osr'"); // same as nmethod::compile_kind |
514 } // else compile_kind='c2c' | 512 } // else compile_kind='c2c' |
515 if (!method.is_null()) log->method(method); | 513 if (!method.is_null()) log->method(method); |
516 if (_osr_bci != CompileBroker::standard_entry_bci) { | 514 if (_osr_bci != CompileBroker::standard_entry_bci) { |
1235 | 1233 |
1236 // return quickly if possible | 1234 // return quickly if possible |
1237 | 1235 |
1238 // lock, make sure that the compilation | 1236 // lock, make sure that the compilation |
1239 // isn't prohibited in a straightforward way. | 1237 // isn't prohibited in a straightforward way. |
1240 | 1238 AbstractCompiler *comp = CompileBroker::compiler(comp_level); |
1241 if (compiler(comp_level) == NULL || !compiler(comp_level)->can_compile_method(method) || compilation_is_prohibited(method, osr_bci, comp_level)) { | 1239 if (comp == NULL || !comp->can_compile_method(method) || |
1240 compilation_is_prohibited(method, osr_bci, comp_level)) { | |
1242 return NULL; | 1241 return NULL; |
1243 } | 1242 } |
1244 | 1243 |
1245 if (osr_bci == InvocationEntryBci) { | 1244 if (osr_bci == InvocationEntryBci) { |
1246 // standard compilation | 1245 // standard compilation |
1273 if (method->is_not_osr_compilable(comp_level)) return NULL; | 1272 if (method->is_not_osr_compilable(comp_level)) return NULL; |
1274 } | 1273 } |
1275 | 1274 |
1276 assert(!HAS_PENDING_EXCEPTION, "No exception should be present"); | 1275 assert(!HAS_PENDING_EXCEPTION, "No exception should be present"); |
1277 // some prerequisites that are compiler specific | 1276 // some prerequisites that are compiler specific |
1278 if (compiler(comp_level)->is_c2() || compiler(comp_level)->is_shark()) { | 1277 if (comp->is_c2() || comp->is_shark()) { |
1279 method->constants()->resolve_string_constants(CHECK_AND_CLEAR_NULL); | 1278 method->constants()->resolve_string_constants(CHECK_AND_CLEAR_NULL); |
1280 // Resolve all classes seen in the signature of the method | 1279 // Resolve all classes seen in the signature of the method |
1281 // we are compiling. | 1280 // we are compiling. |
1282 Method::load_signature_classes(method, CHECK_AND_CLEAR_NULL); | 1281 Method::load_signature_classes(method, CHECK_AND_CLEAR_NULL); |
1283 } | 1282 } |
1390 // | 1389 // |
1391 // See if this compilation is not allowed. | 1390 // See if this compilation is not allowed. |
1392 bool CompileBroker::compilation_is_prohibited(methodHandle method, int osr_bci, int comp_level) { | 1391 bool CompileBroker::compilation_is_prohibited(methodHandle method, int osr_bci, int comp_level) { |
1393 bool is_native = method->is_native(); | 1392 bool is_native = method->is_native(); |
1394 // Some compilers may not support the compilation of natives. | 1393 // Some compilers may not support the compilation of natives. |
1394 AbstractCompiler *comp = compiler(comp_level); | |
1395 if (is_native && | 1395 if (is_native && |
1396 (!CICompileNatives || !compiler(comp_level)->supports_native())) { | 1396 (!CICompileNatives || comp == NULL || !comp->supports_native())) { |
1397 method->set_not_compilable_quietly(comp_level); | 1397 method->set_not_compilable_quietly(comp_level); |
1398 return true; | 1398 return true; |
1399 } | 1399 } |
1400 | 1400 |
1401 bool is_osr = (osr_bci != standard_entry_bci); | 1401 bool is_osr = (osr_bci != standard_entry_bci); |
1402 // Some compilers may not support on stack replacement. | 1402 // Some compilers may not support on stack replacement. |
1403 if (is_osr && | 1403 if (is_osr && |
1404 (!CICompileOSR || !compiler(comp_level)->supports_osr())) { | 1404 (!CICompileOSR || comp == NULL || !comp->supports_osr())) { |
1405 method->set_not_osr_compilable(comp_level); | 1405 method->set_not_osr_compilable(comp_level); |
1406 return true; | 1406 return true; |
1407 } | 1407 } |
1408 | 1408 |
1409 // The method may be explicitly excluded by the user. | 1409 // The method may be explicitly excluded by the user. |
1771 uint compile_id = task->compile_id(); | 1771 uint compile_id = task->compile_id(); |
1772 int osr_bci = task->osr_bci(); | 1772 int osr_bci = task->osr_bci(); |
1773 bool is_osr = (osr_bci != standard_entry_bci); | 1773 bool is_osr = (osr_bci != standard_entry_bci); |
1774 bool should_log = (thread->log() != NULL); | 1774 bool should_log = (thread->log() != NULL); |
1775 bool should_break = false; | 1775 bool should_break = false; |
1776 int task_level = task->comp_level(); | |
1776 { | 1777 { |
1777 // create the handle inside it's own block so it can't | 1778 // create the handle inside it's own block so it can't |
1778 // accidentally be referenced once the thread transitions to | 1779 // accidentally be referenced once the thread transitions to |
1779 // native. The NoHandleMark before the transition should catch | 1780 // native. The NoHandleMark before the transition should catch |
1780 // any cases where this occurs in the future. | 1781 // any cases where this occurs in the future. |
1784 should_log = false; | 1785 should_log = false; |
1785 } | 1786 } |
1786 assert(!method->is_native(), "no longer compile natives"); | 1787 assert(!method->is_native(), "no longer compile natives"); |
1787 | 1788 |
1788 // Save information about this method in case of failure. | 1789 // Save information about this method in case of failure. |
1789 set_last_compile(thread, method, is_osr, task->comp_level()); | 1790 set_last_compile(thread, method, is_osr, task_level); |
1790 | 1791 |
1791 DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler(task->comp_level()), method); | 1792 DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler(task_level), method, |
1793 compiler_name(task_level)); | |
1792 } | 1794 } |
1793 | 1795 |
1794 // Allocate a new set of JNI handles. | 1796 // Allocate a new set of JNI handles. |
1795 push_jni_handle_block(); | 1797 push_jni_handle_block(); |
1796 Method* target_handle = task->method(); | 1798 Method* target_handle = task->method(); |
1823 | 1825 |
1824 ciMethod* target = ci_env.get_method_from_handle(target_handle); | 1826 ciMethod* target = ci_env.get_method_from_handle(target_handle); |
1825 | 1827 |
1826 TraceTime t1("compilation", &time); | 1828 TraceTime t1("compilation", &time); |
1827 | 1829 |
1828 compiler(task->comp_level())->compile_method(&ci_env, target, osr_bci); | 1830 AbstractCompiler *comp = compiler(task_level); |
1831 if (comp == NULL) { | |
1832 ci_env.record_method_not_compilable("no compiler", !TieredCompilation); | |
1833 } else { | |
1834 comp->compile_method(&ci_env, target, osr_bci); | |
1835 } | |
1829 | 1836 |
1830 if (!ci_env.failing() && task->code() == NULL) { | 1837 if (!ci_env.failing() && task->code() == NULL) { |
1831 //assert(false, "compiler should always document failure"); | 1838 //assert(false, "compiler should always document failure"); |
1832 // The compiler elected, without comment, not to register a result. | 1839 // The compiler elected, without comment, not to register a result. |
1833 // Do not attempt further compilations of this method. | 1840 // Do not attempt further compilations of this method. |
1861 } | 1868 } |
1862 pop_jni_handle_block(); | 1869 pop_jni_handle_block(); |
1863 | 1870 |
1864 methodHandle method(thread, task->method()); | 1871 methodHandle method(thread, task->method()); |
1865 | 1872 |
1866 DTRACE_METHOD_COMPILE_END_PROBE(compiler(task->comp_level()), method, task->is_success()); | 1873 DTRACE_METHOD_COMPILE_END_PROBE(compiler(task_level), method, |
1874 compiler_name(task_level), task->is_success()); | |
1867 | 1875 |
1868 collect_statistics(thread, time, task); | 1876 collect_statistics(thread, time, task); |
1869 | 1877 |
1870 if (PrintCompilation && PrintCompilation2) { | 1878 if (PrintCompilation && PrintCompilation2) { |
1871 tty->print("%7d ", (int) tty->time_stamp().milliseconds()); // print timestamp | 1879 tty->print("%7d ", (int) tty->time_stamp().milliseconds()); // print timestamp |
1886 else | 1894 else |
1887 method->set_not_compilable_quietly(); | 1895 method->set_not_compilable_quietly(); |
1888 break; | 1896 break; |
1889 case ciEnv::MethodCompilable_not_at_tier: | 1897 case ciEnv::MethodCompilable_not_at_tier: |
1890 if (is_osr) | 1898 if (is_osr) |
1891 method->set_not_osr_compilable_quietly(task->comp_level()); | 1899 method->set_not_osr_compilable_quietly(task_level); |
1892 else | 1900 else |
1893 method->set_not_compilable_quietly(task->comp_level()); | 1901 method->set_not_compilable_quietly(task_level); |
1894 break; | 1902 break; |
1895 } | 1903 } |
1896 | 1904 |
1897 // Note that the queued_for_compilation bits are cleared without | 1905 // Note that the queued_for_compilation bits are cleared without |
1898 // protection of a mutex. [They were set by the requester thread, | 1906 // protection of a mutex. [They were set by the requester thread, |
2154 } | 2162 } |
2155 // set the current method for the thread to null | 2163 // set the current method for the thread to null |
2156 if (UsePerfData) counters->set_current_method(""); | 2164 if (UsePerfData) counters->set_current_method(""); |
2157 } | 2165 } |
2158 | 2166 |
2159 | 2167 const char* CompileBroker::compiler_name(int comp_level) { |
2168 AbstractCompiler *comp = CompileBroker::compiler(comp_level); | |
2169 if (comp == NULL) { | |
2170 return "no compiler"; | |
2171 } else { | |
2172 return (comp->name()); | |
2173 } | |
2174 } | |
2160 | 2175 |
2161 void CompileBroker::print_times() { | 2176 void CompileBroker::print_times() { |
2162 tty->cr(); | 2177 tty->cr(); |
2163 tty->print_cr("Accumulated compiler times (for compiled methods only)"); | 2178 tty->print_cr("Accumulated compiler times (for compiled methods only)"); |
2164 tty->print_cr("------------------------------------------------"); | 2179 tty->print_cr("------------------------------------------------"); |
2168 tty->print_cr(" Standard compilation : %6.3f s, Average : %2.3f", | 2183 tty->print_cr(" Standard compilation : %6.3f s, Average : %2.3f", |
2169 CompileBroker::_t_standard_compilation.seconds(), | 2184 CompileBroker::_t_standard_compilation.seconds(), |
2170 CompileBroker::_t_standard_compilation.seconds() / CompileBroker::_total_standard_compile_count); | 2185 CompileBroker::_t_standard_compilation.seconds() / CompileBroker::_total_standard_compile_count); |
2171 tty->print_cr(" On stack replacement : %6.3f s, Average : %2.3f", CompileBroker::_t_osr_compilation.seconds(), CompileBroker::_t_osr_compilation.seconds() / CompileBroker::_total_osr_compile_count); | 2186 tty->print_cr(" On stack replacement : %6.3f s, Average : %2.3f", CompileBroker::_t_osr_compilation.seconds(), CompileBroker::_t_osr_compilation.seconds() / CompileBroker::_total_osr_compile_count); |
2172 | 2187 |
2173 if (compiler(CompLevel_simple) != NULL) { | 2188 AbstractCompiler *comp = compiler(CompLevel_simple); |
2174 compiler(CompLevel_simple)->print_timers(); | 2189 if (comp != NULL) { |
2175 } | 2190 comp->print_timers(); |
2176 if (compiler(CompLevel_full_optimization) != NULL) { | 2191 } |
2177 compiler(CompLevel_full_optimization)->print_timers(); | 2192 comp = compiler(CompLevel_full_optimization); |
2193 if (comp != NULL) { | |
2194 comp->print_timers(); | |
2178 } | 2195 } |
2179 tty->cr(); | 2196 tty->cr(); |
2197 tty->print_cr(" Total compiled methods : %6d methods", CompileBroker::_total_compile_count); | |
2198 tty->print_cr(" Standard compilation : %6d methods", CompileBroker::_total_standard_compile_count); | |
2199 tty->print_cr(" On stack replacement : %6d methods", CompileBroker::_total_osr_compile_count); | |
2180 int tcb = CompileBroker::_sum_osr_bytes_compiled + CompileBroker::_sum_standard_bytes_compiled; | 2200 int tcb = CompileBroker::_sum_osr_bytes_compiled + CompileBroker::_sum_standard_bytes_compiled; |
2181 tty->print_cr(" Total compiled bytecodes : %6d bytes", tcb); | 2201 tty->print_cr(" Total compiled bytecodes : %6d bytes", tcb); |
2182 tty->print_cr(" Standard compilation : %6d bytes", CompileBroker::_sum_standard_bytes_compiled); | 2202 tty->print_cr(" Standard compilation : %6d bytes", CompileBroker::_sum_standard_bytes_compiled); |
2183 tty->print_cr(" On stack replacement : %6d bytes", CompileBroker::_sum_osr_bytes_compiled); | 2203 tty->print_cr(" On stack replacement : %6d bytes", CompileBroker::_sum_osr_bytes_compiled); |
2184 double tcs = CompileBroker::_t_total_compilation.seconds(); | 2204 double tcs = CompileBroker::_t_total_compilation.seconds(); |