test/compiler/whitebox/CompilerWhiteBoxTest.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8019915 Sdiff test/compiler/whitebox

test/compiler/whitebox/CompilerWhiteBoxTest.java

Print this page
rev 4963 : 8019915: whitebox testClearMethodStateTest fails with tiered on sparc
Reviewed-by:


 241 
 242     /**
 243      * Tries to trigger compilation of {@linkplain #method} by call
 244      * {@linkplain #callable} enough times.
 245      *
 246      * @return accumulated result
 247      * @see #compile(int)
 248      */
 249     protected final int compile() {
 250         return compile(Math.max(COMPILE_THRESHOLD, 150000));
 251     }
 252 
 253     /**
 254      * Tries to trigger compilation of {@linkplain #method} by call
 255      * {@linkplain #callable} specified times.
 256      *
 257      * @param count invocation count
 258      * @return accumulated result
 259      */
 260     protected final int compile(int count) {

 261         int result = 0;
 262         Integer tmp;
 263         for (int i = 0; i < count; ++i) {
 264             try {
 265                 tmp = callable.call();
 266             } catch (Exception e) {
 267                 tmp = null;
 268             }
 269             result += tmp == null ? 0 : tmp;
 270         }
 271         System.out.println("method was invoked " + count + " times");
 272         return result;
 273     }



















 274 }
 275 
 276 /**
 277  * Utility structure containing tested method and object to invoke it.
 278  */
 279 enum TestCase {
 280     /** constructor test case */
 281     CONSTRUCTOR_TEST(Helper.CONSTRUCTOR, Helper.CONSTRUCTOR_CALLABLE),
 282     /** method test case */
 283     METOD_TEST(Helper.METHOD, Helper.METHOD_CALLABLE),
 284     /** static method test case */
 285     STATIC_TEST(Helper.STATIC, Helper.STATIC_CALLABLE);
 286 
 287     /** tested method */
 288     final Executable executable;
 289     /** object to invoke {@linkplain #executable} */
 290     final Callable<Integer> callable;
 291 
 292     private TestCase(Executable executable, Callable<Integer> callable) {
 293         this.executable = executable;




 241 
 242     /**
 243      * Tries to trigger compilation of {@linkplain #method} by call
 244      * {@linkplain #callable} enough times.
 245      *
 246      * @return accumulated result
 247      * @see #compile(int)
 248      */
 249     protected final int compile() {
 250         return compile(Math.max(COMPILE_THRESHOLD, 150000));
 251     }
 252 
 253     /**
 254      * Tries to trigger compilation of {@linkplain #method} by call
 255      * {@linkplain #callable} specified times.
 256      *
 257      * @param count invocation count
 258      * @return accumulated result
 259      */
 260     protected final int compile(int count) {
 261         waitEmptyQueue();
 262         int result = 0;
 263         Integer tmp;
 264         for (int i = 0; i < count; ++i) {
 265             try {
 266                 tmp = callable.call();
 267             } catch (Exception e) {
 268                 tmp = null;
 269             }
 270             result += tmp == null ? 0 : tmp;
 271         }
 272         System.out.println("method was invoked " + count + " times");
 273         return result;
 274     }
 275 
 276     /**
 277      * Waits for completion of all background compilations.
 278      */
 279     protected final void waitEmptyQueue() {
 280         int size;
 281         final Object obj = new Object();
 282         while ((size = WHITE_BOX.getCompileQueuesSize()) != 0) {
 283             System.out.printf("Compiler queue size is %d, waiting...%n", size);
 284             synchronized (obj) {
 285                 try {
 286                     obj.wait(1000);
 287                 } catch (InterruptedException e) {
 288                     Thread.currentThread().interrupt();
 289                 }
 290             }
 291         }
 292     }
 293 
 294 }
 295 
 296 /**
 297  * Utility structure containing tested method and object to invoke it.
 298  */
 299 enum TestCase {
 300     /** constructor test case */
 301     CONSTRUCTOR_TEST(Helper.CONSTRUCTOR, Helper.CONSTRUCTOR_CALLABLE),
 302     /** method test case */
 303     METOD_TEST(Helper.METHOD, Helper.METHOD_CALLABLE),
 304     /** static method test case */
 305     STATIC_TEST(Helper.STATIC, Helper.STATIC_CALLABLE);
 306 
 307     /** tested method */
 308     final Executable executable;
 309     /** object to invoke {@linkplain #executable} */
 310     final Callable<Integer> callable;
 311 
 312     private TestCase(Executable executable, Callable<Integer> callable) {
 313         this.executable = executable;


test/compiler/whitebox/CompilerWhiteBoxTest.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File