8255072: [TESTBUG] com/sun/jdi/EATests.java should not fail if expected VMOutOfMemoryException is not thrown

Reviewed-by: cjplummer, sspitsyn, kvn
This commit is contained in:
Richard Reingruber 2020-11-03 12:36:59 +00:00
parent b8d4e02ce7
commit 63461d59a1
2 changed files with 57 additions and 28 deletions

View File

@ -26,5 +26,3 @@
# List of quarantined tests for testing with ZGC. # List of quarantined tests for testing with ZGC.
# #
############################################################################# #############################################################################
com/sun/jdi/EATests.java#id0 8255072 generic-all

View File

@ -147,6 +147,7 @@ import java.util.function.Function;
import jdk.test.lib.Asserts; import jdk.test.lib.Asserts;
import sun.hotspot.WhiteBox; import sun.hotspot.WhiteBox;
import sun.hotspot.gc.GC;
// //
@ -297,6 +298,7 @@ public class EATests extends TestScaffold {
public final boolean EliminateAllocations; public final boolean EliminateAllocations;
public final boolean DeoptimizeObjectsALot; public final boolean DeoptimizeObjectsALot;
public final boolean DoEscapeAnalysis; public final boolean DoEscapeAnalysis;
public final boolean ZGCIsSelected;
public TargetVMOptions(EATests env, ClassType testCaseBaseTargetClass) { public TargetVMOptions(EATests env, ClassType testCaseBaseTargetClass) {
Value val; Value val;
@ -309,6 +311,8 @@ public class EATests extends TestScaffold {
DeoptimizeObjectsALot = ((PrimitiveValue) val).booleanValue(); DeoptimizeObjectsALot = ((PrimitiveValue) val).booleanValue();
val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("UseJVMCICompiler")); val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("UseJVMCICompiler"));
UseJVMCICompiler = ((PrimitiveValue) val).booleanValue(); UseJVMCICompiler = ((PrimitiveValue) val).booleanValue();
val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("ZGCIsSelected"));
ZGCIsSelected = ((PrimitiveValue) val).booleanValue();
} }
} }
@ -774,12 +778,14 @@ abstract class EATestCaseBaseTarget extends EATestCaseBaseShared implements Runn
return value == null ? dflt : value; return value == null ? dflt : value;
} }
public static final boolean UseJVMCICompiler = unbox(WB.getBooleanVMFlag("UseJVMCICompiler"), false); // read by debugger // Some of the fields are only read by the debugger
public static final boolean DoEscapeAnalysis = unbox(WB.getBooleanVMFlag("DoEscapeAnalysis"), UseJVMCICompiler); public static final boolean UseJVMCICompiler = unbox(WB.getBooleanVMFlag("UseJVMCICompiler"), false);
public static final boolean EliminateAllocations = unbox(WB.getBooleanVMFlag("EliminateAllocations"), UseJVMCICompiler); // read by debugger public static final boolean DoEscapeAnalysis = unbox(WB.getBooleanVMFlag("DoEscapeAnalysis"), UseJVMCICompiler);
public static final boolean DeoptimizeObjectsALot = WB.getBooleanVMFlag("DeoptimizeObjectsALot"); // read by debugger public static final boolean EliminateAllocations = unbox(WB.getBooleanVMFlag("EliminateAllocations"), UseJVMCICompiler);
public static final boolean DeoptimizeObjectsALot = WB.getBooleanVMFlag("DeoptimizeObjectsALot");
public static final long BiasedLockingBulkRebiasThreshold = WB.getIntxVMFlag("BiasedLockingBulkRebiasThreshold"); public static final long BiasedLockingBulkRebiasThreshold = WB.getIntxVMFlag("BiasedLockingBulkRebiasThreshold");
public static final long BiasedLockingBulkRevokeThreshold = WB.getIntxVMFlag("BiasedLockingBulkRevokeThreshold"); public static final long BiasedLockingBulkRevokeThreshold = WB.getIntxVMFlag("BiasedLockingBulkRevokeThreshold");
public static final boolean ZGCIsSelected = GC.Z.isSelected();
public String testMethodName; public String testMethodName;
public int testMethodDepth; public int testMethodDepth;
@ -1079,7 +1085,7 @@ abstract class EATestCaseBaseTarget extends EATestCaseBaseShared implements Runn
LinkedList l; LinkedList l;
public long[] array; public long[] array;
public LinkedList(LinkedList l, int size) { public LinkedList(LinkedList l, int size) {
this.array = new long[size]; this.array = size > 0 ? new long[size] : null;
this.l = l; this.l = l;
} }
} }
@ -1089,12 +1095,13 @@ abstract class EATestCaseBaseTarget extends EATestCaseBaseShared implements Runn
public void consumeAllMemory() { public void consumeAllMemory() {
msg("consume all memory"); msg("consume all memory");
int size = 128 * 1024 * 1024; int size = 128 * 1024 * 1024;
while(size > 0) { while(true) {
try { try {
while(true) { while(true) {
consumedMemory = new LinkedList(consumedMemory, size); consumedMemory = new LinkedList(consumedMemory, size);
} }
} catch(OutOfMemoryError oom) { } catch(OutOfMemoryError oom) {
if (size == 0) break;
} }
size = size / 2; size = size / 2;
} }
@ -2603,10 +2610,8 @@ class EAPopFrameNotInlinedReallocFailure extends EATestCaseBaseDebugger {
} }
freeAllMemory(); freeAllMemory();
// We succeeded to pop just one frame. When we continue, we will call dontinline_brkpt() again. // We succeeded to pop just one frame. When we continue, we will call dontinline_brkpt() again.
Asserts.assertTrue(coughtOom || !env.targetVMOptions.EliminateAllocations, Asserts.assertTrue(coughtOom, "PopFrame should have triggered an OOM exception in target");
"PopFrame should have triggered an OOM exception in target"); String expectedTopFrame = "dontinline_consume_all_memory_brkpt";
String expectedTopFrame =
env.targetVMOptions.EliminateAllocations ? "dontinline_consume_all_memory_brkpt" : "dontinline_testMethod";
Asserts.assertEQ(expectedTopFrame, thread.frame(0).location().method().name()); Asserts.assertEQ(expectedTopFrame, thread.frame(0).location().method().name());
printStack(thread); printStack(thread);
} }
@ -2615,7 +2620,12 @@ class EAPopFrameNotInlinedReallocFailure extends EATestCaseBaseDebugger {
public boolean shouldSkip() { public boolean shouldSkip() {
// OOMEs because of realloc failures with DeoptimizeObjectsALot are too random. // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
// And Graal currently doesn't provide all information about non-escaping objects in debug info // And Graal currently doesn't provide all information about non-escaping objects in debug info
return super.shouldSkip() || env.targetVMOptions.DeoptimizeObjectsALot || env.targetVMOptions.UseJVMCICompiler; return super.shouldSkip() ||
!env.targetVMOptions.EliminateAllocations ||
// With ZGC the OOME is not always thrown as expected
env.targetVMOptions.ZGCIsSelected ||
env.targetVMOptions.DeoptimizeObjectsALot ||
env.targetVMOptions.UseJVMCICompiler;
} }
} }
@ -2655,7 +2665,12 @@ class EAPopFrameNotInlinedReallocFailureTarget extends EATestCaseBaseTarget {
public boolean shouldSkip() { public boolean shouldSkip() {
// OOMEs because of realloc failures with DeoptimizeObjectsALot are too random. // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
// And Graal currently doesn't provide all information about non-escaping objects in debug info // And Graal currently doesn't provide all information about non-escaping objects in debug info
return super.shouldSkip() || DeoptimizeObjectsALot || UseJVMCICompiler; return super.shouldSkip() ||
!EliminateAllocations ||
// With ZGC the OOME is not always thrown as expected
ZGCIsSelected ||
DeoptimizeObjectsALot ||
UseJVMCICompiler;
} }
} }
@ -2694,10 +2709,8 @@ class EAPopInlinedMethodWithScalarReplacedObjectsReallocFailure extends EATestCa
freeAllMemory(); freeAllMemory();
setField(testCase, "loopCount", env.vm().mirrorOf(0)); // terminate loop setField(testCase, "loopCount", env.vm().mirrorOf(0)); // terminate loop
Asserts.assertTrue(coughtOom || !env.targetVMOptions.EliminateAllocations, Asserts.assertTrue(coughtOom, "PopFrame should have triggered an OOM exception in target");
"PopFrame should have triggered an OOM exception in target"); String expectedTopFrame = "inlinedCallForcedToReturn";
String expectedTopFrame =
env.targetVMOptions.EliminateAllocations ? "inlinedCallForcedToReturn" : "dontinline_testMethod";
Asserts.assertEQ(expectedTopFrame, thread.frame(0).location().method().name()); Asserts.assertEQ(expectedTopFrame, thread.frame(0).location().method().name());
} }
@ -2705,7 +2718,12 @@ class EAPopInlinedMethodWithScalarReplacedObjectsReallocFailure extends EATestCa
public boolean shouldSkip() { public boolean shouldSkip() {
// OOMEs because of realloc failures with DeoptimizeObjectsALot are too random. // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
// And Graal currently doesn't provide all information about non-escaping objects in debug info // And Graal currently doesn't provide all information about non-escaping objects in debug info
return super.shouldSkip() || env.targetVMOptions.DeoptimizeObjectsALot || env.targetVMOptions.UseJVMCICompiler; return super.shouldSkip() ||
!env.targetVMOptions.EliminateAllocations ||
// With ZGC the OOME is not always thrown as expected
env.targetVMOptions.ZGCIsSelected ||
env.targetVMOptions.DeoptimizeObjectsALot ||
env.targetVMOptions.UseJVMCICompiler;
} }
} }
@ -2761,7 +2779,12 @@ class EAPopInlinedMethodWithScalarReplacedObjectsReallocFailureTarget extends EA
public boolean shouldSkip() { public boolean shouldSkip() {
// OOMEs because of realloc failures with DeoptimizeObjectsALot are too random. // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
// And Graal currently doesn't provide all information about non-escaping objects in debug info // And Graal currently doesn't provide all information about non-escaping objects in debug info
return super.shouldSkip() || DeoptimizeObjectsALot || UseJVMCICompiler; return super.shouldSkip() ||
!EliminateAllocations ||
// With ZGC the OOME is not always thrown as expected
ZGCIsSelected ||
DeoptimizeObjectsALot ||
UseJVMCICompiler;
} }
} }
@ -2948,12 +2971,10 @@ class EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjectsReallocFailure e
coughtOom = true; coughtOom = true;
} }
freeAllMemory(); freeAllMemory();
if (env.targetVMOptions.EliminateAllocations) { Asserts.assertTrue(coughtOom, "ForceEarlyReturn should have triggered an OOM exception in target");
printStack(thread); printStack(thread);
Asserts.assertTrue(coughtOom, "ForceEarlyReturn should have triggered an OOM exception in target"); msg("ForceEarlyReturn(2)");
msg("ForceEarlyReturn(2)"); thread.forceEarlyReturn(env.vm().mirrorOf(43));
thread.forceEarlyReturn(env.vm().mirrorOf(43));
}
msg("Step over instruction to do the forced return"); msg("Step over instruction to do the forced return");
env.stepOverInstruction(thread); env.stepOverInstruction(thread);
printStack(thread); printStack(thread);
@ -2964,7 +2985,12 @@ class EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjectsReallocFailure e
public boolean shouldSkip() { public boolean shouldSkip() {
// OOMEs because of realloc failures with DeoptimizeObjectsALot are too random. // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
// And Graal currently doesn't support Force Early Return // And Graal currently doesn't support Force Early Return
return super.shouldSkip() || env.targetVMOptions.DeoptimizeObjectsALot || env.targetVMOptions.UseJVMCICompiler; return super.shouldSkip() ||
!env.targetVMOptions.EliminateAllocations ||
// With ZGC the OOME is not always thrown as expected
env.targetVMOptions.ZGCIsSelected ||
env.targetVMOptions.DeoptimizeObjectsALot ||
env.targetVMOptions.UseJVMCICompiler;
} }
} }
@ -3021,7 +3047,12 @@ class EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjectsReallocFailureTa
public boolean shouldSkip() { public boolean shouldSkip() {
// OOMEs because of realloc failures with DeoptimizeObjectsALot are too random. // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
// And Graal currently doesn't support Force Early Return // And Graal currently doesn't support Force Early Return
return super.shouldSkip() || DeoptimizeObjectsALot || UseJVMCICompiler; return super.shouldSkip() ||
!EliminateAllocations ||
// With ZGC the OOME is not always thrown as expected
ZGCIsSelected ||
DeoptimizeObjectsALot ||
UseJVMCICompiler;
} }
} }