< prev index next >

test/testlibrary/ctw/src/sun/hotspot/tools/ctw/Compiler.java

Print this page




  51     }
  52 
  53     /**
  54      * Compiles all methods and constructors.
  55      *
  56      * @param aClass class to compile
  57      * @param id an id of the class
  58      * @param executor executor used for compile task invocation
  59      * @throws NullPointerException if {@code class} or {@code executor}
  60      *                              is {@code null}
  61      */
  62     public static void compileClass(Class<?> aClass, long id, Executor executor) {
  63         Objects.requireNonNull(aClass);
  64         Objects.requireNonNull(executor);
  65         try {
  66             ConstantPool constantPool = SharedSecrets.getJavaLangAccess().
  67                     getConstantPool(aClass);
  68             if (Utils.COMPILE_THE_WORLD_PRELOAD_CLASSES) {
  69                 preloadClasses(aClass.getName(), id, constantPool);
  70             }





  71             long methodCount = 0;
  72             for (Executable e : aClass.getDeclaredConstructors()) {
  73                 ++methodCount;
  74                 executor.execute(new CompileMethodCommand(id, e));
  75             }
  76             for (Executable e : aClass.getDeclaredMethods()) {
  77                 ++methodCount;
  78                 executor.execute(new CompileMethodCommand(id, e));
  79             }
  80             METHOD_COUNT.addAndGet(methodCount);
  81 
  82             if (Utils.DEOPTIMIZE_ALL_CLASSES_RATE > 0
  83                     && (id % Utils.DEOPTIMIZE_ALL_CLASSES_RATE == 0)) {
  84                 WHITE_BOX.deoptimizeAll();
  85             }
  86         } catch (Throwable t) {
  87             CompileTheWorld.OUT.printf("[%d]\t%s\tskipping %s%n", id, aClass.getName(), t);
  88             t.printStackTrace();
  89         }
  90     }




  51     }
  52 
  53     /**
  54      * Compiles all methods and constructors.
  55      *
  56      * @param aClass class to compile
  57      * @param id an id of the class
  58      * @param executor executor used for compile task invocation
  59      * @throws NullPointerException if {@code class} or {@code executor}
  60      *                              is {@code null}
  61      */
  62     public static void compileClass(Class<?> aClass, long id, Executor executor) {
  63         Objects.requireNonNull(aClass);
  64         Objects.requireNonNull(executor);
  65         try {
  66             ConstantPool constantPool = SharedSecrets.getJavaLangAccess().
  67                     getConstantPool(aClass);
  68             if (Utils.COMPILE_THE_WORLD_PRELOAD_CLASSES) {
  69                 preloadClasses(aClass.getName(), id, constantPool);
  70             }
  71             int startLevel = Utils.INITIAL_COMP_LEVEL;
  72             int endLevel = Utils.TIERED_COMPILATION ? Utils.TIERED_STOP_AT_LEVEL : startLevel;
  73             for (int i = startLevel; i <= endLevel; ++i) {
  74                 WHITE_BOX.enqueueInitializerForCompilation(aClass, i);
  75             }
  76             long methodCount = 0;
  77             for (Executable e : aClass.getDeclaredConstructors()) {
  78                 ++methodCount;
  79                 executor.execute(new CompileMethodCommand(id, e));
  80             }
  81             for (Executable e : aClass.getDeclaredMethods()) {
  82                 ++methodCount;
  83                 executor.execute(new CompileMethodCommand(id, e));
  84             }
  85             METHOD_COUNT.addAndGet(methodCount);
  86 
  87             if (Utils.DEOPTIMIZE_ALL_CLASSES_RATE > 0
  88                     && (id % Utils.DEOPTIMIZE_ALL_CLASSES_RATE == 0)) {
  89                 WHITE_BOX.deoptimizeAll();
  90             }
  91         } catch (Throwable t) {
  92             CompileTheWorld.OUT.printf("[%d]\t%s\tskipping %s%n", id, aClass.getName(), t);
  93             t.printStackTrace();
  94         }
  95     }


< prev index next >