# HG changeset patch # User Thomas Wuerthinger # Date 1400888516 -7200 # Node ID 1aaadf06db1bea397085d56f098b0c63bd82e4f3 # Parent 839ea165f816e3bb1bbb0be70de98ba6f55f9102# Parent 70bb12bdd1786663478e77dc107896c6b8a12536 Merge. diff -r 839ea165f816 -r 1aaadf06db1b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java --- 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 + "=' format"); + System.err.println("Value for option '" + optionName + "' must use '-G:" + optionName + "=' format"); return false; } @@ -175,7 +175,7 @@ } } else { if (optionType != Boolean.class) { - System.out.println("Value for option '" + optionName + "' must use '-G:" + optionName + "=' format"); + System.err.println("Value for option '" + optionName + "' must use '-G:" + optionName + "=' 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 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 ? "" : "=")); + System.err.println(String.format(" %s%s%s", isBoolean ? "(+/-)" : "", match.getName(), isBoolean ? "" : "=")); } } } @@ -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); diff -r 839ea165f816 -r 1aaadf06db1b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptionsLoader.java --- 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 lengths = new TreeSet<>(); - for (String s : options.keySet()) { - lengths.add(s.length()); + public static void main(String[] args) { + PrintStream out = System.out; + try { + Set 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 = style options. if (len == "PrintFlags".length() && isBoolean) { printedCase = true; out.println(" case " + len + ":"); diff -r 839ea165f816 -r 1aaadf06db1b mx/mx_graal.py --- 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 diff -r 839ea165f816 -r 1aaadf06db1b mxtool/mx.py --- 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: