[pypy-commit] pypy default: merge heads

bdkearns noreply at buildbot.pypy.org
Fri Mar 22 11:00:26 CET 2013


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r62652:6c566f6935d5
Date: 2013-03-22 05:59 -0400
http://bitbucket.org/pypy/pypy/changeset/6c566f6935d5/

Log:	merge heads

diff too long, truncating to 2000 out of 2542 lines

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1,27 +1,30 @@
 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
@@ -696,6 +699,7 @@
                 raise
             return None
 
+    @signature(types.bool(), returns=types.instance(W_Root))
     def newbool(self, b):
         if b:
             return self.w_True
diff --git a/pypy/tool/ann_override.py b/pypy/tool/ann_override.py
--- a/pypy/tool/ann_override.py
+++ b/pypy/tool/ann_override.py
@@ -1,19 +1,15 @@
 # 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):
diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -180,13 +180,11 @@
             # 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:
diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -11,13 +11,12 @@
 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
@@ -130,7 +129,7 @@
     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
@@ -148,7 +147,7 @@
 
             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
@@ -174,7 +173,7 @@
         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):
@@ -321,7 +320,7 @@
             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):
@@ -332,7 +331,7 @@
         # 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:
@@ -353,14 +352,14 @@
 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()
@@ -385,13 +384,13 @@
             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)):
@@ -494,7 +493,7 @@
         return s_string.__class__()
 
 class __extend__(pairtype(SomeFloat, SomeFloat)):
-    
+
     def union((flt1, flt2)):
         return SomeFloat()
 
@@ -511,13 +510,13 @@
 
 
 class __extend__(pairtype(SomeSingleFloat, SomeSingleFloat)):
-    
+
     def union((flt1, flt2)):
         return SomeSingleFloat()
 
 
 class __extend__(pairtype(SomeLongFloat, SomeLongFloat)):
-    
+
     def union((flt1, flt2)):
         return SomeLongFloat()
 
@@ -609,7 +608,7 @@
 
 
 class __extend__(pairtype(SomeTuple, SomeInteger)):
-    
+
     def getitem((tup1, int2)):
         if int2.is_immutable_constant():
             try:
@@ -623,7 +622,7 @@
 
 
 class __extend__(pairtype(SomeList, SomeInteger)):
-    
+
     def mul((lst1, int2)):
         return lst1.listdef.offspring()
 
@@ -642,27 +641,27 @@
     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]
 
@@ -674,14 +673,14 @@
 
 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]
 
@@ -693,7 +692,7 @@
 
 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()
@@ -713,7 +712,7 @@
         return result
 
 class __extend__(pairtype(SomeInteger, SomeList)):
-    
+
     def mul((int1, lst2)):
         return lst2.listdef.offspring()
 
@@ -786,7 +785,7 @@
 
 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)
@@ -803,20 +802,6 @@
                     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
@@ -853,7 +838,6 @@
 _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
@@ -880,12 +864,6 @@
             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
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -426,8 +426,8 @@
         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))
diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -29,13 +29,15 @@
 
 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
@@ -56,8 +58,10 @@
     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
@@ -75,7 +79,7 @@
                     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]
@@ -83,7 +87,7 @@
 
     def fmt_knowntype(self, t):
         return t.__name__
-    
+
     def contains(self, other):
         if self == other:
             return True
@@ -130,6 +134,7 @@
     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,
@@ -152,6 +157,7 @@
     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
@@ -161,6 +167,7 @@
     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
@@ -170,9 +177,11 @@
     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
@@ -189,25 +198,29 @@
         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):
@@ -226,8 +239,10 @@
         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):
@@ -236,27 +251,34 @@
     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
@@ -266,11 +288,14 @@
 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
@@ -285,10 +310,12 @@
     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:
@@ -300,11 +327,14 @@
     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
@@ -323,12 +353,13 @@
         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
@@ -336,6 +367,7 @@
     def can_be_none(self):
         return False
 
+
 class SomeInstance(SomeObject):
     "Stands for an instance of a (user-defined) class."
 
@@ -347,11 +379,13 @@
 
     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)
@@ -444,7 +478,7 @@
         if hasattr(self, 'const'):
             return None
         else:
-            return '{...%s...}'%(len(pbis),)
+            return '{...%s...}' % (len(pbis),)
 
     def fmt_knowntype(self, kt):
         if self.is_constant():
@@ -452,15 +486,6 @@
         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."
@@ -480,26 +505,18 @@
     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
@@ -507,16 +524,18 @@
 
 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
@@ -526,6 +545,7 @@
 
 from rpython.rtyper.lltypesystem import llmemory
 
+
 class SomeAddress(SomeObject):
     immutable = True
 
@@ -535,6 +555,7 @@
     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
@@ -550,11 +571,12 @@
 # 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
@@ -562,41 +584,52 @@
     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
 
@@ -611,7 +644,10 @@
     (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):
@@ -644,7 +680,10 @@
 
 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:
@@ -669,6 +708,7 @@
     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
@@ -681,13 +721,15 @@
         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:
@@ -703,12 +745,14 @@
             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:
@@ -716,6 +760,7 @@
             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__)
@@ -727,21 +772,23 @@
         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):
@@ -750,12 +797,13 @@
             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
diff --git a/rpython/annotator/signature.py b/rpython/annotator/signature.py
--- a/rpython/annotator/signature.py
+++ b/rpython/annotator/signature.py
@@ -82,8 +82,8 @@
         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()
@@ -97,7 +97,7 @@
 
     def __init__(self, *argtypes):
         self.argtypes = argtypes
-        
+
     def __call__(self, funcdesc, inputcells):
         from rpython.rtyper.lltypesystem import lltype
         args_s = []
diff --git a/rpython/annotator/test/test_annrpython.py b/rpython/annotator/test/test_annrpython.py
--- a/rpython/annotator/test/test_annrpython.py
+++ b/rpython/annotator/test/test_annrpython.py
@@ -3033,33 +3033,6 @@
         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
diff --git a/rpython/annotator/test/test_signature.py b/rpython/annotator/test/test_signature.py
--- a/rpython/annotator/test/test_signature.py
+++ b/rpython/annotator/test/test_signature.py
@@ -6,10 +6,3 @@
     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
diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -9,14 +9,13 @@
      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!
@@ -358,7 +357,7 @@
         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)
@@ -751,32 +750,6 @@
         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
@@ -843,7 +816,7 @@
             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()
diff --git a/rpython/jit/backend/arm/assembler.py b/rpython/jit/backend/arm/assembler.py
--- a/rpython/jit/backend/arm/assembler.py
+++ b/rpython/jit/backend/arm/assembler.py
@@ -1036,6 +1036,7 @@
             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'
@@ -1044,24 +1045,24 @@
             # 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():
diff --git a/rpython/jit/backend/arm/regalloc.py b/rpython/jit/backend/arm/regalloc.py
--- a/rpython/jit/backend/arm/regalloc.py
+++ b/rpython/jit/backend/arm/regalloc.py
@@ -166,6 +166,13 @@
                                                     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):
 
@@ -250,6 +257,8 @@
                                                                 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()
diff --git a/rpython/jit/backend/arm/test/test_calling_convention.py b/rpython/jit/backend/arm/test/test_calling_convention.py
--- a/rpython/jit/backend/arm/test/test_calling_convention.py
+++ b/rpython/jit/backend/arm/test/test_calling_convention.py
@@ -7,6 +7,18 @@
 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):
@@ -39,17 +51,6 @@
         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())
@@ -60,3 +61,82 @@
         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
diff --git a/rpython/jit/backend/arm/test/test_regalloc_mov.py b/rpython/jit/backend/arm/test/test_regalloc_mov.py
--- a/rpython/jit/backend/arm/test/test_regalloc_mov.py
+++ b/rpython/jit/backend/arm/test/test_regalloc_mov.py
@@ -64,11 +64,15 @@
         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):
@@ -170,10 +174,8 @@
         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):
@@ -195,7 +197,7 @@
     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):
@@ -211,7 +213,7 @@
     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):
@@ -420,10 +422,8 @@
 
     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)
@@ -436,7 +436,7 @@
     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)
@@ -444,11 +444,9 @@
     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)
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -598,7 +598,7 @@
             return result
 
         return decorate
-        
+
 
     def clone(self):
         assert self.inline_jit_merge_point, 'JitDriver.clone works only after @inline'
@@ -844,7 +844,7 @@
         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
@@ -876,7 +876,7 @@
 
 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
@@ -986,7 +986,7 @@
 
     def specialize_call(self, hop):
         from rpython.rtyper.lltypesystem import rclass, lltype
-        
+
         classrepr = rclass.get_type_repr(hop.rtyper)
 
         hop.exception_cannot_occur()
diff --git a/rpython/rlib/signature.py b/rpython/rlib/signature.py
--- a/rpython/rlib/signature.py
+++ b/rpython/rlib/signature.py
@@ -1,5 +1,6 @@
 from rpython.rlib import types
 
+
 def signature(*paramtypes, **kwargs):
     """Decorate a function to specify its type signature.
 
@@ -12,7 +13,7 @@
     """
     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)
diff --git a/rpython/rlib/types.py b/rpython/rlib/types.py
--- a/rpython/rlib/types.py
+++ b/rpython/rlib/types.py
@@ -10,9 +10,11 @@
 def float():
     return model.SomeFloat()
 
+
 def singlefloat():
     return model.SomeSingleFloat()
 
+
 def longfloat():
     return model.SomeLongFloat()
 
@@ -21,18 +23,26 @@
     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()
 
@@ -46,21 +56,25 @@
     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()
 
@@ -68,5 +82,6 @@
 class AnyTypeMarker(object):
     pass
 
+
 def any():
     return AnyTypeMarker()
diff --git a/rpython/rtyper/extfunc.py b/rpython/rtyper/extfunc.py
--- a/rpython/rtyper/extfunc.py
+++ b/rpython/rtyper/extfunc.py
@@ -125,23 +125,6 @@
     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
 
@@ -249,7 +232,7 @@
     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__
 
diff --git a/rpython/rtyper/extregistry.py b/rpython/rtyper/extregistry.py
--- a/rpython/rtyper/extregistry.py
+++ b/rpython/rtyper/extregistry.py
@@ -22,17 +22,9 @@
             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)
@@ -43,32 +35,6 @@
     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
@@ -159,36 +125,36 @@
 # ____________________________________________________________
 # 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
diff --git a/rpython/rtyper/lltypesystem/rgeneric.py b/rpython/rtyper/lltypesystem/rgeneric.py
deleted file mode 100644
--- a/rpython/rtyper/lltypesystem/rgeneric.py
+++ /dev/null
@@ -1,9 +0,0 @@
-
-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))
diff --git a/rpython/rtyper/lltypesystem/rlist.py b/rpython/rtyper/lltypesystem/rlist.py
--- a/rpython/rtyper/lltypesystem/rlist.py
+++ b/rpython/rtyper/lltypesystem/rlist.py
@@ -1,6 +1,6 @@
-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)
@@ -171,7 +171,7 @@
 
 # adapted C code
 
- at enforceargs(None, int, None)
+ at 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
@@ -227,7 +227,8 @@
     if allocated < newsize or newsize < (allocated >> 1) - 5:
         _ll_list_resize_hint_really(l, newsize, False)
 
- at enforceargs(None, int, None)
+
+ at 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
diff --git a/rpython/rtyper/ootypesystem/ootype.py b/rpython/rtyper/ootypesystem/ootype.py
--- a/rpython/rtyper/ootypesystem/ootype.py
+++ b/rpython/rtyper/ootypesystem/ootype.py
@@ -1,12 +1,12 @@
 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
 
 
@@ -75,7 +75,7 @@
 
     def _example(self):
         return _class(ROOT)
-    
+
 Class = Class()
 
 class Instance(OOType):
@@ -111,7 +111,7 @@
 
     def __hash__(self):
         return object.__hash__(self)
-        
+
     def _defl(self):
         return self._null
 
@@ -153,7 +153,7 @@
             _, 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)
@@ -161,7 +161,7 @@
             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
@@ -198,7 +198,7 @@
     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)
 
@@ -587,10 +587,10 @@
 
     # 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
@@ -613,7 +613,7 @@
     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__,
@@ -625,7 +625,7 @@
     def _specialize(self, generic_types):
         ITEMTYPE = self._specialize_type(self.ITEM, generic_types)
         return self.__class__(ITEMTYPE)
-    
+
     def _defl(self):
         return self._null
 
@@ -644,7 +644,7 @@
     # 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'
@@ -694,7 +694,7 @@
     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__,
@@ -717,14 +717,15 @@
         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()
@@ -790,7 +791,7 @@
             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)
@@ -812,7 +813,7 @@
         self._KEYTYPE = KEYTYPE
         self._VALUETYPE = VALUETYPE
         self._init_methods()
-                                           
+
 
 class CustomDict(Dict):
     def __init__(self, KEYTYPE=None, VALUETYPE=None):
@@ -871,7 +872,7 @@
         KEYTYPE = self._specialize_type(self._KEYTYPE, generic_types)
         VALUETYPE = self._specialize_type(self._VALUETYPE, generic_types)
         return self.__class__(KEYTYPE, VALUETYPE)
-    
+
 # ____________________________________________________________
 
 class _object(object):
@@ -943,7 +944,7 @@
 Class._null = nullruntimeclass
 
 class _instance(object):
-    
+
     def __init__(self, INSTANCE):
         self.__dict__["_TYPE"] = INSTANCE
         INSTANCE._init_instance(self)
@@ -958,7 +959,7 @@
         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]
@@ -998,7 +999,7 @@
         return self
 
     _enforce = _upcast
-    
+
     def _downcast(self, INSTANCE):
         assert instanceof(self, INSTANCE)
         return self
@@ -1023,7 +1024,7 @@
         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):
@@ -1189,7 +1190,7 @@
 
    def __ne__(self, other):
        return not (self == other)
-   
+
    def __hash__(self):
        return hash(frozendict(self.__dict__))
 
@@ -1227,7 +1228,7 @@
 
    def __eq__(self, other):
        return self is other
-   
+
    def __hash__(self):
        return id(self)
 
@@ -1251,7 +1252,7 @@
 
 class _meth(_callable):
     _bound_class = _bound_meth
-    
+
     def __init__(self, METHOD, **attrs):
         assert isinstance(METHOD, Meth)
         _callable.__init__(self, METHOD, **attrs)
@@ -1339,7 +1340,7 @@
             return True
         else:
             return False
-    
+
     def annotation_to_lltype(cls, ann):
         from rpython.annotator import model as annmodel
         return annmodel.annotation_to_lltype(ann)
@@ -1605,7 +1606,7 @@
         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
@@ -1641,7 +1642,7 @@
 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):
@@ -1674,7 +1675,7 @@
 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):
@@ -1772,7 +1773,7 @@
     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:
@@ -1783,7 +1784,7 @@
         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()
@@ -1843,7 +1844,7 @@
 class _null_record(_null_mixin(_record), _record):
 
     def __init__(self, RECORD):
-        self.__dict__["_TYPE"] = RECORD 
+        self.__dict__["_TYPE"] = RECORD
 
 
 def new(TYPE):
@@ -1935,7 +1936,7 @@
 
 def ooupcast(INSTANCE, instance):
     return instance._upcast(INSTANCE)
-    
+
 def oodowncast(INSTANCE, instance):
     return instance._downcast(INSTANCE)
 
@@ -1962,7 +1963,7 @@
 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.
diff --git a/rpython/rtyper/ootypesystem/rgeneric.py b/rpython/rtyper/ootypesystem/rgeneric.py
deleted file mode 100644
--- a/rpython/rtyper/ootypesystem/rgeneric.py
+++ /dev/null
@@ -1,9 +0,0 @@
-
-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)
diff --git a/rpython/rtyper/rexternalobj.py b/rpython/rtyper/rexternalobj.py
deleted file mode 100644
--- a/rpython/rtyper/rexternalobj.py
+++ /dev/null
@@ -1,21 +0,0 @@
-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
diff --git a/rpython/rtyper/rgeneric.py b/rpython/rtyper/rgeneric.py
deleted file mode 100644
--- a/rpython/rtyper/rgeneric.py
+++ /dev/null
@@ -1,56 +0,0 @@
-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


More information about the pypy-commit mailing list