diff graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java @ 16872:ce8ac92efb14

Don't recreate suites on every CTW compile.
author Roland Schatz <roland.schatz@oracle.com>
date Wed, 20 Aug 2014 16:50:25 +0200
parents 217eee2ddead
children 58f45b63b802
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java	Wed Aug 20 16:43:05 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java	Wed Aug 20 16:50:25 2014 +0200
@@ -42,7 +42,6 @@
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.options.*;
 import com.oracle.graal.options.OptionValue.OverrideScope;
-import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.replacements.*;
 
 /**
@@ -237,79 +236,81 @@
     private void compile(String fileList) throws Throwable {
         final String[] entries = fileList.split(File.pathSeparator);
 
-        for (int i = 0; i < entries.length; i++) {
-            final String entry = entries[i];
-
-            // For now we only compile all methods in all classes in zip/jar files.
-            if (!entry.endsWith(".zip") && !entry.endsWith(".jar")) {
-                println("CompileTheWorld : Skipped classes in " + entry);
-                println();
-                continue;
-            }
+        try (AutoCloseable s = config.apply()) {
+            for (int i = 0; i < entries.length; i++) {
+                final String entry = entries[i];
 
-            println("CompileTheWorld : Compiling all classes in " + entry);
-            println();
-
-            URL url = new URL("jar", "", "file:" + entry + "!/");
-            ClassLoader loader = new URLClassLoader(new URL[]{url});
-
-            JarFile jarFile = new JarFile(entry);
-            Enumeration<JarEntry> e = jarFile.entries();
-
-            while (e.hasMoreElements()) {
-                JarEntry je = e.nextElement();
-                if (je.isDirectory() || !je.getName().endsWith(".class")) {
+                // For now we only compile all methods in all classes in zip/jar files.
+                if (!entry.endsWith(".zip") && !entry.endsWith(".jar")) {
+                    println("CompileTheWorld : Skipped classes in " + entry);
+                    println();
                     continue;
                 }
 
-                // Are we done?
-                if (classFileCounter >= stopAt) {
-                    break;
-                }
+                println("CompileTheWorld : Compiling all classes in " + entry);
+                println();
 
-                String className = je.getName().substring(0, je.getName().length() - ".class".length());
-                classFileCounter++;
+                URL url = new URL("jar", "", "file:" + entry + "!/");
+                ClassLoader loader = new URLClassLoader(new URL[]{url});
+
+                JarFile jarFile = new JarFile(entry);
+                Enumeration<JarEntry> e = jarFile.entries();
 
-                try (AutoCloseable s = config.apply()) {
-                    // Load and initialize class
-                    Class<?> javaClass = Class.forName(className.replace('/', '.'), true, loader);
+                while (e.hasMoreElements()) {
+                    JarEntry je = e.nextElement();
+                    if (je.isDirectory() || !je.getName().endsWith(".class")) {
+                        continue;
+                    }
 
-                    // Pre-load all classes in the constant pool.
-                    try {
-                        HotSpotResolvedObjectType objectType = (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromClass(javaClass);
-                        ConstantPool constantPool = objectType.constantPool();
-                        for (int cpi = 1; cpi < constantPool.length(); cpi++) {
-                            constantPool.loadReferencedType(cpi, Bytecodes.LDC);
-                        }
-                    } catch (Throwable t) {
-                        // If something went wrong during pre-loading we just ignore it.
-                        println("Preloading failed for (%d) %s", classFileCounter, className);
+                    // Are we done?
+                    if (classFileCounter >= stopAt) {
+                        break;
                     }
 
-                    // Are we compiling this class?
-                    HotSpotMetaAccessProvider metaAccess = runtime.getHostProviders().getMetaAccess();
-                    if (classFileCounter >= startAt) {
-                        println("CompileTheWorld (%d) : %s", classFileCounter, className);
+                    String className = je.getName().substring(0, je.getName().length() - ".class".length());
+                    classFileCounter++;
+
+                    try {
+                        // Load and initialize class
+                        Class<?> javaClass = Class.forName(className.replace('/', '.'), true, loader);
 
-                        // Compile each constructor/method in the class.
-                        for (Constructor<?> constructor : javaClass.getDeclaredConstructors()) {
-                            HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaConstructor(constructor);
-                            if (canBeCompiled(javaMethod, constructor.getModifiers())) {
-                                compileMethod(javaMethod);
+                        // Pre-load all classes in the constant pool.
+                        try {
+                            HotSpotResolvedObjectType objectType = (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromClass(javaClass);
+                            ConstantPool constantPool = objectType.constantPool();
+                            for (int cpi = 1; cpi < constantPool.length(); cpi++) {
+                                constantPool.loadReferencedType(cpi, Bytecodes.LDC);
+                            }
+                        } catch (Throwable t) {
+                            // If something went wrong during pre-loading we just ignore it.
+                            println("Preloading failed for (%d) %s", classFileCounter, className);
+                        }
+
+                        // Are we compiling this class?
+                        HotSpotMetaAccessProvider metaAccess = runtime.getHostProviders().getMetaAccess();
+                        if (classFileCounter >= startAt) {
+                            println("CompileTheWorld (%d) : %s", classFileCounter, className);
+
+                            // Compile each constructor/method in the class.
+                            for (Constructor<?> constructor : javaClass.getDeclaredConstructors()) {
+                                HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaConstructor(constructor);
+                                if (canBeCompiled(javaMethod, constructor.getModifiers())) {
+                                    compileMethod(javaMethod);
+                                }
+                            }
+                            for (Method method : javaClass.getDeclaredMethods()) {
+                                HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(method);
+                                if (canBeCompiled(javaMethod, method.getModifiers())) {
+                                    compileMethod(javaMethod);
+                                }
                             }
                         }
-                        for (Method method : javaClass.getDeclaredMethods()) {
-                            HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(method);
-                            if (canBeCompiled(javaMethod, method.getModifiers())) {
-                                compileMethod(javaMethod);
-                            }
-                        }
+                    } catch (Throwable t) {
+                        println("CompileTheWorld (%d) : Skipping %s", classFileCounter, className);
                     }
-                } catch (Throwable t) {
-                    println("CompileTheWorld (%d) : Skipping %s", classFileCounter, className);
                 }
+                jarFile.close();
             }
-            jarFile.close();
         }
 
         println();
@@ -323,16 +324,6 @@
         }
 
         /**
-         * Returns a fresh compilation suite for its compilation so that the CTW option value
-         * overriding configuration has effect.
-         */
-        @Override
-        protected Suites getSuites(HotSpotProviders providers) {
-            assert config.scope != null : "not inside a CTW option value overriding scope";
-            return providers.getSuites().createSuites();
-        }
-
-        /**
          * Returns empty profiling info to be as close to the CTW behavior of C1 and C2 as possible.
          */
         @Override