changeset 3695:7c26db3259c6

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 24 Nov 2011 16:14:33 +0100
parents 221133c5ed6c (current diff) 60d31b1fada5 (diff)
children 9b5611392eb9 67e92894d065
files
diffstat 2 files changed, 80 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/pytools/commands.py	Thu Nov 24 16:14:21 2011 +0100
+++ b/pytools/commands.py	Thu Nov 24 16:14:33 2011 +0100
@@ -38,36 +38,72 @@
 def bootstrap(env, args):
     return env.run_vm(args + ['-version'])
 
-def avrora(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'avrora'])
-
-def batik(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'batik'])
+def example(env, args):
+    """run some or all Graal examples"""
+    examples = {
+        'safeadd': ['com.oracle.max.graal.examples.safeadd', 'com.oracle.max.graal.examples.safeadd.Main'],
+        'vectorlib': ['com.oracle.max.graal.examples.vectorlib', 'com.oracle.max.graal.examples.vectorlib.Main'],
+    }
 
-def eclipse(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'eclipse'])
+    def run_example(env, verbose, project, mainClass):
+        cp = env.mx().pdb().classpath(project)
+        sharedArgs = ['-Xcomp', '-XX:CompileOnly=Main', mainClass]
+        
+        res = []
+        env.log("=== Server VM ===")
+        printArg = '-XX:+PrintCompilation' if verbose else '-XX:-PrintCompilation'
+        res.append(env.run_vm(['-cp', cp, printArg] + sharedArgs, vm="-server"))
+        env.log("=== Graal VM ===")
+        printArg = '-G:+PrintCompilation' if verbose else '-G:-PrintCompilation'
+        res.append(env.run_vm(['-cp', cp, printArg, '-G:-Extend', '-G:-Inline'] + sharedArgs))
+        env.log("=== Graal VM with extensions ===")
+        res.append(env.run_vm(['-cp', cp, printArg, '-G:+Extend', '-G:-Inline'] + sharedArgs))
+        
+        if len([x for x in res if x != 0]) != 0:
+            return 1
+        return 0
 
-def fop(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '100', 'fop'])
-
-def h2(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '10', 'h2'])
+    verbose = False
+    if '-v' in args:
+        verbose = True
+        args = [a for a in args if a != '-v']
 
-def jython(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '10', 'jython'])
-
-def lusearch(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '5', 'lusearch'])
+    if len(args) == 0:
+        args = examples.keys()
+    for a in args:
+        config = examples.get(a)
+        if config is None:
+            env.log('unknown example: ' + a + '  {available examples = ' + str(examples.keys()) + '}')
+        else:
+            env.log('--------- ' + a + ' ------------')
+            project, mainClass = config
+            run_example(env, verbose, project, mainClass)
 
-def pmd(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '10', 'pmd'])
-
-def tradebeans(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'tradebeans'])
-
-def xalan(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'xalan'])
-
+def dacapo(env, args):
+    """run a DaCapo benchmark"""
+    
+    benchmarks = {
+        'avrora': ['--preserve', '-n', '20'],
+        'batik': ['-n', '20'],
+        'eclipse': ['-n', '20'],
+        'fop': ['-n', '100'],
+        'h2': ['-n', '10'],
+        'jython': ['-n', '10'],
+        'lusearch': ['-n', '5'],
+        'pmd': ['-n', '10'],
+        'tradebeans': ['-n', '20'],
+        'xalan': ['-n', '20'],
+    }
+    
+    if len(args) == 0:
+        env.abort('which benchmark?\nselect one of: ' + str(benchmarks.keys()))
+    bm = args[0]
+    config = benchmarks.get(bm)
+    if (config is None):
+        env.abort('unknown benchmark: ' + bm + '\nselect one of: ' + str(benchmarks.keys()))
+    args = args[1:]
+    return env.run_dacapo(args + ['Harness'] + config + [bm])
+    
 def tests(env, args):
     """run a selection of the Maxine JTT tests in Graal"""
     
@@ -165,19 +201,12 @@
 # used in the call to str.format().  
 # Extensions should update this table directly
 table = {
-    'avrora': [avrora, ''],
-    'batik': [batik, ''],
+    'dacapo': [dacapo, 'benchmark [VM options]'],
+    'example': [example, '[-v] example names...'],
     'bootstrap': [bootstrap, ''],
     'clean': [clean, ''],
-    'fop': [fop, ''],
-    'h2': [h2, ''],
-    'jython': [jython, ''],
-    'lusearch': [lusearch, ''],
-    'pmd': [pmd, ''],
-    'tradebeans': [tradebeans, ''],
-    'tests': [tests, ''],
     'help': [help_, '[command]'],
     'make': [make, ''],
-    'xalan': [xalan, ''],
+    'tests': [tests, ''],
     'vm': [vm, ''],
 }
--- a/pytools/gl.py	Thu Nov 24 16:14:21 2011 +0100
+++ b/pytools/gl.py	Thu Nov 24 16:14:33 2011 +0100
@@ -56,6 +56,7 @@
         self.dacapo = os.getenv('DACAPO')
         self.jdk7 = os.getenv('JDK7')
         self.maxine = os.getenv('MAXINE')
+        self._mx = None
         
         ArgumentParser.__init__(self, prog='gl')
     
@@ -109,11 +110,13 @@
         return name
 
     def run_dacapo(self, args):
+        if self.dacapo is None:
+            self.abort('Need to specify DaCapo jar with --dacapo option or DACAPO environment variable')
         if not isfile(self.dacapo) or not self.dacapo.endswith('.jar'):
             self.abort('Specified DaCapo jar file does not exist or is not a jar file: ' + self.dacapo)
         return self.run_vm(['-Xms1g', '-Xmx2g', '-esa', '-XX:-GraalBailoutIsFatal', '-G:-QuietBailout', '-cp', self.dacapo] + args)
 
-    def run_vm(self, args):
+    def run_vm(self, args, vm='-graal'):
         if self.maxine is None:
             configFile = join(dirname(sys.argv[0]), 'glrc')
             self.abort('Path to Maxine code base must be specified with -M option or MAXINE environment variable (in ' + configFile + ')')
@@ -122,7 +125,7 @@
             
         os.environ['MAXINE'] = self.maxine
         exe = join(self.jdk7, 'bin', self.exe('java'))
-        return self.run([exe, '-graal'] + args)
+        return self.run([exe, vm] + args)
 
     def run(self, args, nonZeroIsFatal=True, out=None, err=None, cwd=None):
         """
@@ -195,6 +198,16 @@
         """ raises a SystemExit exception with the provided exit code """
         raise SystemExit(code)
 
+    def mx(self):
+        if (self._mx is None):
+            p = join(self.maxine, 'com.oracle.max.shell')
+            sys.path.insert(0, p)
+            import mx
+            self._mx = mx.Env()
+            self._mx.maxine_home = self.maxine
+            self._mx.parse_cmd_line([])
+        return self._mx
+
 def main(env):
     configFile = join(dirname(sys.argv[0]), 'glrc')
     env.load_config_file(configFile)