test/compiler/whitebox/IsMethodCompilableTest.java

Print this page




  43         }
  44     }
  45 
  46     public static void main(String[] args) throws Exception {
  47         // to prevent inlining #method into #compile()
  48         WHITE_BOX.setDontInlineMethod(METHOD, true);
  49         new IsMethodCompilableTest().runTest();
  50     }
  51 
  52     protected void test() throws Exception {
  53         if (!WHITE_BOX.isMethodCompilable(METHOD)) {
  54             throw new RuntimeException(METHOD + " must be compilable");
  55         }
  56         System.out.println("PerMethodRecompilationCutoff = "
  57                 + PER_METHOD_RECOMPILATION_CUTOFF);
  58         if (PER_METHOD_RECOMPILATION_CUTOFF == -1) {
  59             System.err.println(
  60                     "Warning: test is not applicable if PerMethodRecompilationCutoff == Inf");
  61             return;
  62         }
  63         boolean madeNotCompilable = false;
  64 
  65         for (long i = 0; i < PER_METHOD_RECOMPILATION_CUTOFF; ++i) {
  66             compile();
  67             waitBackgroundCompilation(METHOD);
  68             WHITE_BOX.deoptimizeMethod(METHOD);
  69             if (!WHITE_BOX.isMethodCompilable(METHOD)) {
  70                 madeNotCompilable = true;
  71                 break;
  72             }












  73         }
  74         if (!madeNotCompilable) {
  75             throw new RuntimeException(METHOD + " is still compilable after "
  76                     + PER_METHOD_RECOMPILATION_CUTOFF + " iterations");
  77         }
  78         compile();
  79         if (WHITE_BOX.isMethodCompiled(METHOD)) {
  80             printInfo(METHOD);
  81             throw new RuntimeException(
  82                     METHOD + " is not compilable but compiled");





  83         }





  84     }
  85 }


  43         }
  44     }
  45 
  46     public static void main(String[] args) throws Exception {
  47         // to prevent inlining #method into #compile()
  48         WHITE_BOX.setDontInlineMethod(METHOD, true);
  49         new IsMethodCompilableTest().runTest();
  50     }
  51 
  52     protected void test() throws Exception {
  53         if (!WHITE_BOX.isMethodCompilable(METHOD)) {
  54             throw new RuntimeException(METHOD + " must be compilable");
  55         }
  56         System.out.println("PerMethodRecompilationCutoff = "
  57                 + PER_METHOD_RECOMPILATION_CUTOFF);
  58         if (PER_METHOD_RECOMPILATION_CUTOFF == -1) {
  59             System.err.println(
  60                     "Warning: test is not applicable if PerMethodRecompilationCutoff == Inf");
  61             return;
  62         }

  63 
  64         // deoptimze 'PerMethodRecompilationCutoff' times and clear state
  65         for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) {
  66             compileAndDeoptimaze();
  67         }
  68         if (!WHITE_BOX.isMethodCompilable(METHOD)) {
  69             throw new RuntimeException(METHOD + " is not compilable after "
  70                     + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations");
  71         }
  72         WHITE_BOX.clearMethodState(METHOD);
  73 
  74         // deoptimze 'PerMethodRecompilationCutoff' + 1 times
  75         long i;
  76         for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF
  77                 && WHITE_BOX.isMethodCompilable(METHOD); ++i) {
  78             compileAndDeoptimaze();
  79         }
  80         if (i != PER_METHOD_RECOMPILATION_CUTOFF) {
  81            throw new RuntimeException(METHOD + " is not compilable after "
  82                    + i + " iterations, but must only after "
  83                    + PER_METHOD_RECOMPILATION_CUTOFF);
  84         }
  85         if (WHITE_BOX.isMethodCompilable(METHOD)) {
  86             throw new RuntimeException(METHOD + " is still compilable after "
  87                     + PER_METHOD_RECOMPILATION_CUTOFF + " iterations");
  88         }
  89         compile();
  90         checkNotCompiled(METHOD);
  91 
  92         WHITE_BOX.clearMethodState(METHOD);
  93         if (!WHITE_BOX.isMethodCompilable(METHOD)) {
  94             throw new RuntimeException(METHOD
  95                     + " is compilable after clearMethodState()");
  96         }
  97         compile();
  98         checkCompiled(METHOD);
  99     }
 100 
 101     private void compileAndDeoptimaze() throws Exception {
 102         compile();
 103         waitBackgroundCompilation(METHOD);
 104         WHITE_BOX.deoptimizeMethod(METHOD);
 105     }
 106 }