Mercurial > hg > graal-compiler
comparison src/share/vm/compiler/compileBroker.cpp @ 4872:aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
Reviewed-by: kvn, jrose, kevinw, brutisso, twisti, jmasa
author | never |
---|---|
date | Wed, 01 Feb 2012 07:59:01 -0800 |
parents | 20334ed5ed3c |
children | 379b22e03c32 |
comparison
equal
deleted
inserted
replaced
4871:f067b4e0e04b | 4872:aa3d708d67c4 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
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) { |
1646 elapsedTimer time; | 1690 elapsedTimer time; |
1647 | 1691 |
1648 CompilerThread* thread = CompilerThread::current(); | 1692 CompilerThread* thread = CompilerThread::current(); |
1649 ResourceMark rm(thread); | 1693 ResourceMark rm(thread); |
1650 | 1694 |
1695 if (LogEvents) { | |
1696 _compilation_log->log_compile(thread, task); | |
1697 } | |
1698 | |
1651 // Common flags. | 1699 // Common flags. |
1652 uint compile_id = task->compile_id(); | 1700 uint compile_id = task->compile_id(); |
1653 int osr_bci = task->osr_bci(); | 1701 int osr_bci = task->osr_bci(); |
1654 bool is_osr = (osr_bci != standard_entry_bci); | 1702 bool is_osr = (osr_bci != standard_entry_bci); |
1655 bool should_log = (thread->log() != NULL); | 1703 bool should_log = (thread->log() != NULL); |
1714 // The compiler elected, without comment, not to register a result. | 1762 // The compiler elected, without comment, not to register a result. |
1715 // Do not attempt further compilations of this method. | 1763 // Do not attempt further compilations of this method. |
1716 ci_env.record_method_not_compilable("compile failed", !TieredCompilation); | 1764 ci_env.record_method_not_compilable("compile failed", !TieredCompilation); |
1717 } | 1765 } |
1718 | 1766 |
1767 // Copy this bit to the enclosing block: | |
1768 compilable = ci_env.compilable(); | |
1769 | |
1719 if (ci_env.failing()) { | 1770 if (ci_env.failing()) { |
1720 // Copy this bit to the enclosing block: | 1771 const char* retry_message = ci_env.retry_message(); |
1721 compilable = ci_env.compilable(); | 1772 if (_compilation_log != NULL) { |
1773 _compilation_log->log_failure(thread, task, ci_env.failure_reason(), retry_message); | |
1774 } | |
1722 if (PrintCompilation) { | 1775 if (PrintCompilation) { |
1723 const char* reason = ci_env.failure_reason(); | 1776 tty->print("%4d COMPILE SKIPPED: %s", compile_id, ci_env.failure_reason()); |
1724 if (compilable == ciEnv::MethodCompilable_not_at_tier) { | 1777 if (retry_message != NULL) { |
1725 tty->print_cr("%4d COMPILE SKIPPED: %s (retry at different tier)", compile_id, reason); | 1778 tty->print(" (%s)", retry_message); |
1726 } else if (compilable == ciEnv::MethodCompilable_never) { | |
1727 tty->print_cr("%4d COMPILE SKIPPED: %s (not retryable)", compile_id, reason); | |
1728 } else if (compilable == ciEnv::MethodCompilable) { | |
1729 tty->print_cr("%4d COMPILE SKIPPED: %s", compile_id, reason); | |
1730 } | 1779 } |
1780 tty->cr(); | |
1731 } | 1781 } |
1732 } else { | 1782 } else { |
1733 task->mark_success(); | 1783 task->mark_success(); |
1734 task->set_num_inlined_bytecodes(ci_env.num_inlined_bytecodes()); | 1784 task->set_num_inlined_bytecodes(ci_env.num_inlined_bytecodes()); |
1785 if (_compilation_log != NULL) { | |
1786 nmethod* code = task->code(); | |
1787 if (code != NULL) { | |
1788 _compilation_log->log_nmethod(thread, code); | |
1789 } | |
1790 } | |
1735 } | 1791 } |
1736 } | 1792 } |
1737 pop_jni_handle_block(); | 1793 pop_jni_handle_block(); |
1738 | 1794 |
1739 methodHandle method(thread, | 1795 methodHandle method(thread, |