comparison mx/commands.py @ 5047:6bc165b0fdcd

Added 'intro' command to mx that runs a simple 'hello world' program and visualizes its compilation in the Graal Visualizer.
author Doug Simon <doug.simon@oracle.com>
date Wed, 07 Mar 2012 21:04:56 +0100
parents 5733884ef819
children 8a88c903e381
comparison
equal deleted inserted replaced
5046:2eb3c0920cf1 5047:6bc165b0fdcd
27 # ---------------------------------------------------------------------------------------------------- 27 # ----------------------------------------------------------------------------------------------------
28 28
29 import os, sys, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing 29 import os, sys, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing
30 from os.path import join, exists, dirname, basename 30 from os.path import join, exists, dirname, basename
31 from argparse import ArgumentParser, REMAINDER 31 from argparse import ArgumentParser, REMAINDER
32 from threading import Thread
32 import mx 33 import mx
33 import sanitycheck 34 import sanitycheck
34 import json 35 import json
35 36
36 _graal_home = dirname(dirname(__file__)) 37 _graal_home = dirname(dirname(__file__))
228 failed.append(test) 229 failed.append(test)
229 230
230 if len(failed) != 0: 231 if len(failed) != 0:
231 mx.abort('DaCapo failures: ' + str(failed)) 232 mx.abort('DaCapo failures: ' + str(failed))
232 233
234 def intro(args):
235 """"run a simple program and visualize its compilation in the Graal Visualizer"""
236 # Start the visualizer in a separate thread
237 t = Thread(target=gv, args=([[]]))
238 t.start()
239
240 # Give visualizer time to start
241 mx.log('Waiting 5 seconds for visualizer to start')
242 time.sleep(5)
243
244 vm(['-G:Dump=HelloWorld', '-G:MethodFilter=main', '-Xcomp', '-XX:CompileOnly=HelloWorld::main', '-cp', mx.classpath('com.oracle.max.graal.examples')] + args + ['examples.HelloWorld'])
233 245
234 def scaladacapo(args): 246 def scaladacapo(args):
235 """run one or all Scala DaCapo benchmarks 247 """run one or all Scala DaCapo benchmarks
236 248
237 Scala DaCapo options are distinguished from VM options by a '@' prefix. 249 Scala DaCapo options are distinguished from VM options by a '@' prefix.
742 mx.log(' =======') 754 mx.log(' =======')
743 mx.log(' ' + str(total.duration)) 755 mx.log(' ' + str(total.duration))
744 756
745 def gv(args): 757 def gv(args):
746 """run the Graal Visualizer""" 758 """run the Graal Visualizer"""
747 mx.run(['ant', '-f', join(_graal_home, 'visualizer', 'build.xml'), '-q', 'run']) 759 with open(join(_graal_home, '.graal_visualizer.log'), 'w') as fp:
760 mx.log('[Graal Visualizer output is in ' + fp.name + ']')
761 mx.run(['ant', '-f', join(_graal_home, 'visualizer', 'build.xml'), '-l', fp.name, 'run'])
748 762
749 def bench(args): 763 def bench(args):
750 """run benchmarks and parse their output for results 764 """run benchmarks and parse their output for results
751 765
752 Results are JSON formated : {group : {benchmark : score}}.""" 766 Results are JSON formated : {group : {benchmark : score}}."""
867 'build': [build, '[-options]'], 881 'build': [build, '[-options]'],
868 'buildvms': [buildvms, '[-options]'], 882 'buildvms': [buildvms, '[-options]'],
869 'clean': [clean, ''], 883 'clean': [clean, ''],
870 'copyrightcheck': [copyrightcheck, ''], 884 'copyrightcheck': [copyrightcheck, ''],
871 'hsdis': [hsdis, '[att]'], 885 'hsdis': [hsdis, '[att]'],
886 'intro': [intro, ''],
872 'dacapo': [dacapo, '[[n] benchmark] [VM options|@DaCapo options]'], 887 'dacapo': [dacapo, '[[n] benchmark] [VM options|@DaCapo options]'],
873 'scaladacapo': [scaladacapo, '[[n] benchmark] [VM options|@Scala DaCapo options]'], 888 'scaladacapo': [scaladacapo, '[[n] benchmark] [VM options|@Scala DaCapo options]'],
874 'specjvm2008': [specjvm2008, '[VM options|@specjvm2008 options]'], 889 'specjvm2008': [specjvm2008, '[VM options|@specjvm2008 options]'],
875 'example': [example, '[-v] example names...'], 890 'example': [example, '[-v] example names...'],
876 'gate' : [gate, '[-options]'], 891 'gate' : [gate, '[-options]'],