[pypy-commit] pypy anntype2: hg merge default

rlamy noreply at buildbot.pypy.org
Thu Nov 26 20:38:56 EST 2015


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: anntype2
Changeset: r80982:d2b5d5173cc6
Date: 2015-11-25 23:20 +0000
http://bitbucket.org/pypy/pypy/changeset/d2b5d5173cc6/

Log:	hg merge default

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -29,3 +29,7 @@
 string buffer and directly casts the bytes to the appropriate type, when
 allowed. Unpacking of floats and doubles is about 15 times faster now, while
 for integer types it's up to ~50% faster for 64bit integers.
+
+.. branch: wrap-specialisation
+
+Remove unnecessary special handling of space.wrap().
diff --git a/pypy/module/pypyjit/test_pypy_c/test_containers.py b/pypy/module/pypyjit/test_pypy_c/test_containers.py
--- a/pypy/module/pypyjit/test_pypy_c/test_containers.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_containers.py
@@ -66,6 +66,7 @@
             guard_not_invalidated(descr=...)
             p10 = call_r(ConstClass(ll_str__IntegerR_SignedConst_Signed), i5, descr=<Callr . i EF=3>)
             guard_no_exception(descr=...)
+            guard_nonnull(p10, descr=...)
             i12 = call_i(ConstClass(ll_strhash), p10, descr=<Calli . r EF=0>)
             p13 = new(descr=...)
             p15 = new_array_clear(16, descr=<ArrayU 1>)
diff --git a/pypy/module/pypyjit/test_pypy_c/test_string.py b/pypy/module/pypyjit/test_pypy_c/test_string.py
--- a/pypy/module/pypyjit/test_pypy_c/test_string.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_string.py
@@ -135,6 +135,7 @@
             guard_no_exception(descr=...)
             p95 = call_r(..., descr=<Callr . r EF=5>)     # ll_build
             guard_no_exception(descr=...)
+            guard_nonnull(p95, descr=...)
             i96 = strlen(p95)
             i97 = int_add_ovf(i71, i96)
             guard_no_overflow(descr=...)
@@ -250,6 +251,7 @@
         guard_not_invalidated(descr=...)
         p80 = call_r(ConstClass(ll_str__IntegerR_SignedConst_Signed), i47, descr=<Callr . i EF=3>)
         guard_no_exception(descr=...)
+        guard_nonnull(p80, descr=...)
         p53 = call_r(ConstClass(fast_str_decode_ascii), p80, descr=<Callr . r EF=4>)
         guard_no_exception(descr=...)
         guard_nonnull(p53, descr=...)
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -130,6 +130,7 @@
     def wrapbytes(self, x):
         return wrapstr(self, x)
 
+    @specialize.argtype(1)
     def wrap(self, x):
         "Wraps the Python value 'x' into one of the wrapper classes."
         # You might notice that this function is rather conspicuously
@@ -172,7 +173,6 @@
             else:
                 return W_LongObject.fromrarith_int(x)
         return self._wrap_not_rpython(x)
-    wrap._annspecialcase_ = "specialize:wrap"
 
     def _wrap_not_rpython(self, x):
         "NOT_RPYTHON"
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,16 +1,7 @@
 # overrides for annotation specific to PyPy codebase
 from rpython.annotator.policy import AnnotatorPolicy
 from rpython.flowspace.model import Constant
-from rpython.annotator import specialize
-from rpython.annotator.classdesc import InstanceSource, ClassDesc
-
-
-
-def isidentifier(s):
-    if not s:
-        return False
-    s = s.replace('_', 'x')
-    return s[0].isalpha() and s.isalnum()
+from rpython.annotator.classdesc import InstanceSource
 
 
 class PyPyAnnotatorPolicy(AnnotatorPolicy):
@@ -19,37 +10,6 @@
         self.lookups_where = {}
         self.pypytypes = {}
 
-    def specialize__wrap(self,  funcdesc, args_s):
-        from pypy.interpreter.baseobjspace import W_Root
-        W_Root_desc = funcdesc.bookkeeper.getdesc(W_Root)
-        typ = args_s[1].knowntype
-        if isinstance(typ, ClassDesc):
-            assert typ.issubclass(W_Root_desc)
-            typ = W_Root
-        else:
-            assert not issubclass(typ, W_Root)
-            assert typ != tuple, "space.wrap(tuple) forbidden; use newtuple()"
-            assert typ != list, "space.wrap(list) forbidden; use newlist()"
-            assert typ != dict, "space.wrap(dict) forbidden; use newdict()"
-            assert typ != object, "degenerated space.wrap(object)"
-            if args_s[0].is_constant() and args_s[1].is_constant():
-                if typ in (str, bool, int, float):
-                    space = args_s[0].const
-                    x = args_s[1].const
-
-                    def fold():
-                        if typ is str and isidentifier(x):
-                            return space.new_interned_str(x)
-                        else:
-                            return space.wrap(x)
-                    builder = specialize.make_constgraphbuilder(2, factory=fold,
-                                                                srcmodule='<ann_override.wrap>')
-                    return funcdesc.cachedgraph((typ, x), builder=builder)
-        if typ is str:
-            if args_s[1].can_be_None:
-                typ = (None, str)
-        return funcdesc.cachedgraph(typ)
-
     def consider_lookup(self, bookkeeper, attr):
         assert attr not in self.lookups
         from pypy.objspace.std import typeobject


More information about the pypy-commit mailing list