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:


  44     protected static int COMP_LEVEL_ANY = -1;
  45     /** {@code CompLevel::CompLevel_simple} -- C1 */
  46     protected static int COMP_LEVEL_SIMPLE = 1;
  47     /** {@code CompLevel::CompLevel_full_optimization} -- C2 or Shark */
  48     protected static int COMP_LEVEL_FULL_OPTIMIZATION = 4;
  49 
  50     /** Instance of WhiteBox */
  51     protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
  52     /** Value of {@code -XX:CompileThreshold} */
  53     protected static final int COMPILE_THRESHOLD
  54             = Integer.parseInt(getVMOption("CompileThreshold", "10000"));
  55     /** Value of {@code -XX:BackgroundCompilation} */
  56     protected static final boolean BACKGROUND_COMPILATION
  57             = Boolean.valueOf(getVMOption("BackgroundCompilation", "true"));
  58     /** Value of {@code -XX:TieredCompilation} */
  59     protected static final boolean TIERED_COMPILATION
  60             = Boolean.valueOf(getVMOption("TieredCompilation", "false"));
  61     /** Value of {@code -XX:TieredStopAtLevel} */
  62     protected static final int TIERED_STOP_AT_LEVEL
  63             = Integer.parseInt(getVMOption("TieredStopAtLevel", "0"));



  64 
  65     /**
  66      * Returns value of VM option.
  67      *
  68      * @param name option's name
  69      * @return value of option or {@code null}, if option doesn't exist
  70      * @throws NullPointerException if name is null
  71      */
  72     protected static String getVMOption(String name) {
  73         Objects.requireNonNull(name);
  74         HotSpotDiagnosticMXBean diagnostic
  75                 = ManagementFactoryHelper.getDiagnosticMXBean();
  76         VMOption tmp;
  77         try {
  78             tmp = diagnostic.getVMOption(name);
  79         } catch (IllegalArgumentException e) {
  80             tmp = null;
  81         }
  82         return (tmp == null ? null : tmp.getValue());
  83     }


 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 




  44     protected static int COMP_LEVEL_ANY = -1;
  45     /** {@code CompLevel::CompLevel_simple} -- C1 */
  46     protected static int COMP_LEVEL_SIMPLE = 1;
  47     /** {@code CompLevel::CompLevel_full_optimization} -- C2 or Shark */
  48     protected static int COMP_LEVEL_FULL_OPTIMIZATION = 4;
  49 
  50     /** Instance of WhiteBox */
  51     protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
  52     /** Value of {@code -XX:CompileThreshold} */
  53     protected static final int COMPILE_THRESHOLD
  54             = Integer.parseInt(getVMOption("CompileThreshold", "10000"));
  55     /** Value of {@code -XX:BackgroundCompilation} */
  56     protected static final boolean BACKGROUND_COMPILATION
  57             = Boolean.valueOf(getVMOption("BackgroundCompilation", "true"));
  58     /** Value of {@code -XX:TieredCompilation} */
  59     protected static final boolean TIERED_COMPILATION
  60             = Boolean.valueOf(getVMOption("TieredCompilation", "false"));
  61     /** Value of {@code -XX:TieredStopAtLevel} */
  62     protected static final int TIERED_STOP_AT_LEVEL
  63             = Integer.parseInt(getVMOption("TieredStopAtLevel", "0"));
  64     /** Flag for verbose output, true if {@code -Dverbose} specified */
  65     protected static final boolean IS_VERBOSE
  66             = System.getProperty("verbose") != null;
  67 
  68     /**
  69      * Returns value of VM option.
  70      *
  71      * @param name option's name
  72      * @return value of option or {@code null}, if option doesn't exist
  73      * @throws NullPointerException if name is null
  74      */
  75     protected static String getVMOption(String name) {
  76         Objects.requireNonNull(name);
  77         HotSpotDiagnosticMXBean diagnostic
  78                 = ManagementFactoryHelper.getDiagnosticMXBean();
  79         VMOption tmp;
  80         try {
  81             tmp = diagnostic.getVMOption(name);
  82         } catch (IllegalArgumentException e) {
  83             tmp = null;
  84         }
  85         return (tmp == null ? null : tmp.getValue());
  86     }


 254     }
 255 
 256     /**
 257      * Tries to trigger compilation of {@linkplain #method} by call
 258      * {@linkplain #callable} specified times.
 259      *
 260      * @param count invocation count
 261      * @return accumulated result
 262      */
 263     protected final int compile(int count) {
 264         int result = 0;
 265         Integer tmp;
 266         for (int i = 0; i < count; ++i) {
 267             try {
 268                 tmp = callable.call();
 269             } catch (Exception e) {
 270                 tmp = null;
 271             }
 272             result += tmp == null ? 0 : tmp;
 273         }
 274         if (IS_VERBOSE) {
 275             System.out.println("method was invoked " + count + " times");
 276         }
 277         return result;
 278     }
 279 }
 280 
 281 /**
 282  * Utility structure containing tested method and object to invoke it.
 283  */
 284 enum TestCase {
 285     /** constructor test case */
 286     CONSTRUCTOR_TEST(Helper.CONSTRUCTOR, Helper.CONSTRUCTOR_CALLABLE),
 287     /** method test case */
 288     METOD_TEST(Helper.METHOD, Helper.METHOD_CALLABLE),
 289     /** static method test case */
 290     STATIC_TEST(Helper.STATIC, Helper.STATIC_CALLABLE);
 291 
 292     /** tested method */
 293     final Executable executable;
 294     /** object to invoke {@linkplain #executable} */
 295     final Callable<Integer> callable;
 296 


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