# HG changeset patch # User Doug Simon # Date 1331150696 -3600 # Node ID 6bc165b0fdcd07b72365d83a5744ff3046569bfb # Parent 2eb3c0920cf16698bf6760fba10207661c3188fa Added 'intro' command to mx that runs a simple 'hello world' program and visualizes its compilation in the Graal Visualizer. diff -r 2eb3c0920cf1 -r 6bc165b0fdcd graal/com.oracle.max.graal.examples/src/examples/HelloWorld.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.examples/src/examples/HelloWorld.java Wed Mar 07 21:04:56 2012 +0100 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package examples; + + +public class HelloWorld { + public static void main(String[] args) { + System.out.println("hello world!"); + } +} diff -r 2eb3c0920cf1 -r 6bc165b0fdcd graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/HotSpotDebugConfig.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/HotSpotDebugConfig.java Wed Mar 07 11:06:14 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/HotSpotDebugConfig.java Wed Mar 07 21:04:56 2012 +0100 @@ -48,7 +48,11 @@ this.timerFilter = timerFilter; this.dumpFilter = dumpFilter; this.methodFilter = methodFilter == null ? null : methodFilter.split(","); - dumpHandlers.add(new IdealGraphPrinterDumpHandler(GraalOptions.PrintIdealGraphAddress, GraalOptions.PrintIdealGraphPort)); + if (GraalOptions.PrintIdealGraphFile) { + dumpHandlers.add(new IdealGraphPrinterDumpHandler()); + } else { + dumpHandlers.add(new IdealGraphPrinterDumpHandler(GraalOptions.PrintIdealGraphAddress, GraalOptions.PrintIdealGraphPort)); + } dumpHandlers.add(new CFGPrinterObserver()); } diff -r 2eb3c0920cf1 -r 6bc165b0fdcd mx/commands.py --- a/mx/commands.py Wed Mar 07 11:06:14 2012 -0800 +++ b/mx/commands.py Wed Mar 07 21:04:56 2012 +0100 @@ -29,6 +29,7 @@ import os, sys, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing from os.path import join, exists, dirname, basename from argparse import ArgumentParser, REMAINDER +from threading import Thread import mx import sanitycheck import json @@ -230,6 +231,17 @@ if len(failed) != 0: mx.abort('DaCapo failures: ' + str(failed)) +def intro(args): + """"run a simple program and visualize its compilation in the Graal Visualizer""" + # Start the visualizer in a separate thread + t = Thread(target=gv, args=([[]])) + t.start() + + # Give visualizer time to start + mx.log('Waiting 5 seconds for visualizer to start') + time.sleep(5) + + vm(['-G:Dump=HelloWorld', '-G:MethodFilter=main', '-Xcomp', '-XX:CompileOnly=HelloWorld::main', '-cp', mx.classpath('com.oracle.max.graal.examples')] + args + ['examples.HelloWorld']) def scaladacapo(args): """run one or all Scala DaCapo benchmarks @@ -744,7 +756,9 @@ def gv(args): """run the Graal Visualizer""" - mx.run(['ant', '-f', join(_graal_home, 'visualizer', 'build.xml'), '-q', 'run']) + with open(join(_graal_home, '.graal_visualizer.log'), 'w') as fp: + mx.log('[Graal Visualizer output is in ' + fp.name + ']') + mx.run(['ant', '-f', join(_graal_home, 'visualizer', 'build.xml'), '-l', fp.name, 'run']) def bench(args): """run benchmarks and parse their output for results @@ -869,6 +883,7 @@ 'clean': [clean, ''], 'copyrightcheck': [copyrightcheck, ''], 'hsdis': [hsdis, '[att]'], + 'intro': [intro, ''], 'dacapo': [dacapo, '[[n] benchmark] [VM options|@DaCapo options]'], 'scaladacapo': [scaladacapo, '[[n] benchmark] [VM options|@Scala DaCapo options]'], 'specjvm2008': [specjvm2008, '[VM options|@specjvm2008 options]'], diff -r 2eb3c0920cf1 -r 6bc165b0fdcd mx/projects --- a/mx/projects Wed Mar 07 11:06:14 2012 -0800 +++ b/mx/projects Wed Mar 07 21:04:56 2012 +0100 @@ -111,6 +111,12 @@ project@com.oracle.max.graal.jtt@checkstyle=com.oracle.max.graal.graph project@com.oracle.max.graal.jtt@javaCompliance=1.7 +# graal.examples +project@com.oracle.max.graal.examples@subDir=graal +project@com.oracle.max.graal.examples@sourceDirs=src +project@com.oracle.max.graal.examples@checkstyle=com.oracle.max.graal.graph +project@com.oracle.max.graal.examples@javaCompliance=1.7 + # max.asm project@com.oracle.max.asm@subDir=graal project@com.oracle.max.asm@sourceDirs=src