changeset 3623:3b2ab8970aa4

Improved gl.py script.
author Doug Simon <doug.simon@oracle.com>
date Wed, 09 Nov 2011 16:02:46 +0100
parents 05b6ae7c23b1
children e81927755129
files .hgignore pytools/.project pytools/.pydevproject pytools/commands.py pytools/gl.py
diffstat 5 files changed, 46 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Wed Nov 09 15:49:51 2011 +0100
+++ b/.hgignore	Wed Nov 09 16:02:46 2011 +0100
@@ -30,6 +30,7 @@
 ^scratch/
 scratch/
 bin/
+pytools/glrc
 ^local/
 ^src/share/tools/hsdis/build/
 ^src/share/tools/IdealGraphVisualizer/[a-zA-Z0-9]*/build/
--- a/pytools/.project	Wed Nov 09 15:49:51 2011 +0100
+++ b/pytools/.project	Wed Nov 09 16:02:46 2011 +0100
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-	<name>shell</name>
+	<name>pytools</name>
 	<comment></comment>
 	<projects>
 	</projects>
--- a/pytools/.pydevproject	Wed Nov 09 15:49:51 2011 +0100
+++ b/pytools/.pydevproject	Wed Nov 09 16:02:46 2011 +0100
@@ -5,7 +5,7 @@
 <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
 <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
 <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
-<path>/shell</path>
+<path>/pytools</path>
 </pydev_pathproperty>
 
 </pydev_project>
--- a/pytools/commands.py	Wed Nov 09 15:49:51 2011 +0100
+++ b/pytools/commands.py	Wed Nov 09 16:02:46 2011 +0100
@@ -72,11 +72,11 @@
     """run a selection of the Maxine JTT tests in Graal"""
     
     def jtt(name):
-        return join(env.maxine_home, 'com.oracle.max.vm', 'test', 'jtt', name)
+        return join(env.maxine, 'com.oracle.max.vm', 'test', 'jtt', name)
     
     return env.run_vm(args + ['-ea', '-esa', '-Xcomp', '-XX:+PrintCompilation', '-XX:CompileOnly=jtt'] + args +
-                       ['-Xbootclasspath/p:' + join(env.maxine_home, 'com.oracle.max.vm', 'bin'), 
-                        '-Xbootclasspath/p:' + join(env.maxine_home, 'com.oracle.max.base', 'bin'),
+                       ['-Xbootclasspath/p:' + join(env.maxine, 'com.oracle.max.vm', 'bin'), 
+                        '-Xbootclasspath/p:' + join(env.maxine, 'com.oracle.max.base', 'bin'),
                         'test.com.sun.max.vm.compiler.JavaTester',
                         '-verbose=1', '-gen-run-scheme=false', '-run-scheme-package=all',
                         jtt('bytecode'),
@@ -123,19 +123,22 @@
 def make(env, args):
     """builds the Graal+HotSpot binary"""
 
-    
-    jvmCfg = join(env.jdk7, 'jre', 'lib', 'amd64', 'jvm.cfg')
-    found = False
-    with open(jvmCfg) as f:
-        for line in f:
-            if '-graal KNOWN' in line:
-                found = True
-                break
-            
-    if not found:
-        env.log('Appending "-graal KNOWN" to ' + jvmCfg)
-        with open(jvmCfg, 'a') as f:
-            f.write('-graal KNOWN\n')
+    def fix_jvm_cfg(env, jdk):
+        jvmCfg = join(jdk, 'jre', 'lib', 'amd64', 'jvm.cfg')
+        found = False
+        with open(jvmCfg) as f:
+            for line in f:
+                if '-graal KNOWN' in line:
+                    found = True
+                    break
+                
+        if not found:
+            env.log('Appending "-graal KNOWN" to ' + jvmCfg)
+            with open(jvmCfg, 'a') as f:
+                f.write('-graal KNOWN\n')
+
+    fix_jvm_cfg(env, env.jdk7)
+    fix_jvm_cfg(env, env.jdk7g)
 
     if env.get_os() != 'windows':
         javaLink = join(env.graal_home, 'graal', 'hotspot', 'java')
@@ -161,6 +164,9 @@
     os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='4', ALT_BOOTDIR=env.jdk7, INSTALL='y')
     env.run(['gmake', 'productgraal'], cwd=join(env.graal_home, 'make'))
     
+def vm(env, args):
+    return env.run_vm(args)
+
 # Table of commands in alphabetical order.
 # Keys are command names, value are lists: [<function>, <usage msg>, <format args to doc string of function>...]
 # If any of the format args are instances of Callable, then they are called with an 'env' are before being
@@ -181,4 +187,5 @@
     'help': [help_, '[command]'],
     'make': [make, ''],
     'xalan': [xalan, ''],
+    'vm': [vm, ''],
 }
--- a/pytools/gl.py	Wed Nov 09 15:49:51 2011 +0100
+++ b/pytools/gl.py	Wed Nov 09 16:02:46 2011 +0100
@@ -56,7 +56,7 @@
         self.dacapo = os.getenv('DACAPO')
         self.jdk7 = os.getenv('JDK7')
         self.jdk7g = os.getenv('JDK7G')
-        self.maxine_home = os.getenv('MAXINE')
+        self.maxine = os.getenv('MAXINE')
         
         ArgumentParser.__init__(self, prog='gl')
     
@@ -64,20 +64,20 @@
         self.add_argument('--dacapo', help='path to DaCapo 91.12 jar file')
         self.add_argument('--jdk7', help='JDK7 installation in which the GraalVM binary is installed', metavar='<path>')
         self.add_argument('--jdk7g', help='JDK7G installation in which the GraalVM binary is installed', metavar='<path>')
-        self.add_argument('-M', '--maxine', dest='maxine_home', help='path to Maxine code base', metavar='<path>')
+        self.add_argument('-M', '--maxine', dest='maxine', help='path to Maxine code base', metavar='<path>')
         
-    def parse_cmd_line(self):
+    def parse_cmd_line(self, configFile):
         
         self.add_argument('commandAndArgs', nargs=REMAINDER, metavar='command args...')
         
         self.parse_args(namespace=self)
 
-        if not isdir(self.jdk7):
-            self.log('JDK7 is required. Use --jdk7 option or set JDK7 environment variable')
+        if self.jdk7 is None or not isdir(self.jdk7):
+            self.log('JDK7 is required. Use --jdk7 option or set JDK7 environment variable (in ' + configFile + ')')
             self.abort(1)
 
-        if not isdir(self.jdk7g):
-            self.log('JDK7G is required. Use --jdk7g option or set JDK7G environment variable')
+        if self.jdk7g is None or not isdir(self.jdk7g):
+            self.log('JDK7G is required. Use --jdk7g option or set JDK7G environment variable (in ' + configFile + ')')
             self.abort(1)
 
         self.graal_home = dirname(abspath(dirname(sys.argv[0])))
@@ -86,12 +86,13 @@
         """ adds attributes to this object from a file containing key=value lines """
         if exists(configFile):
             with open(configFile) as f:
-                self.log('[loading vars from ' + configFile + ']')
+                #self.log('[loading vars from ' + configFile + ']')
                 for line in f:
-                    kv = line.split('=', 1)
-                    if len(kv) == 2:
-                        k = kv[0].strip().lower()
-                        setattr(self, k, os.path.expandvars(kv[1].strip()))
+                    if not line.startswith('#'):
+                        kv = line.split('=', 1)
+                        if len(kv) == 2:
+                            k = kv[0].strip().lower()
+                            setattr(self, k, os.path.expandvars(kv[1].strip()))
 
     def get_os(self):
         if sys.platform.startswith('darwin'):
@@ -119,14 +120,15 @@
         return self.run_vm(['-Xms1g', '-Xmx2g', '-esa', '-XX:-GraalBailoutIsFatal', '-G:-QuietBailout', '-cp', self.dacapo] + args)
 
     def run_vm(self, args):
-        if self.maxine_home is None:
-            self.log('Path to Maxine code base must be specified with -M option of MAXINE environment variable')
+        if self.maxine is None:
+            configFile = join(dirname(sys.argv[0]), 'glrc')
+            self.log('Path to Maxine code base must be specified with -M option or MAXINE environment variable (in ' + configFile + ')')
             self.abort(1)
-        if not exists(join(self.maxine_home, 'com.oracle.max.graal.hotspot', 'bin', 'com', 'oracle', 'max', 'graal', 'hotspot', 'VMEntriesNative.class')):
-            self.log('Maxine code base path specified -M option or MAXINE environment variable does not contain com.oracle.max.graal.hotspot/bin/com/oracle/max/graal/hotspot/VMEntriesNative.class: ' + self.maxine_home)
+        if not exists(join(self.maxine, 'com.oracle.max.graal.hotspot', 'bin', 'com', 'oracle', 'max', 'graal', 'hotspot', 'VMEntriesNative.class')):
+            self.log('Maxine code base path specified -M option or MAXINE environment variable does not contain com.oracle.max.graal.hotspot/bin/com/oracle/max/graal/hotspot/VMEntriesNative.class: ' + self.maxine)
             self.abort(1)
             
-        os.environ['MAXINE'] = self.maxine_home
+        os.environ['MAXINE'] = self.maxine
         exe = join(self.jdk7, 'bin', self.exe('java'))
         return self.run([exe, '-graal'] + args)
 
@@ -196,7 +198,7 @@
 def main(env):
     configFile = join(dirname(sys.argv[0]), 'glrc')
     env.load_config_file(configFile)
-    env.parse_cmd_line()
+    env.parse_cmd_line(configFile)
     
     if len(env.commandAndArgs) == 0:
         env.print_help()