[pypy-svn] r20020 - in pypy/branch/somepbc-refactoring/pypy: annotation rpython
arigo at codespeak.net
arigo at codespeak.net
Fri Nov 18 17:22:32 CET 2005
Author: arigo
Date: Fri Nov 18 17:22:31 2005
New Revision: 20020
Modified:
pypy/branch/somepbc-refactoring/pypy/annotation/bookkeeper.py
pypy/branch/somepbc-refactoring/pypy/annotation/policy.py
pypy/branch/somepbc-refactoring/pypy/annotation/specialize.py
pypy/branch/somepbc-refactoring/pypy/rpython/annlowlevel.py
Log:
(arigo, mwh, pedronis)
removed now unused specialisation code.
Modified: pypy/branch/somepbc-refactoring/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/annotation/bookkeeper.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/annotation/bookkeeper.py Fri Nov 18 17:22:31 2005
@@ -25,8 +25,6 @@
from pypy.rpython.ootypesystem import ootype
from pypy.rpython.memory import lladdress
-from pypy.annotation.specialize import decide_callable
-
class Stats:
def __init__(self, bookkeeper):
Modified: pypy/branch/somepbc-refactoring/pypy/annotation/policy.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/annotation/policy.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/annotation/policy.py Fri Nov 18 17:22:31 2005
@@ -1,5 +1,5 @@
# base annotation policy for overrides and specialization
-from pypy.annotation.specialize import memo, ctr_location, default_specialize as default
+from pypy.annotation.specialize import memo, default_specialize as default
from pypy.annotation.specialize import argtype, argvalue
# for some reason, model must be imported first,
# or we create a cycle.
@@ -50,7 +50,6 @@
default_specialize = staticmethod(default)
specialize__memo = staticmethod(memo)
- specialize__ctr_location = staticmethod(ctr_location)
specialize__arg0 = staticmethod(argvalue(0))
specialize__argtype0 = staticmethod(argtype(0))
specialize__arg1 = staticmethod(argvalue(1))
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 Fri Nov 18 17:22:31 2005
@@ -1,58 +1,5 @@
# specialization support
-import types, inspect, new
-
-from pypy.tool.sourcetools import valid_identifier, func_with_new_name
-
-def decide_callable(bookkeeper, position, func, args, mono=True, unpacked=False):
- from pypy.objspace.flow.model import SpaceOperation
- from pypy.annotation.model import SomeObject
-
- key = None
- ismeth, im_class, im_self, func, args = unpack_method(bookkeeper, func, args)
-
-
- if position is None or isinstance(position, SpaceOperation):
- spaceop = position
- else:
- fn, block, i = position
- spaceop = block.operations[i]
-
- key, new_args = bookkeeper.annotator.policy.specialize(bookkeeper, spaceop, func, args, mono)
- if key is not None:
- if isinstance(key, SomeObject):
- # direct computation
- return None, key
- assert mono, "not-static call to specialized %s" % func
- args = new_args
- if isinstance(key, tuple):
- # cache specialization
- try:
- newfunc = bookkeeper.cachespecializations[key]
- except KeyError:
- if key[0] is func:
- postfix = key[1:]
- else:
- postfix = key
- newfunc = clone(func, postfix)
- if key[0] is func:
- bookkeeper.cachespecializations[(newfunc,) + postfix] = newfunc
- bookkeeper.cachespecializations[key] = newfunc
- elif isinstance(key, str):
- # specialization explicit in operation annotation
- postfix = key
- newfunc = clone(func, postfix)
- else:
- # specialization already retrieved
- newfunc = key
- newfunc._specializedversionof_ = func
- func = newfunc
-
- if unpacked:
- func = func, args
- else:
- func = repack_method(ismeth, im_class, im_self, func)
-
- return func, key
+import types
def default_specialize(funcdesc, args_s):
argnames, vararg, kwarg = funcdesc.signature
@@ -71,62 +18,6 @@
else:
return funcdesc.cachedgraph(None)
-# helpers
-
-def unpack_method(bookkeeper, func, args):
- if not hasattr(func, 'im_func'):
- return False, None, None, func, args
- if func.im_self is not None:
- s_self = bookkeeper.immutablevalue(func.im_self)
- args = args.prepend(s_self)
- # for debugging only, but useful to keep anyway:
- try:
- func.im_func.class_ = func.im_class
- except AttributeError:
- # probably a builtin function, we don't care to preserve
- # class information then
- pass
- return True, func.im_class, func.im_self, func.im_func, args
-
-def repack_method(ismeth, im_class, im_self, func):
- if not ismeth:
- return func
- return new.instancemethod(func, im_self, im_class)
-
-
-def clone(callb, postfix):
- if not isinstance(postfix, str):
- postfix = '_'.join([getattr(comp, '__name__', str(comp)) for comp in postfix])
-
- name = valid_identifier(callb.__name__ + "__" + postfix)
-
- if isinstance(callb, types.FunctionType):
- newcallb = func_with_new_name(callb, name)
- elif isinstance(callb, (type, types.ClassType)):
- superclasses = iter(inspect.getmro(callb))
- superclasses.next() # skip callb itself
- for cls in superclasses:
- assert not hasattr(cls, "_annspecialcase_"), "for now specialization only for leaf classes"
-
- newdict = {}
- for attrname,val in callb.__dict__.iteritems():
- if attrname == '_annspecialcase_': # don't copy the marker
- continue
- if isinstance(val, types.FunctionType):
- fname = val.func_name
- fname = "%s_for_%s" % (fname, name)
- newval = func_with_new_name(val, fname)
- # xxx more special cases
- else:
- newval = val
- newdict[attrname] = newval
-
- newcallb = type(callb)(name or callb.__name__, (callb,), newdict)
- else:
- raise Exception, "specializing %r?? why??" % callb
-
- return newcallb
-
# ____________________________________________________________________________
# specializations
@@ -175,32 +66,6 @@
for value in lstlst[0]:
yield (value,) + tuple_tail
-#def argtypes(bookkeeper, spaceop, func, args, mono):
-# """NOT_RPYTHON"""
-# from pypy.annotation.model import SomeInstance
-# l = []
-# shape, args_w = args.flatten()
-# for x in args_w:
-# if isinstance(x, SomeInstance) and hasattr(x, 'knowntype'):
-# name = "SI_" + x.knowntype.__name__
-# else:
-# name = x.__class__.__name__
-# l.append(name)
-# return func, "__".join(l)
-
-def ctr_location(bookkeeper, mod, spaceop, orig_cls, args, mono):
- """NOT_RPYTHON"""
- from pypy.annotation.model import SomeInstance
- v = spaceop.result
- s_ins = bookkeeper.annotator.binding(v, extquery=True)
- if s_ins is None:
- return "Giving_"+v.name, args
- else:
- assert isinstance(s_ins, SomeInstance)
- cls = s_ins.classdef.cls
- assert issubclass(cls, orig_cls)
- return cls, args
-
def argvalue(i):
def specialize_argvalue(funcdesc, args_s):
key = args_s[i].const
Modified: pypy/branch/somepbc-refactoring/pypy/rpython/annlowlevel.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/annlowlevel.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/annlowlevel.py Fri Nov 18 17:22:31 2005
@@ -4,7 +4,6 @@
import types
from pypy.annotation import model as annmodel
-from pypy.annotation.specialize import decide_callable
from pypy.annotation.policy import AnnotatorPolicy
from pypy.rpython.lltypesystem import lltype
from pypy.rpython import extfunctable
More information about the Pypy-commit
mailing list