Skip to content

Commit 1079147

Browse files
committed
8348570: CTW: Expose the code hidden by uncommon traps
Reviewed-by: kvn, thartmann
1 parent 1a74ee6 commit 1079147

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/Compiler.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,27 @@ public static long getMethodCount() {
7272
public static void compileClass(Class<?> aClass, long id, Executor executor) {
7373
Objects.requireNonNull(aClass);
7474
Objects.requireNonNull(executor);
75-
ConstantPool constantPool = SharedSecrets.getJavaLangAccess().
76-
getConstantPool(aClass);
75+
76+
// Initialize all constant pool entries, if requested.
7777
if (Utils.COMPILE_THE_WORLD_PRELOAD_CLASSES) {
78+
ConstantPool constantPool = SharedSecrets.getJavaLangAccess().getConstantPool(aClass);
7879
preloadClasses(aClass.getName(), id, constantPool);
7980
}
81+
82+
// Make sure the class is initialized.
8083
UNSAFE.ensureClassInitialized(aClass);
8184
compileClinit(aClass, id);
85+
86+
// Populate profile for all methods to expand the scope of
87+
// compiler optimizations. Do this before compilations start.
88+
for (Executable e : aClass.getDeclaredConstructors()) {
89+
WHITE_BOX.markMethodProfiled(e);
90+
}
91+
for (Executable e : aClass.getDeclaredMethods()) {
92+
WHITE_BOX.markMethodProfiled(e);
93+
}
94+
95+
// Now schedule the compilations.
8296
long methodCount = 0;
8397
for (Executable e : aClass.getDeclaredConstructors()) {
8498
++methodCount;

test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ private String[] cmd(long classStart, long classStop) {
279279
"-Xbatch",
280280
"-XX:-ShowMessageBoxOnError",
281281
"-XX:+UnlockDiagnosticVMOptions",
282+
"-XX:+UnlockExperimentalVMOptions",
282283
// redirect VM output to cerr so it won't collide w/ ctw output
283284
"-XX:+DisplayVMOutputToStderr",
284285
// define phase start
@@ -299,6 +300,11 @@ private String[] cmd(long classStart, long classStop) {
299300
String.format("-XX:ReplayDataFile=replay_%s_%%p.log", phase),
300301
// MethodHandle MUST NOT be compiled
301302
"-XX:CompileCommand=exclude,java/lang/invoke/MethodHandle.*",
303+
// CTW does not have good execution profile info, which would uncommon-trap
304+
// a lot of branches/calls that are presumed to be never executed.
305+
// Expand the optimization scope by disallowing most traps.
306+
"-XX:PerMethodTrapLimit=0",
307+
"-XX:PerMethodSpecTrapLimit=0",
302308
"-XX:+IgnoreUnrecognizedVMOptions",
303309
// Do not pay extra zapping cost for explicit GC invocations
304310
"-XX:-ZapUnusedHeapArea",

0 commit comments

Comments
 (0)