[pypy-svn] r17873 - in pypy/dist/pypy/translator: goal llvm llvm/module
ericvrp at codespeak.net
ericvrp at codespeak.net
Mon Sep 26 13:53:56 CEST 2005
Author: ericvrp
Date: Mon Sep 26 13:53:50 2005
New Revision: 17873
Modified:
pypy/dist/pypy/translator/goal/bench-cronjob.py
pypy/dist/pypy/translator/goal/bench-unix.py
pypy/dist/pypy/translator/llvm/build_llvm_module.py
pypy/dist/pypy/translator/llvm/exception.py
pypy/dist/pypy/translator/llvm/externs2ll.py
pypy/dist/pypy/translator/llvm/genllvm.py
pypy/dist/pypy/translator/llvm/module/support.py
Log:
Ironed out minor shortcomings.
pypy-llvm is (on the snake server) about a factor 14-15 slower then CPython.
pypy-c is over a factor 25 slower that CPython here.
Modified: pypy/dist/pypy/translator/goal/bench-cronjob.py
==============================================================================
--- pypy/dist/pypy/translator/goal/bench-cronjob.py (original)
+++ pypy/dist/pypy/translator/goal/bench-cronjob.py Mon Sep 26 13:53:50 2005
@@ -2,7 +2,8 @@
import time, os, sys, stat
-homedir = os.environ['HOME']
+homedir = os.getenv('HOME')
+os.putenv('PATH','~/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/3.3.6')
def update_pypy():
os.chdir(homedir + '/projects/pypy-dist')
@@ -25,7 +26,9 @@
basename = homedir + '/projects/pypy-dist/pypy/translator/goal/' + 'pypy-' + backend
realname = basename + '-' + revision
- open(realname, 'wb').write( open(basename).read() )
+ pypy = open(basename, 'rb').read()
+ if len(pypy) > 0:
+ open(realname, 'wb').write(pypy)
os.chmod(realname, stat.S_IRWXU)
os.unlink(basename)
@@ -35,15 +38,17 @@
os.chdir(homedir + '/projects/pypy-dist/pypy/translator/goal')
os.system('python bench-unix.py 2>&1' % locals())
-def main():
+def main(backends=[]):
+ if backends == []:
+ backends = 'llvm c'.split()
print time.ctime()
update_pypy()
update_llvm()
- for backend in 'llvm c'.split():
+ for backend in backends:
compile(backend)
benchmark()
print time.ctime()
print 80*'-'
if __name__ == '__main__':
- main()
+ main(sys.argv[1:])
Modified: pypy/dist/pypy/translator/goal/bench-unix.py
==============================================================================
--- pypy/dist/pypy/translator/goal/bench-unix.py (original)
+++ pypy/dist/pypy/translator/goal/bench-unix.py Mon Sep 26 13:53:50 2005
@@ -5,15 +5,16 @@
import os, sys
current_result = '''
-executable richards pystone
-pypy-c-17758 30626ms ( 35.74x) 1268 ( 33.98x)
-pypy-c-17797 29657ms ( 34.61x) error
-pypy-c-17799 29184ms ( 34.05x) error
-pypy-llvm-17758 25361ms ( 29.59x) 1525 ( 28.26x)
-pypy-llvm-17792 20775ms ( 24.24x) 1912 ( 22.53x)
-pypy-llvm-17797 20423ms ( 23.83x) 1943 ( 22.18x)
-pypy-llvm-17799 error error
-python 2.4.2c1 857ms ( 1.00x) 43103 ( 1.00x)
+executable richards pystone
+python 2.4.2c1 864ms ( 1.00x) 43103 ( 1.00x)
+pypy-llvm-17870 12574ms ( 14.55x) 3069 ( 14.04x)
+pypy-llvm-17862 12980ms ( 15.02x) 3041 ( 14.17x)
+pypy-llvm-17797 13473ms ( 15.59x) 2824 ( 15.26x)
+pypy-llvm-17792 13755ms ( 15.92x) 2823 ( 15.27x)
+pypy-llvm-17758 17057ms ( 19.74x) 2229 ( 19.34x)
+pypy-c-17853 22411ms ( 25.94x) 1653 ( 26.07x)
+pypy-c-17806 22315ms ( 25.83x) 1656 ( 26.03x)
+pypy-c-17758 23500ms ( 27.20x) 1570 ( 27.45x)
'''
PYSTONE_CMD = 'from test import pystone;pystone.main(%s)'
@@ -31,47 +32,39 @@
return float(line.split()[len(pattern.split())])
def run_cmd(cmd):
- print "running", cmd
+ #print "running", cmd
pipe = os.popen(cmd + ' 2>&1')
- result = pipe.read()
- #print "done"
- return result
+ return pipe.read()
def run_pystone(executable='python', n=0):
argstr = PYSTONE_CMD % (str(n) and n or '')
txt = run_cmd('%s -c "%s"' % (executable, argstr))
- res = get_result(txt, PYSTONE_PATTERN)
- #print res
- return res
+ return get_result(txt, PYSTONE_PATTERN)
def run_richards(executable='python', n=10):
argstr = RICHARDS_CMD % n
txt = run_cmd('%s -c "%s"' % (executable, argstr))
- res = get_result(txt, RICHARDS_PATTERN)
- #print res
- return res
+ return get_result(txt, RICHARDS_PATTERN)
def get_executables():
exes = [os.path.join('.', name) for name in os.listdir('.') if name.startswith('pypy-')]
exes.sort()
+ exes.reverse()
return exes
-HEADLINE = '''executable richards pystone'''
-FMT = '''%-30s %6dms (%6.2fx) %6d (%6.2fx)'''
+HEADLINE = 'executable richards pystone'
+FMT = '%-30s %6dms (%6.2fx) %6d (%6.2fx)'
def main():
- #print 'getting the richards reference'
+ print HEADLINE
ref_rich = run_richards()
- #print 'getting the pystone reference'
ref_stone = run_pystone()
- res = []
+ print FMT % ('python %s' % sys.version.split()[0], ref_rich, 1.0, ref_stone, 1.0)
for exe in get_executables():
exename = os.path.splitext(exe)[0].lstrip('./')
- res.append( (exename, run_richards(exe, 1), run_pystone(exe)) )
- res.append( ('python %s' % sys.version.split()[0], ref_rich, ref_stone) )
- print HEADLINE
- for exe, rich, stone in res:
- print FMT % (exe, rich, rich / ref_rich, stone, ref_stone / stone)
+ rich = run_richards(exe, 1)
+ stone = run_pystone(exe)
+ print FMT % (exename, rich, rich / ref_rich, stone, ref_stone / stone)
if __name__ == '__main__':
main()
Modified: pypy/dist/pypy/translator/llvm/build_llvm_module.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/build_llvm_module.py (original)
+++ pypy/dist/pypy/translator/llvm/build_llvm_module.py Mon Sep 26 13:53:50 2005
@@ -81,29 +81,29 @@
#ball = str(dirpath.join('%s_all.bc' % b))
#cmds.append("opt %s %s -f -o %s.bc" % (OPTIMIZATION_SWITCHES, ball, b))
- use_gcc = False
+ use_gcc = True
profile = False
cmds = ["llvm-as < %s.ll | opt %s -f -o %s.bc" % (b, OPTIMIZATION_SWITCHES, b)]
if not use_gcc:
- if exe_name:
- cmds.append('llvm-ld %s.bc -native -O5 -l=gc -lm -l=dl -o %s' % (b, exe_name))
- else:
- cmds.append("llc %s %s.bc -f -o %s.s" % (genllvm.exceptionpolicy.llc_options(), b, b))
- cmds.append("as %s.s -o %s.o" % (b, b))
- object_files.append("%s.o" % b)
+ cmds.append("llc %s %s.bc -f -o %s.s" % (genllvm.exceptionpolicy.llc_options(), b, b))
+ cmds.append("as %s.s -o %s.o" % (b, b))
+ object_files.append("%s.o" % b)
else:
cmds.append("llc %s %s.bc -march=c -f -o %s.c" % (genllvm.exceptionpolicy.llc_options(), b, b))
if exe_name:
- cmd = "gcc %s.c -c -O3 -pipe" % b
+ cmd = "gcc %s.c -c -O2 -pipe" % b
if profile:
cmd += ' -pg'
+ else:
+ cmd += ' -fomit-frame-pointer'
cmds.append(cmd)
cmd = "gcc %s.o %s -lm -ldl -pipe -o %s" % (b, gc_libs, exe_name)
if profile:
cmd += ' -pg'
cmds.append(cmd)
source_files.append("%s.c" % b)
+
if exe_name and not profile:
cmds.append('strip ' + exe_name)
upx = os.popen('which upx').read()
Modified: pypy/dist/pypy/translator/llvm/exception.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/exception.py (original)
+++ pypy/dist/pypy/translator/llvm/exception.py Mon Sep 26 13:53:50 2005
@@ -53,7 +53,7 @@
def __init__(self):
pass
- def pyrex_entrypoint_code(self, entrynode):
+ def llvmcode(self, entrynode):
returntype, entrypointname = entrynode.getdecl().split('%', 1)
noresult = self._noresult(returntype)
cconv = DEFAULT_CCONV
@@ -74,6 +74,10 @@
%%result = cast %%RPYTHON_EXCEPTION_VTABLE* %%tmp to int
ret int %%result
}
+
+internal fastcc void %%unwind() {
+ unwind
+}
''' % locals()
def invoke(self, codewriter, targetvar, tail_, cconv, returntype, functionref, args, label, except_label):
@@ -139,7 +143,7 @@
def __init__(self):
self.invoke_count = 0
- def pyrex_entrypoint_code(self, entrynode):
+ def llvmcode(self, entrynode):
returntype, entrypointname = entrynode.getdecl().split('%', 1)
noresult = self._noresult(returntype)
cconv = DEFAULT_CCONV
@@ -163,6 +167,10 @@
%%result = cast %%RPYTHON_EXCEPTION_VTABLE* %%tmp to int
ret int %%result
}
+
+internal fastcc void %%unwind() {
+ ret void
+}
''' % locals()
def transform(self, translator, graph=None):
Modified: pypy/dist/pypy/translator/llvm/externs2ll.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/externs2ll.py (original)
+++ pypy/dist/pypy/translator/llvm/externs2ll.py Mon Sep 26 13:53:50 2005
@@ -38,7 +38,9 @@
funcname , s = s.split('(', 1)
funcnames[funcname] = True
if line.find("internal") == -1:
- line = 'internal %s %s' % (DEFAULT_CCONV, line,)
+ #internal = ''
+ internal = 'internal '
+ line = '%s%s %s' % (internal, DEFAULT_CCONV, line,)
ll_lines.append(line)
# patch calls to function that we just declared fastcc
Modified: pypy/dist/pypy/translator/llvm/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/genllvm.py (original)
+++ pypy/dist/pypy/translator/llvm/genllvm.py Mon Sep 26 13:53:50 2005
@@ -41,7 +41,6 @@
self.exceptionpolicy = exceptionpolicy
extfuncnode.ExternalFuncNode.used_external_functions = {}
self.debug = debug # for debug we create comments of every operation that may be executed
- #exceptionpolicy.transform(translator) #now done in FuncNode (optimization)
if debug:
translator.checkgraphs()
@@ -190,7 +189,7 @@
typ_decl.writeimpl(codewriter)
self._checkpoint('write implementations')
- codewriter.append(self.exceptionpolicy.pyrex_entrypoint_code(self.entrynode))
+ codewriter.append(self.exceptionpolicy.llvmcode(self.entrynode))
# XXX we need to create our own main() that calls the actual entry_point function
if entryfunc_name == 'pypy_entry_point': #XXX just to get on with translate_pypy
Modified: pypy/dist/pypy/translator/llvm/module/support.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/module/support.py (original)
+++ pypy/dist/pypy/translator/llvm/module/support.py Mon Sep 26 13:53:50 2005
@@ -97,7 +97,7 @@
%%exception_type = load %%RPYTHON_EXCEPTION_VTABLE** %%tmp
store %%RPYTHON_EXCEPTION_VTABLE* %%exception_type, %%RPYTHON_EXCEPTION_VTABLE** %%last_exception_type
store %%RPYTHON_EXCEPTION* %%exception_value, %%RPYTHON_EXCEPTION** %%last_exception_value
- unwind ; XXX (1) if exceptionpolicy == 'boehm'
+ call fastcc void %%unwind()
ret void
}
""" % locals())
@@ -110,7 +110,7 @@
br bool %%cond, label %%is_0, label %%is_not_0
is_0:
call fastcc void %%prepare_ZeroDivisionError()
- unwind ; XXX (2) if exceptionpolicy == 'boehm'
+ call fastcc void %%unwind()
ret %s 0
is_not_0:
@@ -134,7 +134,7 @@
; br bool %cond3, label %return_block, label %ovf3
;ovf3:
call fastcc void %prepare_OverflowError()
- unwind ; XXX (3) if exceptionpolicy == 'boehm'
+ call fastcc void %unwind()
ret int 0
"""
More information about the Pypy-commit
mailing list