8356778: Compiler add event logging in case of failures

Backport-of: 6c42856b8d
This commit is contained in:
Matthias Baesken
2025-06-24 11:52:33 +00:00
committed by Vitaly Provodin
parent 5e1729a1a0
commit 31be8fcea2
3 changed files with 22 additions and 1 deletions

View File

@@ -33,6 +33,7 @@
#include "c1/c1_ValueMap.hpp"
#include "c1/c1_ValueStack.hpp"
#include "code/debugInfoRec.hpp"
#include "compiler/compilationLog.hpp"
#include "compiler/compileLog.hpp"
#include "compiler/compilerDirectives.hpp"
#include "memory/resourceArea.hpp"
@@ -638,6 +639,13 @@ void Compilation::notice_inlined_method(ciMethod* method) {
void Compilation::bailout(const char* msg) {
assert(msg != nullptr, "bailout message must exist");
// record the bailout for hserr envlog
if (CompilationLog::log() != nullptr) {
CompilerThread* thread = CompilerThread::current();
CompileTask* task = thread->task();
CompilationLog::log()->log_failure(thread, task, msg, nullptr);
}
if (!bailed_out()) {
// keep first bailout message
if (PrintCompilation || PrintBailouts) tty->print_cr("compilation bailout: %s", msg);

View File

@@ -1230,6 +1230,15 @@ int ciEnv::num_inlined_bytecodes() const {
// ------------------------------------------------------------------
// ciEnv::record_failure()
void ciEnv::record_failure(const char* reason) {
// record the bailout for hserr envlog
if (reason != nullptr) {
if (CompilationLog::log() != nullptr) {
CompilerThread* thread = CompilerThread::current();
CompileTask* task = thread->task();
CompilationLog::log()->log_failure(thread, task, reason, nullptr);
}
}
if (_failure_reason.get() == nullptr) {
// Record the first failure reason.
_failure_reason.set(reason);

View File

@@ -52,7 +52,11 @@ void CompilationLog::log_nmethod(JavaThread* thread, nmethod* nm) {
void CompilationLog::log_failure(JavaThread* thread, CompileTask* task, const char* reason, const char* retry_message) {
StringLogMessage lm;
lm.print("%4d COMPILE SKIPPED: %s", task->compile_id(), reason);
if (task == nullptr) {
lm.print("Id not known, task was 0; COMPILE SKIPPED: %s", reason);
} else {
lm.print("%4d COMPILE SKIPPED: %s", task->compile_id(), reason);
}
if (retry_message != nullptr) {
lm.append(" (%s)", retry_message);
}