Mercurial > hg > graal-compiler
comparison test/compiler/whitebox/IsMethodCompilableTest.java @ 10113:4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
Reviewed-by: kvn, vlivanov
author | iignatyev |
---|---|
date | Tue, 16 Apr 2013 10:04:01 -0700 |
parents | b84fd7d73702 |
children | 11237ee74aae |
comparison
equal
deleted
inserted
replaced
10112:c89eab0b6b30 | 10113:4b2eebe03f93 |
---|---|
26 * @bug 8007270 | 26 * @bug 8007270 |
27 * @library /testlibrary /testlibrary/whitebox | 27 * @library /testlibrary /testlibrary/whitebox |
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=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI IsMethodCompilableTest | 30 * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI IsMethodCompilableTest |
31 * @summary testing of WB::isMethodCompilable() | |
31 * @author igor.ignatyev@oracle.com | 32 * @author igor.ignatyev@oracle.com |
32 */ | 33 */ |
33 public class IsMethodCompilableTest extends CompilerWhiteBoxTest { | 34 public class IsMethodCompilableTest extends CompilerWhiteBoxTest { |
35 /** | |
36 * Value of {@code -XX:PerMethodRecompilationCutoff} | |
37 */ | |
34 protected static final long PER_METHOD_RECOMPILATION_CUTOFF; | 38 protected static final long PER_METHOD_RECOMPILATION_CUTOFF; |
35 | 39 |
36 static { | 40 static { |
37 long tmp = Long.parseLong( | 41 long tmp = Long.parseLong( |
38 getVMOption("PerMethodRecompilationCutoff", "400")); | 42 getVMOption("PerMethodRecompilationCutoff", "400")); |
42 PER_METHOD_RECOMPILATION_CUTOFF = 1 + (0xFFFFFFFFL & tmp); | 46 PER_METHOD_RECOMPILATION_CUTOFF = 1 + (0xFFFFFFFFL & tmp); |
43 } | 47 } |
44 } | 48 } |
45 | 49 |
46 public static void main(String[] args) throws Exception { | 50 public static void main(String[] args) throws Exception { |
47 // to prevent inlining #method into #compile() | 51 for (TestCase test : TestCase.values()) { |
48 WHITE_BOX.testSetDontInlineMethod(METHOD, true); | 52 new IsMethodCompilableTest(test).runTest(); |
49 new IsMethodCompilableTest().runTest(); | 53 } |
50 } | 54 } |
51 | 55 |
56 public IsMethodCompilableTest(TestCase testCase) { | |
57 super(testCase); | |
58 // to prevent inlining of #method | |
59 WHITE_BOX.testSetDontInlineMethod(method, true); | |
60 } | |
61 | |
62 /** | |
63 * Tests {@code WB::isMethodCompilable()} by recompilation of tested method | |
64 * 'PerMethodRecompilationCutoff' times and checks compilation status. Also | |
65 * checks that WB::clearMethodState() clears no-compilable flags. | |
66 * | |
67 * @throws Exception if one of the checks fails. | |
68 */ | |
69 @Override | |
52 protected void test() throws Exception { | 70 protected void test() throws Exception { |
53 if (!WHITE_BOX.isMethodCompilable(METHOD)) { | 71 if (!WHITE_BOX.isMethodCompilable(method)) { |
54 throw new RuntimeException(METHOD + " must be compilable"); | 72 throw new RuntimeException(method + " must be compilable"); |
55 } | 73 } |
56 System.out.println("PerMethodRecompilationCutoff = " | 74 System.out.println("PerMethodRecompilationCutoff = " |
57 + PER_METHOD_RECOMPILATION_CUTOFF); | 75 + PER_METHOD_RECOMPILATION_CUTOFF); |
58 if (PER_METHOD_RECOMPILATION_CUTOFF == -1) { | 76 if (PER_METHOD_RECOMPILATION_CUTOFF == -1) { |
59 System.err.println( | 77 System.err.println( |
60 "Warning: test is not applicable if PerMethodRecompilationCutoff == Inf"); | 78 "Warning: test is not applicable if PerMethodRecompilationCutoff == Inf"); |
61 return; | 79 return; |
62 } | 80 } |
63 | 81 |
64 // deoptimze 'PerMethodRecompilationCutoff' times and clear state | 82 // deoptimize 'PerMethodRecompilationCutoff' times and clear state |
65 for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) { | 83 for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) { |
66 compileAndDeoptimaze(); | 84 compileAndDeoptimize(); |
67 } | 85 } |
68 if (!WHITE_BOX.isMethodCompilable(METHOD)) { | 86 if (!WHITE_BOX.isMethodCompilable(method)) { |
69 throw new RuntimeException(METHOD + " is not compilable after " | 87 throw new RuntimeException(method + " is not compilable after " |
70 + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations"); | 88 + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations"); |
71 } | 89 } |
72 WHITE_BOX.clearMethodState(METHOD); | 90 WHITE_BOX.clearMethodState(method); |
73 | 91 |
74 // deoptimze 'PerMethodRecompilationCutoff' + 1 times | 92 // deoptimize 'PerMethodRecompilationCutoff' + 1 times |
75 long i; | 93 long i; |
76 for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF | 94 for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF |
77 && WHITE_BOX.isMethodCompilable(METHOD); ++i) { | 95 && WHITE_BOX.isMethodCompilable(method); ++i) { |
78 compileAndDeoptimaze(); | 96 compileAndDeoptimize(); |
79 } | 97 } |
80 if (i != PER_METHOD_RECOMPILATION_CUTOFF) { | 98 if (i != PER_METHOD_RECOMPILATION_CUTOFF) { |
81 throw new RuntimeException(METHOD + " is not compilable after " | 99 throw new RuntimeException(method + " is not compilable after " |
82 + i + " iterations, but must only after " | 100 + i + " iterations, but must only after " |
83 + PER_METHOD_RECOMPILATION_CUTOFF); | 101 + PER_METHOD_RECOMPILATION_CUTOFF); |
84 } | 102 } |
85 if (WHITE_BOX.isMethodCompilable(METHOD)) { | 103 if (WHITE_BOX.isMethodCompilable(method)) { |
86 throw new RuntimeException(METHOD + " is still compilable after " | 104 throw new RuntimeException(method + " is still compilable after " |
87 + PER_METHOD_RECOMPILATION_CUTOFF + " iterations"); | 105 + PER_METHOD_RECOMPILATION_CUTOFF + " iterations"); |
88 } | 106 } |
89 compile(); | 107 compile(); |
90 checkNotCompiled(METHOD); | 108 checkNotCompiled(); |
91 | 109 |
92 WHITE_BOX.clearMethodState(METHOD); | 110 // WB.clearMethodState() must reset no-compilable flags |
93 if (!WHITE_BOX.isMethodCompilable(METHOD)) { | 111 WHITE_BOX.clearMethodState(method); |
94 throw new RuntimeException(METHOD | 112 if (!WHITE_BOX.isMethodCompilable(method)) { |
95 + " is compilable after clearMethodState()"); | 113 throw new RuntimeException(method |
114 + " is not compilable after clearMethodState()"); | |
96 } | 115 } |
97 compile(); | 116 compile(); |
98 checkCompiled(METHOD); | 117 checkCompiled(); |
99 } | 118 } |
100 | 119 |
101 private void compileAndDeoptimaze() throws Exception { | 120 private void compileAndDeoptimize() throws Exception { |
102 compile(); | 121 compile(); |
103 waitBackgroundCompilation(METHOD); | 122 waitBackgroundCompilation(); |
104 WHITE_BOX.deoptimizeMethod(METHOD); | 123 WHITE_BOX.deoptimizeMethod(method); |
105 } | 124 } |
106 } | 125 } |