comparison src/share/vm/compiler/compileBroker.cpp @ 4875:379b22e03c32

Merge
author jcoomes
date Fri, 03 Feb 2012 12:08:55 -0800
parents bf5da1648543 aa3d708d67c4
children 09d00c18e323
comparison
equal deleted inserted replaced
4866:527cf36f4a20 4875:379b22e03c32
42 #include "runtime/javaCalls.hpp" 42 #include "runtime/javaCalls.hpp"
43 #include "runtime/os.hpp" 43 #include "runtime/os.hpp"
44 #include "runtime/sharedRuntime.hpp" 44 #include "runtime/sharedRuntime.hpp"
45 #include "runtime/sweeper.hpp" 45 #include "runtime/sweeper.hpp"
46 #include "utilities/dtrace.hpp" 46 #include "utilities/dtrace.hpp"
47 #include "utilities/events.hpp"
47 #ifdef COMPILER1 48 #ifdef COMPILER1
48 #include "c1/c1_Compiler.hpp" 49 #include "c1/c1_Compiler.hpp"
49 #endif 50 #endif
50 #ifdef COMPILER2 51 #ifdef COMPILER2
51 #include "opto/c2compiler.hpp" 52 #include "opto/c2compiler.hpp"
186 CompileQueue* CompileBroker::_c1_method_queue = NULL; 187 CompileQueue* CompileBroker::_c1_method_queue = NULL;
187 CompileTask* CompileBroker::_task_free_list = NULL; 188 CompileTask* CompileBroker::_task_free_list = NULL;
188 189
189 GrowableArray<CompilerThread*>* CompileBroker::_method_threads = NULL; 190 GrowableArray<CompilerThread*>* CompileBroker::_method_threads = NULL;
190 191
192
193 class CompilationLog : public StringEventLog {
194 public:
195 CompilationLog() : StringEventLog("Compilation events") {
196 }
197
198 void log_compile(JavaThread* thread, CompileTask* task) {
199 StringLogMessage lm;
200 stringStream msg = lm.stream();
201 // msg.time_stamp().update_to(tty->time_stamp().ticks());
202 task->print_compilation(&msg, true);
203 log(thread, "%s", (const char*)lm);
204 }
205
206 void log_nmethod(JavaThread* thread, nmethod* nm) {
207 log(thread, "nmethod " INTPTR_FORMAT " code ["INTPTR_FORMAT ", " INTPTR_FORMAT "]",
208 nm, nm->code_begin(), nm->code_end());
209 }
210
211 void log_failure(JavaThread* thread, CompileTask* task, const char* reason, const char* retry_message) {
212 StringLogMessage lm;
213 lm.print("%4d COMPILE SKIPPED: %s", task->compile_id(), reason);
214 if (retry_message != NULL) {
215 lm.append(" (%s)", retry_message);
216 }
217 lm.print("\n");
218 log(thread, "%s", (const char*)lm);
219 }
220 };
221
222 static CompilationLog* _compilation_log = NULL;
223
224 void compileBroker_init() {
225 if (LogEvents) {
226 _compilation_log = new CompilationLog();
227 }
228 }
191 229
192 CompileTaskWrapper::CompileTaskWrapper(CompileTask* task) { 230 CompileTaskWrapper::CompileTaskWrapper(CompileTask* task) {
193 CompilerThread* thread = CompilerThread::current(); 231 CompilerThread* thread = CompilerThread::current();
194 thread->set_task(task); 232 thread->set_task(task);
195 CompileLog* log = thread->log(); 233 CompileLog* log = thread->log();
324 } 362 }
325 363
326 364
327 // ------------------------------------------------------------------ 365 // ------------------------------------------------------------------
328 // CompileTask::print_compilation_impl 366 // CompileTask::print_compilation_impl
329 void CompileTask::print_compilation_impl(outputStream* st, methodOop method, int compile_id, int comp_level, bool is_osr_method, int osr_bci, bool is_blocking, const char* msg) { 367 void CompileTask::print_compilation_impl(outputStream* st, methodOop method, int compile_id, int comp_level,
330 st->print("%7d ", (int) st->time_stamp().milliseconds()); // print timestamp 368 bool is_osr_method, int osr_bci, bool is_blocking,
369 const char* msg, bool short_form) {
370 if (!short_form) {
371 st->print("%7d ", (int) st->time_stamp().milliseconds()); // print timestamp
372 }
331 st->print("%4d ", compile_id); // print compilation number 373 st->print("%4d ", compile_id); // print compilation number
332 374
333 // For unloaded methods the transition to zombie occurs after the 375 // For unloaded methods the transition to zombie occurs after the
334 // method is cleared so it's impossible to report accurate 376 // method is cleared so it's impossible to report accurate
335 // information for that case. 377 // information for that case.
368 } 410 }
369 411
370 if (msg != NULL) { 412 if (msg != NULL) {
371 st->print(" %s", msg); 413 st->print(" %s", msg);
372 } 414 }
373 st->cr(); 415 if (!short_form) {
416 st->cr();
417 }
374 } 418 }
375 419
376 // ------------------------------------------------------------------ 420 // ------------------------------------------------------------------
377 // CompileTask::print_inlining 421 // CompileTask::print_inlining
378 void CompileTask::print_inlining(outputStream* st, ciMethod* method, int inline_level, int bci, const char* msg) { 422 void CompileTask::print_inlining(outputStream* st, ciMethod* method, int inline_level, int bci, const char* msg) {
424 for (int i = 0; i < inline_level; i++) st->print(" "); 468 for (int i = 0; i < inline_level; i++) st->print(" ");
425 } 469 }
426 470
427 // ------------------------------------------------------------------ 471 // ------------------------------------------------------------------
428 // CompileTask::print_compilation 472 // CompileTask::print_compilation
429 void CompileTask::print_compilation(outputStream* st) { 473 void CompileTask::print_compilation(outputStream* st, bool short_form) {
430 oop rem = JNIHandles::resolve(method_handle()); 474 oop rem = JNIHandles::resolve(method_handle());
431 assert(rem != NULL && rem->is_method(), "must be"); 475 assert(rem != NULL && rem->is_method(), "must be");
432 methodOop method = (methodOop) rem; 476 methodOop method = (methodOop) rem;
433 bool is_osr_method = osr_bci() != InvocationEntryBci; 477 bool is_osr_method = osr_bci() != InvocationEntryBci;
434 print_compilation_impl(st, method, compile_id(), comp_level(), is_osr_method, osr_bci(), is_blocking()); 478 print_compilation_impl(st, method, compile_id(), comp_level(), is_osr_method, osr_bci(), is_blocking(), NULL, short_form);
435 } 479 }
436 480
437 // ------------------------------------------------------------------ 481 // ------------------------------------------------------------------
438 // CompileTask::log_task 482 // CompileTask::log_task
439 void CompileTask::log_task(xmlStream* log) { 483 void CompileTask::log_task(xmlStream* log) {
1647 elapsedTimer time; 1691 elapsedTimer time;
1648 1692
1649 CompilerThread* thread = CompilerThread::current(); 1693 CompilerThread* thread = CompilerThread::current();
1650 ResourceMark rm(thread); 1694 ResourceMark rm(thread);
1651 1695
1696 if (LogEvents) {
1697 _compilation_log->log_compile(thread, task);
1698 }
1699
1652 // Common flags. 1700 // Common flags.
1653 uint compile_id = task->compile_id(); 1701 uint compile_id = task->compile_id();
1654 int osr_bci = task->osr_bci(); 1702 int osr_bci = task->osr_bci();
1655 bool is_osr = (osr_bci != standard_entry_bci); 1703 bool is_osr = (osr_bci != standard_entry_bci);
1656 bool should_log = (thread->log() != NULL); 1704 bool should_log = (thread->log() != NULL);
1715 // The compiler elected, without comment, not to register a result. 1763 // The compiler elected, without comment, not to register a result.
1716 // Do not attempt further compilations of this method. 1764 // Do not attempt further compilations of this method.
1717 ci_env.record_method_not_compilable("compile failed", !TieredCompilation); 1765 ci_env.record_method_not_compilable("compile failed", !TieredCompilation);
1718 } 1766 }
1719 1767
1768 // Copy this bit to the enclosing block:
1769 compilable = ci_env.compilable();
1770
1720 if (ci_env.failing()) { 1771 if (ci_env.failing()) {
1721 // Copy this bit to the enclosing block: 1772 const char* retry_message = ci_env.retry_message();
1722 compilable = ci_env.compilable(); 1773 if (_compilation_log != NULL) {
1774 _compilation_log->log_failure(thread, task, ci_env.failure_reason(), retry_message);
1775 }
1723 if (PrintCompilation) { 1776 if (PrintCompilation) {
1724 const char* reason = ci_env.failure_reason(); 1777 tty->print("%4d COMPILE SKIPPED: %s", compile_id, ci_env.failure_reason());
1725 if (compilable == ciEnv::MethodCompilable_not_at_tier) { 1778 if (retry_message != NULL) {
1726 tty->print_cr("%4d COMPILE SKIPPED: %s (retry at different tier)", compile_id, reason); 1779 tty->print(" (%s)", retry_message);
1727 } else if (compilable == ciEnv::MethodCompilable_never) {
1728 tty->print_cr("%4d COMPILE SKIPPED: %s (not retryable)", compile_id, reason);
1729 } else if (compilable == ciEnv::MethodCompilable) {
1730 tty->print_cr("%4d COMPILE SKIPPED: %s", compile_id, reason);
1731 } 1780 }
1781 tty->cr();
1732 } 1782 }
1733 } else { 1783 } else {
1734 task->mark_success(); 1784 task->mark_success();
1735 task->set_num_inlined_bytecodes(ci_env.num_inlined_bytecodes()); 1785 task->set_num_inlined_bytecodes(ci_env.num_inlined_bytecodes());
1786 if (_compilation_log != NULL) {
1787 nmethod* code = task->code();
1788 if (code != NULL) {
1789 _compilation_log->log_nmethod(thread, code);
1790 }
1791 }
1736 } 1792 }
1737 } 1793 }
1738 pop_jni_handle_block(); 1794 pop_jni_handle_block();
1739 1795
1740 methodHandle method(thread, 1796 methodHandle method(thread,