[pypy-svn] r20448 - pypy/branch/somepbc-refactoring/pypy/annotation
arigo at codespeak.net
arigo at codespeak.net
Wed Nov 30 20:23:43 CET 2005
Author: arigo
Date: Wed Nov 30 20:23:42 2005
New Revision: 20448
Modified:
pypy/branch/somepbc-refactoring/pypy/annotation/specialize.py
Log:
Hacking at specialize:methodmemo... This creates more specialized
versions of the memoized() helpers, in the hope that it will avoid
some kind of annotation-mixing we see while translating PyPy.
Modified: pypy/branch/somepbc-refactoring/pypy/annotation/specialize.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/annotation/specialize.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/annotation/specialize.py Wed Nov 30 20:23:42 2005
@@ -2,7 +2,7 @@
import types
from pypy.tool.uid import uid
from pypy.objspace.flow.model import Block, Link, Variable, SpaceOperation
-from pypy.objspace.flow.model import checkgraph
+from pypy.objspace.flow.model import Constant, checkgraph
def default_specialize(funcdesc, args_s):
argnames, vararg, kwarg = funcdesc.signature
@@ -90,8 +90,12 @@
return getattr(x, attrname)
def builder(translator, func):
return translator.buildflowgraph(memoized) # instead of 'func'
- return funcdesc.cachedgraph('memo1', alt_name='memo_%s' % funcdesc.name,
- builder=builder)
+ # if 's' is actually a constant, make sure we get a new copy of
+ # 'memoized' for it. This copy of memoized is all-constant and so
+ # it will get inlined.
+ key = ('memo1', s.is_constant() and Constant(s.const))
+ return funcdesc.cachedgraph(key, alt_name='memo_%s' % funcdesc.name,
+ builder=builder)
def methodmemo(funcdesc, arglist_s):
"""NOT_RPYTHON"""
@@ -160,8 +164,14 @@
return reader_fn(y)
def builder(translator, func):
return translator.buildflowgraph(memoized) # instead of 'func'
- return funcdesc.cachedgraph(s1_type, alt_name='memo_%s' % funcdesc.name,
- builder=builder)
+ # if 's2' is actually a constant, make sure we get a new copy of
+ # 'memoized' for it. This copy of memoized is all-constant and so
+ # it will get inlined. In addition, if this methodmemo 'func' shows
+ # up on instances of different classes, use a different copy of
+ # 'memoized' as well to minimize annotation mixes.
+ key = ('memo2', s1_type, s2.is_constant() and Constant(s2.const))
+ return funcdesc.cachedgraph(key, alt_name='memo_%s' % funcdesc.name,
+ builder=builder)
def argvalue(i):
def specialize_argvalue(funcdesc, args_s):
More information about the Pypy-commit
mailing list