Mercurial > hg > truffle
diff test/compiler/whitebox/IsMethodCompilableTest.java @ 9080:b84fd7d73702
8007288: Additional WB API for compiler's testing
Reviewed-by: kvn, vlivanov
author | iignatyev |
---|---|
date | Tue, 09 Apr 2013 09:54:17 -0700 |
parents | 4efac99a998b |
children | 4b2eebe03f93 |
line wrap: on
line diff
--- a/test/compiler/whitebox/IsMethodCompilableTest.java Mon Apr 08 07:40:08 2013 -0700 +++ b/test/compiler/whitebox/IsMethodCompilableTest.java Tue Apr 09 09:54:17 2013 -0700 @@ -45,7 +45,7 @@ public static void main(String[] args) throws Exception { // to prevent inlining #method into #compile() - WHITE_BOX.setDontInlineMethod(METHOD, true); + WHITE_BOX.testSetDontInlineMethod(METHOD, true); new IsMethodCompilableTest().runTest(); } @@ -60,26 +60,47 @@ "Warning: test is not applicable if PerMethodRecompilationCutoff == Inf"); return; } - boolean madeNotCompilable = false; + + // deoptimze 'PerMethodRecompilationCutoff' times and clear state + for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) { + compileAndDeoptimaze(); + } + if (!WHITE_BOX.isMethodCompilable(METHOD)) { + throw new RuntimeException(METHOD + " is not compilable after " + + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations"); + } + WHITE_BOX.clearMethodState(METHOD); - for (long i = 0; i < PER_METHOD_RECOMPILATION_CUTOFF; ++i) { - compile(); - waitBackgroundCompilation(METHOD); - WHITE_BOX.deoptimizeMethod(METHOD); - if (!WHITE_BOX.isMethodCompilable(METHOD)) { - madeNotCompilable = true; - break; - } + // deoptimze 'PerMethodRecompilationCutoff' + 1 times + long i; + for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF + && WHITE_BOX.isMethodCompilable(METHOD); ++i) { + compileAndDeoptimaze(); } - if (!madeNotCompilable) { + if (i != PER_METHOD_RECOMPILATION_CUTOFF) { + throw new RuntimeException(METHOD + " is not compilable after " + + i + " iterations, but must only after " + + PER_METHOD_RECOMPILATION_CUTOFF); + } + if (WHITE_BOX.isMethodCompilable(METHOD)) { throw new RuntimeException(METHOD + " is still compilable after " + PER_METHOD_RECOMPILATION_CUTOFF + " iterations"); } compile(); - if (WHITE_BOX.isMethodCompiled(METHOD)) { - printInfo(METHOD); - throw new RuntimeException( - METHOD + " is not compilable but compiled"); + checkNotCompiled(METHOD); + + WHITE_BOX.clearMethodState(METHOD); + if (!WHITE_BOX.isMethodCompilable(METHOD)) { + throw new RuntimeException(METHOD + + " is compilable after clearMethodState()"); } + compile(); + checkCompiled(METHOD); + } + + private void compileAndDeoptimaze() throws Exception { + compile(); + waitBackgroundCompilation(METHOD); + WHITE_BOX.deoptimizeMethod(METHOD); } }