# HG changeset patch # User Doug Simon # Date 1400885193 -7200 # Node ID 6dcf8ab4ad86ef8dd7c5f317bd54be59a444a5a8 # Parent b7fc7cdb900596b0aa5b6f55417508328506000f HotSpotOptions.inline.hpp generator writes to System.out to make generator errors more visible (they will show up when compiling the generated source) diff -r b7fc7cdb9005 -r 6dcf8ab4ad86 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 00:25:29 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptionsLoader.java Sat May 24 00:46:33 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(); } diff -r b7fc7cdb9005 -r 6dcf8ab4ad86 mx/mx_graal.py --- a/mx/mx_graal.py Sat May 24 00:25:29 2014 +0200 +++ b/mx/mx_graal.py Sat May 24 00:46:33 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