< prev index next >

test/jdk/com/sun/jdi/EATests.java

Print this page

 299 
 300     EATests(String args[]) {
 301         super(args);
 302     }
 303 
 304     public static void main(String[] args) throws Exception {
 305         if (EATestCaseBaseShared.RUN_ONLY_TEST_CASE != null) {
 306             args = Arrays.copyOf(args, args.length + 1);
 307             args[args.length - 1] = "-D" + EATestCaseBaseShared.RUN_ONLY_TEST_CASE_PROPERTY + "=" + EATestCaseBaseShared.RUN_ONLY_TEST_CASE;
 308         }
 309         new EATests(args).startTests();
 310     }
 311 
 312     public static class TargetVMOptions {
 313 
 314         public final boolean UseJVMCICompiler;
 315         public final boolean EliminateAllocations;
 316         public final boolean DeoptimizeObjectsALot;
 317         public final boolean DoEscapeAnalysis;
 318         public final boolean ZGCIsSelected;

 319         public final boolean StressReflectiveCode;
 320 
 321         public TargetVMOptions(EATests env, ClassType testCaseBaseTargetClass) {
 322             Value val;
 323             val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("DoEscapeAnalysis"));
 324             DoEscapeAnalysis = ((PrimitiveValue) val).booleanValue();
 325             // Escape analysis is a prerequisite for scalar replacement (EliminateAllocations)
 326             val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("EliminateAllocations"));
 327             EliminateAllocations = DoEscapeAnalysis && ((PrimitiveValue) val).booleanValue();
 328             val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("DeoptimizeObjectsALot"));
 329             DeoptimizeObjectsALot = ((PrimitiveValue) val).booleanValue();
 330             val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("UseJVMCICompiler"));
 331             UseJVMCICompiler = ((PrimitiveValue) val).booleanValue();
 332             val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("ZGCIsSelected"));
 333             ZGCIsSelected = ((PrimitiveValue) val).booleanValue();


 334             val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("StressReflectiveCode"));
 335             StressReflectiveCode = ((PrimitiveValue) val).booleanValue();
 336         }
 337 
 338     }
 339 
 340     // Execute known test cases
 341     protected void runTests() throws Exception {
 342         String targetProgName = EATestsTarget.class.getName();
 343         msg("starting to main method in class " +  targetProgName);
 344         startToMain(targetProgName);
 345         msg("resuming to EATestCaseBaseTarget.staticSetUpDone()V");
 346         targetMainThread = resumeTo("EATestCaseBaseTarget", "staticSetUpDone", "()V").thread();
 347         Location loc = targetMainThread.frame(0).location();
 348         Asserts.assertEQ("staticSetUpDone", loc.method().name());
 349 
 350         targetVMOptions = new TargetVMOptions(this, (ClassType) loc.declaringType());
 351 
 352         // Materializing test cases, i.e. reallocating objects on the heap
 353         new EAMaterializeLocalVariableUponGet()                                       .run(this);

 803      * Used in {@link EATestCaseBaseDebugger#terminateEndlessLoop()} to signal target to leave the endless loop.
 804      */
 805     public volatile boolean doLoop;
 806 
 807     public long checkSum;
 808 
 809     public static final String TESTMETHOD_DEFAULT_NAME = "dontinline_testMethod";
 810 
 811     public static final WhiteBox WB = WhiteBox.getWhiteBox();
 812 
 813     public static boolean unbox(Boolean value, boolean dflt) {
 814         return value == null ? dflt : value;
 815     }
 816 
 817     // Some of the fields are only read by the debugger
 818     public static final boolean UseJVMCICompiler = unbox(WB.getBooleanVMFlag("UseJVMCICompiler"), false);
 819     public static final boolean DoEscapeAnalysis = unbox(WB.getBooleanVMFlag("DoEscapeAnalysis"), UseJVMCICompiler);
 820     public static final boolean EliminateAllocations = unbox(WB.getBooleanVMFlag("EliminateAllocations"), UseJVMCICompiler);
 821     public static final boolean DeoptimizeObjectsALot = WB.getBooleanVMFlag("DeoptimizeObjectsALot");
 822     public static final boolean ZGCIsSelected = GC.Z.isSelected();

 823     public static final boolean StressReflectiveCode = unbox(WB.getBooleanVMFlag("StressReflectiveCode"), false);
 824 
 825     public String testMethodName;
 826     public int testMethodDepth;
 827 
 828     // Results produced by dontinline_testMethod()
 829     public int  iResult;
 830     public long lResult;
 831     public float  fResult;
 832     public double dResult;
 833 
 834 
 835     public boolean warmupDone;
 836 
 837     // an object with an inflated monitor
 838     public static XYVal inflatedLock;
 839     public static Thread  inflatorThread;
 840     public static boolean inflatedLockIsPermanentlyInflated;
 841 
 842     public static int    NOT_CONST_1I = 1;

2667             thread.popFrames(thread.frame(1));
2668         } catch (VMOutOfMemoryException oom) {
2669             // as expected
2670             msg("cought OOM");
2671             coughtOom  = true;
2672         }
2673         freeAllMemory();
2674         // We succeeded to pop just one frame. When we continue, we will call dontinline_brkpt() again.
2675         Asserts.assertTrue(coughtOom, "PopFrame should have triggered an OOM exception in target");
2676         String expectedTopFrame = "dontinline_consume_all_memory_brkpt";
2677         Asserts.assertEQ(expectedTopFrame, thread.frame(0).location().method().name());
2678         printStack(thread);
2679     }
2680 
2681     @Override
2682     public boolean shouldSkip() {
2683         // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
2684         // And Graal currently doesn't provide all information about non-escaping objects in debug info
2685         return super.shouldSkip() ||
2686                 !env.targetVMOptions.EliminateAllocations ||
2687                 // With ZGC the OOME is not always thrown as expected
2688                 env.targetVMOptions.ZGCIsSelected ||

2689                 env.targetVMOptions.DeoptimizeObjectsALot ||
2690                 env.targetVMOptions.UseJVMCICompiler;
2691     }
2692 }
2693 
2694 class EAPopFrameNotInlinedReallocFailureTarget extends EATestCaseBaseTarget {
2695 
2696     public boolean doneAlready;
2697 
2698     public void dontinline_testMethod() {
2699         long a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};                // scalar replaced
2700         Vector10 v = new Vector10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);  // scalar replaced
2701         dontinline_consume_all_memory_brkpt();
2702         lResult = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9]
2703                + v.i0 + v.i1 + v.i2 + v.i3 + v.i4 + v.i5 + v.i6 + v.i7 + v.i8 + v.i9;
2704     }
2705 
2706     public void dontinline_consume_all_memory_brkpt() {
2707         if (warmupDone && !doneAlready) {
2708             doneAlready = true;

2712     }
2713 
2714     @Override
2715     public void setUp() {
2716         super.setUp();
2717         testMethodDepth = 2;
2718     }
2719 
2720     @Override
2721     public long getExpectedLResult() {
2722         long n = 10;
2723         return 2*n*(n+1)/2;
2724     }
2725 
2726     @Override
2727     public boolean shouldSkip() {
2728         // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
2729         // And Graal currently doesn't provide all information about non-escaping objects in debug info
2730         return super.shouldSkip() ||
2731                 !EliminateAllocations ||
2732                 // With ZGC the OOME is not always thrown as expected
2733                 ZGCIsSelected ||

2734                 DeoptimizeObjectsALot ||
2735                 UseJVMCICompiler;
2736     }
2737 }
2738 
2739 /////////////////////////////////////////////////////////////////////////////
2740 
2741 /**
2742  * Pop inlined top frame dropping into method with scalar replaced opjects.
2743  */
2744 class EAPopInlinedMethodWithScalarReplacedObjectsReallocFailure extends EATestCaseBaseDebugger {
2745 
2746     public void runTestCase() throws Exception {
2747         ThreadReference thread = env.targetMainThread;
2748         env.vm().resume();
2749         waitUntilTargetHasEnteredEndlessLoop();
2750 
2751         thread.suspend();
2752         printStack(thread);
2753         // frame[0]: EAPopInlinedMethodWithScalarReplacedObjectsReallocFailureTarget.inlinedCallForcedToReturn()

2765             coughtOom = true;
2766         }
2767         printStack(thread);
2768         // frame[0]: EAPopInlinedMethodWithScalarReplacedObjectsReallocFailureTarget.inlinedCallForcedToReturn()
2769         // frame[1]: EAPopInlinedMethodWithScalarReplacedObjectsReallocFailureTarget.dontinline_testMethod()
2770         // frame[2]: EATestCaseBaseTarget.run()
2771 
2772         freeAllMemory();
2773         setField(testCase, "loopCount", env.vm().mirrorOf(0)); // terminate loop
2774         Asserts.assertTrue(coughtOom, "PopFrame should have triggered an OOM exception in target");
2775         String expectedTopFrame = "inlinedCallForcedToReturn";
2776         Asserts.assertEQ(expectedTopFrame, thread.frame(0).location().method().name());
2777     }
2778 
2779     @Override
2780     public boolean shouldSkip() {
2781         // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
2782         // And Graal currently doesn't provide all information about non-escaping objects in debug info
2783         return super.shouldSkip() ||
2784                 !env.targetVMOptions.EliminateAllocations ||
2785                 // With ZGC the OOME is not always thrown as expected
2786                 env.targetVMOptions.ZGCIsSelected ||

2787                 env.targetVMOptions.DeoptimizeObjectsALot ||
2788                 env.targetVMOptions.UseJVMCICompiler;
2789     }
2790 }
2791 
2792 class EAPopInlinedMethodWithScalarReplacedObjectsReallocFailureTarget extends EATestCaseBaseTarget {
2793 
2794     public long checkSum;
2795 
2796     public void dontinline_testMethod() {
2797         long a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};                // scalar replaced
2798         Vector10 v = new Vector10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);  // scalar replaced
2799         long l = inlinedCallForcedToReturn();
2800         lResult = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9]
2801                + v.i0 + v.i1 + v.i2 + v.i3 + v.i4 + v.i5 + v.i6 + v.i7 + v.i8 + v.i9;
2802     }
2803 
2804     public long inlinedCallForcedToReturn() {
2805         long cs = checkSum;
2806         dontinline_consumeAllMemory();

2826     }
2827 
2828     @Override
2829     public void setUp() {
2830         super.setUp();
2831         loopCount = 3;
2832     }
2833 
2834     public void warmupDone() {
2835         super.warmupDone();
2836         msg("enter 'endless' loop by setting loopCount = Long.MAX_VALUE");
2837         loopCount = Long.MAX_VALUE; // endless loop
2838     }
2839 
2840     @Override
2841     public boolean shouldSkip() {
2842         // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
2843         // And Graal currently doesn't provide all information about non-escaping objects in debug info
2844         return super.shouldSkip() ||
2845                 !EliminateAllocations ||
2846                 // With ZGC the OOME is not always thrown as expected
2847                 ZGCIsSelected ||

2848                 DeoptimizeObjectsALot ||
2849                 UseJVMCICompiler;
2850     }
2851 }
2852 
2853 /////////////////////////////////////////////////////////////////////////////
2854 //
2855 // ForceEarlyReturn tests
2856 //
2857 /////////////////////////////////////////////////////////////////////////////
2858 
2859 /**
2860  * ForceEarlyReturn into caller frame with scalar replaced objects.
2861  */
2862 class EAForceEarlyReturnNotInlined extends EATestCaseBaseDebugger {
2863 
2864     public void runTestCase() throws Exception {
2865         BreakpointEvent bpe = resumeTo(TARGET_TESTCASE_BASE_NAME, "dontinline_brkpt", "()V");
2866         ThreadReference thread = bpe.thread();
2867         printStack(thread);

3032             msg("cought OOM");
3033             coughtOom   = true;
3034         }
3035         freeAllMemory();
3036         Asserts.assertTrue(coughtOom, "ForceEarlyReturn should have triggered an OOM exception in target");
3037         printStack(thread);
3038         msg("ForceEarlyReturn(2)");
3039         thread.forceEarlyReturn(env.vm().mirrorOf(43));
3040         msg("Step over instruction to do the forced return");
3041         env.stepOverInstruction(thread);
3042         printStack(thread);
3043         msg("ForceEarlyReturn DONE");
3044     }
3045 
3046     @Override
3047     public boolean shouldSkip() {
3048         // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
3049         // And Graal currently doesn't support Force Early Return
3050         return super.shouldSkip() ||
3051                 !env.targetVMOptions.EliminateAllocations ||
3052                 // With ZGC the OOME is not always thrown as expected
3053                 env.targetVMOptions.ZGCIsSelected ||

3054                 env.targetVMOptions.DeoptimizeObjectsALot ||
3055                 env.targetVMOptions.UseJVMCICompiler;
3056     }
3057 }
3058 
3059 class EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjectsReallocFailureTarget extends EATestCaseBaseTarget {
3060 
3061     public int checkSum;
3062 
3063     public void dontinline_testMethod() {
3064         long a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};                // scalar replaced
3065         Vector10 v = new Vector10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);  // scalar replaced
3066         long l = inlinedCallForcedToReturn();
3067         lResult = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9]
3068                + v.i0 + v.i1 + v.i2 + v.i3 + v.i4 + v.i5 + v.i6 + v.i7 + v.i8 + v.i9 + l;
3069     }
3070 
3071     public long inlinedCallForcedToReturn() {                      // forced to return 43
3072         long cs = checkSum;
3073         dontinline_consumeAllMemory();

3094 
3095     @Override
3096     public void setUp() {
3097         super.setUp();
3098         testMethodDepth = 2;
3099         loopCount = 3;
3100     }
3101 
3102     public void warmupDone() {
3103         super.warmupDone();
3104         msg("enter 'endless' loop by setting loopCount = Long.MAX_VALUE");
3105         loopCount = Long.MAX_VALUE; // endless loop
3106     }
3107 
3108     @Override
3109     public boolean shouldSkip() {
3110         // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
3111         // And Graal currently doesn't support Force Early Return
3112         return super.shouldSkip() ||
3113                 !EliminateAllocations ||
3114                 // With ZGC the OOME is not always thrown as expected
3115                 ZGCIsSelected ||

3116                 DeoptimizeObjectsALot ||
3117                 UseJVMCICompiler;
3118     }
3119 }
3120 
3121 /////////////////////////////////////////////////////////////////////////////
3122 //
3123 // Get Instances of ReferenceType
3124 //
3125 /////////////////////////////////////////////////////////////////////////////
3126 
3127 /**
3128  * Check if instances of a type are found even if they are scalar replaced.  To stress the
3129  * implementation a little more, the instances should be retrieved while the target is running.
3130  */
3131 class EAGetInstancesOfReferenceType extends EATestCaseBaseDebugger {
3132 
3133     public void runTestCase() throws Exception {
3134         printStack(env.targetMainThread);
3135         ReferenceType cls = ((ClassObjectReference)getField(testCase, "cls")).reflectedType();

 299 
 300     EATests(String args[]) {
 301         super(args);
 302     }
 303 
 304     public static void main(String[] args) throws Exception {
 305         if (EATestCaseBaseShared.RUN_ONLY_TEST_CASE != null) {
 306             args = Arrays.copyOf(args, args.length + 1);
 307             args[args.length - 1] = "-D" + EATestCaseBaseShared.RUN_ONLY_TEST_CASE_PROPERTY + "=" + EATestCaseBaseShared.RUN_ONLY_TEST_CASE;
 308         }
 309         new EATests(args).startTests();
 310     }
 311 
 312     public static class TargetVMOptions {
 313 
 314         public final boolean UseJVMCICompiler;
 315         public final boolean EliminateAllocations;
 316         public final boolean DeoptimizeObjectsALot;
 317         public final boolean DoEscapeAnalysis;
 318         public final boolean ZGCIsSelected;
 319         public final boolean ShenandoahGCIsSelected;
 320         public final boolean StressReflectiveCode;
 321 
 322         public TargetVMOptions(EATests env, ClassType testCaseBaseTargetClass) {
 323             Value val;
 324             val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("DoEscapeAnalysis"));
 325             DoEscapeAnalysis = ((PrimitiveValue) val).booleanValue();
 326             // Escape analysis is a prerequisite for scalar replacement (EliminateAllocations)
 327             val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("EliminateAllocations"));
 328             EliminateAllocations = DoEscapeAnalysis && ((PrimitiveValue) val).booleanValue();
 329             val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("DeoptimizeObjectsALot"));
 330             DeoptimizeObjectsALot = ((PrimitiveValue) val).booleanValue();
 331             val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("UseJVMCICompiler"));
 332             UseJVMCICompiler = ((PrimitiveValue) val).booleanValue();
 333             val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("ZGCIsSelected"));
 334             ZGCIsSelected = ((PrimitiveValue) val).booleanValue();
 335             val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("ShenandoahGCIsSelected"));
 336             ShenandoahGCIsSelected = ((PrimitiveValue) val).booleanValue();
 337             val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("StressReflectiveCode"));
 338             StressReflectiveCode = ((PrimitiveValue) val).booleanValue();
 339         }
 340 
 341     }
 342 
 343     // Execute known test cases
 344     protected void runTests() throws Exception {
 345         String targetProgName = EATestsTarget.class.getName();
 346         msg("starting to main method in class " +  targetProgName);
 347         startToMain(targetProgName);
 348         msg("resuming to EATestCaseBaseTarget.staticSetUpDone()V");
 349         targetMainThread = resumeTo("EATestCaseBaseTarget", "staticSetUpDone", "()V").thread();
 350         Location loc = targetMainThread.frame(0).location();
 351         Asserts.assertEQ("staticSetUpDone", loc.method().name());
 352 
 353         targetVMOptions = new TargetVMOptions(this, (ClassType) loc.declaringType());
 354 
 355         // Materializing test cases, i.e. reallocating objects on the heap
 356         new EAMaterializeLocalVariableUponGet()                                       .run(this);

 806      * Used in {@link EATestCaseBaseDebugger#terminateEndlessLoop()} to signal target to leave the endless loop.
 807      */
 808     public volatile boolean doLoop;
 809 
 810     public long checkSum;
 811 
 812     public static final String TESTMETHOD_DEFAULT_NAME = "dontinline_testMethod";
 813 
 814     public static final WhiteBox WB = WhiteBox.getWhiteBox();
 815 
 816     public static boolean unbox(Boolean value, boolean dflt) {
 817         return value == null ? dflt : value;
 818     }
 819 
 820     // Some of the fields are only read by the debugger
 821     public static final boolean UseJVMCICompiler = unbox(WB.getBooleanVMFlag("UseJVMCICompiler"), false);
 822     public static final boolean DoEscapeAnalysis = unbox(WB.getBooleanVMFlag("DoEscapeAnalysis"), UseJVMCICompiler);
 823     public static final boolean EliminateAllocations = unbox(WB.getBooleanVMFlag("EliminateAllocations"), UseJVMCICompiler);
 824     public static final boolean DeoptimizeObjectsALot = WB.getBooleanVMFlag("DeoptimizeObjectsALot");
 825     public static final boolean ZGCIsSelected = GC.Z.isSelected();
 826     public static final boolean ShenandoahGCIsSelected = GC.Shenandoah.isSelected();
 827     public static final boolean StressReflectiveCode = unbox(WB.getBooleanVMFlag("StressReflectiveCode"), false);
 828 
 829     public String testMethodName;
 830     public int testMethodDepth;
 831 
 832     // Results produced by dontinline_testMethod()
 833     public int  iResult;
 834     public long lResult;
 835     public float  fResult;
 836     public double dResult;
 837 
 838 
 839     public boolean warmupDone;
 840 
 841     // an object with an inflated monitor
 842     public static XYVal inflatedLock;
 843     public static Thread  inflatorThread;
 844     public static boolean inflatedLockIsPermanentlyInflated;
 845 
 846     public static int    NOT_CONST_1I = 1;

2671             thread.popFrames(thread.frame(1));
2672         } catch (VMOutOfMemoryException oom) {
2673             // as expected
2674             msg("cought OOM");
2675             coughtOom  = true;
2676         }
2677         freeAllMemory();
2678         // We succeeded to pop just one frame. When we continue, we will call dontinline_brkpt() again.
2679         Asserts.assertTrue(coughtOom, "PopFrame should have triggered an OOM exception in target");
2680         String expectedTopFrame = "dontinline_consume_all_memory_brkpt";
2681         Asserts.assertEQ(expectedTopFrame, thread.frame(0).location().method().name());
2682         printStack(thread);
2683     }
2684 
2685     @Override
2686     public boolean shouldSkip() {
2687         // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
2688         // And Graal currently doesn't provide all information about non-escaping objects in debug info
2689         return super.shouldSkip() ||
2690                 !env.targetVMOptions.EliminateAllocations ||
2691                 // With ZGC or Shenandoah the OOME is not always thrown as expected
2692                 env.targetVMOptions.ZGCIsSelected ||
2693                 env.targetVMOptions.ShenandoahGCIsSelected ||
2694                 env.targetVMOptions.DeoptimizeObjectsALot ||
2695                 env.targetVMOptions.UseJVMCICompiler;
2696     }
2697 }
2698 
2699 class EAPopFrameNotInlinedReallocFailureTarget extends EATestCaseBaseTarget {
2700 
2701     public boolean doneAlready;
2702 
2703     public void dontinline_testMethod() {
2704         long a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};                // scalar replaced
2705         Vector10 v = new Vector10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);  // scalar replaced
2706         dontinline_consume_all_memory_brkpt();
2707         lResult = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9]
2708                + v.i0 + v.i1 + v.i2 + v.i3 + v.i4 + v.i5 + v.i6 + v.i7 + v.i8 + v.i9;
2709     }
2710 
2711     public void dontinline_consume_all_memory_brkpt() {
2712         if (warmupDone && !doneAlready) {
2713             doneAlready = true;

2717     }
2718 
2719     @Override
2720     public void setUp() {
2721         super.setUp();
2722         testMethodDepth = 2;
2723     }
2724 
2725     @Override
2726     public long getExpectedLResult() {
2727         long n = 10;
2728         return 2*n*(n+1)/2;
2729     }
2730 
2731     @Override
2732     public boolean shouldSkip() {
2733         // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
2734         // And Graal currently doesn't provide all information about non-escaping objects in debug info
2735         return super.shouldSkip() ||
2736                 !EliminateAllocations ||
2737                 // With ZGC or Shenandoah the OOME is not always thrown as expected
2738                 ZGCIsSelected ||
2739                 ShenandoahGCIsSelected ||
2740                 DeoptimizeObjectsALot ||
2741                 UseJVMCICompiler;
2742     }
2743 }
2744 
2745 /////////////////////////////////////////////////////////////////////////////
2746 
2747 /**
2748  * Pop inlined top frame dropping into method with scalar replaced opjects.
2749  */
2750 class EAPopInlinedMethodWithScalarReplacedObjectsReallocFailure extends EATestCaseBaseDebugger {
2751 
2752     public void runTestCase() throws Exception {
2753         ThreadReference thread = env.targetMainThread;
2754         env.vm().resume();
2755         waitUntilTargetHasEnteredEndlessLoop();
2756 
2757         thread.suspend();
2758         printStack(thread);
2759         // frame[0]: EAPopInlinedMethodWithScalarReplacedObjectsReallocFailureTarget.inlinedCallForcedToReturn()

2771             coughtOom = true;
2772         }
2773         printStack(thread);
2774         // frame[0]: EAPopInlinedMethodWithScalarReplacedObjectsReallocFailureTarget.inlinedCallForcedToReturn()
2775         // frame[1]: EAPopInlinedMethodWithScalarReplacedObjectsReallocFailureTarget.dontinline_testMethod()
2776         // frame[2]: EATestCaseBaseTarget.run()
2777 
2778         freeAllMemory();
2779         setField(testCase, "loopCount", env.vm().mirrorOf(0)); // terminate loop
2780         Asserts.assertTrue(coughtOom, "PopFrame should have triggered an OOM exception in target");
2781         String expectedTopFrame = "inlinedCallForcedToReturn";
2782         Asserts.assertEQ(expectedTopFrame, thread.frame(0).location().method().name());
2783     }
2784 
2785     @Override
2786     public boolean shouldSkip() {
2787         // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
2788         // And Graal currently doesn't provide all information about non-escaping objects in debug info
2789         return super.shouldSkip() ||
2790                 !env.targetVMOptions.EliminateAllocations ||
2791                 // With ZGC or Shenandoah the OOME is not always thrown as expected
2792                 env.targetVMOptions.ZGCIsSelected ||
2793                 env.targetVMOptions.ShenandoahGCIsSelected ||
2794                 env.targetVMOptions.DeoptimizeObjectsALot ||
2795                 env.targetVMOptions.UseJVMCICompiler;
2796     }
2797 }
2798 
2799 class EAPopInlinedMethodWithScalarReplacedObjectsReallocFailureTarget extends EATestCaseBaseTarget {
2800 
2801     public long checkSum;
2802 
2803     public void dontinline_testMethod() {
2804         long a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};                // scalar replaced
2805         Vector10 v = new Vector10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);  // scalar replaced
2806         long l = inlinedCallForcedToReturn();
2807         lResult = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9]
2808                + v.i0 + v.i1 + v.i2 + v.i3 + v.i4 + v.i5 + v.i6 + v.i7 + v.i8 + v.i9;
2809     }
2810 
2811     public long inlinedCallForcedToReturn() {
2812         long cs = checkSum;
2813         dontinline_consumeAllMemory();

2833     }
2834 
2835     @Override
2836     public void setUp() {
2837         super.setUp();
2838         loopCount = 3;
2839     }
2840 
2841     public void warmupDone() {
2842         super.warmupDone();
2843         msg("enter 'endless' loop by setting loopCount = Long.MAX_VALUE");
2844         loopCount = Long.MAX_VALUE; // endless loop
2845     }
2846 
2847     @Override
2848     public boolean shouldSkip() {
2849         // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
2850         // And Graal currently doesn't provide all information about non-escaping objects in debug info
2851         return super.shouldSkip() ||
2852                 !EliminateAllocations ||
2853                 // With ZGC or Shenandoah the OOME is not always thrown as expected
2854                 ZGCIsSelected ||
2855                 ShenandoahGCIsSelected ||
2856                 DeoptimizeObjectsALot ||
2857                 UseJVMCICompiler;
2858     }
2859 }
2860 
2861 /////////////////////////////////////////////////////////////////////////////
2862 //
2863 // ForceEarlyReturn tests
2864 //
2865 /////////////////////////////////////////////////////////////////////////////
2866 
2867 /**
2868  * ForceEarlyReturn into caller frame with scalar replaced objects.
2869  */
2870 class EAForceEarlyReturnNotInlined extends EATestCaseBaseDebugger {
2871 
2872     public void runTestCase() throws Exception {
2873         BreakpointEvent bpe = resumeTo(TARGET_TESTCASE_BASE_NAME, "dontinline_brkpt", "()V");
2874         ThreadReference thread = bpe.thread();
2875         printStack(thread);

3040             msg("cought OOM");
3041             coughtOom   = true;
3042         }
3043         freeAllMemory();
3044         Asserts.assertTrue(coughtOom, "ForceEarlyReturn should have triggered an OOM exception in target");
3045         printStack(thread);
3046         msg("ForceEarlyReturn(2)");
3047         thread.forceEarlyReturn(env.vm().mirrorOf(43));
3048         msg("Step over instruction to do the forced return");
3049         env.stepOverInstruction(thread);
3050         printStack(thread);
3051         msg("ForceEarlyReturn DONE");
3052     }
3053 
3054     @Override
3055     public boolean shouldSkip() {
3056         // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
3057         // And Graal currently doesn't support Force Early Return
3058         return super.shouldSkip() ||
3059                 !env.targetVMOptions.EliminateAllocations ||
3060                 // With ZGC or Shenandoah the OOME is not always thrown as expected
3061                 env.targetVMOptions.ZGCIsSelected ||
3062                 env.targetVMOptions.ShenandoahGCIsSelected ||
3063                 env.targetVMOptions.DeoptimizeObjectsALot ||
3064                 env.targetVMOptions.UseJVMCICompiler;
3065     }
3066 }
3067 
3068 class EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjectsReallocFailureTarget extends EATestCaseBaseTarget {
3069 
3070     public int checkSum;
3071 
3072     public void dontinline_testMethod() {
3073         long a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};                // scalar replaced
3074         Vector10 v = new Vector10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);  // scalar replaced
3075         long l = inlinedCallForcedToReturn();
3076         lResult = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9]
3077                + v.i0 + v.i1 + v.i2 + v.i3 + v.i4 + v.i5 + v.i6 + v.i7 + v.i8 + v.i9 + l;
3078     }
3079 
3080     public long inlinedCallForcedToReturn() {                      // forced to return 43
3081         long cs = checkSum;
3082         dontinline_consumeAllMemory();

3103 
3104     @Override
3105     public void setUp() {
3106         super.setUp();
3107         testMethodDepth = 2;
3108         loopCount = 3;
3109     }
3110 
3111     public void warmupDone() {
3112         super.warmupDone();
3113         msg("enter 'endless' loop by setting loopCount = Long.MAX_VALUE");
3114         loopCount = Long.MAX_VALUE; // endless loop
3115     }
3116 
3117     @Override
3118     public boolean shouldSkip() {
3119         // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random.
3120         // And Graal currently doesn't support Force Early Return
3121         return super.shouldSkip() ||
3122                 !EliminateAllocations ||
3123                 // With ZGC or Shenandoah the OOME is not always thrown as expected
3124                 ZGCIsSelected ||
3125                 ShenandoahGCIsSelected ||
3126                 DeoptimizeObjectsALot ||
3127                 UseJVMCICompiler;
3128     }
3129 }
3130 
3131 /////////////////////////////////////////////////////////////////////////////
3132 //
3133 // Get Instances of ReferenceType
3134 //
3135 /////////////////////////////////////////////////////////////////////////////
3136 
3137 /**
3138  * Check if instances of a type are found even if they are scalar replaced.  To stress the
3139  * implementation a little more, the instances should be retrieved while the target is running.
3140  */
3141 class EAGetInstancesOfReferenceType extends EATestCaseBaseDebugger {
3142 
3143     public void runTestCase() throws Exception {
3144         printStack(env.targetMainThread);
3145         ReferenceType cls = ((ClassObjectReference)getField(testCase, "cls")).reflectedType();
< prev index next >