changeset 13361:5a6c617a66ac

added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
author Doug Simon <doug.simon@oracle.com>
date Tue, 17 Dec 2013 16:41:26 +0100
parents cf7b5b507541
children 9fd85def8368
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java
diffstat 3 files changed, 43 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java	Tue Dec 17 15:44:23 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java	Tue Dec 17 16:41:26 2013 +0100
@@ -51,10 +51,19 @@
  */
 public final class CompileTheWorld {
 
-    static class Options {
+    /**
+     * Magic token to trigger reading files from the boot class path.
+     */
+    public static final String SUN_BOOT_CLASS_PATH = "sun.boot.class.path";
+
+    public static class Options {
         // @formatter:off
         @Option(help = "Compile all methods in all classes on given class path")
-        public static final OptionValue<String> CompileTheWorldClasspath = new OptionValue<>(null);
+        public static final OptionValue<String> CompileTheWorldClasspath = new OptionValue<>(SUN_BOOT_CLASS_PATH);
+        @Option(help = "Verbose CompileTheWorld operation")
+        public static final OptionValue<Boolean> CompileTheWorldVerbose = new OptionValue<>(true);
+        @Option(help = "The number of CompileTheWorld iterations to perform")
+        public static final OptionValue<Integer> CompileTheWorldIterations = new OptionValue<>(1);
         @Option(help = "First class to consider when using -XX:+CompileTheWorld")
         public static final OptionValue<Integer> CompileTheWorldStartAt = new OptionValue<>(1);
         @Option(help = "Last class to consider when using -XX:+CompileTheWorld")
@@ -64,6 +73,19 @@
                        "The format for each option is the same as on the command line just without the '-G:' prefix.")
         public static final OptionValue<String> CompileTheWorldConfig = new OptionValue<>(null);
         // @formatter:on
+
+        /**
+         * Overrides {@link #CompileTheWorldStartAt} and {@link #CompileTheWorldStopAt} from
+         * {@code -XX} HotSpot options of the same name if the latter have non-default values.
+         */
+        static void overrideWithNativeOptions(HotSpotVMConfig c) {
+            if (c.compileTheWorldStartAt != 1) {
+                CompileTheWorldStartAt.setValue(c.compileTheWorldStartAt);
+            }
+            if (c.compileTheWorldStopAt != Integer.MAX_VALUE) {
+                CompileTheWorldStopAt.setValue(c.compileTheWorldStopAt);
+            }
+        }
     }
 
     /**
@@ -79,7 +101,7 @@
      * </pre>
      */
     @SuppressWarnings("serial")
-    static class Config extends HashMap<OptionValue<?>, Object> implements AutoCloseable, OptionConsumer {
+    public static class Config extends HashMap<OptionValue<?>, Object> implements AutoCloseable, OptionConsumer {
         OverrideScope scope;
 
         /**
@@ -89,7 +111,7 @@
          *            a format compatible with
          *            {@link HotSpotOptions#parseOption(String, OptionConsumer)}
          */
-        Config(String options) {
+        public Config(String options) {
             for (String option : options.split("\\s+")) {
                 if (!HotSpotOptions.parseOption(option, this)) {
                     throw new GraalInternalError("Invalid option specified: %s", option);
@@ -118,21 +140,16 @@
         public void set(OptionDescriptor desc, Object value) {
             put(desc.getOptionValue(), value);
         }
-    }
 
-    static Config parseConfig(String input) {
-        if (input == null) {
-            return null;
-        } else {
-            return new Config(input);
+        public static Config parse(String input) {
+            if (input == null) {
+                return null;
+            } else {
+                return new Config(input);
+            }
         }
     }
 
-    /**
-     * This is our magic token to trigger reading files from the boot class path.
-     */
-    public static final String SUN_BOOT_CLASS_PATH = "sun.boot.class.path";
-
     // Some runtime instances we need.
     private final HotSpotGraalRuntime runtime = runtime();
     private final VMToCompilerImpl vmToCompiler = (VMToCompilerImpl) runtime.getVMToCompiler();
@@ -155,15 +172,6 @@
     private final Config config;
 
     /**
-     * Creates a compile-the-world instance with default values from
-     * {@link Options#CompileTheWorldClasspath}, {@link Options#CompileTheWorldStartAt} and
-     * {@link Options#CompileTheWorldStopAt}.
-     */
-    public CompileTheWorld() {
-        this(CompileTheWorldClasspath.getValue(), parseConfig(CompileTheWorldConfig.getValue()), CompileTheWorldStartAt.getValue(), CompileTheWorldStopAt.getValue(), true);
-    }
-
-    /**
      * Creates a compile-the-world instance.
      * 
      * @param files {@link File#pathSeparator} separated list of Zip/Jar files to compile
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Tue Dec 17 15:44:23 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Tue Dec 17 16:41:26 2013 +0100
@@ -23,7 +23,6 @@
 package com.oracle.graal.hotspot;
 
 import static com.oracle.graal.graph.UnsafeAccess.*;
-import static com.oracle.graal.hotspot.CompileTheWorld.*;
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.Options.*;
 import static com.oracle.graal.phases.GraalOptions.*;
 
@@ -233,16 +232,7 @@
         initMirror(typeDouble);
         initMirror(typeVoid);
 
-        // Set some global options:
-        if (config.compileTheWorld && CompileTheWorld.Options.CompileTheWorldClasspath.getValue() == null) {
-            CompileTheWorld.Options.CompileTheWorldClasspath.setValue(SUN_BOOT_CLASS_PATH);
-        }
-        if (config.compileTheWorldStartAt != 1) {
-            CompileTheWorld.Options.CompileTheWorldStartAt.setValue(config.compileTheWorldStartAt);
-        }
-        if (config.compileTheWorldStopAt != Integer.MAX_VALUE) {
-            CompileTheWorld.Options.CompileTheWorldStopAt.setValue(config.compileTheWorldStopAt);
-        }
+        CompileTheWorld.Options.overrideWithNativeOptions(config);
 
         // Only set HotSpotPrintCompilation and HotSpotPrintInlining if they still have their
         // default value (false).
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Tue Dec 17 15:44:23 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Tue Dec 17 16:41:26 2013 +0100
@@ -25,6 +25,7 @@
 
 import static com.oracle.graal.compiler.GraalDebugConfig.*;
 import static com.oracle.graal.graph.UnsafeAccess.*;
+import static com.oracle.graal.hotspot.CompileTheWorld.Options.*;
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 
 import java.io.*;
@@ -42,6 +43,7 @@
 import com.oracle.graal.debug.internal.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.CompileTheWorld.Config;
 import com.oracle.graal.hotspot.debug.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.phases.*;
@@ -116,8 +118,6 @@
             }
         }
 
-        runtime.getCompilerToVM();
-
         TTY.initialize(log);
 
         if (Log.getValue() == null && Meter.getValue() == null && Time.getValue() == null && Dump.getValue() == null) {
@@ -307,7 +307,14 @@
     }
 
     public void compileTheWorld() throws Throwable {
-        new CompileTheWorld().compile();
+        int iterations = CompileTheWorld.Options.CompileTheWorldIterations.getValue();
+        for (int i = 0; i < iterations; i++) {
+            runtime.getCompilerToVM().resetCompilationStatistics();
+            TTY.println("CompileTheWorld : iteration " + i);
+            CompileTheWorld ctw = new CompileTheWorld(CompileTheWorldClasspath.getValue(), Config.parse(CompileTheWorldConfig.getValue()), CompileTheWorldStartAt.getValue(),
+                            CompileTheWorldStopAt.getValue(), CompileTheWorldVerbose.getValue());
+            ctw.compile();
+        }
         System.exit(0);
     }