-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8350642: Interpreter: Upgrade CountBytecodes to 64 bit on 64 bit platforms #23766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e9ba782
6194f67
6dc57b6
1891d8c
3cc63fb
2708e14
091cc88
d58c550
4dbe796
714c580
3165254
fbe4067
45699ec
76bdd19
31a5215
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2025 SAP SE. 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. | ||
* | ||
* 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. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
/* | ||
* @test | ||
* @bug 8350642 | ||
* @requires vm.debug & vm.bits == "64" | ||
* @summary Test the output for CountBytecodes and validate that the counter | ||
* does not overflow for more than 2^32 bytecodes counted. | ||
* @library /test/lib | ||
* @run main/othervm/timeout=300 CountBytecodesTest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The long tests should be excluded from tier1. Please update TEST.groups. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I excluded the test from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this should work. In current definition, |
||
*/ | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import jdk.test.lib.Asserts; | ||
import jdk.test.lib.process.OutputAnalyzer; | ||
import jdk.test.lib.process.ProcessTools; | ||
|
||
public class CountBytecodesTest { | ||
private final static long iterations = (1L << 32) / 9; | ||
|
||
public static void main(String args[]) throws Exception { | ||
if (args.length == 1 && args[0].equals("test")) { | ||
for (long i = 0; i < iterations; i++) { | ||
// Just iterating is enough to execute and count bytecodes. | ||
// According to javap -c this loop translates to the following 9 bytecodes: | ||
// 19: lload_1 | ||
// 20: ldc2_w #17 | ||
// 23: lcmp | ||
// 24: ifge 34 | ||
// 27: lload_1 | ||
// 28: lconst_1 | ||
// 29: ladd | ||
// 30: lstore_1 | ||
// 31: goto 19 | ||
// | ||
// Thus we can divide the 2^32 by 9 to set the minimum number of iterations | ||
// while maintaining execution of more than 2^32 bytecodes. | ||
} | ||
} else { | ||
OutputAnalyzer output = ProcessTools.executeTestJava("-Xint", "-XX:+CountBytecodes", "CountBytecodesTest", "test"); | ||
output.shouldHaveExitValue(0); | ||
|
||
// Output format: [BytecodeCounter::counter_value = 38676232802] | ||
output.stdoutShouldContain("BytecodeCounter::counter_value"); | ||
String bytecodesStr = output.firstMatch("BytecodeCounter::counter_value\s*=\s*(\\d+)", 1); | ||
long bytecodes = Long.parseLong(bytecodesStr); | ||
|
||
System.out.println("Executed bytecodes: " + bytecodes); | ||
|
||
Asserts.assertGTE(bytecodes, 4294967296L); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like there are more than 8 digits now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this, too, but I don't think it's a problem because the width is specified like this: "Minimum number of characters to be printed. If the value to be printed is shorter than this number, the result is padded with blank spaces. The value is not truncated even if the result is larger." [https://cplusplus.com/reference/cstdio/printf/].
Do we want a larger fixed number of digits?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it is not about the correctness. It is more about readability: if we expect more than 8 digits, then the "table" we are printing here would be a bit ragged. UINT64_MAX is about 20 digits. In practice we would probably never do this for longer than 1 hour, and with (ballparking) 100M/sec bytecodes, this gives us a practical upper limit of 12 digits or so? My math might be off a digit or two.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, nevermind. I don't think this is useful to adjust. The bytecode counter is global, so it is not a per-bytecode printout like I initially thought.