2
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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
7
* published by the Free Software Foundation.
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
25
#include "precompiled.hpp"
26
#include "code/nmethod.hpp"
27
#include "compiler/compilationLog.hpp"
28
#include "compiler/compileTask.hpp"
29
#include "logging/log.hpp"
30
#include "memory/resourceArea.hpp"
31
#include "runtime/thread.hpp"
32
#include "utilities/ostream.hpp"
34
CompilationLog* CompilationLog::_log;
36
CompilationLog::CompilationLog() : StringEventLog("Compilation events", "jit") {
39
void CompilationLog::log_compile(JavaThread* thread, CompileTask* task) {
41
stringStream sstr(lm.buffer(), lm.size());
42
// msg.time_stamp().update_to(tty->time_stamp().ticks());
43
task->print(&sstr, nullptr, true, false);
44
log(thread, "%s", (const char*)lm);
47
void CompilationLog::log_nmethod(JavaThread* thread, nmethod* nm) {
48
log(thread, "nmethod %d%s " INTPTR_FORMAT " code [" INTPTR_FORMAT ", " INTPTR_FORMAT "]",
49
nm->compile_id(), nm->is_osr_method() ? "%" : "",
50
p2i(nm), p2i(nm->code_begin()), p2i(nm->code_end()));
53
void CompilationLog::log_failure(JavaThread* thread, CompileTask* task, const char* reason, const char* retry_message) {
55
lm.print("%4d COMPILE SKIPPED: %s", task->compile_id(), reason);
56
if (retry_message != nullptr) {
57
lm.append(" (%s)", retry_message);
60
log(thread, "%s", (const char*)lm);
63
void CompilationLog::log_metaspace_failure(const char* reason) {
64
// Note: This method can be called from non-Java/compiler threads to
65
// log the global metaspace failure that might affect profiling.
68
lm.print("%4d COMPILE PROFILING SKIPPED: %s", -1, reason);
70
log(Thread::current(), "%s", (const char*)lm);
73
void CompilationLog::init() {
74
_log = new CompilationLog();