Skip to content

Commit 6afb11c

Browse files
committed
8382777: PrintMethodData not showing BranchData
Reviewed-by: phubner, roland, coleenp
1 parent 8b7c364 commit 6afb11c

2 files changed

Lines changed: 78 additions & 1 deletion

File tree

src/hotspot/share/runtime/java.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "cds/dynamicArchive.hpp"
3030
#include "classfile/classLoader.hpp"
3131
#include "classfile/classLoaderDataGraph.hpp"
32+
#include "classfile/classPrinter.hpp"
3233
#include "classfile/javaClasses.hpp"
3334
#include "classfile/stringTable.hpp"
3435
#include "classfile/symbolTable.hpp"
@@ -157,7 +158,7 @@ static void print_method_profiling_data() {
157158
m->method_data()->parameters_type_data()->print_data_on(&ss);
158159
}
159160
// Buffering to a stringStream, disable internal buffering so it's not done twice.
160-
m->print_codes_on(&ss, 0, false);
161+
m->print_codes_on(&ss, ClassPrinter::PRINT_METHOD_DATA, false);
161162
tty->print("%s", ss.as_string()); // print all at once
162163
total_size += m->method_data()->size_in_bytes();
163164
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright (c) 2026 IBM Corporation. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
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.
8+
*
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).
14+
*
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.
18+
*
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
21+
* questions.
22+
*/
23+
24+
/**
25+
* @test
26+
* @bug 8382777
27+
* @summary Test that PrintMethodData output matches expectations
28+
* @requires vm.flagless
29+
* @modules java.base/jdk.internal.misc
30+
* @library /test/lib /
31+
* @run driver ${test.main.class}
32+
*/
33+
34+
package compiler.profiling;
35+
36+
import compiler.lib.generators.Generator;
37+
import compiler.lib.generators.Generators;
38+
import jdk.test.lib.process.OutputAnalyzer;
39+
import jdk.test.lib.process.ProcessTools;
40+
41+
public class TestPrintMethodData {
42+
public static void main(String[] args) throws Exception {
43+
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
44+
"-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintMethodData",
45+
"-XX:CompileCommand=compileonly,compiler.profiling.TestPrintMethodData::test*",
46+
Launcher.class.getName());
47+
48+
OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
49+
analyzer.shouldHaveExitValue(0);
50+
analyzer.shouldContain("BranchData");
51+
analyzer.shouldMatch("taken\\(\\d+\\)");
52+
}
53+
54+
static long testLongReductionSimpleMax(long[] array) {
55+
long result = Long.MIN_VALUE;
56+
for (int i = 0; i < array.length; i++) {
57+
var v = array[i];
58+
result = Math.max(v, result);
59+
}
60+
return result;
61+
}
62+
63+
static class Launcher {
64+
private static final Generator<Long> GEN_LONG = Generators.G.longs();
65+
private static final int SIZE = 1024;
66+
67+
static void main(String[] args) throws Exception {
68+
long[] longs = new long[SIZE];
69+
Generators.G.fill(GEN_LONG, longs);
70+
71+
for (int i = 0; i < 20_000; i++) {
72+
testLongReductionSimpleMax(longs);
73+
}
74+
}
75+
}
76+
}

0 commit comments

Comments
 (0)