[pypy-svn] r14754 - in pypy/dist/pypy: rpython translator/goal
pedronis at codespeak.net
pedronis at codespeak.net
Tue Jul 19 01:34:12 CEST 2005
Author: pedronis
Date: Tue Jul 19 01:34:11 2005
New Revision: 14754
Added:
pypy/dist/pypy/translator/goal/module-list.example (contents, props changed)
pypy/dist/pypy/translator/goal/order.py (contents, props changed)
Modified:
pypy/dist/pypy/rpython/rtyper.py
Log:
Experimental hook to have more fine control over which blocks get specialized in which order.
The order.py module is an example using it, it uses a list of modules names (or <module-name>:<func-name>) to sort the blocks
use RTYPERORDER=order and edit locally 'module-list.example' as 'module-list' to try it out.
with this approach I discovered e.g. that the ~8500 blocks from (synthetic) functions without module (module=None) all specialize fine.
Modified: pypy/dist/pypy/rpython/rtyper.py
==============================================================================
--- pypy/dist/pypy/rpython/rtyper.py (original)
+++ pypy/dist/pypy/rpython/rtyper.py Tue Jul 19 01:34:11 2005
@@ -59,6 +59,15 @@
print '*' * len(s)
except:
self.seed = 0
+ try:
+ self.order = __import__(os.getenv('RTYPERORDER'), {}, {}, ['*']).order
+ s = 'Using %s.%s for order' % (self.order.__module__, self.order.__name__)
+ print '*' * len(s)
+ print s
+ print '*' * len(s)
+ except:
+ self.order = None
+
def getexceptiondata(self):
return self.exceptiondata # built at the end of specialize()
@@ -114,8 +123,15 @@
import random
r = random.Random(self.seed)
r.shuffle(pending)
+
+ if self.order:
+ tracking = self.order(self.annotator, pending)
+ else:
+ tracking = lambda block: None
+
# specialize all blocks in the 'pending' list
for block in pending:
+ tracking(block)
self.specialize_block(block)
self.already_seen[block] = True
# progress bar
Added: pypy/dist/pypy/translator/goal/module-list.example
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/goal/module-list.example Tue Jul 19 01:34:11 2005
@@ -0,0 +1,71 @@
+pypy.objspace.std.listobject
+pypy.objspace.std.listobject:unwrap
+None
+posixpath
+pypy._cache._exceptions_45b09df9652a189b2135b8b32a956e3e
+pypy.interpreter.argument
+pypy.interpreter.baseobjspace
+pypy.interpreter.compiler
+pypy.interpreter.error
+pypy.interpreter.eval
+pypy.interpreter.executioncontext
+pypy.interpreter.function
+pypy.interpreter.gateway
+pypy.interpreter.generator
+pypy.interpreter.miscutils
+pypy.interpreter.mixedmodule
+pypy.interpreter.module
+pypy.interpreter.nestedscope
+pypy.interpreter.pycode
+pypy.interpreter.pyframe
+pypy.interpreter.pyopcode
+pypy.interpreter.pytraceback
+pypy.interpreter.special
+pypy.interpreter.typedef
+pypy.module.__builtin__
+pypy.module.__builtin__.compiling
+pypy.module.__builtin__.importing
+pypy.module.__builtin__.operation
+pypy.module.sys
+pypy.module.sys.hook
+pypy.module.sys.state
+pypy.module.sys.vm
+pypy.module.unicodedata.function
+pypy.module.unicodedata.unicodedb
+pypy.objspace.descroperation
+pypy.objspace.std.boolobject
+pypy.objspace.std.booltype
+pypy.objspace.std.default
+pypy.objspace.std.dictobject
+pypy.objspace.std.dictproxyobject
+pypy.objspace.std.dictproxytype
+pypy.objspace.std.dicttype
+pypy.objspace.std.fake
+pypy.objspace.std.floatobject
+pypy.objspace.std.floattype
+pypy.objspace.std.intobject
+pypy.objspace.std.inttype
+pypy.objspace.std.iterobject
+pypy.objspace.std.listsort
+pypy.objspace.std.listtype
+pypy.objspace.std.longobject
+pypy.objspace.std.longtype
+pypy.objspace.std.model
+pypy.objspace.std.multimethod
+pypy.objspace.std.noneobject
+pypy.objspace.std.objecttype
+pypy.objspace.std.objspace
+pypy.objspace.std.register_all
+pypy.objspace.std.sliceobject
+pypy.objspace.std.slicetype
+pypy.objspace.std.stdtypedef
+pypy.objspace.std.stringobject
+pypy.objspace.std.stringtype
+pypy.objspace.std.strutil
+pypy.objspace.std.tupleobject
+pypy.objspace.std.tupletype
+pypy.objspace.std.typeobject
+pypy.objspace.std.typetype
+pypy.objspace.std.unicodeobject
+pypy.objspace.std.unicodetype
+pypy.rpython.normalizecalls
Added: pypy/dist/pypy/translator/goal/order.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/goal/order.py Tue Jul 19 01:34:11 2005
@@ -0,0 +1,47 @@
+import sys
+import os
+
+lst = open('module-list', 'r')
+try:
+ prefixes = lst.read().split()
+finally:
+ lst.close()
+
+NOMATCH = sys.maxint
+
+def order(annotator, pending):
+ cache = {}
+ annotated = annotator.annotated
+ def indx(block):
+ func = annotated[block]
+ module = func.__module__
+ if module is None:
+ module = 'None'
+ tag = "%s:%s" % (module, func.__name__)
+ try:
+ return cache[tag]
+ except KeyError:
+ match = NOMATCH
+ i = 0
+ for pfx in prefixes:
+ if tag.startswith(pfx):
+ if match == NOMATCH:
+ match = i
+ else:
+ if len(pfx) > len(prefixes[match]):
+ match = i
+ i += 1
+ cache[tag] = match
+ return match
+
+ pending.sort(lambda blk1, blk2: cmp(indx(blk1), indx(blk2)))
+
+ cur_module = ['$']
+ def track(block):
+ module = annotated[block].__module__
+ if module != cur_module[0]:
+ print "Specializing blocks in module: %s" % module
+ cur_module[0] = module
+ return track
+
+
More information about the Pypy-commit
mailing list