Author: Ronan Lamy <[email protected]>
Branch:
Changeset: r80969:3537a011647d
Date: 2015-11-25 23:16 +0000
http://bitbucket.org/pypy/pypy/changeset/3537a011647d/
Log: Merge branch 'wrap-specialisation'
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, ClassDef
-
-
-
-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_def = funcdesc.bookkeeper.getuniqueclassdef(W_Root)
- typ = args_s[1].knowntype
- if isinstance(typ, ClassDef):
- assert typ.issubclass(W_Root_def)
- 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
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit