From 0074b48ad77d68ece8633a165aaba7f42bb52c5d Mon Sep 17 00:00:00 2001 From: Ben Taylor Date: Mon, 14 Aug 2023 22:50:37 +0000 Subject: [PATCH] 8312597: Convert TraceTypeProfile to UL Reviewed-by: shade, phh --- src/hotspot/share/opto/doCall.cpp | 27 ++++++++++---- .../jtreg/compiler/arguments/TestLogJIT.java | 36 ++++++++++++++++++ .../arguments/TestTraceTypeProfile.java | 37 +++++++++++++++++++ 3 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/arguments/TestLogJIT.java create mode 100644 test/hotspot/jtreg/compiler/arguments/TestTraceTypeProfile.java diff --git a/src/hotspot/share/opto/doCall.cpp b/src/hotspot/share/opto/doCall.cpp index 4f3184cb48b..7e9e08a7e1b 100644 --- a/src/hotspot/share/opto/doCall.cpp +++ b/src/hotspot/share/opto/doCall.cpp @@ -30,6 +30,10 @@ #include "compiler/compileBroker.hpp" #include "compiler/compileLog.hpp" #include "interpreter/linkResolver.hpp" +#include "logging/log.hpp" +#include "logging/logLevel.hpp" +#include "logging/logMessage.hpp" +#include "logging/logStream.hpp" #include "opto/addnode.hpp" #include "opto/callGenerator.hpp" #include "opto/castnode.hpp" @@ -46,7 +50,15 @@ #include "jfr/jfr.hpp" #endif -void trace_type_profile(Compile* C, ciMethod *method, int depth, int bci, ciMethod *prof_method, ciKlass *prof_klass, int site_count, int receiver_count) { +void print_trace_type_profile(outputStream* out, int depth, ciKlass* prof_klass, int site_count, int receiver_count) { + CompileTask::print_inline_indent(depth, out); + out->print(" \\-> TypeProfile (%d/%d counts) = ", receiver_count, site_count); + prof_klass->name()->print_symbol_on(out); + out->cr(); +} + +void trace_type_profile(Compile* C, ciMethod* method, int depth, int bci, ciMethod* prof_method, + ciKlass* prof_klass, int site_count, int receiver_count) { if (TraceTypeProfile || C->print_inlining()) { outputStream* out = tty; if (!C->print_inlining()) { @@ -58,12 +70,13 @@ void trace_type_profile(Compile* C, ciMethod *method, int depth, int bci, ciMeth } else { out = C->print_inlining_stream(); } - CompileTask::print_inline_indent(depth, out); - out->print(" \\-> TypeProfile (%d/%d counts) = ", receiver_count, site_count); - stringStream ss; - prof_klass->name()->print_symbol_on(&ss); - out->print("%s", ss.freeze()); - out->cr(); + print_trace_type_profile(out, depth, prof_klass, site_count, receiver_count); + } + + LogTarget(Debug, jit, inlining) lt; + if (lt.is_enabled()) { + LogStream ls(lt); + print_trace_type_profile(&ls, depth, prof_klass, site_count, receiver_count); } } diff --git a/test/hotspot/jtreg/compiler/arguments/TestLogJIT.java b/test/hotspot/jtreg/compiler/arguments/TestLogJIT.java new file mode 100644 index 00000000000..5974419a4c2 --- /dev/null +++ b/test/hotspot/jtreg/compiler/arguments/TestLogJIT.java @@ -0,0 +1,36 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Amazon designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/* + * @test + * @summary Test running with log:jit*=debug enabled. + * @run main/othervm -Xlog:jit*=debug compiler.arguments.TestTraceTypeProfile + */ + +package compiler.arguments; + +public class TestLogJIT { + + static public void main(String[] args) { + System.out.println("Passed"); + } +} + diff --git a/test/hotspot/jtreg/compiler/arguments/TestTraceTypeProfile.java b/test/hotspot/jtreg/compiler/arguments/TestTraceTypeProfile.java new file mode 100644 index 00000000000..f2797b329f1 --- /dev/null +++ b/test/hotspot/jtreg/compiler/arguments/TestTraceTypeProfile.java @@ -0,0 +1,37 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Amazon designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/* + * @test + * @summary Test running TraceTypeProfile enabled. + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions + * -XX:+TraceTypeProfile compiler.arguments.TestTraceTypeProfile + */ + +package compiler.arguments; + +public class TestTraceTypeProfile { + + static public void main(String[] args) { + System.out.println("Passed"); + } +} +