Commits

Brian Kearns committed 6c566f6 Merge

merge heads

  • Participants
  • Parent commits f4837cb, 14906f1

Comments (0)

Files changed (33)

File pypy/interpreter/baseobjspace.py

 import sys
 
+from rpython.rlib.cache import Cache
+from rpython.tool.uid import HUGEVAL_BYTES
+from rpython.rlib import jit, types
+from rpython.rlib.debug import make_sure_not_resized
+from rpython.rlib.objectmodel import (we_are_translated, newlist_hint,
+     compute_unique_id)
+from rpython.rlib.signature import signature
+from rpython.rlib.rarithmetic import r_uint
+
 from pypy.interpreter.executioncontext import (ExecutionContext, ActionFlag,
     UserDelAction, FrameTraceAction)
 from pypy.interpreter.error import (OperationError, operationerrfmt,
     new_exception_class, typed_unwrap_error_msg)
 from pypy.interpreter.argument import Arguments
 from pypy.interpreter.miscutils import ThreadLocals
-from rpython.rlib.cache import Cache
-from rpython.tool.uid import HUGEVAL_BYTES
-from rpython.rlib import jit
-from rpython.rlib.debug import make_sure_not_resized
-from rpython.rlib.objectmodel import we_are_translated, newlist_hint,\
-     compute_unique_id
-from rpython.rlib.rarithmetic import r_uint
 
 
 __all__ = ['ObjSpace', 'OperationError', 'Wrappable', 'W_Root']
 
 UINT_MAX_32_BITS = r_uint(4294967295)
 
-unpackiterable_driver = jit.JitDriver(name = 'unpackiterable',
-                                      greens = ['tp'],
-                                      reds = ['items', 'w_iterator'])
+unpackiterable_driver = jit.JitDriver(name='unpackiterable',
+                                      greens=['tp'],
+                                      reds=['items', 'w_iterator'])
+
 
 class W_Root(object):
     """This is the abstract root class of all wrapped objects that live
                 raise
             return None
 
+    @signature(types.bool(), returns=types.instance(W_Root))
     def newbool(self, b):
         if b:
             return self.w_True

File pypy/tool/ann_override.py

 # overrides for annotation specific to PyPy codebase
 from rpython.annotator.policy import AnnotatorPolicy
-from rpython.annotator.signature import Sig
 from rpython.flowspace.model import Constant
 from rpython.annotator import specialize
-from pypy.interpreter import baseobjspace
+
 
 def isidentifier(s):
-    if not s: return False
+    if not s:
+        return False
     s = s.replace('_', 'x')
     return s[0].isalpha() and s.isalnum()
 
-# patch - mostly for debugging, to enforce some signatures
-baseobjspace.ObjSpace.newbool.im_func._annenforceargs_ = Sig(lambda s1,s2: s1,
-                                                             bool)
-
 
 class PyPyAnnotatorPolicy(AnnotatorPolicy):
     def __init__(pol, single_space=None):

File rpython/annotator/annrpython.py

             # a graph that has already been rtyped.  Safety-check the new
             # annotations that are passed in, and don't annotate the old
             # graph -- it's already low-level operations!
-            for a, s_newarg in zip(graph.getargs(), cells):
+            for a, s_newarg in zip(block.inputargs, cells):
                 s_oldarg = self.binding(a)
                 assert annmodel.unionof(s_oldarg, s_newarg) == s_oldarg
         else:
             assert not self.frozen
-            for a in cells:
-                assert isinstance(a, annmodel.SomeObject)
             if block not in self.annotated:
                 self.bindinputargs(graph, block, cells)
             else:

File rpython/annotator/binaryop.py

 from rpython.annotator.model import SomeTuple, SomeImpossibleValue, s_ImpossibleValue
 from rpython.annotator.model import SomeInstance, SomeBuiltin, SomeIterator
 from rpython.annotator.model import SomePBC, SomeFloat, s_None, SomeByteArray
-from rpython.annotator.model import SomeExternalObject, SomeWeakRef
+from rpython.annotator.model import SomeWeakRef
 from rpython.annotator.model import SomeAddress, SomeTypedAddressAccess
 from rpython.annotator.model import SomeSingleFloat, SomeLongFloat, SomeType
 from rpython.annotator.model import unionof, UnionError, missing_operation
 from rpython.annotator.model import read_can_only_throw
 from rpython.annotator.model import add_knowntypedata, merge_knowntypedata
-from rpython.annotator.model import SomeGenericCallable
 from rpython.annotator.bookkeeper import getbookkeeper
 from rpython.flowspace.model import Variable, Constant
 from rpython.rlib import rarithmetic
     def is_((obj1, obj2)):
         r = SomeBool()
         if obj2.is_constant():
-            if obj1.is_constant(): 
+            if obj1.is_constant():
                 r.const = obj1.const is obj2.const
             if obj2.const is None and not obj1.can_be_none():
                 r.const = False
 
             def bind(src_obj, tgt_obj, tgt_arg):
                 if hasattr(tgt_obj, 'is_type_of') and src_obj.is_constant():
-                    add_knowntypedata(knowntypedata, True, tgt_obj.is_type_of, 
+                    add_knowntypedata(knowntypedata, True, tgt_obj.is_type_of,
                                       bk.valueoftype(src_obj.const))
 
                 assert annotator.binding(op.args[tgt_arg]) == tgt_obj
         getbookkeeper().count("coerce", obj1, obj2)
         return pair(obj1, obj2).union()   # reasonable enough
 
-    # approximation of an annotation intersection, the result should be the annotation obj or 
+    # approximation of an annotation intersection, the result should be the annotation obj or
     # the intersection of obj and improvement
     def improve((obj, improvement)):
         if not improvement.contains(obj) and obj.contains(improvement):
             return int0.knowntype
         if int1.nonneg and isinstance(op.args[1], Variable):
             case = opname in ('lt', 'le', 'eq')
-                
+
             add_knowntypedata(knowntypedata, case, [op.args[1]],
                               SomeInteger(nonneg=True, knowntype=tointtype(int2)))
         if int2.nonneg and isinstance(op.args[0], Variable):
         # a special case for 'x < 0' or 'x >= 0',
         # where 0 is a flow graph Constant
         # (in this case we are sure that it cannot become a r_uint later)
-        if (isinstance(op.args[1], Constant) and 
+        if (isinstance(op.args[1], Constant) and
             type(op.args[1].value) is int and    # filter out Symbolics
             op.args[1].value == 0):
             if int1.nonneg:
 class __extend__(pairtype(SomeBool, SomeBool)):
 
     def union((boo1, boo2)):
-        s = SomeBool() 
-        if getattr(boo1, 'const', -1) == getattr(boo2, 'const', -2): 
-            s.const = boo1.const 
+        s = SomeBool()
+        if getattr(boo1, 'const', -1) == getattr(boo2, 'const', -2):
+            s.const = boo1.const
         if hasattr(boo1, 'knowntypedata') and \
            hasattr(boo2, 'knowntypedata'):
             ktd = merge_knowntypedata(boo1.knowntypedata, boo2.knowntypedata)
             s.set_knowntypedata(ktd)
-        return s 
+        return s
 
     def and_((boo1, boo2)):
         s = SomeBool()
             if boo2.const:
                 s.const = True
         return s
-        
+
     def xor((boo1, boo2)):
         s = SomeBool()
         if boo1.is_constant() and boo2.is_constant():
             s.const = boo1.const ^ boo2.const
         return s
-        
+
 class __extend__(pairtype(SomeString, SomeString)):
 
     def union((str1, str2)):
         return s_string.__class__()
 
 class __extend__(pairtype(SomeFloat, SomeFloat)):
-    
+
     def union((flt1, flt2)):
         return SomeFloat()
 
 
 
 class __extend__(pairtype(SomeSingleFloat, SomeSingleFloat)):
-    
+
     def union((flt1, flt2)):
         return SomeSingleFloat()
 
 
 class __extend__(pairtype(SomeLongFloat, SomeLongFloat)):
-    
+
     def union((flt1, flt2)):
         return SomeLongFloat()
 
 
 
 class __extend__(pairtype(SomeTuple, SomeInteger)):
-    
+
     def getitem((tup1, int2)):
         if int2.is_immutable_constant():
             try:
 
 
 class __extend__(pairtype(SomeList, SomeInteger)):
-    
+
     def mul((lst1, int2)):
         return lst1.listdef.offspring()
 
     getitem_idx_key = getitem_idx
 
     def setitem((lst1, int2), s_value):
-        getbookkeeper().count("list_setitem", int2)        
+        getbookkeeper().count("list_setitem", int2)
         lst1.listdef.mutate()
         lst1.listdef.generalize(s_value)
     setitem.can_only_throw = [IndexError]
 
     def delitem((lst1, int2)):
-        getbookkeeper().count("list_delitem", int2)        
+        getbookkeeper().count("list_delitem", int2)
         lst1.listdef.resize()
     delitem.can_only_throw = [IndexError]
 
 class __extend__(pairtype(SomeString, SomeInteger)):
 
     def getitem((str1, int2)):
-        getbookkeeper().count("str_getitem", int2)        
+        getbookkeeper().count("str_getitem", int2)
         return SomeChar(no_nul=str1.no_nul)
     getitem.can_only_throw = []
 
     getitem_key = getitem
 
     def getitem_idx((str1, int2)):
-        getbookkeeper().count("str_getitem", int2)        
+        getbookkeeper().count("str_getitem", int2)
         return SomeChar(no_nul=str1.no_nul)
     getitem_idx.can_only_throw = [IndexError]
 
 
 class __extend__(pairtype(SomeUnicodeString, SomeInteger)):
     def getitem((str1, int2)):
-        getbookkeeper().count("str_getitem", int2)        
+        getbookkeeper().count("str_getitem", int2)
         return SomeUnicodeCodePoint()
     getitem.can_only_throw = []
 
     getitem_key = getitem
 
     def getitem_idx((str1, int2)):
-        getbookkeeper().count("str_getitem", int2)        
+        getbookkeeper().count("str_getitem", int2)
         return SomeUnicodeCodePoint()
     getitem_idx.can_only_throw = [IndexError]
 
 
 class __extend__(pairtype(SomeInteger, SomeString),
                  pairtype(SomeInteger, SomeUnicodeString)):
-    
+
     def mul((int1, str2)): # xxx do we want to support this
         getbookkeeper().count("str_mul", str2, int1)
         return str2.basestringclass()
         return result
 
 class __extend__(pairtype(SomeInteger, SomeList)):
-    
+
     def mul((int1, lst2)):
         return lst2.listdef.offspring()
 
 
 class __extend__(pairtype(SomePBC, SomePBC)):
 
-    def union((pbc1, pbc2)):       
+    def union((pbc1, pbc2)):
         d = pbc1.descriptions.copy()
         d.update(pbc2.descriptions)
         return SomePBC(d, can_be_None = pbc1.can_be_None or pbc2.can_be_None)
                     s.const = False    # no common desc in the two sets
         return s
 
-class __extend__(pairtype(SomeGenericCallable, SomePBC)):
-    def union((gencall, pbc)):
-        for desc in pbc.descriptions:
-            unique_key = desc
-            bk = desc.bookkeeper
-            s_result = bk.emulate_pbc_call(unique_key, pbc, gencall.args_s)
-            s_result = unionof(s_result, gencall.s_result)
-            assert gencall.s_result.contains(s_result)
-        return gencall
-
-class __extend__(pairtype(SomePBC, SomeGenericCallable)):
-    def union((pbc, gencall)):
-        return pair(gencall, pbc).union()
-
 class __extend__(pairtype(SomeImpossibleValue, SomeObject)):
     def union((imp1, obj2)):
         return obj2
 _make_none_union('SomeUnicodeString', 'can_be_None=True')
 _make_none_union('SomeList',         'obj.listdef')
 _make_none_union('SomeDict',          'obj.dictdef')
-_make_none_union('SomeExternalObject', 'obj.knowntype')
 _make_none_union('SomeWeakRef',         'obj.classdef')
 
 # getitem on SomePBCs, in particular None fails
             raise AnnotatorError('add on %r' % pbc)
         return s_ImpossibleValue
 
-class __extend__(pairtype(SomeExternalObject, SomeExternalObject)):
-    def union((ext1, ext2)):
-        if ext1.knowntype == ext2.knowntype:
-            return SomeExternalObject(ext1.knowntype)
-        return SomeObject()
-
 # ____________________________________________________________
 # annotation of low-level types
 from rpython.annotator.model import SomePtr, SomeOOInstance, SomeOOClass

File rpython/annotator/bookkeeper.py

         elif ishashable(x) and x in BUILTIN_ANALYZERS:
             _module = getattr(x,"__module__","unknown")
             result = SomeBuiltin(BUILTIN_ANALYZERS[x], methodname="%s.%s" % (_module, x.__name__))
-        elif extregistry.is_registered(x, self.policy):
-            entry = extregistry.lookup(x, self.policy)
+        elif extregistry.is_registered(x):
+            entry = extregistry.lookup(x)
             result = entry.compute_annotation_bk(self)
         elif isinstance(x, lltype._ptr):
             result = SomePtr(lltype.typeOf(x))

File rpython/annotator/model.py

 
 from __future__ import absolute_import
 
+import inspect
+import weakref
 from types import BuiltinFunctionType, MethodType
+
 import rpython
 from rpython.tool import descriptor
 from rpython.tool.pairtype import pair, extendabletype
-from rpython.rlib.rarithmetic import r_uint, base_int
-from rpython.rlib.rarithmetic import r_singlefloat, r_longfloat
-import inspect, weakref
+from rpython.rlib.rarithmetic import r_uint, base_int, r_singlefloat, r_longfloat
+
 
 class State(object):
     # A global attribute :-(  Patch it with 'True' to enable checking of
     def __eq__(self, other):
         return (self.__class__ is other.__class__ and
                 self.__dict__  == other.__dict__)
+
     def __ne__(self, other):
         return not (self == other)
+
     def __repr__(self):
         try:
             reprdict = TLS.reprdict
                     m = getattr(self, 'fmt_' + k, repr)
                     r = m(v)
                     if r is not None:
-                        args.append('%s=%s'%(k, r))
+                        args.append('%s=%s' % (k, r))
                 kwds = ', '.join(args)
             finally:
                 del reprdict[self]
 
     def fmt_knowntype(self, t):
         return t.__name__
-    
+
     def contains(self, other):
         if self == other:
             return True
     def can_be_none(self):
         return False
 
+
 class SomeFloat(SomeObject):
     "Stands for a float or an integer."
     knowntype = float   # if we don't know if it's a float or an int,
     def can_be_none(self):
         return False
 
+
 class SomeSingleFloat(SomeObject):
     "Stands for an r_singlefloat."
     # No operation supported, not even union with a regular float
     def can_be_none(self):
         return False
 
+
 class SomeLongFloat(SomeObject):
     "Stands for an r_longfloat."
     # No operation supported, not even union with a regular float
     def can_be_none(self):
         return False
 
+
 class SomeInteger(SomeFloat):
     "Stands for an object which is known to be an integer."
     knowntype = int
+
     # size is in multiples of C's sizeof(long)!
     def __init__(self, nonneg=False, unsigned=None, knowntype=None):
         assert (knowntype is None or knowntype is int or
         self.nonneg = unsigned or nonneg
         self.unsigned = unsigned  # rpython.rlib.rarithmetic.r_uint
 
+
 class SomeBool(SomeInteger):
     "Stands for true or false."
     knowntype = bool
     nonneg = True
     unsigned = False
+
     def __init__(self):
         pass
+
     def set_knowntypedata(self, knowntypedata):
         assert not hasattr(self, 'knowntypedata')
         if knowntypedata:
             self.knowntypedata = knowntypedata
 
+
 class SomeStringOrUnicode(SomeObject):
     """Base class for shared implementation of SomeString and SomeUnicodeString.
 
     Cannot be an annotation."""
 
     immutable = True
-    can_be_None=False
+    can_be_None = False
     no_nul = False  # No NUL character in the string.
 
     def __init__(self, can_be_None=False, no_nul=False):
         d1 = self.__dict__
         d2 = other.__dict__
         if not TLS.check_str_without_nul:
-            d1 = d1.copy(); d1['no_nul'] = 0   # ignored
-            d2 = d2.copy(); d2['no_nul'] = 0   # ignored
+            d1 = d1.copy()
+            d1['no_nul'] = 0
+            d2 = d2.copy()
+            d2['no_nul'] = 0
         return d1 == d2
 
     def nonnoneify(self):
     def nonnulify(self):
         return self.__class__(can_be_None=self.can_be_None, no_nul=True)
 
+
 class SomeString(SomeStringOrUnicode):
     "Stands for an object which is known to be a string."
     knowntype = str
 
+
 class SomeUnicodeString(SomeStringOrUnicode):
     "Stands for an object which is known to be an unicode string"
     knowntype = unicode
 
+
 class SomeByteArray(SomeStringOrUnicode):
     knowntype = bytearray
 
+
 class SomeChar(SomeString):
     "Stands for an object known to be a string of length 1."
     can_be_None = False
+
     def __init__(self, no_nul=False):    # no 'can_be_None' argument here
         if no_nul:
             self.no_nul = True
 
+
 class SomeUnicodeCodePoint(SomeUnicodeString):
     "Stands for an object known to be a unicode codepoint."
     can_be_None = False
+
     def __init__(self, no_nul=False):    # no 'can_be_None' argument here
         if no_nul:
             self.no_nul = True
 SomeUnicodeString.basestringclass = SomeUnicodeString
 SomeUnicodeString.basecharclass = SomeUnicodeCodePoint
 
+
 class SomeList(SomeObject):
     "Stands for a homogenous list of any length."
     knowntype = list
+
     def __init__(self, listdef):
         self.listdef = listdef
+
     def __eq__(self, other):
         if self.__class__ is not other.__class__:
             return False
     def can_be_none(self):
         return True
 
+
 class SomeTuple(SomeObject):
     "Stands for a tuple of known length."
     knowntype = tuple
     immutable = True
+
     def __init__(self, items):
         self.items = tuple(items)   # tuple of s_xxx elements
         for i in items:
     def can_be_none(self):
         return False
 
+
 class SomeDict(SomeObject):
     "Stands for a dict."
     knowntype = dict
+
     def __init__(self, dictdef):
         self.dictdef = dictdef
+
     def __eq__(self, other):
         if self.__class__ is not other.__class__:
             return False
         if len(const) < 20:
             return repr(const)
         else:
-            return '{...%s...}'%(len(const),)
+            return '{...%s...}' % (len(const),)
 
 
 class SomeIterator(SomeObject):
     "Stands for an iterator returning objects from a given container."
     knowntype = type(iter([]))  # arbitrarily chose seqiter as the type
+
     def __init__(self, s_container, *variant):
         self.variant = variant
         self.s_container = s_container
     def can_be_none(self):
         return False
 
+
 class SomeInstance(SomeObject):
     "Stands for an instance of a (user-defined) class."
 
 
     def fmt_knowntype(self, kt):
         return None
+
     def fmt_classdef(self, cdef):
         if cdef is None:
             return 'object'
         else:
             return cdef.name
+
     def fmt_flags(self, flags):
         if flags:
             return repr(flags)
         if hasattr(self, 'const'):
             return None
         else:
-            return '{...%s...}'%(len(pbis),)
+            return '{...%s...}' % (len(pbis),)
 
     def fmt_knowntype(self, kt):
         if self.is_constant():
         else:
             return kt.__name__
 
-class SomeGenericCallable(SomeObject):
-    """ Stands for external callable with known signature
-    """
-    def __init__(self, args, result):
-        self.args_s = args
-        self.s_result = result
-
-    def can_be_None(self):
-        return True
 
 class SomeBuiltin(SomeObject):
     "Stands for a built-in function or method with special-cased analysis."
     def can_be_none(self):
         return False
 
+
 class SomeBuiltinMethod(SomeBuiltin):
     """ Stands for a built-in method which has got special meaning
     """
     knowntype = MethodType
 
-class SomeExternalObject(SomeObject):
-    """Stands for an object of 'external' type.  External types have a Repr
-    controlled by rpython.rtyper.extregistry."""
-
-    def __init__(self, knowntype):
-        self.knowntype = knowntype
-
-    def can_be_none(self):
-        return True
 
 class SomeImpossibleValue(SomeObject):
     """The empty set.  Instances are placeholders for objects that
     will never show up at run-time, e.g. elements of an empty list."""
     immutable = True
-    annotationcolor = (160,160,160)
+    annotationcolor = (160, 160, 160)
 
     def can_be_none(self):
         return False
 
 s_None = SomePBC([], can_be_None=True)
 s_Bool = SomeBool()
-s_Int  = SomeInteger()
+s_Int = SomeInteger()
 s_ImpossibleValue = SomeImpossibleValue()
 s_Str0 = SomeString(no_nul=True)
 
+
 # ____________________________________________________________
 # weakrefs
 
 class SomeWeakRef(SomeObject):
     knowntype = weakref.ReferenceType
     immutable = True
+
     def __init__(self, classdef):
         # 'classdef' is None for known-to-be-dead weakrefs.
         self.classdef = classdef
 
 from rpython.rtyper.lltypesystem import llmemory
 
+
 class SomeAddress(SomeObject):
     immutable = True
 
     def is_null_address(self):
         return self.is_immutable_constant() and not self.const
 
+
 # The following class is used to annotate the intermediate value that
 # appears in expressions of the form:
 # addr.signed[offset] and addr.signed[offset] = value
 # annotation of low-level types
 
 from rpython.rtyper.lltypesystem import lltype
-from rpython.rtyper.ootypesystem import ootype
+
 
 class SomePtr(SomeObject):
     knowntype = lltype._ptr
     immutable = True
+
     def __init__(self, ll_ptrtype):
         assert isinstance(ll_ptrtype, lltype.Ptr)
         self.ll_ptrtype = ll_ptrtype
     def can_be_none(self):
         return False
 
+
 class SomeInteriorPtr(SomePtr):
     def __init__(self, ll_ptrtype):
         assert isinstance(ll_ptrtype, lltype.InteriorPtr)
         self.ll_ptrtype = ll_ptrtype
 
+
 class SomeLLADTMeth(SomeObject):
     immutable = True
+
     def __init__(self, ll_ptrtype, func):
         self.ll_ptrtype = ll_ptrtype
-        self.func = func 
+        self.func = func
 
     def can_be_none(self):
         return False
 
+
 class SomeOOObject(SomeObject):
     def __init__(self):
+        from rpython.rtyper.ootypesystem import ootype
         self.ootype = ootype.Object
 
+
 class SomeOOClass(SomeObject):
     def __init__(self, ootype):
         self.ootype = ootype
 
+
 class SomeOOInstance(SomeObject):
     def __init__(self, ootype, can_be_None=False):
         self.ootype = ootype
         self.can_be_None = can_be_None
 
+
 class SomeOOBoundMeth(SomeObject):
     immutable = True
+
     def __init__(self, ootype, name):
         self.ootype = ootype
         self.name = name
 
+
 class SomeOOStaticMeth(SomeObject):
     immutable = True
+
     def __init__(self, method):
         self.method = method
 
     (SomeAddress(), llmemory.Address),
 ]
 
+
 def annotation_to_lltype(s_val, info=None):
+    from rpython.rtyper.ootypesystem import ootype
+
     if isinstance(s_val, SomeOOInstance):
         return s_val.ootype
     if isinstance(s_val, SomeOOStaticMeth):
 
 ll_to_annotation_map = dict([(ll, ann) for ann, ll in annotation_to_ll_map])
 
+
 def lltype_to_annotation(T):
+    from rpython.rtyper.ootypesystem import ootype
+
     try:
         s = ll_to_annotation_map.get(T)
     except TypeError:
     else:
         return s
 
+
 def ll_to_annotation(v):
     if v is None:
         # i think we can only get here in the case of void-returning
         T = lltype.InteriorPtr(lltype.typeOf(ob), v._T, v._offsets)
         return SomeInteriorPtr(T)
     return lltype_to_annotation(lltype.typeOf(v))
-    
+
+
 # ____________________________________________________________
 
 class UnionError(Exception):
     """Signals an suspicious attempt at taking the union of
     deeply incompatible SomeXxx instances."""
 
+
 def unionof(*somevalues):
     "The most precise SomeValue instance that contains all the values."
     try:
             s1 = pair(s1, s2).union()
     return s1
 
+
 # make knowntypedata dictionary
 
 def add_knowntypedata(ktd, truth, vars, s_obj):
     for v in vars:
         ktd[(truth, v)] = s_obj
 
+
 def merge_knowntypedata(ktd1, ktd2):
     r = {}
     for truth_v in ktd1:
             r[truth_v] = unionof(ktd1[truth_v], ktd2[truth_v])
     return r
 
+
 def not_const(s_obj):
     if s_obj.is_constant() and not isinstance(s_obj, SomePBC):
         new_s_obj = SomeObject.__new__(s_obj.__class__)
         s_obj = new_s_obj
     return s_obj
 
+
 # ____________________________________________________________
 # internal
 
 def commonbase(cls1, cls2):   # XXX single inheritance only  XXX hum
     l1 = inspect.getmro(cls1)
-    l2 = inspect.getmro(cls2) 
-    if l1[-1] != object: 
-        l1 = l1 + (object,) 
-    if l2[-1] != object: 
-        l2 = l2 + (object,) 
-    for x in l1: 
-        if x in l2: 
-            return x 
+    l2 = inspect.getmro(cls2)
+    if l1[-1] != object:
+        l1 = l1 + (object,)
+    if l2[-1] != object:
+        l2 = l2 + (object,)
+    for x in l1:
+        if x in l2:
+            return x
     assert 0, "couldn't get to commonbase of %r and %r" % (cls1, cls2)
 
+
 def missing_operation(cls, name):
     def default_op(*args):
         if args and isinstance(args[0], tuple):
             flattened = args
         for arg in flattened:
             if arg.__class__ is SomeObject and arg.knowntype is not type:
-                return  SomeObject()
+                return SomeObject()
         bookkeeper = rpython.annotator.bookkeeper.getbookkeeper()
         bookkeeper.warning("no precise annotation supplied for %s%r" % (name, args))
         return s_ImpossibleValue
     setattr(cls, name, default_op)
 
+
 class HarmlesslyBlocked(Exception):
     """Raised by the unaryop/binaryop to signal a harmless kind of
     BlockedInference: the current block is blocked, but not in a way

File rpython/annotator/signature.py

         return SomeUnicodeString()
     elif t is types.NoneType:
         return s_None
-    elif bookkeeper and extregistry.is_registered_type(t, bookkeeper.policy):
-        entry = extregistry.lookup_type(t, bookkeeper.policy)
+    elif bookkeeper and extregistry.is_registered_type(t):
+        entry = extregistry.lookup_type(t)
         return entry.compute_annotation_bk(bookkeeper)
     elif t is type:
         return SomeType()
 
     def __init__(self, *argtypes):
         self.argtypes = argtypes
-        
+
     def __call__(self, funcdesc, inputcells):
         from rpython.rtyper.lltypesystem import lltype
         args_s = []

File rpython/annotator/test/test_annrpython.py

         s = a.build_types(fun, [])
         assert s.const == 0
 
-    def test_some_generic_function_call(self):
-        def h(x):
-            return int(x)
-
-        def c(x):
-            return int(x)
-
-        def g(a, x):
-            if x == -1:
-                a = None
-            if x < 0:
-                if x == -1:
-                    a = h
-                else:
-                    a = c
-                x = x + .01
-            return a(x)
-
-        #def fun(x):
-
-        a = self.RPythonAnnotator(policy=policy.AnnotatorPolicy())
-        s = a.build_types(g, [annmodel.SomeGenericCallable(
-            args=[annmodel.SomeFloat()], result=annmodel.SomeInteger()),
-                              annmodel.SomeFloat()])
-        assert isinstance(s, annmodel.SomeInteger)
-        assert not hasattr(s, 'const')
-
     def test_compare_int_bool(self):
         def fun(x):
             return 50 < x

File rpython/annotator/test/test_signature.py

     assert _annotation_key({str:(str, [str])}) == ('dict', (str, (str, ('list', str))))
     for i in ([[str]], [str], (int, int, {str: [str]})):
         assert hash(_annotation_key(i))
-
-def test_genericcallable():
-    py.test.skip("this two annotations should be equal - fix!")
-    from rpython.rtyper.extfunc import genericcallable
-    s1 = annotation([genericcallable([str], int)])
-    s2 = annotation([genericcallable([str], int)])
-    assert s1 == s2

File rpython/annotator/unaryop.py

      SomeObject, SomeInteger, SomeBool, SomeString, SomeChar, SomeList, \
      SomeDict, SomeTuple, SomeImpossibleValue, SomeUnicodeCodePoint, \
      SomeInstance, SomeBuiltin, SomeFloat, SomeIterator, SomePBC, \
-     SomeExternalObject, SomeTypedAddressAccess, SomeAddress, SomeType, \
+     SomeTypedAddressAccess, SomeAddress, SomeType, \
      s_ImpossibleValue, s_Bool, s_None, \
      unionof, missing_operation, add_knowntypedata, HarmlesslyBlocked, \
-     SomeGenericCallable, SomeWeakRef, SomeUnicodeString
+     SomeWeakRef, SomeUnicodeString
 from rpython.annotator.bookkeeper import getbookkeeper
 from rpython.annotator import builtin
 from rpython.annotator.binaryop import _clone ## XXX where to put this?
-from rpython.rtyper import extregistry
 from rpython.tool.error import AnnotatorError
 
 # convenience only!
         s_value = dct.dictdef.read_value()
         return (isinstance(s_key, SomeImpossibleValue) or
                 isinstance(s_value, SomeImpossibleValue))
-        
+
     def len(dct):
         if dct._is_empty():
             return immutablevalue(0)
         else:
             return SomeObject()    # len() on a pbc? no chance
 
-class __extend__(SomeGenericCallable):
-    def call(self, args):
-        for arg, expected in zip(args.unpack()[0], self.args_s):
-            assert expected.contains(arg)
-        return self.s_result
-
-class __extend__(SomeExternalObject):
-    def getattr(p, s_attr):
-        if s_attr.is_constant() and isinstance(s_attr.const, str):
-            attr = s_attr.const
-            entry = extregistry.lookup_type(p.knowntype)
-            s_value = entry.get_field_annotation(p.knowntype, attr)
-            return s_value
-        else:
-            return SomeObject()
-    getattr.can_only_throw = []
-
-    def setattr(p, s_attr, s_value):
-        assert s_attr.is_constant()
-        attr = s_attr.const
-        entry = extregistry.lookup_type(p.knowntype)
-        entry.set_field_annotation(p.knowntype, attr, s_value)
-
-    def is_true(p):
-        return s_Bool
-
 # annotation of low-level types
 from rpython.annotator.model import SomePtr, SomeLLADTMeth
 from rpython.annotator.model import SomeOOInstance, SomeOOBoundMeth, SomeOOStaticMeth
             return SomeOOBoundMeth(r.ootype, s_attr.const)
         return ll_to_annotation(v)
 
-    def setattr(r, s_attr, s_value): 
+    def setattr(r, s_attr, s_value):
         assert s_attr.is_constant(), "setattr on ref %r with non-constant field-name" % r.ootype
         v = annotation_to_lltype(s_value)
         example = r.ootype._example()

File rpython/jit/backend/arm/assembler.py

             assert 0, 'unsupported case'
 
     def _mov_stack_to_loc(self, prev_loc, loc, cond=c.AL):
+        helper = self._regalloc.get_free_reg()
         if loc.is_reg():
             assert prev_loc.type != FLOAT, 'trying to load from an \
                 incompatible location into a core register'
             # unspill a core register
             offset = prev_loc.value
             is_imm = check_imm_arg(offset, size=0xFFF)
-            if not is_imm:
-                self.mc.PUSH([r.lr.value], cond=cond)
-            self.load_reg(self.mc, loc, r.fp, offset, cond=cond, helper=r.lr)
-            if not is_imm:
-                self.mc.POP([r.lr.value], cond=cond)
+            helper = r.lr if helper is None else helper
+            save_helper = not is_imm and helper is r.lr
         elif loc.is_vfp_reg():
             assert prev_loc.type == FLOAT, 'trying to load from an \
                 incompatible location into a float register'
             # load spilled value into vfp reg
             offset = prev_loc.value
             is_imm = check_imm_arg(offset)
-            if not is_imm:
-                self.mc.PUSH([r.ip.value], cond=cond)
-            self.load_reg(self.mc, loc, r.fp, offset, cond=cond, helper=r.ip)
-            if not is_imm:
-                self.mc.POP([r.ip.value], cond=cond)
+            helper = r.ip if helper is None else helper
+            save_helper = not is_imm and helper is r.ip
         else:
             assert 0, 'unsupported case'
+        if save_helper:
+            self.mc.PUSH([helper.value], cond=cond)
+        self.load_reg(self.mc, loc, r.fp, offset, cond=cond, helper=helper)
+        if save_helper:
+	    self.mc.POP([helper.value], cond=cond)
+
 
     def _mov_imm_float_to_loc(self, prev_loc, loc, cond=c.AL):
         if loc.is_vfp_reg():

File rpython/jit/backend/arm/regalloc.py

                                                     selected_reg=selected_reg)
         return reg
 
+    def get_free_reg():
+        free_regs = self.free_regs        
+        for i in range(len(free_regs), -1, -1):
+            if free_regs[i] in self.save_around_call_regs:
+                continue
+            return free_regs[i]
+
 
 class Regalloc(BaseRegalloc):
 
                                                                 selected_reg)
         else:
             return self.rm.get_scratch_reg(type, forbidden_vars, selected_reg)
+    def get_free_reg(self):
+        return self.rm.get_free_reg()
 
     def free_temp_vars(self):
         self.rm.free_temp_vars()

File rpython/jit/backend/arm/test/test_calling_convention.py

 from rpython.jit.backend.arm.codebuilder import ARMv7Builder
 from rpython.jit.backend.arm import registers as r
 from rpython.jit.backend.arm.test.support import skip_unless_run_slow_tests
+from rpython.jit.backend.arm.test.test_runner import boxfloat, constfloat
+from rpython.jit.metainterp.resoperation import ResOperation, rop
+from rpython.jit.metainterp.history import (AbstractFailDescr,
+                                         AbstractDescr,
+                                         BasicFailDescr,
+                                         BasicFinalDescr,
+                                         BoxInt, Box, BoxPtr,
+                                         JitCellToken, TargetToken,
+                                         ConstInt, ConstPtr,
+                                         BoxObj,
+                                         ConstObj, BoxFloat, ConstFloat)
+
 skip_unless_run_slow_tests()
 
 class TestARMCallingConvention(CallingConvTests):
         ops = """
         [%s]
         i99 = call(ConstClass(func_ptr), 22, descr=calldescr)
-        force_spill(i0)
-        force_spill(i1)
-        force_spill(i2)
-        force_spill(i3)
-        force_spill(i4)
-        force_spill(i5)
-        force_spill(i6)
-        force_spill(i7)
-        force_spill(i8)
-        force_spill(i9)
-        force_spill(i10)
         guard_true(i0) [%s, i99]
         finish()""" % (args, args)
         loop = parse(ops, namespace=locals())
         for x in range(11):
             assert self.cpu.get_int_value(deadframe, x) == x
         assert self.cpu.get_int_value(deadframe, 11) == 38
+
+   
+    def test_float_hf_call_mixed(self):
+        if not self.cpu.supports_floats:
+            py.test.skip("requires floats")
+        cpu = self.cpu
+        callargs = []
+        def func(f0, f1, f2, f3, f4, f5, f6, i0, f7, i1, f8, f9):
+            callargs.append(zip(range(12),
+			[f0, f1, f2, f3, f4, f5, f6, i0, f7, i1, f8, f9]))
+            return f0 + f1 + f2 + f3 + f4 + f5 + f6 + float(i0 + i1) + f7 + f8 + f9
+        F = lltype.Float
+        I = lltype.Signed
+        FUNC = self.FuncType([F] * 7 + [I] + [F] + [I] + [F]* 2, F)
+        FPTR = self.Ptr(FUNC)
+        func_ptr = llhelper(FPTR, func)
+        calldescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
+                                    EffectInfo.MOST_GENERAL)
+        funcbox = self.get_funcbox(cpu, func_ptr)
+        args = ([boxfloat(.1) for i in range(7)] +
+                [BoxInt(1), boxfloat(.2), BoxInt(2), boxfloat(.3),
+                 boxfloat(.4)])
+        res = self.execute_operation(rop.CALL,
+                                     [funcbox] + args,
+                                     'float', descr=calldescr)
+        for i,j in enumerate(callargs[0]):
+            box = args[i]
+            if box.type == 'f':
+                assert (i, args[i].getfloat()) == j
+            else:
+                assert (i, args[i].getint()) == j
+        assert abs(res.getfloat() - 4.6) < 0.0001
+
+    def test_float_hf_call_float(self):
+        if not self.cpu.supports_floats:
+            py.test.skip("requires floats")
+        cpu = self.cpu
+        callargs = []
+        def func(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9):
+            callargs.append(zip(range(10),
+			[f0, f1, f2, f3, f4, f5, f6, f7, f8, f9]))
+            return f0 + f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9
+        F = lltype.Float
+        FUNC = self.FuncType([F] * 10, F)
+        FPTR = self.Ptr(FUNC)
+        func_ptr = llhelper(FPTR, func)
+        calldescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
+                                    EffectInfo.MOST_GENERAL)
+        funcbox = self.get_funcbox(cpu, func_ptr)
+        args = ([boxfloat(.1) for i in range(10)])
+        res = self.execute_operation(rop.CALL,
+                                     [funcbox] + args,
+                                     'float', descr=calldescr)
+        for i,j in enumerate(callargs[0]):
+            assert (i, 0.1) == j
+        assert abs(res.getfloat() - 1) < 0.0001
+
+    def test_float_hf_call_int(self):
+        cpu = self.cpu
+        callargs = []
+        def func(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9):
+            callargs.append(zip(range(10),
+			[f0, f1, f2, f3, f4, f5, f6, f7, f8, f9]))
+            return f0 + f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9
+
+        I = lltype.Signed
+        FUNC = self.FuncType([I] * 10, I)
+        FPTR = self.Ptr(FUNC)
+        func_ptr = llhelper(FPTR, func)
+        calldescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
+                                    EffectInfo.MOST_GENERAL)
+        funcbox = self.get_funcbox(cpu, func_ptr)
+        args = ([BoxInt(1) for i in range(10)])
+        res = self.execute_operation(rop.CALL,
+                                     [funcbox] + args,
+                                     'int', descr=calldescr)
+        for i,j in enumerate(callargs[0]):
+            assert (i, 1) == j
+        assert res.getint() == 10

File rpython/jit/backend/arm/test/test_regalloc_mov.py

         self.instrs.append(i)
         return i
 
+class MockRegalloc(object):
+    def get_free_reg(self):
+        return r('helper')
 
 class BaseMovTest(object):
     def setup_method(self, method):
         self.builder = MockBuilder()
         self.asm = instantiate(AssemblerARM)
+        self.asm._regalloc = MockRegalloc()
         self.asm.mc = self.builder
 
     def validate(self, expected):
         s = stack(8191)
         r6 = r(6)
         expected = [
-                    mi('PUSH', [lr.value], cond=AL),
-                    mi('gen_load_int', lr.value, s.value, cond=AL),
-                    mi('LDR_rr', r6.value, fp.value, lr.value, cond=AL),
-                    mi('POP', [lr.value], cond=AL)]
+                    mi('gen_load_int', 'helper', s.value, cond=AL),
+                    mi('LDR_rr', r6.value, fp.value, 'helper', cond=AL)]
         self.mov(s, r6, expected)
 
     def test_mov_float_imm_to_vfp_reg(self):
     def test_mov_vfp_reg_to_stack(self):
         reg = vfp(7)
         s = stack_float(3)
-        expected = [mi('VSTR', reg.value, fp.value, imm=188, cond=AL)]
+        expected = [mi('VSTR', reg.value, fp.value, imm=192, cond=AL)]
         self.mov(reg, s, expected)
 
     def test_mov_vfp_reg_to_large_stackloc(self):
     def test_mov_stack_to_vfp_reg(self):
         reg = vfp(7)
         s = stack_float(3)
-        expected = [mi('VLDR', reg.value, fp.value, imm=188, cond=AL)]
+        expected = [mi('VLDR', reg.value, fp.value, imm=192, cond=AL)]
         self.mov(s, reg, expected)
 
     def test_mov_big_stackloc_to_vfp_reg(self):
 
     def test_push_big_stack(self):
         s = stack(1025)
-        e = [mi('PUSH', [lr.value], cond=AL),
-            mi('gen_load_int', lr.value, s.value, cond=AL),
-            mi('LDR_rr', ip.value, fp.value, lr.value, cond=AL),
-            mi('POP', [lr.value], cond=AL),
+        e = [mi('gen_load_int', 'helper', s.value, cond=AL),
+            mi('LDR_rr', ip.value, fp.value, 'helper', cond=AL),
             mi('PUSH', [ip.value], cond=AL)
             ]
         self.push(s, e)
     def test_push_stack_float(self):
         sf = stack_float(4)
         e = [
-            mi('VLDR', vfp_ip.value, fp.value, imm=192, cond=AL),
+            mi('VLDR', vfp_ip.value, fp.value, imm=196, cond=AL),
             mi('VPUSH', [vfp_ip.value], cond=AL),
         ]
         self.push(sf, e)
     def test_push_large_stackfloat(self):
         sf = stack_float(100)
         e = [
-            mi('PUSH', [ip.value], cond=AL),
-            mi('gen_load_int', ip.value, sf.value, cond=AL),
-            mi('ADD_rr', ip.value, fp.value, ip.value, cond=AL),
-            mi('VLDR', vfp_ip.value, ip.value, cond=AL),
-            mi('POP', [ip.value], cond=AL),
+            mi('gen_load_int', 'helper', sf.value, cond=AL),
+            mi('ADD_rr', 'helper', fp.value, 'helper', cond=AL),
+            mi('VLDR', vfp_ip.value, 'helper', cond=AL),
             mi('VPUSH', [vfp_ip.value], cond=AL),
         ]
         self.push(sf, e)

File rpython/rlib/jit.py

             return result
 
         return decorate
-        
+
 
     def clone(self):
         assert self.inline_jit_merge_point, 'JitDriver.clone works only after @inline'
         assert s_name.is_constant()
         if s_name.const == 'enable_opts':
             assert annmodel.SomeString(can_be_None=True).contains(s_value)
-        else: 
+        else:
             assert (s_value == annmodel.s_None or
                     annmodel.SomeInteger().contains(s_value))
         return annmodel.s_None
 
 class AsmInfo(object):
     """ An addition to JitDebugInfo concerning assembler. Attributes:
-    
+
     ops_offset - dict of offsets of operations or None
     asmaddr - (int) raw address of assembler block
     asmlen - assembler block length
 
     def specialize_call(self, hop):
         from rpython.rtyper.lltypesystem import rclass, lltype
-        
+
         classrepr = rclass.get_type_repr(hop.rtyper)
 
         hop.exception_cannot_occur()

File rpython/rlib/signature.py

 from rpython.rlib import types
 
+
 def signature(*paramtypes, **kwargs):
     """Decorate a function to specify its type signature.
 
     """
     returntype = kwargs.pop('returns', None)
     if returntype is None:
-        raise TypeError, "signature: parameter 'returns' required"
+        raise TypeError("signature: parameter 'returns' required")
 
     def decorator(f):
         f._signature_ = (paramtypes, returntype)

File rpython/rlib/types.py

 def float():
     return model.SomeFloat()
 
+
 def singlefloat():
     return model.SomeSingleFloat()
 
+
 def longfloat():
     return model.SomeLongFloat()
 
     return model.SomeInteger()
 
 
+def bool():
+    return model.SomeBool()
+
+
 def unicode():
     return model.SomeUnicodeString()
 
+
 def unicode0():
     return model.SomeUnicodeString(no_nul=True)
 
+
 def str():
     return model.SomeString()
 
+
 def str0():
     return model.SomeString(no_nul=True)
 
+
 def char():
     return model.SomeChar()
 
     listdef = ListDef(None, element, mutated=True, resized=True)
     return model.SomeList(listdef)
 
+
 def array(element):
     listdef = ListDef(None, element, mutated=True, resized=False)
     return model.SomeList(listdef)
 
+
 def dict(keytype, valuetype):
     dictdef = DictDef(None, keytype, valuetype)
     return model.SomeDict(dictdef)
 
 
-def instance(class_):
-    return lambda bookkeeper: model.SomeInstance(bookkeeper.getuniqueclassdef(class_))
+def instance(cls):
+    return lambda bookkeeper: model.SomeInstance(bookkeeper.getuniqueclassdef(cls))
+
 
 class SelfTypeMarker(object):
     pass
 
+
 def self():
     return SelfTypeMarker()
 
 class AnyTypeMarker(object):
     pass
 
+
 def any():
     return AnyTypeMarker()

File rpython/rtyper/extfunc.py

     def _freeze_(self):
         return True
 
-class genericcallable(object):
-    """ A way to specify the callable annotation, but deferred until
-    we have bookkeeper
-    """
-    def __init__(self, args, result=None):
-        self.args = args
-        self.result = result
-
-class _ext_callable(ExtRegistryEntry):
-    _type_ = genericcallable
-    # we defer a bit annotation here
-
-    def compute_result_annotation(self):
-        return annmodel.SomeGenericCallable([annotation(i, self.bookkeeper)
-                                             for i in self.instance.args],
-                           annotation(self.instance.result, self.bookkeeper))
-
 class ExtFuncEntry(ExtRegistryEntry):
     safe_not_sandboxed = False
 
     llfakeimpl, oofakeimpl: optional; if provided, they are called by the llinterpreter
     sandboxsafe: use True if the function performs no I/O (safe for --sandbox)
     """
-    
+
     if export_name is None:
         export_name = function.__name__
 

File rpython/rtyper/extregistry.py

             for k in key:
                 selfcls._register(dict, k)
         else:
-            for basecls in selfcls.__mro__:
-                if '_condition_' in basecls.__dict__:
-                    cond = basecls.__dict__['_condition_']
-                    break
-            else:
-                cond = None
-            try:
-                family = dict[key]
-            except KeyError:
-                family = dict[key] = ClassFamily()
-            family.add(selfcls, cond)
+            if key in dict:
+                raise ValueError("duplicate extregistry entry %r" % (selfcls,))
+            dict[key] = selfcls
 
     def _register_value(selfcls, key):
         selfcls._register(EXT_REGISTRY_BY_VALUE, key)
     def _register_metatype(selfcls, key):
         selfcls._register(EXT_REGISTRY_BY_METATYPE, key)
 
-class ClassFamily(object):
-
-    def __init__(self):
-        self.default = None
-        self.conditionals = []
-
-    def add(self, cls, cond=None):
-        if cond is None:
-            assert self.default is None, (
-                "duplicate extregistry entry %r" % (cls,))
-            self.default = cls
-        else:
-            self.conditionals.append((cls, cond))
-
-    def match(self, config):
-        if config is not None:
-            matches = [cls for cls, cond in self.conditionals
-                           if cond(config)]
-            if matches:
-                assert len(matches) == 1, (
-                    "multiple extregistry matches: %r" % (matches,))
-                return matches[0]
-        if self.default:
-            return self.default
-        raise KeyError("no default extregistry entry")
-
 
 class ExtRegistryEntry(object):
     __metaclass__ = AutoRegisteringType
 # ____________________________________________________________
 # Public interface to access the registry
 
-def _lookup_type_cls(tp, config):
+def _lookup_type_cls(tp):
     try:
-        return EXT_REGISTRY_BY_TYPE[tp].match(config)
+        return EXT_REGISTRY_BY_TYPE[tp]
     except (KeyError, TypeError):
-        return EXT_REGISTRY_BY_METATYPE[type(tp)].match(config)
+        return EXT_REGISTRY_BY_METATYPE[type(tp)]
 
-def lookup_type(tp, config=None):
-    Entry = _lookup_type_cls(tp, config)
+def lookup_type(tp):
+    Entry = _lookup_type_cls(tp)
     return Entry(tp)
 
-def is_registered_type(tp, config=None):
+def is_registered_type(tp):
     try:
-        _lookup_type_cls(tp, config)
+        _lookup_type_cls(tp)
     except KeyError:
         return False
     return True
 
-def _lookup_cls(instance, config):
+def _lookup_cls(instance):
     try:
-        return EXT_REGISTRY_BY_VALUE[instance].match(config)
+        return EXT_REGISTRY_BY_VALUE[instance]
     except (KeyError, TypeError):
-        return _lookup_type_cls(type(instance), config)
+        return _lookup_type_cls(type(instance))
 
-def lookup(instance, config=None):
-    Entry = _lookup_cls(instance, config)
+def lookup(instance):
+    Entry = _lookup_cls(instance)
     return Entry(type(instance), instance)
 
-def is_registered(instance, config=None):
+def is_registered(instance):
     try:
-        _lookup_cls(instance, config)
+        _lookup_cls(instance)
     except KeyError:
         return False
     return True

File rpython/rtyper/lltypesystem/rgeneric.py

-
-from rpython.rtyper.rgeneric import AbstractGenericCallableRepr
-from rpython.rtyper.lltypesystem.lltype import Ptr, FuncType
-
-class GenericCallableRepr(AbstractGenericCallableRepr):
-    def create_low_leveltype(self):
-        l_args = [r_arg.lowleveltype for r_arg in self.args_r]
-        l_retval = self.r_result.lowleveltype
-        return Ptr(FuncType(l_args, l_retval))

File rpython/rtyper/lltypesystem/rlist.py

-from rpython.rlib import rgc, jit
+from rpython.rlib import rgc, jit, types
 from rpython.rlib.debug import ll_assert
-from rpython.rlib.objectmodel import enforceargs
+from rpython.rlib.signature import signature
 from rpython.rtyper.lltypesystem import rstr
 from rpython.rtyper.lltypesystem.lltype import (GcForwardReference, Ptr, GcArray,
      GcStruct, Void, Signed, malloc, typeOf, nullptr, typeMethod)
 
 # adapted C code
 
-@enforceargs(None, int, None)
+@signature(types.any(), types.int(), types.bool(), returns=types.none())
 def _ll_list_resize_hint_really(l, newsize, overallocate):
     """
     Ensure l.items has room for at least newsize elements.  Note that
     if allocated < newsize or newsize < (allocated >> 1) - 5:
         _ll_list_resize_hint_really(l, newsize, False)
 
-@enforceargs(None, int, None)
+
+@signature(types.any(), types.int(), types.bool(), returns=types.none())
 def _ll_list_resize_really(l, newsize, overallocate):
     """
     Ensure l.items has room for at least newsize elements, and set

File rpython/rtyper/ootypesystem/ootype.py

 import py
-from py.builtin import set
-from rpython.rtyper.lltypesystem.lltype import LowLevelType, Signed, Unsigned, Float, Char
-from rpython.rtyper.lltypesystem.lltype import Bool, Void, UniChar, typeOf, \
-        Primitive, isCompatibleType, enforce, saferecursive, SignedLongLong, UnsignedLongLong
-from rpython.rtyper.lltypesystem.lltype import frozendict
-from rpython.rtyper.lltypesystem.lltype import identityhash
+
+from rpython.rlib import objectmodel, types
+from rpython.rlib.signature import signature
 from rpython.rlib.rarithmetic import intmask
-from rpython.rlib import objectmodel
+from rpython.rtyper.lltypesystem.lltype import (LowLevelType, Signed, Unsigned,
+    Float, Char, Bool, Void, UniChar, typeOf, Primitive, isCompatibleType,
+    enforce, saferecursive, SignedLongLong, UnsignedLongLong, frozendict,
+    identityhash)
 from rpython.tool.uid import uid
 
 
 
     def _example(self):
         return _class(ROOT)
-    
+
 Class = Class()
 
 class Instance(OOType):
 
     def __hash__(self):
         return object.__hash__(self)
-        
+
     def _defl(self):
         return self._null
 
             _, meth = self._lookup(name)
             if meth is not None:
                 raise TypeError("Cannot add field %r: method already exists" % name)
-        
+
             if self._superclass is not None:
                 if self._superclass._has_field(name):
                     raise TypeError("Field %r exists in superclass" % name)
             if type(defn) is not tuple:
                 if isinstance(defn, Meth):
                     raise TypeError("Attempting to store method in field")
-                
+
                 fields[name] = (defn, defn._defl())
             else:
                 ootype, default = defn
     def _init_instance(self, instance):
         if self._superclass is not None:
             self._superclass._init_instance(instance)
-        
+
         for name, (ootype, default) in self._fields.iteritems():
             instance.__dict__[name] = enforce(ootype, default)
 
 
     # this is the equivalent of the lltypesystem ll_newlist that is
     # marked as typeMethod.
+    @signature(types.any(), types.int(), returns=types.any())
     def ll_newlist(self, length):
         from rpython.rtyper.ootypesystem import rlist
         return rlist.ll_newlist(self, length)
-    ll_newlist._annenforceargs_ = (None, int)
 
     # NB: We are expecting Lists of the same ITEMTYPE to compare/hash
     # equal. We don't redefine __eq__/__hash__ since the implementations
     def __hash__(self):
         if self.ITEM is None:
             raise TypeError("Can't hash uninitialized List type.")
-        return BuiltinADTType.__hash__(self)    
+        return BuiltinADTType.__hash__(self)
 
     def __str__(self):
         return '%s(%s)' % (self.__class__.__name__,
     def _specialize(self, generic_types):
         ITEMTYPE = self._specialize_type(self.ITEM, generic_types)
         return self.__class__(ITEMTYPE)
-    
+
     def _defl(self):
         return self._null
 
     # placeholders for types
     # make sure that each derived class has his own SELFTYPE_T
     # placeholder, because we want backends to distinguish that.
-    
+
     SELFTYPE_T = object()
     ITEMTYPE_T = object()
     oopspec_name = 'list'
     def __hash__(self):
         if self.ITEM is None:
             raise TypeError("Can't hash uninitialized List type.")
-        return BuiltinADTType.__hash__(self)    
+        return BuiltinADTType.__hash__(self)
 
     def __str__(self):
         return '%s(%s)' % (self.__class__.__name__,
         self.ITEM = ITEMTYPE
         self._init_methods()
 
+    @signature(types.any(), types.int(), returns=types.any())
     def ll_newlist(self, length):
         from rpython.rtyper.ootypesystem import rlist
         return rlist.ll_newarray(self, length)
-    ll_newlist._annenforceargs_ = (None, int)
 
     def ll_convert_from_array(self, array):
         return array
 
+
 class Dict(BuiltinADTType):
     # placeholders for types
     SELFTYPE_T = object()
             return False
         if not self._is_initialized() or not other._is_initialized():
             return False # behave like a ForwardReference, i.e. compare by identity
-        return BuiltinADTType.__eq__(self, other) 
+        return BuiltinADTType.__eq__(self, other)
 
     def __ne__(self, other):
         return not (self == other)
         self._KEYTYPE = KEYTYPE
         self._VALUETYPE = VALUETYPE
         self._init_methods()
-                                           
+
 
 class CustomDict(Dict):
     def __init__(self, KEYTYPE=None, VALUETYPE=None):
         KEYTYPE = self._specialize_type(self._KEYTYPE, generic_types)
         VALUETYPE = self._specialize_type(self._VALUETYPE, generic_types)
         return self.__class__(KEYTYPE, VALUETYPE)
-    
+
 # ____________________________________________________________
 
 class _object(object):
 Class._null = nullruntimeclass
 
 class _instance(object):
-    
+
     def __init__(self, INSTANCE):
         self.__dict__["_TYPE"] = INSTANCE
         INSTANCE._init_instance(self)
         DEFINST, meth = self._TYPE._lookup(name)
         if meth is not None:
             return meth._bound(DEFINST, self)
-        
+
         self._TYPE._check_field(name)
 
         return self.__dict__[name]
         return self
 
     _enforce = _upcast
-    
+
     def _downcast(self, INSTANCE):
         assert instanceof(self, INSTANCE)
         return self
         def __getattribute__(self, name):
             if name.startswith("_"):
                 return object.__getattribute__(self, name)
-        
+
             raise RuntimeError("Access to field in null object")
 
         def __setattr__(self, name, value):
 
    def __ne__(self, other):
        return not (self == other)
-   
+
    def __hash__(self):
        return hash(frozendict(self.__dict__))
 
 
    def __eq__(self, other):
        return self is other
-   
+
    def __hash__(self):
        return id(self)
 
 
 class _meth(_callable):
     _bound_class = _bound_meth
-    
+
     def __init__(self, METHOD, **attrs):
         assert isinstance(METHOD, Meth)
         _callable.__init__(self, METHOD, **attrs)
             return True
         else:
             return False
-    
+
     def annotation_to_lltype(cls, ann):
         from rpython.annotator import model as annmodel
         return annmodel.annotation_to_lltype(ann)
         return len(self._list)
 
     def _ll_resize_ge(self, length):
-        # NOT_RPYTHON        
+        # NOT_RPYTHON
         if len(self._list) < length:
             diff = length - len(self._list)
             self._list += [self._TYPE.ITEM._defl()] * diff
 class _null_list(_null_mixin(_list), _list):
 
     def __init__(self, LIST):
-        self.__dict__["_TYPE"] = LIST 
+        self.__dict__["_TYPE"] = LIST
 
 class _array(_builtin_type):
     def __init__(self, ARRAY, length):
 class _null_array(_null_mixin(_array), _array):
 
     def __init__(self, ARRAY):
-        self.__dict__["_TYPE"] = ARRAY 
+        self.__dict__["_TYPE"] = ARRAY
 
 class _dict(_builtin_type):
     def __init__(self, DICT):
     def ll_go_next(self):
         # NOT_RPYTHON
         self._check_stamp()
-        self._index += 1        
+        self._index += 1
         if self._index >= len(self._items):
             return False
         else:
         self._check_stamp()
         assert 0 <= self._index < len(self._items)
         return self._items[self._index][0]
-    
+
     def ll_current_value(self):
         # NOT_RPYTHON
         self._check_stamp()
 class _null_record(_null_mixin(_record), _record):
 
     def __init__(self, RECORD):
-        self.__dict__["_TYPE"] = RECORD 
+        self.__dict__["_TYPE"] = RECORD
 
 
 def new(TYPE):
 
 def ooupcast(INSTANCE, instance):
     return instance._upcast(INSTANCE)
-    
+
 def oodowncast(INSTANCE, instance):
     return instance._downcast(INSTANCE)
 
 def oostring(obj, base):
     """
     Convert char, int, float, instances and str to str.
-    
+
     Base is used only for formatting int: for other types is ignored
     and should be set to -1. For int only base 8, 10 and 16 are
     supported.

File rpython/rtyper/ootypesystem/rgeneric.py

-
-from rpython.rtyper.rgeneric import AbstractGenericCallableRepr
-from rpython.rtyper.ootypesystem import ootype
-
-class GenericCallableRepr(AbstractGenericCallableRepr):
-    def create_low_leveltype(self):
-        l_args = [r_arg.lowleveltype for r_arg in self.args_r]
-        l_retval = self.r_result.lowleveltype
-        return ootype.StaticMethod(l_args, l_retval)

File rpython/rtyper/rexternalobj.py

-from rpython.annotator import model as annmodel
-from rpython.rtyper import extregistry
-from rpython.rtyper.lltypesystem import lltype
-
-# ExternalObjects
-
-
-class __extend__(annmodel.SomeExternalObject):
-    def rtyper_makerepr(self, rtyper):
-       # delegate to the get_repr() of the extregistrered Entry class
-        entry = extregistry.lookup_type(self.knowntype)
-        return entry.get_repr(rtyper, self)
-
-    def rtyper_makekey(self):
-        # grab all attributes of the SomeExternalObject for the key
-        attrs = lltype.frozendict(self.__dict__)
-        if 'const' in attrs:
-            del attrs['const']
-        if 'const_box' in attrs:
-            del attrs['const_box']
-        return self.__class__, attrs

File rpython/rtyper/rgeneric.py

-from rpython.annotator import model as annmodel
-from rpython.rtyper.lltypesystem import lltype
-from rpython.rtyper.rmodel import Repr
-from rpython.rtyper.rpbc import AbstractFunctionsPBCRepr
-from rpython.tool.pairtype import pairtype
-
-
-class AbstractGenericCallableRepr(Repr):
-    def __init__(self, rtyper, s_generic):
-        self.rtyper = rtyper
-        self.s_generic = s_generic
-        self.args_r = [self.rtyper.getrepr(arg) for arg in s_generic.args_s]
-        self.r_result = self.rtyper.getrepr(s_generic.s_result)
-        self.lowleveltype = self.create_low_leveltype()
-
-    def rtype_simple_call(self, hop):
-        return self.call('simple_call', hop)
-
-    def rtype_call_args(self, hop):
-        return self.call('call_args', hop)
-
-    def call(self, opname, hop):
-        vlist = hop.inputargs(self, *self.args_r) + [hop.inputconst(lltype.Void, None)]
-        hop.exception_is_here()
-        v_result = hop.genop('indirect_call', vlist, resultty