diff c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java @ 1437:9e5e83ca2259

Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Mon, 25 Oct 2010 16:47:52 +0200
parents 72cfb36c6bb2
children a7a0ef3c6858
line wrap: on
line diff
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java	Fri Oct 22 17:33:24 2010 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java	Mon Oct 25 16:47:52 2010 +0200
@@ -1,25 +1,30 @@
 /*
- * Copyright (c) 2009-2010 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2010 Sun Microsystems, Inc.  All rights reserved.
  *
- * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is
- * described in this document. In particular, and without limitation, these intellectual property rights may include one
- * or more of the U.S. patents listed at http://www.sun.com/patents and one or more additional patents or pending patent
- * applications in the U.S. and in other countries.
+ * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation, these intellectual property
+ * rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or
+ * more additional patents or pending patent applications in the U.S. and in other countries.
  *
- * U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard
- * license agreement and applicable provisions of the FAR and its supplements.
+ * U.S. Government Rights - Commercial software. Government users are subject to the Sun
+ * Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its
+ * supplements.
  *
- * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or registered
- * trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks are used under license and
- * are trademarks or registered trademarks of SPARC International, Inc. in the U.S. and other countries.
+ * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or
+ * registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks
+ * are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the
+ * U.S. and other countries.
  *
- * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open Company, Ltd.
+ * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open
+ * Company, Ltd.
  */
 
 package com.sun.hotspot.c1x;
 
 import java.io.*;
+import java.lang.reflect.*;
 
+import com.sun.c1x.*;
 import com.sun.cri.ci.*;
 import com.sun.cri.ri.*;
 import com.sun.hotspot.c1x.logging.*;
@@ -32,9 +37,70 @@
 public class VMExitsNative implements VMExits {
 
     @Override
-    public void compileMethod(long methodVmId, String name, int entry_bci) {
+    public boolean setOption(String option) {
+        if (option.length() == 0) {
+            return false;
+        }
+
+        Object value = null;
+        String fieldName = null;
+        String valueString = null;
+
+        char first = option.charAt(0);
+        if (first == '+' || first == '-') {
+            fieldName = option.substring(1);
+            value = (first == '+');
+        } else {
+            int index = option.indexOf('=');
+            if (index == -1) {
+                return false;
+            }
+            fieldName = option.substring(0, index);
+            valueString = option.substring(index + 1);
+        }
+
+        Field f;
         try {
-            long t1 = System.nanoTime();
+            f = C1XOptions.class.getField(fieldName);
+
+            if (value == null) {
+                if (f.getType() == Float.TYPE) {
+                    value = Float.parseFloat(valueString);
+                } else if (f.getType() == Double.TYPE) {
+                    value = Double.parseDouble(valueString);
+                } else if (f.getType() == Integer.TYPE) {
+                    value = Integer.parseInt(valueString);
+                } else if (f.getType() == Boolean.TYPE) {
+                    value = Boolean.parseBoolean(valueString);
+                }
+            }
+            if (value != null) {
+                f.set(null, value);
+                Logger.info("Set option " + fieldName + " to " + value);
+            } else {
+                Logger.info("Wrong value \"" + valueString + "\" for option fieldName");
+                return false;
+            }
+        } catch (SecurityException e) {
+            Logger.info("Security exception when setting option " + option);
+            return false;
+        } catch (NoSuchFieldException e) {
+            Logger.info("Could not find option " + fieldName);
+            return false;
+        } catch (IllegalArgumentException e) {
+            Logger.info("Illegal value for option " + option);
+            return false;
+        } catch (IllegalAccessException e) {
+            Logger.info("Illegal access exception when setting option " + option);
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public void compileMethod(long methodVmId, String name, int entryBCI) {
+        try {
             Compiler compiler = Compiler.getInstance();
             HotSpotMethodResolved riMethod = new HotSpotMethodResolved(methodVmId, name);
             CiResult result = compiler.getCompiler().compileMethod(riMethod, null);
@@ -47,8 +113,6 @@
                 Logger.log("Compilation result: " + result.targetMethod());
                 HotSpotTargetMethod.installMethod(riMethod, result.targetMethod());
             }
-            long time = (System.nanoTime() - t1) / 1000000;
-            Logger.info("compiling " + name + " (0x" + Long.toHexString(methodVmId) + "): " + (time) + "ms");
         } catch (Throwable t) {
             StringWriter out = new StringWriter();
             t.printStackTrace(new PrintWriter(out));