Mercurial > hg > truffle
comparison test/compiler/whitebox/IsMethodCompilableTest.java @ 18041:52b4284cb496
Merge with jdk8u20-b26
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 15 Oct 2014 16:02:50 +0200 |
parents | 4ca6dc0799b6 e5d5e7922283 |
children | 7848fc12602b |
comparison
equal
deleted
inserted
replaced
17606:45d7b2c7029d | 18041:52b4284cb496 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
22 */ | 22 */ |
23 | 23 |
24 /* | 24 /* |
25 * @test IsMethodCompilableTest | 25 * @test IsMethodCompilableTest |
26 * @bug 8007270 8006683 8007288 8022832 | 26 * @bug 8007270 8006683 8007288 8022832 |
27 * @library /testlibrary /testlibrary/whitebox | 27 * @library /testlibrary /testlibrary/whitebox /testlibrary/com/oracle/java/testlibrary |
28 * @build IsMethodCompilableTest | 28 * @build IsMethodCompilableTest |
29 * @run main ClassFileInstaller sun.hotspot.WhiteBox | 29 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
30 * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,TestCase$Helper::* IsMethodCompilableTest | 30 * @run main ClassFileInstaller com.oracle.java.testlibrary.Platform |
31 * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:PerMethodRecompilationCutoff=3 -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* IsMethodCompilableTest | |
31 * @summary testing of WB::isMethodCompilable() | 32 * @summary testing of WB::isMethodCompilable() |
32 * @author igor.ignatyev@oracle.com | 33 * @author igor.ignatyev@oracle.com |
33 */ | 34 */ |
35 | |
36 import com.oracle.java.testlibrary.Platform; | |
37 | |
34 public class IsMethodCompilableTest extends CompilerWhiteBoxTest { | 38 public class IsMethodCompilableTest extends CompilerWhiteBoxTest { |
35 /** | 39 /** |
36 * Value of {@code -XX:PerMethodRecompilationCutoff} | 40 * Value of {@code -XX:PerMethodRecompilationCutoff} |
37 */ | 41 */ |
38 protected static final long PER_METHOD_RECOMPILATION_CUTOFF; | 42 protected static final long PER_METHOD_RECOMPILATION_CUTOFF; |
41 long tmp = Long.parseLong( | 45 long tmp = Long.parseLong( |
42 getVMOption("PerMethodRecompilationCutoff", "400")); | 46 getVMOption("PerMethodRecompilationCutoff", "400")); |
43 if (tmp == -1) { | 47 if (tmp == -1) { |
44 PER_METHOD_RECOMPILATION_CUTOFF = -1 /* Inf */; | 48 PER_METHOD_RECOMPILATION_CUTOFF = -1 /* Inf */; |
45 } else { | 49 } else { |
46 PER_METHOD_RECOMPILATION_CUTOFF = 1 + (0xFFFFFFFFL & tmp); | 50 PER_METHOD_RECOMPILATION_CUTOFF = (0xFFFFFFFFL & tmp); |
47 } | 51 } |
48 } | 52 } |
49 | 53 |
50 public static void main(String[] args) throws Exception { | 54 public static void main(String[] args) throws Exception { |
51 for (TestCase test : TestCase.values()) { | 55 CompilerWhiteBoxTest.main(IsMethodCompilableTest::new, args); |
52 new IsMethodCompilableTest(test).runTest(); | |
53 } | |
54 } | 56 } |
55 | 57 |
56 public IsMethodCompilableTest(TestCase testCase) { | 58 private IsMethodCompilableTest(TestCase testCase) { |
57 super(testCase); | 59 super(testCase); |
58 // to prevent inlining of #method | 60 // to prevent inlining of #method |
59 WHITE_BOX.testSetDontInlineMethod(method, true); | 61 WHITE_BOX.testSetDontInlineMethod(method, true); |
60 } | 62 } |
61 | 63 |
62 /** | 64 /** |
63 * Tests {@code WB::isMethodCompilable()} by recompilation of tested method | 65 * Tests {@code WB::isMethodCompilable()} by recompilation of tested method |
64 * 'PerMethodRecompilationCutoff' times and checks compilation status. Also | 66 * 'PerMethodRecompilationCutoff' times and checks compilation status. Also |
65 * checks that WB::clearMethodState() clears no-compilable flags. | 67 * checks that WB::clearMethodState() clears no-compilable flags. Only |
68 * applicable to c2 compiled methods. | |
66 * | 69 * |
67 * @throws Exception if one of the checks fails. | 70 * @throws Exception if one of the checks fails. |
68 */ | 71 */ |
69 @Override | 72 @Override |
70 protected void test() throws Exception { | 73 protected void test() throws Exception { |
71 if (testCase.isOsr && CompilerWhiteBoxTest.MODE.startsWith( | 74 // Only c2 compilations can be disabled through PerMethodRecompilationCutoff |
72 "compiled ")) { | 75 if (!Platform.isServer()) { |
73 System.err.printf("Warning: %s is not applicable in %s%n", | 76 return; |
74 testCase.name(), CompilerWhiteBoxTest.MODE); | 77 } |
78 | |
79 if (skipXcompOSR()) { | |
75 return; | 80 return; |
76 } | 81 } |
77 if (!isCompilable()) { | 82 if (!isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) { |
78 throw new RuntimeException(method + " must be compilable"); | 83 throw new RuntimeException(method + " must be compilable"); |
79 } | 84 } |
80 System.out.println("PerMethodRecompilationCutoff = " | 85 System.out.println("PerMethodRecompilationCutoff = " |
81 + PER_METHOD_RECOMPILATION_CUTOFF); | 86 + PER_METHOD_RECOMPILATION_CUTOFF); |
82 if (PER_METHOD_RECOMPILATION_CUTOFF == -1) { | 87 if (PER_METHOD_RECOMPILATION_CUTOFF == -1) { |
83 System.err.println( | 88 System.err.println( |
84 "Warning: test is not applicable if PerMethodRecompilationCutoff == Inf"); | 89 "Warning: test is not applicable if PerMethodRecompilationCutoff == Inf"); |
85 return; | 90 return; |
86 } | 91 } |
87 | 92 |
88 // deoptimize 'PerMethodRecompilationCutoff' times and clear state | 93 // deoptimize 'PerMethodRecompilationCutoff' times |
89 for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) { | 94 for (long attempts = 0, successes = 0; |
90 compileAndDeoptimize(); | 95 (successes < PER_METHOD_RECOMPILATION_CUTOFF) && |
96 (attempts < PER_METHOD_RECOMPILATION_CUTOFF*2) && | |
97 isCompilable(COMP_LEVEL_FULL_OPTIMIZATION); attempts++) { | |
98 if (compileAndDeoptimize() == COMP_LEVEL_FULL_OPTIMIZATION) { | |
99 successes++; | |
100 } | |
91 } | 101 } |
92 if (!testCase.isOsr && !isCompilable()) { | 102 |
103 if (!testCase.isOsr() && !isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) { | |
93 // in osr test case count of deopt maybe more than iterations | 104 // in osr test case count of deopt maybe more than iterations |
94 throw new RuntimeException(method + " is not compilable after " | 105 throw new RuntimeException(method + " is not compilable after " |
95 + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations"); | 106 + PER_METHOD_RECOMPILATION_CUTOFF + " iterations"); |
96 } | 107 } |
97 WHITE_BOX.clearMethodState(method); | |
98 | 108 |
99 // deoptimize 'PerMethodRecompilationCutoff' + 1 times | 109 // Now compile once more |
100 long i; | 110 compileAndDeoptimize(); |
101 for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF | 111 |
102 && isCompilable(); ++i) { | 112 if (isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) { |
103 compileAndDeoptimize(); | |
104 } | |
105 if (!testCase.isOsr && i != PER_METHOD_RECOMPILATION_CUTOFF) { | |
106 // in osr test case count of deopt maybe more than iterations | |
107 throw new RuntimeException(method + " is not compilable after " | |
108 + i + " iterations, but must only after " | |
109 + PER_METHOD_RECOMPILATION_CUTOFF); | |
110 } | |
111 if (isCompilable()) { | |
112 throw new RuntimeException(method + " is still compilable after " | 113 throw new RuntimeException(method + " is still compilable after " |
113 + PER_METHOD_RECOMPILATION_CUTOFF + " iterations"); | 114 + PER_METHOD_RECOMPILATION_CUTOFF + " iterations"); |
114 } | 115 } |
116 checkNotCompiled(); | |
115 compile(); | 117 compile(); |
116 checkNotCompiled(); | 118 waitBackgroundCompilation(); |
119 checkNotCompiled(COMP_LEVEL_FULL_OPTIMIZATION); | |
117 | 120 |
118 // WB.clearMethodState() must reset no-compilable flags | 121 // WB.clearMethodState() must reset no-compilable flags |
119 WHITE_BOX.clearMethodState(method); | 122 WHITE_BOX.clearMethodState(method); |
120 if (!isCompilable()) { | 123 if (!isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) { |
121 throw new RuntimeException(method | 124 throw new RuntimeException(method |
122 + " is not compilable after clearMethodState()"); | 125 + " is not compilable after clearMethodState()"); |
123 } | 126 } |
124 compile(); | 127 compile(); |
125 checkCompiled(); | 128 checkCompiled(); |
126 } | 129 } |
127 | 130 |
128 private void compileAndDeoptimize() throws Exception { | 131 private int compileAndDeoptimize() throws Exception { |
129 compile(); | 132 compile(); |
130 waitBackgroundCompilation(); | 133 waitBackgroundCompilation(); |
134 int compLevel = getCompLevel(); | |
131 deoptimize(); | 135 deoptimize(); |
136 return compLevel; | |
132 } | 137 } |
133 } | 138 } |