test/compiler/compilercontrol/share/actions/CompileAction.java

Print this page




  62         if (first < 4) {
  63             checkCompilation(executable, first, state.isC1Compilable());
  64         }
  65         int last = COMP_LEVELS[COMP_LEVELS.length - 1];
  66         if (last == 4) {
  67             checkCompilation(executable, last, state.isC2Compilable());
  68         }
  69     }
  70 
  71     private static void checkCompilation(Executable executable,
  72                                          int level,
  73                                          boolean expectedCompiled) {
  74         execute(executable);
  75         WHITE_BOX.enqueueMethodForCompilation(executable, level);
  76         Utils.waitForCondition(
  77                 () -> {
  78                     execute(executable);
  79                     return !WHITE_BOX.isMethodQueuedForCompilation(executable);
  80                 }, 100L);
  81         execute(executable);
  82         boolean isCompiled = WHITE_BOX.isMethodCompiled(executable);
  83         Asserts.assertEQ(isCompiled, expectedCompiled,
  84                 String.format("FAILED: method %s compiled: %b, but should: %b"
  85                         + " on required level: %d", executable, isCompiled,
  86                         expectedCompiled, level));
  87     }
  88 
  89     private static void execute(Executable executable) {
  90         Callable<?> callable = getCallableFor(executable);
  91         try {
  92             for (int i = 0; i < EXEC_AMOUNT; i++) {
  93                 callable.call();
  94             }
  95         } catch (Exception e) {
  96             throw new Error("Got exception during execution", e);
  97         }
  98     }
  99 
 100     private static Callable<?> getCallableFor(Executable executable) {
 101         for (Pair<Executable, Callable<?>> pair : METHODS) {
 102             if (pair.first == executable) {
 103                 return pair.second;
 104             }
 105         }


  62         if (first < 4) {
  63             checkCompilation(executable, first, state.isC1Compilable());
  64         }
  65         int last = COMP_LEVELS[COMP_LEVELS.length - 1];
  66         if (last == 4) {
  67             checkCompilation(executable, last, state.isC2Compilable());
  68         }
  69     }
  70 
  71     private static void checkCompilation(Executable executable,
  72                                          int level,
  73                                          boolean expectedCompiled) {
  74         execute(executable);
  75         WHITE_BOX.enqueueMethodForCompilation(executable, level);
  76         Utils.waitForCondition(
  77                 () -> {
  78                     execute(executable);
  79                     return !WHITE_BOX.isMethodQueuedForCompilation(executable);
  80                 }, 100L);
  81         execute(executable);
  82         boolean isCompilable = WHITE_BOX.isMethodCompilable(executable, level);
  83         Asserts.assertEQ(isCompilable, expectedCompiled,
  84                 String.format("FAILED: method %s compilable: %b, but should: %b"
  85                         + " on required level: %d", executable, isCompilable,
  86                         expectedCompiled, level));
  87     }
  88 
  89     private static void execute(Executable executable) {
  90         Callable<?> callable = getCallableFor(executable);
  91         try {
  92             for (int i = 0; i < EXEC_AMOUNT; i++) {
  93                 callable.call();
  94             }
  95         } catch (Exception e) {
  96             throw new Error("Got exception during execution", e);
  97         }
  98     }
  99 
 100     private static Callable<?> getCallableFor(Executable executable) {
 101         for (Pair<Executable, Callable<?>> pair : METHODS) {
 102             if (pair.first == executable) {
 103                 return pair.second;
 104             }
 105         }