changeset 15888:1aaadf06db1b

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sat, 24 May 2014 01:41:56 +0200
parents 839ea165f816 (current diff) 70bb12bdd178 (diff)
children 8184c00fefd2
files
diffstat 4 files changed, 49 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java	Sat May 24 01:38:23 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java	Sat May 24 01:41:56 2014 +0200
@@ -155,12 +155,12 @@
 
         if (value == null) {
             if (optionType == Boolean.TYPE || optionType == Boolean.class) {
-                System.out.println("Value for boolean option '" + optionName + "' must use '-G:+" + optionName + "' or '-G:-" + optionName + "' format");
+                System.err.println("Value for boolean option '" + optionName + "' must use '-G:+" + optionName + "' or '-G:-" + optionName + "' format");
                 return false;
             }
 
             if (valueString == null) {
-                System.out.println("Value for option '" + optionName + "' must use '-G:" + optionName + "=<value>' format");
+                System.err.println("Value for option '" + optionName + "' must use '-G:" + optionName + "=<value>' format");
                 return false;
             }
 
@@ -175,7 +175,7 @@
             }
         } else {
             if (optionType != Boolean.class) {
-                System.out.println("Value for option '" + optionName + "' must use '-G:" + optionName + "=<value>' format");
+                System.err.println("Value for option '" + optionName + "' must use '-G:" + optionName + "=<value>' format");
                 return false;
             }
         }
@@ -186,10 +186,10 @@
             } else {
                 OptionValue<?> optionValue = desc.getOptionValue();
                 optionValue.setValue(value);
-                // System.out.println("Set option " + desc.getName() + " to " + value);
+                // System.err.println("Set option " + desc.getName() + " to " + value);
             }
         } else {
-            System.out.println("Wrong value \"" + valueString + "\" for option " + optionName);
+            System.err.println("Wrong value \"" + valueString + "\" for option " + optionName);
             return false;
         }
 
@@ -197,13 +197,13 @@
     }
 
     protected static void printNoMatchMessage(String optionName) {
-        System.out.println("Could not find option " + optionName + " (use -G:+PrintFlags to see Graal options)");
+        System.err.println("Could not find option " + optionName + " (use -G:+PrintFlags to see Graal options)");
         List<OptionDescriptor> matches = fuzzyMatch(optionName);
         if (!matches.isEmpty()) {
-            System.out.println("Did you mean one of the following?");
+            System.err.println("Did you mean one of the following?");
             for (OptionDescriptor match : matches) {
                 boolean isBoolean = match.getType() == boolean.class;
-                System.out.println(String.format("    %s%s%s", isBoolean ? "(+/-)" : "", match.getName(), isBoolean ? "" : "=<value>"));
+                System.err.println(String.format("    %s%s%s", isBoolean ? "(+/-)" : "", match.getName(), isBoolean ? "" : "=<value>"));
             }
         }
     }
@@ -230,7 +230,7 @@
             }
             String previous = System.setProperty(propertyName, "true");
             if (previous != null) {
-                System.out.println("Overrode value \"" + previous + "\" of system property \"" + propertyName + "\" with \"true\"");
+                System.err.println("Overrode value \"" + previous + "\" of system property \"" + propertyName + "\" with \"true\"");
             }
         } catch (Exception e) {
             throw new GraalInternalError(e);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptionsLoader.java	Sat May 24 01:38:23 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptionsLoader.java	Sat May 24 01:41:56 2014 +0200
@@ -58,30 +58,31 @@
     }
 
     /**
-     * Command line utility for generating the source code of GraalRuntime::set_option().
-     *
-     * @param args one element array with the path of the source file to be created
+     * Command line utility for generating the source code of GraalRuntime::set_option() which is
+     * written {@link System#out}.
      */
-    public static void main(String[] args) throws Exception {
-        File outputFile = new File(args[0]);
-        PrintStream out = new PrintStream(outputFile);
-        Set<Integer> lengths = new TreeSet<>();
-        for (String s : options.keySet()) {
-            lengths.add(s.length());
+    public static void main(String[] args) {
+        PrintStream out = System.out;
+        try {
+            Set<Integer> lengths = new TreeSet<>();
+            for (String s : options.keySet()) {
+                lengths.add(s.length());
+            }
+            lengths.add("PrintFlags".length());
+
+            out.println("bool GraalRuntime::set_option(KlassHandle hotSpotOptionsClass, const char* name, int name_len, Handle name_handle, const char* value, TRAPS) {");
+            out.println("  if (value[0] == '+' || value[0] == '-') {");
+            out.println("    // boolean options");
+            genMatchers(out, lengths, true);
+            out.println("  } else {");
+            out.println("    // non-boolean options");
+            genMatchers(out, lengths, false);
+            out.println("  }");
+            out.println("  return false;");
+            out.println("}");
+        } catch (Throwable t) {
+            t.printStackTrace(out);
         }
-        lengths.add("PrintFlags".length());
-
-        out.println("bool GraalRuntime::set_option(KlassHandle hotSpotOptionsClass, const char* name, int name_len, Handle name_handle, const char* value, TRAPS) {");
-        out.println("  if (value[0] == '+' || value[0] == '-') {");
-        out.println("    // boolean options");
-        genMatchers(out, lengths, true);
-        out.println("  } else {");
-        out.println("    // non-boolean options");
-        genMatchers(out, lengths, false);
-        out.println("  }");
-        out.println("  return false;");
-        out.println("}");
-
         out.flush();
     }
 
@@ -90,6 +91,8 @@
         for (int len : lengths) {
             boolean printedCase = false;
 
+            // The use of strncmp is required (instead of strcmp) as the option name will not be
+            // null terminated for <name>=<value> style options.
             if (len == "PrintFlags".length() && isBoolean) {
                 printedCase = true;
                 out.println("    case " + len + ":");
--- a/mx/mx_graal.py	Sat May 24 01:38:23 2014 +0200
+++ b/mx/mx_graal.py	Sat May 24 01:41:56 2014 +0200
@@ -491,23 +491,16 @@
     hsSrcGenDir = join(p.source_gen_dir(), 'hotspot')
     if not exists(hsSrcGenDir):
         os.makedirs(hsSrcGenDir)
-    path = join(hsSrcGenDir, 'HotSpotOptions.inline.hpp')
-    fd, tmp = tempfile.mkstemp(suffix='', prefix='HotSpotOptions.inline.hpp', dir=hsSrcGenDir)
-    os.close(fd)
-    try:
-        retcode = mx.run_java(['-cp', graalJar, mainClass, tmp], nonZeroIsFatal=False)
-        if retcode != 0:
-            # Suppress the error if it's because the utility class isn't compiled yet
-            with zipfile.ZipFile(graalJar, 'r') as zf:
-                mainClassFile = mainClass.replace('.', '/') + '.class'
-                if mainClassFile not in zf.namelist():
-                    return
-            mx.abort(retcode)
-        with open(tmp) as fp:
-            content = fp.read()
-        mx.update_file(path, content)
-    finally:
-        os.remove(tmp)
+    tmp = StringIO.StringIO()
+    retcode = mx.run_java(['-cp', graalJar, mainClass], out=tmp.write, nonZeroIsFatal=False)
+    if retcode != 0:
+        # Suppress the error if it's because the utility class isn't compiled yet
+        with zipfile.ZipFile(graalJar, 'r') as zf:
+            mainClassFile = mainClass.replace('.', '/') + '.class'
+            if mainClassFile not in zf.namelist():
+                return
+        mx.abort(retcode)
+    mx.update_file(join(hsSrcGenDir, 'HotSpotOptions.inline.hpp'), tmp.getvalue())
 
 def _installGraalJarInJdks(graalDist):
     graalJar = graalDist.path
--- a/mxtool/mx.py	Sat May 24 01:38:23 2014 +0200
+++ b/mxtool/mx.py	Sat May 24 01:41:56 2014 +0200
@@ -1514,14 +1514,19 @@
         stderr = err if not callable(err) else subprocess.PIPE
         p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, creationflags=creationflags, env=env)
         sub = _addSubprocess(p, args)
+        joiners = []
         if callable(out):
             t = Thread(target=redirect, args=(p.stdout, out))
             # Don't make the reader thread a daemon otherwise output can be droppped
             t.start()
+            joiners.append(t)
         if callable(err):
             t = Thread(target=redirect, args=(p.stderr, err))
             # Don't make the reader thread a daemon otherwise output can be droppped
             t.start()
+            joiners.append(t)
+        for t in joiners:
+            t.join()
         if timeout is None or timeout == 0:
             retcode = waitOn(p)
         else: