Skip to content

Commit 6c42856

Browse files
committed
8356778: Compiler add event logging in case of failures
Reviewed-by: lucy
1 parent 76570c6 commit 6c42856

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/hotspot/share/c1/c1_Compilation.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "c1/c1_ValueStack.hpp"
3434
#include "code/debugInfoRec.hpp"
3535
#include "compiler/compilationFailureInfo.hpp"
36+
#include "compiler/compilationLog.hpp"
3637
#include "compiler/compilationMemoryStatistic.hpp"
3738
#include "compiler/compileLog.hpp"
3839
#include "compiler/compiler_globals.hpp"
@@ -646,6 +647,13 @@ void Compilation::notice_inlined_method(ciMethod* method) {
646647

647648
void Compilation::bailout(const char* msg) {
648649
assert(msg != nullptr, "bailout message must exist");
650+
// record the bailout for hserr envlog
651+
if (CompilationLog::log() != nullptr) {
652+
CompilerThread* thread = CompilerThread::current();
653+
CompileTask* task = thread->task();
654+
CompilationLog::log()->log_failure(thread, task, msg, nullptr);
655+
}
656+
649657
if (!bailed_out()) {
650658
// keep first bailout message
651659
if (PrintCompilation || PrintBailouts) tty->print_cr("compilation bailout: %s", msg);

src/hotspot/share/ci/ciEnv.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,15 @@ int ciEnv::num_inlined_bytecodes() const {
11701170
// ------------------------------------------------------------------
11711171
// ciEnv::record_failure()
11721172
void ciEnv::record_failure(const char* reason) {
1173+
// record the bailout for hserr envlog
1174+
if (reason != nullptr) {
1175+
if (CompilationLog::log() != nullptr) {
1176+
CompilerThread* thread = CompilerThread::current();
1177+
CompileTask* task = thread->task();
1178+
CompilationLog::log()->log_failure(thread, task, reason, nullptr);
1179+
}
1180+
}
1181+
11731182
if (_failure_reason.get() == nullptr) {
11741183
// Record the first failure reason.
11751184
_failure_reason.set(reason);

src/hotspot/share/compiler/compilationLog.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ void CompilationLog::log_nmethod(JavaThread* thread, nmethod* nm) {
5151

5252
void CompilationLog::log_failure(JavaThread* thread, CompileTask* task, const char* reason, const char* retry_message) {
5353
StringLogMessage lm;
54-
lm.print("%4d COMPILE SKIPPED: %s", task->compile_id(), reason);
54+
if (task == nullptr) {
55+
lm.print("Id not known, task was 0; COMPILE SKIPPED: %s", reason);
56+
} else {
57+
lm.print("%4d COMPILE SKIPPED: %s", task->compile_id(), reason);
58+
}
5559
if (retry_message != nullptr) {
5660
lm.append(" (%s)", retry_message);
5761
}

0 commit comments

Comments
 (0)