36 37 @Test 38 public void testOSR01() { 39 try { 40 testOSR(getInitialOptions(), "testReduceLoop"); 41 } catch (Throwable t) { 42 Assert.assertEquals("OSR compilation without OSR entry loop.", t.getMessage()); 43 } 44 } 45 46 @Test 47 public void testOSR02() { 48 testOSR(getInitialOptions(), "testSequentialLoop"); 49 } 50 51 @Test 52 public void testOSR03() { 53 testOSR(getInitialOptions(), "testNonReduceLoop"); 54 } 55 56 static int limit = 10000; 57 58 public static int sideEffect; 59 60 public static ReturnValue testReduceLoop() { 61 for (int i = 0; i < limit * limit; i++) { 62 GraalDirectives.blackhole(i); 63 if (GraalDirectives.inCompiledCode()) { 64 return ReturnValue.SUCCESS; 65 } 66 } 67 return ReturnValue.FAILURE; 68 } 69 70 public static ReturnValue testSequentialLoop() { 71 ReturnValue ret = ReturnValue.FAILURE; 72 for (int i = 1; i < limit * limit; i++) { 73 GraalDirectives.blackhole(i); 74 if (i % 7 == 0) { 75 ret = ReturnValue.SUCCESS; 82 for (int i = 1; i < limit * limit; i++) { 83 GraalDirectives.blackhole(i); 84 if (i % 33 == 0) { 85 ret = ReturnValue.SUCCESS; 86 } 87 } 88 GraalDirectives.controlFlowAnchor(); 89 return ret; 90 } 91 92 public static ReturnValue testNonReduceLoop() { 93 ReturnValue ret = ReturnValue.FAILURE; 94 for (int i = 0; i < limit * limit; i++) { 95 GraalDirectives.blackhole(i); 96 if (i % 33 == 0) { 97 ret = ReturnValue.SUCCESS; 98 } 99 } 100 GraalDirectives.controlFlowAnchor(); 101 return ret; 102 } 103 } | 36 37 @Test 38 public void testOSR01() { 39 try { 40 testOSR(getInitialOptions(), "testReduceLoop"); 41 } catch (Throwable t) { 42 Assert.assertEquals("OSR compilation without OSR entry loop.", t.getMessage()); 43 } 44 } 45 46 @Test 47 public void testOSR02() { 48 testOSR(getInitialOptions(), "testSequentialLoop"); 49 } 50 51 @Test 52 public void testOSR03() { 53 testOSR(getInitialOptions(), "testNonReduceLoop"); 54 } 55 56 @Test 57 public void testOSR04() { 58 testOSR(getInitialOptions(), "testDeoptAfterCountedLoop"); 59 } 60 61 static int limit = 10000; 62 63 public static int sideEffect; 64 65 public static ReturnValue testReduceLoop() { 66 for (int i = 0; i < limit * limit; i++) { 67 GraalDirectives.blackhole(i); 68 if (GraalDirectives.inCompiledCode()) { 69 return ReturnValue.SUCCESS; 70 } 71 } 72 return ReturnValue.FAILURE; 73 } 74 75 public static ReturnValue testSequentialLoop() { 76 ReturnValue ret = ReturnValue.FAILURE; 77 for (int i = 1; i < limit * limit; i++) { 78 GraalDirectives.blackhole(i); 79 if (i % 7 == 0) { 80 ret = ReturnValue.SUCCESS; 87 for (int i = 1; i < limit * limit; i++) { 88 GraalDirectives.blackhole(i); 89 if (i % 33 == 0) { 90 ret = ReturnValue.SUCCESS; 91 } 92 } 93 GraalDirectives.controlFlowAnchor(); 94 return ret; 95 } 96 97 public static ReturnValue testNonReduceLoop() { 98 ReturnValue ret = ReturnValue.FAILURE; 99 for (int i = 0; i < limit * limit; i++) { 100 GraalDirectives.blackhole(i); 101 if (i % 33 == 0) { 102 ret = ReturnValue.SUCCESS; 103 } 104 } 105 GraalDirectives.controlFlowAnchor(); 106 return ret; 107 } 108 109 public static ReturnValue testDeoptAfterCountedLoop() { 110 long ret = 0; 111 for (int i = 0; GraalDirectives.injectBranchProbability(1, i < limit * limit); i++) { 112 GraalDirectives.blackhole(i); 113 ret = GraalDirectives.opaque(i); 114 } 115 GraalDirectives.controlFlowAnchor(); 116 return ret + 1 == limit * limit ? ReturnValue.SUCCESS : ReturnValue.FAILURE; 117 } 118 } |