SF.net SVN: jikesrvm:[15764] rvmroot/trunk/rvm/src

View: New views
1 Messages — Rating Filter:   Alert me  

SF.net SVN: jikesrvm:[15764] rvmroot/trunk/rvm/src

by dgrove-oss :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Revision: 15764
          http://jikesrvm.svn.sourceforge.net/jikesrvm/?rev=15764&view=rev
Author:   dgrove-oss
Date:     2009-08-10 20:36:32 +0000 (Mon, 10 Aug 2009)

Log Message:
-----------
Implement a simpler strategy for ensuring that classes that
are annotated as SaveVolatile are always compiled by the optimizing
compiler before any of their methods are dynamically invoked.
Instead of letting the baseline compiler do a useless compilation during
bootimage building and then dynamically recompiling them as part of
opt compiler initialization, just use the optimizing compiler to compile them
at bootimage writing time, even if we're otherwise useing the baseline
compiler to compile the bootimage.  

Also eliminated the hacky loadSpecialClass hook in OptimizingCompiler
that was used as part of the previous strategy for dealing with this issue.

Modified Paths:
--------------
    rvmroot/trunk/rvm/src/org/jikesrvm/adaptive/controller/RecompilationStrategy.java
    rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/BaselineCompiler.java
    rvmroot/trunk/rvm/src/org/jikesrvm/compilers/common/BootImageCompiler.java
    rvmroot/trunk/rvm/src/org/jikesrvm/compilers/common/RuntimeCompiler.java
    rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/driver/OptimizingCompiler.java
    rvmroot/trunk/rvm/src-generated/options/SharedBooleanOptions.dat
    rvmroot/trunk/rvm/src-generated/options/SharedValueOptions.dat

Modified: rvmroot/trunk/rvm/src/org/jikesrvm/adaptive/controller/RecompilationStrategy.java
===================================================================
--- rvmroot/trunk/rvm/src/org/jikesrvm/adaptive/controller/RecompilationStrategy.java 2009-08-10 15:37:54 UTC (rev 15763)
+++ rvmroot/trunk/rvm/src/org/jikesrvm/adaptive/controller/RecompilationStrategy.java 2009-08-10 20:36:32 UTC (rev 15764)
@@ -249,10 +249,6 @@
       _options[i].setOptLevel(i);               // set optimization level specific optimiations
       processCommandLineOptions(_options[i], i, maxOptLevel, optCompilerOptions);
       _optPlans[i] = OptimizationPlanner.createOptimizationPlan(_options[i]);
-      if (_options[i].PRELOAD_CLASS != null) {
-        VM.sysWrite("PRELOAD_CLASS should be specified with -X:irc not -X:recomp\n");
-        VM.sysExit(VM.EXIT_STATUS_BOGUS_COMMAND_LINE_ARG);
-      }
     }
   }
 

Modified: rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/BaselineCompiler.java
===================================================================
--- rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/BaselineCompiler.java 2009-08-10 15:37:54 UTC (rev 15763)
+++ rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/BaselineCompiler.java 2009-08-10 20:36:32 UTC (rev 15764)
@@ -105,11 +105,6 @@
     if (options.hasMETHOD_TO_PRINT() && options.fuzzyMatchMETHOD_TO_PRINT("???")) {
       VM.sysWrite("??? is not a sensible string to specify for method name");
     }
-    if (!VM.BuildForAdaptiveSystem && options.PRELOAD_CLASS != null) {
-      VM.sysWrite("Option preload_class should only be used when the optimizing compiler is the runtime");
-      VM.sysWrite(" compiler or in an adaptive system\n");
-      VM.sysExit(VM.EXIT_STATUS_BOGUS_COMMAND_LINE_ARG);
-    }
     fullyBootedVM = true;
   }
 
@@ -171,6 +166,8 @@
    * @return the generated CompiledMethod for said NormalMethod.
    */
   public static CompiledMethod compile(NormalMethod method) {
+    if (VM.VerifyAssertions) VM._assert(!method.getDeclaringClass().hasSaveVolatileAnnotation(), "Baseline compiler doesn't implement SaveVolatile");
+
     BaselineCompiledMethod cm =
         (BaselineCompiledMethod) CompiledMethods.createCompiledMethod(method, CompiledMethod.BASELINE);
     cm.compile();

Modified: rvmroot/trunk/rvm/src/org/jikesrvm/compilers/common/BootImageCompiler.java
===================================================================
--- rvmroot/trunk/rvm/src/org/jikesrvm/compilers/common/BootImageCompiler.java 2009-08-10 15:37:54 UTC (rev 15763)
+++ rvmroot/trunk/rvm/src/org/jikesrvm/compilers/common/BootImageCompiler.java 2009-08-10 20:36:32 UTC (rev 15764)
@@ -27,9 +27,12 @@
  */
 public abstract class BootImageCompiler {
 
-  private static BootImageCompiler compiler =
-      VM.BuildWithBaseBootImageCompiler ? new BaselineBootImageCompiler() : new org.jikesrvm.compilers.opt.driver.OptimizingBootImageCompiler();
+  protected static BootImageCompiler baseCompiler = new BaselineBootImageCompiler();
+  protected static BootImageCompiler optCompiler = VM.BuildForAdaptiveSystem ? new org.jikesrvm.compilers.opt.driver.OptimizingBootImageCompiler() : null;
 
+  protected static BootImageCompiler compiler = VM.BuildWithBaseBootImageCompiler ? baseCompiler : optCompiler;
+
+
   /**
    * Initialize boot image compiler.
    * @param args command line arguments to the bootimage compiler
@@ -50,6 +53,12 @@
   public static void init(String[] args) {
     try {
       compiler.initCompiler(args);
+      if (VM.BuildForAdaptiveSystem && VM.BuildWithBaseBootImageCompiler) {
+        // We have to use the opt compiler to compile the org.jikesrvm.compiler.opt.OptSaveVolatile class,
+        // so if we're building a baseline compiled configuration that includes AOS, we also need to init
+        // the optimizing bootimage compiler so it can be invoked to compile this class.
+        optCompiler.initCompiler(args);
+      }
     } catch (Throwable e) {
       while (e != null) {
         e.printStackTrace();
@@ -59,7 +68,12 @@
   }
 
   public static CompiledMethod compile(NormalMethod method, TypeReference[] params) {
-    return compiler.compileMethod(method, params);
+    if (VM.BuildForAdaptiveSystem && VM.BuildWithBaseBootImageCompiler && method.getDeclaringClass().hasSaveVolatileAnnotation()) {
+      // Force opt compilation of SaveVolatile methods.
+      return optCompiler.compileMethod(method, params);
+    } else {
+      return compiler.compileMethod(method, params);
+    }
   }
 
   public static CompiledMethod compile(NormalMethod method) {

Modified: rvmroot/trunk/rvm/src/org/jikesrvm/compilers/common/RuntimeCompiler.java
===================================================================
--- rvmroot/trunk/rvm/src/org/jikesrvm/compilers/common/RuntimeCompiler.java 2009-08-10 15:37:54 UTC (rev 15763)
+++ rvmroot/trunk/rvm/src/org/jikesrvm/compilers/common/RuntimeCompiler.java 2009-08-10 20:36:32 UTC (rev 15764)
@@ -110,9 +110,6 @@
   // you know what you're doing before modifying it!!!
   protected static boolean compilationInProgress;
 
-  // One time check to optionally preload and compile a specified class
-  protected static boolean preloadChecked = false;
-
   // Cache objects needed to cons up compilation plans
   // TODO: cutting link to opt compiler by declaring type as object.
   public static final Object /* Options */ options = VM.BuildForAdaptiveSystem ? new OptOptions() : null;
@@ -645,26 +642,6 @@
         cm = baselineCompile(method);
         ControllerMemory.incrementNumBase();
       } else {
-        if (!preloadChecked) {
-          preloadChecked = true;                  // prevent subsequent calls
-          // N.B. This will use irc options
-          if (BaselineCompiler.options.PRELOAD_CLASS != null) {
-            compilationInProgress = true;         // use baseline during preload
-            // Other than when boot options are requested (processed during preloadSpecialClass
-            // It is hard to communicate options for these special compilations. Use the
-            // default options and at least pick up the verbose if requested for base/irc
-            OptOptions tmpoptions = ((OptOptions) options).dup();
-            tmpoptions.PRELOAD_CLASS = BaselineCompiler.options.PRELOAD_CLASS;
-            tmpoptions.PRELOAD_AS_BOOT = BaselineCompiler.options.PRELOAD_AS_BOOT;
-            if (BaselineCompiler.options.PRINT_METHOD) {
-              tmpoptions.PRINT_METHOD = true;
-            } else {
-              tmpoptions = (OptOptions) options;
-            }
-            OptimizingCompiler.preloadSpecialClass(tmpoptions);
-            compilationInProgress = false;
-          }
-        }
         if (Controller.options.optIRC()) {
           if (// will only run once: don't bother optimizing
               method.isClassInitializer() ||

Modified: rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/driver/OptimizingCompiler.java
===================================================================
--- rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/driver/OptimizingCompiler.java 2009-08-10 15:37:54 UTC (rev 15763)
+++ rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/driver/OptimizingCompiler.java 2009-08-10 20:36:32 UTC (rev 15764)
@@ -12,14 +12,9 @@
  */
 package org.jikesrvm.compilers.opt.driver;
 
-import org.jikesrvm.VM;
 import org.jikesrvm.Callbacks;
-import org.jikesrvm.classloader.Atom;
-import org.jikesrvm.classloader.BootstrapClassLoader;
-import org.jikesrvm.classloader.RVMClass;
-import org.jikesrvm.classloader.RVMMethod;
+import org.jikesrvm.VM;
 import org.jikesrvm.classloader.NormalMethod;
-import org.jikesrvm.classloader.TypeReference;
 import org.jikesrvm.compilers.common.CompiledMethod;
 import org.jikesrvm.compilers.opt.MagicNotImplementedException;
 import org.jikesrvm.compilers.opt.OptOptions;
@@ -72,14 +67,7 @@
       options.ESCAPE_SIMPLE_IPA = false;
 
       initializeStatics();
-      if (VM.runningVM) {
-        // Make sure that OptSaveVolatile.java is opt
-        // compiled (to get special prologues/epilogues)
-        // TODO: This could be phased out as the new DynamicBridge
-        // magic comes on line.
-        loadSpecialClass("Lorg/jikesrvm/compilers/opt/runtimesupport/OptSaveVolatile;", options);
 
-      }
       // want to be notified when VM boot is done and ready to start application
       Callbacks.addStartupMonitor(new OptimizingCompiler());
       isInitialized = true;
@@ -132,49 +120,6 @@
   }
 
   /**
-   * Load a class which must be compiled by the opt compiler in a special way
-   * @param klassName the class to load
-   * @param options compiler options for compiling the class
-   */
-  private static void loadSpecialClass(String klassName, OptOptions options) {
-    TypeReference tRef =
-        TypeReference.findOrCreate(BootstrapClassLoader.getBootstrapClassLoader(),
-                                      Atom.findOrCreateAsciiAtom(klassName));
-    RVMClass klass = (RVMClass) tRef.peekType();
-    for (RVMMethod meth : klass.getDeclaredMethods()) {
-      if (meth.isClassInitializer()) {
-        continue;
-      }
-      if (!meth.isCompiled() || meth.getCurrentCompiledMethod().getCompilerType() != CompiledMethod.OPT) {
-        CompilationPlan cp =
-            new CompilationPlan((NormalMethod) meth,
-                                    OptimizationPlanner.createOptimizationPlan(options),
-                                    null,
-                                    options);
-        meth.replaceCompiledMethod(compile(cp));
-      }
-    }
-  }
-
-  public static void preloadSpecialClass(OptOptions options) {
-    String klassName = "L" + options.PRELOAD_CLASS + ";";
-
-    if (options.PRELOAD_AS_BOOT) {
-      setBootOptions(options);
-      // Make a local copy so that some options can be altered to mimic options
-      // during boot build
-      options = options.dup();
-    }
-
-    try {
-      loadSpecialClass(klassName, options);
-    } catch (Throwable e) {
-      e.printStackTrace();
-      VM.sysWrite("Ignoring failure of preloadSpecialClass of " + klassName + "\n");
-    }
-  }
-
-  /**
    * Call the static init functions for the Compiler subsystems
    */
   private static void initializeStatics() {

Modified: rvmroot/trunk/rvm/src-generated/options/SharedBooleanOptions.dat
===================================================================
--- rvmroot/trunk/rvm/src-generated/options/SharedBooleanOptions.dat 2009-08-10 15:37:54 UTC (rev 15763)
+++ rvmroot/trunk/rvm/src-generated/options/SharedBooleanOptions.dat 2009-08-10 20:36:32 UTC (rev 15764)
@@ -20,9 +20,6 @@
 #   May want to consider moving some like NO_CHECKCAST NO_CHECKSTORE from
 #   opt only to here
 ##########
-PRELOAD_AS_BOOT -1 false
-Apply boot options to preload_class
-
 ##########
 # Next, declare all the printing options
 # MUST start with PRINT_ or VCG_ prefix

Modified: rvmroot/trunk/rvm/src-generated/options/SharedValueOptions.dat
===================================================================
--- rvmroot/trunk/rvm/src-generated/options/SharedValueOptions.dat 2009-08-10 15:37:54 UTC (rev 15763)
+++ rvmroot/trunk/rvm/src-generated/options/SharedValueOptions.dat 2009-08-10 20:36:32 UTC (rev 15764)
@@ -18,10 +18,6 @@
 ENUMS
 #Structure of ENUMS "ITEM_NAME QUERY_NAME CMD_NAME"
 
-V PRELOAD_CLASS String null
-Class to preload upon 1st OPT compilation
-
-
 S METHOD_TO_PRINT String
 Only apply print options against methods whose name contains this string
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Jikesrvm-commits mailing list
Jikesrvm-commits@...
https://lists.sourceforge.net/lists/listinfo/jikesrvm-commits