Skip to content

Commit 2366b22

Browse files
committed
get deoptimization count only on default compilation
1 parent 5ff85f1 commit 2366b22

File tree

6 files changed

+40
-3
lines changed

6 files changed

+40
-3
lines changed

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/CountedLoopOverflowTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ public void testDownOverflow() {
129129
}
130130
}
131131

132+
@Override
133+
protected boolean installAsDefault() {
134+
return true;
135+
}
136+
132137
@Test
133138
public void testDownOverflowUnsigned() {
134139
try {

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/GraalCompilerTest.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -902,12 +902,16 @@ protected Result executeActual(ResolvedJavaMethod method, Object receiver, Objec
902902
}
903903

904904
protected Result executeActual(OptionValues options, ResolvedJavaMethod method, Object receiver, Object... args) {
905+
return executeActual(options, method, false, receiver, args);
906+
}
907+
908+
protected Result executeActual(OptionValues options, ResolvedJavaMethod method, boolean installAsDefault, Object receiver, Object... args) {
905909
before(method);
906910
Object[] executeArgs = argsWithReceiver(receiver, args);
907911

908912
checkArgs(method, executeArgs);
909913

910-
InstalledCode compiledMethod = getCode(method, options);
914+
InstalledCode compiledMethod = getCode(method, null, false, installAsDefault, options);
911915
try {
912916
return new Result(compiledMethod.executeVarargs(executeArgs), null);
913917
} catch (Throwable e) {
@@ -1053,7 +1057,7 @@ protected Result executeActualCheckDeopt(OptionValues options, ResolvedJavaMetho
10531057
for (DeoptimizationReason reason : shouldNotDeopt) {
10541058
deoptCounts.put(reason, profile.getDeoptimizationCount(reason));
10551059
}
1056-
Result actual = executeActual(options, method, receiver, args);
1060+
Result actual = executeActual(options, method, !shouldNotDeopt.isEmpty(), receiver, args);
10571061
profile = method.getProfilingInfo(); // profile can change after execution
10581062
for (DeoptimizationReason reason : shouldNotDeopt) {
10591063
Assert.assertEquals("wrong number of deopt counts for " + reason, (int) deoptCounts.get(reason), profile.getDeoptimizationCount(reason));
@@ -1162,7 +1166,7 @@ protected InstalledCode getCode(final ResolvedJavaMethod installedCodeOwner, Str
11621166
try (DebugContext.Scope _ = debug.scope("CodeInstall", getCodeCache(), installedCodeOwner, compResult);
11631167
DebugContext.Activation _ = debug.activate()) {
11641168
try {
1165-
if (installAsDefault) {
1169+
if (installAsDefault || installAsDefault()) {
11661170
installedCode = addDefaultMethod(debug, installedCodeOwner, compResult);
11671171
} else {
11681172
installedCode = addMethod(debug, installedCodeOwner, compResult);
@@ -1195,6 +1199,14 @@ protected InstalledCode getCode(final ResolvedJavaMethod installedCodeOwner, Str
11951199
throw GraalError.shouldNotReachHere("Bailout limit reached"); // ExcludeFromJacocoGeneratedReport
11961200
}
11971201

1202+
/**
1203+
* Allows subclasses to override and install compiled code as the default. Note that since
1204+
* JDK26+5, deoptimization counts are only updated for default compiled code.
1205+
*/
1206+
protected boolean installAsDefault() {
1207+
return false;
1208+
}
1209+
11981210
private static boolean optionsMapDeepEquals(UnmodifiableEconomicMap<OptionKey<?>, Object> map1, UnmodifiableEconomicMap<OptionKey<?>, Object> map2) {
11991211
if (map1.size() != map2.size()) {
12001212
return false;

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/DeoptimizeReasonAccountingTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,9 @@ public void testDeoptimize() {
131131
}
132132
}
133133
}
134+
135+
@Override
136+
protected boolean installAsDefault() {
137+
return true;
138+
}
134139
}

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/RangeCheckPredicatesTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,4 +1142,9 @@ public static int rangeCheckPredicatesGuardAboveExitTest(int[] array, int start,
11421142
public void testGuardAboveExitTest() {
11431143
verifyRangeCheckInLoop("rangeCheckPredicatesGuardAboveExitTest");
11441144
}
1145+
1146+
@Override
1147+
protected boolean installAsDefault() {
1148+
return true;
1149+
}
11451150
}

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/ArrayCopyExceptionSeenTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,9 @@ public void testFailingCopy() throws InvalidInstalledCodeException {
9898
code.executeVarargs(new Object[3], -1, new Object[3], 0, 1);
9999
Assert.assertEquals("No more deopts expected after recompile with explicit exception edge.", 1, method.getProfilingInfo().getDeoptimizationCount(DeoptimizationReason.BoundsCheckException));
100100
}
101+
102+
@Override
103+
protected boolean installAsDefault() {
104+
return true;
105+
}
101106
}

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/DeoptimizeOnExceptionTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,9 @@ public static boolean test3Snippet(boolean rethrowException) throws Exception {
220220

221221
return GraalDirectives.inCompiledCode();
222222
}
223+
224+
@Override
225+
protected boolean installAsDefault() {
226+
return true;
227+
}
223228
}

0 commit comments

Comments
 (0)