[pypy-commit] pypy reflex-support: merge default into branch
wlav
noreply at buildbot.pypy.org
Fri Apr 5 03:11:13 CEST 2013
Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r63040:300a0b23172a
Date: 2013-04-01 19:23 -0700
http://bitbucket.org/pypy/pypy/changeset/300a0b23172a/
Log: merge default into branch
diff too long, truncating to 2000 out of 4659 lines
diff --git a/.tddium.requirements.txt b/.tddium.requirements.txt
new file mode 100644
--- /dev/null
+++ b/.tddium.requirements.txt
@@ -0,0 +1,1 @@
+pytest
diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -33,7 +33,7 @@
"crypt", "signal", "_rawffi", "termios", "zlib", "bz2",
"struct", "_hashlib", "_md5", "_sha", "_minimal_curses", "cStringIO",
"thread", "itertools", "pyexpat", "_ssl", "cpyext", "array",
- "_bisect", "binascii", "_multiprocessing", '_warnings',
+ "binascii", "_multiprocessing", '_warnings',
"_collections", "_multibytecodec", "micronumpy", "_ffi",
"_continuation", "_cffi_backend", "_csv"]
))
diff --git a/pypy/config/test/test_pypyoption.py b/pypy/config/test/test_pypyoption.py
--- a/pypy/config/test/test_pypyoption.py
+++ b/pypy/config/test/test_pypyoption.py
@@ -11,11 +11,11 @@
assert conf.objspace.usemodules.gc
- conf.objspace.std.withsmallint = True
- assert not conf.objspace.std.withprebuiltint
+ conf.objspace.std.withmapdict = True
+ assert conf.objspace.std.withmethodcache
conf = get_pypy_config()
- conf.objspace.std.withprebuiltint = True
- py.test.raises(ConfigError, "conf.objspace.std.withsmallint = True")
+ conf.objspace.std.withmethodcache = False
+ py.test.raises(ConfigError, "conf.objspace.std.withmapdict = True")
def test_conflicting_gcrootfinder():
conf = get_pypy_config()
diff --git a/pypy/doc/arm.rst b/pypy/doc/arm.rst
--- a/pypy/doc/arm.rst
+++ b/pypy/doc/arm.rst
@@ -145,7 +145,7 @@
::
- pypy ~/path_to_pypy_checkout/rpython/translator/goal/translate.py -O1 --platform=arm target.py
+ pypy ~/path_to_pypy_checkout/rpython/bin/rpython -O1 --platform=arm target.py
If everything worked correctly this should yield an ARM binary. Running this binary in the ARM chroot or on an ARM device should produce the output ``"Hello World"``.
@@ -153,7 +153,7 @@
::
- pypy <path to rpython>/rpython/translator/goal/translate.py -Ojit --platform=arm --gcrootfinder=shadowstack --jit-backend=arm targetpypystandalone.py
+ pypy <path to rpython>/rpython/bin/rpython -Ojit --platform=arm --gcrootfinder=shadowstack --jit-backend=armv7 targetpypystandalone.py
The gcrootfinder option is needed to work around `issue 1377`_ and the jit-backend works around `issue 1376`_
diff --git a/pypy/doc/config/objspace.std.withsmallint.txt b/pypy/doc/config/objspace.std.withsmallint.txt
deleted file mode 100644
--- a/pypy/doc/config/objspace.std.withsmallint.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-Use "tagged pointers" to represent small enough integer values: Integers that
-fit into 31 bits (respective 63 bits on 64 bit machines) are not represented by
-boxing them in an instance of ``W_IntObject``. Instead they are represented as a
-pointer having the lowest bit set and the rest of the bits used to store the
-value of the integer. This gives a small speedup for integer operations as well
-as better memory behaviour.
diff --git a/pypy/doc/config/objspace.usemodules._bisect.txt b/pypy/doc/config/objspace.usemodules._bisect.txt
deleted file mode 100644
--- a/pypy/doc/config/objspace.usemodules._bisect.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-Use the '_bisect' module.
-Used, optionally, by the 'bisect' standard lib module. This module is expected to be working and is included by default.
-
-
diff --git a/pypy/doc/config/translation.taggedpointers.txt b/pypy/doc/config/translation.taggedpointers.txt
--- a/pypy/doc/config/translation.taggedpointers.txt
+++ b/pypy/doc/config/translation.taggedpointers.txt
@@ -1,3 +1,3 @@
Enable tagged pointers. This option is mostly useful for the Smalltalk and
Prolog interpreters. For the Python interpreter the option
-:config:`objspace.std.withsmallint` should be used.
+:config:`objspace.std.withsmalllong` should be used.
diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -21,7 +21,6 @@
__builtin__
`__pypy__`_
_ast
- _bisect
_codecs
_collections
`_continuation`_
diff --git a/pypy/doc/interpreter-optimizations.rst b/pypy/doc/interpreter-optimizations.rst
--- a/pypy/doc/interpreter-optimizations.rst
+++ b/pypy/doc/interpreter-optimizations.rst
@@ -55,7 +55,7 @@
them from normal pointers. This completely avoids the boxing step, saving
time and memory.
-You can enable this feature with the :config:`objspace.std.withsmallint` option.
+You can enable this feature with the :config:`objspace.std.withsmalllong` option.
Dictionary Optimizations
------------------------
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
@@ -42,6 +42,10 @@
.. branch: rpython-bytearray
Rudimentary support for bytearray in RPython
+.. branch: refactor-call_release_gil
+Fix a bug which casused cffi to return the wrong result when calling a C
+function which calls a Python callback which forces the frames
+
.. branches we don't care about
.. branch: autoreds
.. branch: reflex-support
diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -22,7 +22,6 @@
assert not func.can_change_code
return func.code
-
class Function(W_Root):
"""A function is a code object captured with some environment:
an object space, a dictionary of globals, default arguments,
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -812,6 +812,8 @@
d = {}
exec func_code.compile() in d
f = d['f']
+ f.__module__ = func.__module__
+ # necessary for unique identifiers for pickling
f.func_name = func.func_name
if unwrap_spec is None:
unwrap_spec = {}
@@ -877,9 +879,9 @@
for name, defaultval in self._staticdefs:
if name.startswith('w_'):
assert defaultval is None, (
- "%s: default value for '%s' can only be None; "
+ "%s: default value for '%s' can only be None, got %r; "
"use unwrap_spec(...=WrappedDefault(default))" % (
- self._code.identifier, name))
+ self._code.identifier, name, defaultval))
defs_w.append(None)
else:
defs_w.append(space.wrap(defaultval))
diff --git a/pypy/module/__builtin__/functional.py b/pypy/module/__builtin__/functional.py
--- a/pypy/module/__builtin__/functional.py
+++ b/pypy/module/__builtin__/functional.py
@@ -330,6 +330,7 @@
next = interp2app(W_ReversedIterator.descr_next),
__reduce__ = interp2app(W_ReversedIterator.descr___reduce__),
)
+W_ReversedIterator.typedef.acceptable_as_base_class = False
# exported through _pickle_support
def _make_reversed(space, w_seq, w_remaining):
@@ -428,7 +429,7 @@
__reversed__ = interp2app(W_XRange.descr_reversed),
__reduce__ = interp2app(W_XRange.descr_reduce),
)
-
+W_XRange.typedef.acceptable_as_base_class = False
class W_XRangeIterator(W_Root):
def __init__(self, space, current, remaining, step):
@@ -475,6 +476,7 @@
next = interp2app(W_XRangeIterator.descr_next),
__reduce__ = interp2app(W_XRangeIterator.descr_reduce),
)
+W_XRangeIterator.typedef.acceptable_as_base_class = False
class W_XRangeStepOneIterator(W_XRangeIterator):
def __init__(self, space, start, stop):
diff --git a/pypy/module/_bisect/__init__.py b/pypy/module/_bisect/__init__.py
deleted file mode 100644
--- a/pypy/module/_bisect/__init__.py
+++ /dev/null
@@ -1,27 +0,0 @@
-"""
-Mixed-module definition for the _bisect module.
-This is an optional module; if not present, bisect.py uses the
-pure Python version of these functions.
-"""
-
-from pypy.interpreter.mixedmodule import MixedModule
-
-
-class Module(MixedModule):
- """\
-This module provides support for maintaining a list in sorted order without
-having to sort the list after each insertion. For long lists of items with
-expensive comparison operations, this can be an improvement over the more
-common approach."""
-
- appleveldefs = {
- 'insort': 'app_bisect.insort_right',
- 'insort_left': 'app_bisect.insort_left',
- 'insort_right': 'app_bisect.insort_right',
- }
-
- interpleveldefs = {
- 'bisect': 'interp_bisect.bisect_right',
- 'bisect_left': 'interp_bisect.bisect_left',
- 'bisect_right': 'interp_bisect.bisect_right',
- }
diff --git a/pypy/module/_bisect/app_bisect.py b/pypy/module/_bisect/app_bisect.py
deleted file mode 100644
--- a/pypy/module/_bisect/app_bisect.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from _bisect import bisect_left, bisect_right
-
-
-def insort_left(a, x, lo=0, hi=-1):
- """Insert item x in list a, and keep it sorted assuming a is sorted.
-
-If x is already in a, insert it to the left of the leftmost x.
-
-Optional args lo (default 0) and hi (default len(a)) bound the
-slice of a to be searched."""
- n = bisect_left(a, x, lo, hi)
- a.insert(n, x)
-
-
-def insort_right(a, x, lo=0, hi=-1):
- """Insert item x in list a, and keep it sorted assuming a is sorted.
-
-If x is already in a, insert it to the right of the rightmost x.
-
-Optional args lo (default 0) and hi (default len(a)) bound the
-slice of a to be searched."""
- n = bisect_right(a, x, lo, hi)
- a.insert(n, x)
diff --git a/pypy/module/_bisect/interp_bisect.py b/pypy/module/_bisect/interp_bisect.py
deleted file mode 100644
--- a/pypy/module/_bisect/interp_bisect.py
+++ /dev/null
@@ -1,53 +0,0 @@
-from pypy.interpreter.error import OperationError
-from pypy.interpreter.gateway import unwrap_spec
-from rpython.rlib.rarithmetic import intmask, r_uint
-
-
- at unwrap_spec(lo=int, hi=int)
-def bisect_left(space, w_a, w_x, lo=0, hi=-1):
- """Return the index where to insert item x in list a, assuming a is sorted.
-
-The return value i is such that all e in a[:i] have e < x, and all e in
-a[i:] have e >= x. So if x already appears in the list, i points just
-before the leftmost x already there.
-
-Optional args lo (default 0) and hi (default len(a)) bound the
-slice of a to be searched."""
- if lo < 0:
- raise OperationError(space.w_ValueError,
- space.wrap("lo must be non-negative"))
- if hi == -1:
- hi = space.len_w(w_a)
- while lo < hi:
- mid = intmask((r_uint(lo) + r_uint(hi)) >> 1)
- w_litem = space.getitem(w_a, space.wrap(mid))
- if space.is_true(space.lt(w_litem, w_x)):
- lo = mid + 1
- else:
- hi = mid
- return space.wrap(lo)
-
-
- at unwrap_spec(lo=int, hi=int)
-def bisect_right(space, w_a, w_x, lo=0, hi=-1):
- """Return the index where to insert item x in list a, assuming a is sorted.
-
-The return value i is such that all e in a[:i] have e <= x, and all e in
-a[i:] have e > x. So if x already appears in the list, i points just
-beyond the rightmost x already there
-
-Optional args lo (default 0) and hi (default len(a)) bound the
-slice of a to be searched."""
- if lo < 0:
- raise OperationError(space.w_ValueError,
- space.wrap("lo must be non-negative"))
- if hi == -1:
- hi = space.len_w(w_a)
- while lo < hi:
- mid = intmask((r_uint(lo) + r_uint(hi)) >> 1)
- w_litem = space.getitem(w_a, space.wrap(mid))
- if space.is_true(space.lt(w_x, w_litem)):
- hi = mid
- else:
- lo = mid + 1
- return space.wrap(lo)
diff --git a/pypy/module/_bisect/test/__init__.py b/pypy/module/_bisect/test/__init__.py
deleted file mode 100644
diff --git a/pypy/module/_bisect/test/test_bisect.py b/pypy/module/_bisect/test/test_bisect.py
deleted file mode 100644
--- a/pypy/module/_bisect/test/test_bisect.py
+++ /dev/null
@@ -1,100 +0,0 @@
-
-class AppTestBisect:
- spaceconfig = dict(usemodules=['_bisect'])
-
- def test_bisect_left(self):
- from _bisect import bisect_left
- a = [0, 5, 6, 6, 6, 7]
- assert bisect_left(a, None) == 0
- assert bisect_left(a, -3) == 0
- assert bisect_left(a, 0) == 0
- assert bisect_left(a, 3) == 1
- assert bisect_left(a, 5) == 1
- assert bisect_left(a, 5.5) == 2
- assert bisect_left(a, 6) == 2
- assert bisect_left(a, 6.0) == 2
- assert bisect_left(a, 6.1) == 5
- assert bisect_left(a, 7) == 5
- assert bisect_left(a, 8) == 6
- a = []
- assert bisect_left(a, 123) == 0
- a = [9]
- assert bisect_left(a, -123) == 0
- assert bisect_left(a, 9) == 0
- assert bisect_left(a, 123) == 1
- a = [9, 9]
- assert bisect_left(a, -123) == 0
- assert bisect_left(a, 9) == 0
- assert bisect_left(a, 123) == 2
- a = [4, 6, 6, 9]
- assert bisect_left(a, 6, 0) == 1
- assert bisect_left(a, 6, 1) == 1
- assert bisect_left(a, 6, 2) == 2
- assert bisect_left(a, 6, 3) == 3
- assert bisect_left(a, 6, 4) == 4
- assert bisect_left(a, 6, 0, 0) == 0
- assert bisect_left(a, 6, 0, 1) == 1
- assert bisect_left(a, 6, 0, 2) == 1
- assert bisect_left(a, 6, 0, 3) == 1
- assert bisect_left(a, 6, 0, 4) == 1
-
- raises(ValueError, bisect_left, [1, 2, 3], 5, -1, 3)
-
- def test_bisect_right(self):
- from _bisect import bisect_right
- a = [0, 5, 6, 6, 6, 7]
- assert bisect_right(a, None) == 0
- assert bisect_right(a, -3) == 0
- assert bisect_right(a, 0) == 1
- assert bisect_right(a, 3) == 1
- assert bisect_right(a, 5) == 2
- assert bisect_right(a, 5.5) == 2
- assert bisect_right(a, 6) == 5
- assert bisect_right(a, 6.0) == 5
- assert bisect_right(a, 6.1) == 5
- assert bisect_right(a, 7) == 6
- assert bisect_right(a, 8) == 6
- a = []
- assert bisect_right(a, 123) == 0
- a = [9]
- assert bisect_right(a, -123) == 0
- assert bisect_right(a, 9) == 1
- assert bisect_right(a, 123) == 1
- a = [9, 9]
- assert bisect_right(a, -123) == 0
- assert bisect_right(a, 9) == 2
- assert bisect_right(a, 123) == 2
- a = [4, 6, 6, 9]
- assert bisect_right(a, 6, 0) == 3
- assert bisect_right(a, 6, 1) == 3
- assert bisect_right(a, 6, 2) == 3
- assert bisect_right(a, 6, 3) == 3
- assert bisect_right(a, 6, 4) == 4
- assert bisect_right(a, 6, 0, 0) == 0
- assert bisect_right(a, 6, 0, 1) == 1
- assert bisect_right(a, 6, 0, 2) == 2
- assert bisect_right(a, 6, 0, 3) == 3
- assert bisect_right(a, 6, 0, 4) == 3
-
- def test_insort_left(self):
- from _bisect import insort_left
- a = [0, 5, 6, 6, 6, 7]
- insort_left(a, 6.0)
- assert a == [0, 5, 6.0, 6, 6, 6, 7]
- assert map(type, a) == [int, int, float, int, int, int, int]
-
- def test_insort_right(self):
- from _bisect import insort_right
- a = [0, 5, 6, 6, 6, 7]
- insort_right(a, 6.0)
- assert a == [0, 5, 6, 6, 6, 6.0, 7]
- assert map(type, a) == [int, int, int, int, int, float, int]
-
- def test_bisect_overflow(self):
- from _bisect import bisect_left, bisect_right
- import sys
-
- size = sys.maxsize
- data = xrange(size - 1)
- assert bisect_left(data, size - 3) == size - 3
- assert bisect_right(data, size - 3) == size - 2
diff --git a/pypy/module/_bisect/test/test_ztranslation.py b/pypy/module/_bisect/test/test_ztranslation.py
deleted file mode 100644
--- a/pypy/module/_bisect/test/test_ztranslation.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from pypy.objspace.fake.checkmodule import checkmodule
-
-def test_checkmodule():
- checkmodule('_bisect')
diff --git a/pypy/module/_cffi_backend/cdataobj.py b/pypy/module/_cffi_backend/cdataobj.py
--- a/pypy/module/_cffi_backend/cdataobj.py
+++ b/pypy/module/_cffi_backend/cdataobj.py
@@ -91,20 +91,15 @@
space = self.space
cdata1 = self._cdata
if isinstance(w_other, W_CData):
- if requires_ordering:
- if (isinstance(self.ctype, W_CTypePrimitive) or
- isinstance(w_other.ctype, W_CTypePrimitive)):
- raise OperationError(space.w_TypeError,
- space.wrap("cannot do comparison on a "
- "primitive cdata"))
cdata2 = w_other._cdata
- elif (misc.is_zero(space, w_other) and
- not isinstance(self.ctype, W_CTypePrimitive)):
- cdata2 = lltype.nullptr(rffi.CCHARP.TO)
else:
return space.w_NotImplemented
if requires_ordering:
+ if (isinstance(self.ctype, W_CTypePrimitive) or
+ isinstance(w_other.ctype, W_CTypePrimitive)):
+ raise OperationError(space.w_TypeError,
+ space.wrap("cannot do comparison on a primitive cdata"))
cdata1 = rffi.cast(lltype.Unsigned, cdata1)
cdata2 = rffi.cast(lltype.Unsigned, cdata2)
return space.newbool(op(cdata1, cdata2))
diff --git a/pypy/module/_cffi_backend/ctypeptr.py b/pypy/module/_cffi_backend/ctypeptr.py
--- a/pypy/module/_cffi_backend/ctypeptr.py
+++ b/pypy/module/_cffi_backend/ctypeptr.py
@@ -152,10 +152,6 @@
def convert_from_object(self, cdata, w_ob):
space = self.space
if not isinstance(w_ob, cdataobj.W_CData):
- if misc.is_zero(space, w_ob):
- NULL = lltype.nullptr(rffi.CCHARP.TO)
- rffi.cast(rffi.CCHARPP, cdata)[0] = NULL
- return
raise self._convert_error("cdata pointer", w_ob)
other = w_ob.ctype
if not isinstance(other, W_CTypePtrBase):
@@ -257,15 +253,7 @@
def _prepare_pointer_call_argument(self, w_init, cdata):
space = self.space
- if misc.is_zero(space, w_init):
- # Convert 0 to NULL. Note that passing 0 is not ambigous,
- # despite the potential confusion: as a 'T*' argument, 0 means
- # NULL, but as a 'T[]' argument it would mean "array of size 0"
- # --- except that we specifically refuse to interpret numbers
- # as the array size when passing arguments.
- rffi.cast(rffi.CCHARPP, cdata)[0] = lltype.nullptr(rffi.CCHARP.TO)
- return 3
- elif (space.isinstance_w(w_init, space.w_list) or
+ if (space.isinstance_w(w_init, space.w_list) or
space.isinstance_w(w_init, space.w_tuple)):
length = space.int_w(space.len(w_init))
elif space.isinstance_w(w_init, space.w_basestring):
diff --git a/pypy/module/_cffi_backend/misc.py b/pypy/module/_cffi_backend/misc.py
--- a/pypy/module/_cffi_backend/misc.py
+++ b/pypy/module/_cffi_backend/misc.py
@@ -202,11 +202,6 @@
neg_msg = "can't convert negative number to unsigned"
ovf_msg = "long too big to convert"
-def is_zero(space, w_ob):
- return ((space.isinstance_w(w_ob, space.w_int) or
- space.isinstance_w(w_ob, space.w_long))
- and not space.is_true(w_ob))
-
# ____________________________________________________________
class _NotStandardObject(Exception):
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -387,19 +387,8 @@
assert (x != None) is True
assert (x == ["hello"]) is False
assert (x != ["hello"]) is True
-
-def test_cmp_pointer_with_0():
- p = new_pointer_type(new_primitive_type("int"))
- x = cast(p, 0)
- assert (x == 0) is True
- assert (x != 0) is False
- assert (0 == x) is True
- assert (0 != x) is False
- y = cast(p, 42)
- assert (y == 0) is False
- assert (y != 0) is True
- assert (0 == y) is False
- assert (0 != y) is True
+ y = cast(p, 0)
+ assert (y == None) is False
def test_invalid_indexing():
p = new_primitive_type("int")
@@ -779,7 +768,7 @@
assert s.a2 == 456
assert s.a3 == 0
assert s.p4 == cast(BVoidP, 0)
- assert s.p4 == 0
+ assert s.p4 != 0
#
s = newp(BStructPtr, {'a2': 41122, 'a3': -123})
assert s.a1 == 0
@@ -792,14 +781,11 @@
p = newp(BIntPtr, 14141)
s = newp(BStructPtr, [12, 34, 56, p])
assert s.p4 == p
- s.p4 = 0
- assert s.p4 == 0
+ assert s.p4
#
s = newp(BStructPtr, [12, 34, 56, cast(BVoidP, 0)])
- assert s.p4 == 0
- #
- s = newp(BStructPtr, [12, 34, 56, 0])
assert s.p4 == cast(BVoidP, 0)
+ assert not s.p4
#
py.test.raises(TypeError, newp, BStructPtr, [12, 34, 56, None])
@@ -1017,11 +1003,10 @@
f = cast(BFunc23, _testfunc(23))
res = f(b"foo")
assert res == 1000 * ord(b'f')
- res = f(0) # NULL
- assert res == -42
- res = f(long(0)) # NULL
+ res = f(cast(BVoidP, 0)) # NULL
assert res == -42
py.test.raises(TypeError, f, None)
+ py.test.raises(TypeError, f, 0)
py.test.raises(TypeError, f, 0.0)
def test_call_function_23_bis():
@@ -2277,6 +2262,7 @@
def test_longdouble():
py_py = 'PY_DOT_PY' in globals()
+ BInt = new_primitive_type("int")
BLongDouble = new_primitive_type("long double")
BLongDoublePtr = new_pointer_type(BLongDouble)
BLongDoubleArray = new_array_type(BLongDoublePtr, None)
@@ -2294,21 +2280,23 @@
assert float(x) == 1.23
assert int(x) == 1
#
- BFunc19 = new_function_type((BLongDouble,), BLongDouble)
+ BFunc19 = new_function_type((BLongDouble, BInt), BLongDouble)
f = cast(BFunc19, _testfunc(19))
- start = 8
+ start = lstart = 1.5
for i in range(107):
- start = f(start)
- if sizeof(BLongDouble) > sizeof(new_primitive_type("double")):
- if not py_py:
- assert repr(start).startswith("<cdata 'long double' 6.15")
- assert repr(start).endswith("E+902>")
- #
- c = newp(BLongDoubleArray, [start])
- x = c[0]
- if not py_py:
- assert repr(x).endswith("E+902>")
- assert float(x) == float("inf")
+ start = 4 * start - start * start
+ lstart = f(lstart, 1)
+ lother = f(1.5, 107)
+ if not py_py:
+ assert float(lstart) == float(lother)
+ assert repr(lstart) == repr(lother)
+ if sizeof(BLongDouble) > sizeof(new_primitive_type("double")):
+ assert float(lstart) != start
+ assert repr(lstart).startswith("<cdata 'long double' ")
+ #
+ c = newp(BLongDoubleArray, [lstart])
+ x = c[0]
+ assert float(f(lstart, 107)) == float(f(x, 107))
def test_get_array_of_length_zero():
for length in [0, 5, 10]:
diff --git a/pypy/module/_cffi_backend/test/_test_lib.c b/pypy/module/_cffi_backend/test/_test_lib.c
--- a/pypy/module/_cffi_backend/test/_test_lib.c
+++ b/pypy/module/_cffi_backend/test/_test_lib.c
@@ -133,11 +133,12 @@
return ptr->a1 + (int)ptr->a2;
}
-static long double _testfunc19(long double x)
+static long double _testfunc19(long double x, int count)
{
int i;
- for (i=0; i<28; i++)
- x += x;
+ for (i=0; i<count; i++) {
+ x = 4*x - x*x;
+ }
return x;
}
diff --git a/pypy/module/_sre/interp_sre.py b/pypy/module/_sre/interp_sre.py
--- a/pypy/module/_sre/interp_sre.py
+++ b/pypy/module/_sre/interp_sre.py
@@ -321,6 +321,7 @@
groups = interp_attrproperty('num_groups', W_SRE_Pattern),
pattern = interp_attrproperty_w('w_pattern', W_SRE_Pattern),
)
+W_SRE_Pattern.typedef.acceptable_as_base_class = False
# ____________________________________________________________
#
@@ -498,7 +499,7 @@
lastindex = GetSetProperty(W_SRE_Match.fget_lastindex),
regs = GetSetProperty(W_SRE_Match.fget_regs),
)
-
+W_SRE_Match.typedef.acceptable_as_base_class = False
# ____________________________________________________________
#
@@ -554,3 +555,4 @@
search = interp2app(W_SRE_Scanner.search_w),
pattern = interp_attrproperty('srepat', W_SRE_Scanner),
)
+W_SRE_Scanner.typedef.acceptable_as_base_class = False
diff --git a/pypy/module/pypyjit/test/test_jit_hook.py b/pypy/module/pypyjit/test/test_jit_hook.py
--- a/pypy/module/pypyjit/test/test_jit_hook.py
+++ b/pypy/module/pypyjit/test/test_jit_hook.py
@@ -132,8 +132,9 @@
assert int_add.name == 'int_add'
assert int_add.num == self.int_add_num
self.on_compile_bridge()
- code_repr = "(<code object function, file '?', line 2>, 0, False)"
- assert repr(all[0]) == '<JitLoopInfo pypyjit, 4 operations, starting at <%s>>' % code_repr
+ expected = ('<JitLoopInfo pypyjit, 4 operations, starting at '
+ '<(%s, 0, False)>>' % repr(self.f.func_code))
+ assert repr(all[0]) == expected
assert len(all) == 2
pypyjit.set_compile_hook(None)
self.on_compile()
diff --git a/pypy/module/pypyjit/test_pypy_c/test_00_model.py b/pypy/module/pypyjit/test_pypy_c/test_00_model.py
--- a/pypy/module/pypyjit/test_pypy_c/test_00_model.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_00_model.py
@@ -75,6 +75,7 @@
rawtraces = logparser.extract_category(rawlog, 'jit-log-opt-')
log = Log(rawtraces)
log.result = eval(stdout)
+ log.logfile = str(logfile)
#
summaries = logparser.extract_category(rawlog, 'jit-summary')
if len(summaries) > 0:
diff --git a/pypy/module/pypyjit/test_pypy_c/test_call.py b/pypy/module/pypyjit/test_pypy_c/test_call.py
--- a/pypy/module/pypyjit/test_pypy_c/test_call.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_call.py
@@ -339,6 +339,7 @@
loop, = log.loops_by_filename(self.filepath)
# the int strategy is used here
assert loop.match_by_id('append', """
+ guard_not_invalidated(descr=...)
i13 = getfield_gc(p8, descr=<FieldS list.length .*>)
i15 = int_add(i13, 1)
# Will be killed by the backend
@@ -581,7 +582,7 @@
d = {'a': 2, 'b': 3, 'd':4}
f(*a, **d) # ID: call
i += 1
- return 13
+ return 13
""", [1000])
loop, = log.loops_by_id('call')
assert loop.match_by_id('call', '''
@@ -602,7 +603,7 @@
while i < stop:
f(*a, **d) # ID: call
i += 1
- return 13
+ return 13
""", [1000])
def test_complex_case_loopconst(self):
@@ -617,5 +618,5 @@
while i < stop:
f(*a, **d) # ID: call
i += 1
- return 13
+ return 13
""", [1000])
diff --git a/pypy/module/pypyjit/test_pypy_c/test_jitlogparser.py b/pypy/module/pypyjit/test_pypy_c/test_jitlogparser.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/pypyjit/test_pypy_c/test_jitlogparser.py
@@ -0,0 +1,76 @@
+import re
+
+from rpython.tool.logparser import extract_category
+
+from pypy.tool.jitlogparser.parser import (import_log, parse_log_counts,
+ mangle_descr)
+from pypy.module.pypyjit.test_pypy_c.test_00_model import BaseTestPyPyC
+
+
+class TestLogParser(BaseTestPyPyC):
+ log_string = 'jit-log-opt,jit-backend'
+
+ def test(self):
+ def fn_with_bridges(N):
+ def is_prime(x):
+ for y in xrange(2, x):
+ if x % y == 0:
+ return False
+ return True
+ result = 0
+ for x in xrange(N):
+ if x % 3 == 0:
+ result += 5
+ elif x % 5 == 0:
+ result += 3
+ elif is_prime(x):
+ result += x
+ elif x == 99:
+ result *= 2
+ return result
+ #
+ N = 10000
+ _log = self.run(fn_with_bridges, [N])
+ log, loops = import_log(_log.logfile)
+ parse_log_counts(extract_category(log, 'jit-backend-count'), loops)
+
+ is_prime_loops = []
+ fn_with_bridges_loops = []
+ bridges = {}
+
+ lib_re = re.compile("file '.*lib-python.*'")
+ for loop in loops:
+ if hasattr(loop, 'force_asm'):
+ loop.force_asm()
+ if lib_re.search(loop.comment) or \
+ lib_re.search(loop.operations[0].repr()):
+ # do not care for _optimize_charset or _mk_bitmap
+ continue
+ assert loop.count > 0
+ if ' is_prime, ' in loop.comment:
+ is_prime_loops.append(loop)
+ elif ' fn_with_bridges, ' in loop.comment:
+ fn_with_bridges_loops.append(loop)
+ else:
+ assert ' bridge ' in loop.comment
+ key = mangle_descr(loop.descr)
+ assert key not in bridges
+ bridges[key] = loop
+
+ by_count = lambda l: -l.count
+ is_prime_loops.sort(key=by_count)
+ fn_with_bridges_loops.sort(key=by_count)
+
+ # check that we can find bridges corresponding to " % 3" and " % 5"
+ mod_bridges = []
+ for op in fn_with_bridges_loops[0].operations:
+ if op.descr is not None:
+ bridge = bridges.get(mangle_descr(op.descr))
+ if bridge is not None:
+ mod_bridges.append(bridge)
+ assert len(mod_bridges) == 2
+
+ # check that counts are reasonable (precise # may change in the future)
+ assert N - 2000 < sum(l.count for l in fn_with_bridges_loops) < N
+
+
diff --git a/pypy/module/zipimport/test/test_zipimport.py b/pypy/module/zipimport/test/test_zipimport.py
--- a/pypy/module/zipimport/test/test_zipimport.py
+++ b/pypy/module/zipimport/test/test_zipimport.py
@@ -7,7 +7,7 @@
from StringIO import StringIO
from rpython.tool.udir import udir
-from zipfile import ZIP_STORED, ZIP_DEFLATED
+from zipfile import ZIP_STORED
class AppTestZipimport:
@@ -53,7 +53,7 @@
space = cls.space
- tmpdir = udir.ensure('zipimport_%s' % cls.__name__, dir=1)
+ tmpdir = udir.ensure('zipimport_%s_%s' % (__name__, cls.__name__), dir=1)
now = time.time()
cls.w_now = space.wrap(now)
test_pyc = cls.make_pyc(space, co, now)
@@ -360,20 +360,6 @@
assert co_filename == expected
-class AppTestZipimportDeflated(AppTestZipimport):
- compression = ZIP_DEFLATED
- spaceconfig = {
- "usemodules": ['zipimport', 'zlib', 'rctime', 'struct', 'itertools', 'binascii'],
- }
-
- def setup_class(cls):
- try:
- import rpython.rlib.rzlib
- except ImportError:
- py.test.skip("zlib not available, cannot test compressed zipfiles")
- cls.make_class()
-
-
if os.sep != '/':
class AppTestNativePathSep(AppTestZipimport):
pathsep = os.sep
diff --git a/pypy/module/zipimport/test/test_zipimport_deflated.py b/pypy/module/zipimport/test/test_zipimport_deflated.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/zipimport/test/test_zipimport_deflated.py
@@ -0,0 +1,18 @@
+import py
+
+from zipfile import ZIP_DEFLATED
+
+from pypy.module.zipimport.test.test_zipimport import AppTestZipimport as Base
+
+class AppTestZipimportDeflated(Base):
+ compression = ZIP_DEFLATED
+ spaceconfig = {
+ "usemodules": ['zipimport', 'zlib', 'rctime', 'struct', 'itertools', 'binascii'],
+ }
+
+ def setup_class(cls):
+ try:
+ import rpython.rlib.rzlib
+ except ImportError:
+ py.test.skip("zlib not available, cannot test compressed zipfiles")
+ cls.make_class()
diff --git a/pypy/objspace/std/dictmultiobject.py b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -12,6 +12,8 @@
from rpython.rlib import rerased, jit
+UNROLL_CUTOFF = 5
+
def _is_str(space, w_key):
return space.is_w(space.type(w_key), space.w_str)
@@ -35,7 +37,7 @@
an actual dict
"""
return jit.isvirtual(w_dct) or (jit.isconstant(w_dct) and
- w_dct.length() <= jit.UNROLL_CUTOFF)
+ w_dct.length() <= UNROLL_CUTOFF)
class W_DictMultiObject(W_Object):
diff --git a/pypy/objspace/std/floatobject.py b/pypy/objspace/std/floatobject.py
--- a/pypy/objspace/std/floatobject.py
+++ b/pypy/objspace/std/floatobject.py
@@ -1,7 +1,7 @@
import operator
-from pypy.interpreter import gateway
from pypy.interpreter.error import OperationError
from pypy.objspace.std import model, newformat
+from pypy.objspace.std.floattype import float_typedef, W_AbstractFloatObject
from pypy.objspace.std.multimethod import FailedToImplementArgs
from pypy.objspace.std.model import registerimplementation, W_Object
from pypy.objspace.std.register_all import register_all
@@ -19,36 +19,14 @@
import math
from pypy.objspace.std.intobject import W_IntObject
-class W_AbstractFloatObject(W_Object):
- __slots__ = ()
-
- def is_w(self, space, w_other):
- from rpython.rlib.longlong2float import float2longlong
- if not isinstance(w_other, W_AbstractFloatObject):
- return False
- if self.user_overridden_class or w_other.user_overridden_class:
- return self is w_other
- one = float2longlong(space.float_w(self))
- two = float2longlong(space.float_w(w_other))
- return one == two
-
- def immutable_unique_id(self, space):
- if self.user_overridden_class:
- return None
- from rpython.rlib.longlong2float import float2longlong
- from pypy.objspace.std.model import IDTAG_FLOAT as tag
- val = float2longlong(space.float_w(self))
- b = rbigint.fromrarith_int(val)
- b = b.lshift(3).or_(rbigint.fromint(tag))
- return space.newlong_from_rbigint(b)
-
class W_FloatObject(W_AbstractFloatObject):
"""This is a implementation of the app-level 'float' type.
The constructor takes an RPython float as an argument."""
- from pypy.objspace.std.floattype import float_typedef as typedef
_immutable_fields_ = ['floatval']
+ typedef = float_typedef
+
def __init__(w_self, floatval):
w_self.floatval = floatval
@@ -59,6 +37,9 @@
return self.floatval
def int(self, space):
+ if (type(self) is not W_FloatObject and
+ space.is_overloaded(self, space.w_float, '__int__')):
+ return W_Object.int(self, space)
try:
value = ovfcheck_float_to_int(self.floatval)
except OverflowError:
diff --git a/pypy/objspace/std/floattype.py b/pypy/objspace/std/floattype.py
--- a/pypy/objspace/std/floattype.py
+++ b/pypy/objspace/std/floattype.py
@@ -3,13 +3,15 @@
from rpython.rlib.unroll import unrolling_iterable
from rpython.rlib import rfloat, rarithmetic
from pypy.interpreter import typedef
-from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
-from pypy.interpreter.baseobjspace import ObjSpace, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault,\
+ interpindirect2app
from pypy.interpreter.error import OperationError
from pypy.objspace.std.register_all import register_all
from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
from pypy.objspace.std.strutil import ParseStringError
from pypy.objspace.std.strutil import string_to_float
+from pypy.objspace.std.model import W_Object
+from rpython.rlib.rbigint import rbigint
float_as_integer_ratio = SMM("as_integer_ratio", 1)
@@ -270,6 +272,32 @@
# ____________________________________________________________
+class W_AbstractFloatObject(W_Object):
+ __slots__ = ()
+
+ def is_w(self, space, w_other):
+ from rpython.rlib.longlong2float import float2longlong
+ if not isinstance(w_other, W_AbstractFloatObject):
+ return False
+ if self.user_overridden_class or w_other.user_overridden_class:
+ return self is w_other
+ one = float2longlong(space.float_w(self))
+ two = float2longlong(space.float_w(w_other))
+ return one == two
+
+ def immutable_unique_id(self, space):
+ if self.user_overridden_class:
+ return None
+ from rpython.rlib.longlong2float import float2longlong
+ from pypy.objspace.std.model import IDTAG_FLOAT as tag
+ val = float2longlong(space.float_w(self))
+ b = rbigint.fromrarith_int(val)
+ b = b.lshift(3).or_(rbigint.fromint(tag))
+ return space.newlong_from_rbigint(b)
+
+ def int(self, space):
+ raise NotImplementedError
+
float_typedef = StdTypeDef("float",
__doc__ = '''float(x) -> floating point number
@@ -280,5 +308,6 @@
conjugate = interp2app(descr_conjugate),
real = typedef.GetSetProperty(descr_get_real),
imag = typedef.GetSetProperty(descr_get_imag),
+ __int__ = interpindirect2app(W_AbstractFloatObject.int),
)
float_typedef.registermethods(globals())
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -18,6 +18,7 @@
from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
from sys import maxint
+UNROLL_CUTOFF = 5
class W_AbstractListObject(W_Object):
__slots__ = ()
@@ -42,7 +43,7 @@
return W_ListObject.from_storage_and_strategy(space, storage, strategy)
@jit.look_inside_iff(lambda space, list_w, sizehint:
- jit.loop_unrolling_heuristic(list_w, len(list_w)))
+ jit.loop_unrolling_heuristic(list_w, len(list_w), UNROLL_CUTOFF))
def get_strategy_from_list_objects(space, list_w, sizehint):
if not list_w:
if sizehint != -1:
@@ -956,7 +957,7 @@
raise NotImplementedError("abstract base class")
@jit.look_inside_iff(lambda space, w_list, list_w:
- jit.loop_unrolling_heuristic(list_w, len(list_w)))
+ jit.loop_unrolling_heuristic(list_w, len(list_w), UNROLL_CUTOFF))
def init_from_list_w(self, w_list, list_w):
l = [self.unwrap(w_item) for w_item in list_w]
w_list.lstorage = self.erase(l)
@@ -1005,7 +1006,7 @@
return self.wrap(r)
@jit.look_inside_iff(lambda self, w_list:
- jit.loop_unrolling_heuristic(w_list, w_list.length()))
+ jit.loop_unrolling_heuristic(w_list, w_list.length(), UNROLL_CUTOFF))
def getitems_copy(self, w_list):
return [self.wrap(item) for item in self.unerase(w_list.lstorage)]
@@ -1014,7 +1015,7 @@
return [self.wrap(item) for item in self.unerase(w_list.lstorage)]
@jit.look_inside_iff(lambda self, w_list:
- jit.loop_unrolling_heuristic(w_list, w_list.length()))
+ jit.loop_unrolling_heuristic(w_list, w_list.length(), UNROLL_CUTOFF))
def getitems_fixedsize(self, w_list):
return self.getitems_unroll(w_list)
@@ -1476,8 +1477,8 @@
return w_list
def list_unroll_condition(space, w_list1, w_list2):
- return jit.loop_unrolling_heuristic(w_list1, w_list1.length()) or \
- jit.loop_unrolling_heuristic(w_list2, w_list2.length())
+ return jit.loop_unrolling_heuristic(w_list1, w_list1.length(), UNROLL_CUTOFF) or \
+ jit.loop_unrolling_heuristic(w_list2, w_list2.length(), UNROLL_CUTOFF)
@jit.look_inside_iff(list_unroll_condition)
def eq__List_List(space, w_list1, w_list2):
diff --git a/pypy/objspace/std/longobject.py b/pypy/objspace/std/longobject.py
--- a/pypy/objspace/std/longobject.py
+++ b/pypy/objspace/std/longobject.py
@@ -6,35 +6,16 @@
from pypy.objspace.std.multimethod import FailedToImplementArgs
from pypy.objspace.std.intobject import W_IntObject
from pypy.objspace.std.noneobject import W_NoneObject
-from rpython.rlib.rbigint import rbigint, SHIFT
-
-class W_AbstractLongObject(W_Object):
- __slots__ = ()
-
- def is_w(self, space, w_other):
- if not isinstance(w_other, W_AbstractLongObject):
- return False
- if self.user_overridden_class or w_other.user_overridden_class:
- return self is w_other
- return space.bigint_w(self).eq(space.bigint_w(w_other))
-
- def immutable_unique_id(self, space):
- if self.user_overridden_class:
- return None
- from pypy.objspace.std.model import IDTAG_LONG as tag
- b = space.bigint_w(self)
- b = b.lshift(3).or_(rbigint.fromint(tag))
- return space.newlong_from_rbigint(b)
-
- def unwrap(w_self, space): #YYYYYY
- return w_self.longval()
+from rpython.rlib.rbigint import rbigint
+from pypy.objspace.std.longtype import long_typedef, W_AbstractLongObject
class W_LongObject(W_AbstractLongObject):
"""This is a wrapper of rbigint."""
- from pypy.objspace.std.longtype import long_typedef as typedef
_immutable_fields_ = ['num']
+ typedef = long_typedef
+
def __init__(w_self, l):
w_self.num = l # instance of rbigint
@@ -88,6 +69,9 @@
return self.num.tofloat()
def int(self, space):
+ if (type(self) is not W_LongObject and
+ space.is_overloaded(self, space.w_long, '__int__')):
+ return W_Object.int(self, space)
try:
return space.newint(self.num.toint())
except OverflowError:
diff --git a/pypy/objspace/std/longtype.py b/pypy/objspace/std/longtype.py
--- a/pypy/objspace/std/longtype.py
+++ b/pypy/objspace/std/longtype.py
@@ -1,9 +1,11 @@
from pypy.interpreter.error import OperationError
from pypy.interpreter import typedef
-from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
-from pypy.objspace.std.register_all import register_all
-from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault,\
+ interpindirect2app
+from pypy.objspace.std.model import W_Object
+from pypy.objspace.std.stdtypedef import StdTypeDef
from pypy.objspace.std.strutil import string_to_bigint, ParseStringError
+from rpython.rlib.rbigint import rbigint
def descr_conjugate(space, w_int):
return space.long(w_int)
@@ -12,7 +14,6 @@
@unwrap_spec(w_x = WrappedDefault(0))
def descr__new__(space, w_longtype, w_x, w_base=None):
from pypy.objspace.std.longobject import W_LongObject
- from rpython.rlib.rbigint import rbigint
if space.config.objspace.std.withsmalllong:
from pypy.objspace.std.smalllongobject import W_SmallLongObject
else:
@@ -56,7 +57,7 @@
else:
try:
s = space.str_w(w_value)
- except OperationError, e:
+ except OperationError:
raise OperationError(space.w_TypeError,
space.wrap("long() can't convert non-string "
"with explicit base"))
@@ -114,6 +115,30 @@
# ____________________________________________________________
+class W_AbstractLongObject(W_Object):
+ __slots__ = ()
+
+ def is_w(self, space, w_other):
+ if not isinstance(w_other, W_AbstractLongObject):
+ return False
+ if self.user_overridden_class or w_other.user_overridden_class:
+ return self is w_other
+ return space.bigint_w(self).eq(space.bigint_w(w_other))
+
+ def immutable_unique_id(self, space):
+ if self.user_overridden_class:
+ return None
+ from pypy.objspace.std.model import IDTAG_LONG as tag
+ b = space.bigint_w(self)
+ b = b.lshift(3).or_(rbigint.fromint(tag))
+ return space.newlong_from_rbigint(b)
+
+ def unwrap(w_self, space): #YYYYYY
+ return w_self.longval()
+
+ def int(self, space):
+ raise NotImplementedError
+
long_typedef = StdTypeDef("long",
__doc__ = '''long(x[, base]) -> integer
@@ -129,5 +154,6 @@
real = typedef.GetSetProperty(descr_get_real),
imag = typedef.GetSetProperty(descr_get_imag),
bit_length = interp2app(bit_length),
+ __int__ = interpindirect2app(W_AbstractLongObject.int),
)
long_typedef.registermethods(globals())
diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -15,6 +15,8 @@
from rpython.rlib.rarithmetic import intmask, r_uint
from rpython.rlib import rerased, jit
+UNROLL_CUTOFF = 5
+
class W_BaseSetObject(W_Object):
typedef = None
@@ -391,7 +393,7 @@
raise NotImplementedError
@jit.look_inside_iff(lambda self, list_w:
- jit.loop_unrolling_heuristic(list_w, len(list_w)))
+ jit.loop_unrolling_heuristic(list_w, len(list_w), UNROLL_CUTOFF))
def get_storage_from_list(self, list_w):
setdata = self.get_empty_dict()
for w_item in list_w:
@@ -399,7 +401,7 @@
return self.erase(setdata)
@jit.look_inside_iff(lambda self, items:
- jit.loop_unrolling_heuristic(items, len(items)))
+ jit.loop_unrolling_heuristic(items, len(items), UNROLL_CUTOFF))
def get_storage_from_unwrapped_list(self, items):
setdata = self.get_empty_dict()
for item in items:
@@ -1033,7 +1035,7 @@
_pick_correct_strategy(space, w_set, iterable_w)
@jit.look_inside_iff(lambda space, w_set, iterable_w:
- jit.loop_unrolling_heuristic(iterable_w, len(iterable_w)))
+ jit.loop_unrolling_heuristic(iterable_w, len(iterable_w), UNROLL_CUTOFF))
def _pick_correct_strategy(space, w_set, iterable_w):
# check for integers
for w_item in iterable_w:
diff --git a/pypy/objspace/std/test/test_longobject.py b/pypy/objspace/std/test/test_longobject.py
--- a/pypy/objspace/std/test/test_longobject.py
+++ b/pypy/objspace/std/test/test_longobject.py
@@ -231,13 +231,13 @@
def test_math_log(self):
import math
- raises(ValueError, math.log, 0L)
- raises(ValueError, math.log, -1L)
- raises(ValueError, math.log, -2L)
+ raises(ValueError, math.log, 0L)
+ raises(ValueError, math.log, -1L)
+ raises(ValueError, math.log, -2L)
raises(ValueError, math.log, -(1L << 10000))
- #raises(ValueError, math.log, 0)
- raises(ValueError, math.log, -1)
- raises(ValueError, math.log, -2)
+ #raises(ValueError, math.log, 0)
+ raises(ValueError, math.log, -1)
+ raises(ValueError, math.log, -2)
def test_long(self):
import sys
@@ -327,3 +327,11 @@
class A(long): pass
b = A(5).real
assert type(b) is long
+
+ def test__int__(self):
+ class A(long):
+ def __int__(self):
+ return 42
+
+ assert int(long(3)) == long(3)
+ assert int(A(13)) == 42
diff --git a/pypy/objspace/std/tupleobject.py b/pypy/objspace/std/tupleobject.py
--- a/pypy/objspace/std/tupleobject.py
+++ b/pypy/objspace/std/tupleobject.py
@@ -10,6 +10,7 @@
from rpython.rlib import jit
from rpython.tool.sourcetools import func_with_new_name
+UNROLL_CUTOFF = 10
class W_AbstractTupleObject(W_Object):
__slots__ = ()
@@ -84,7 +85,7 @@
return space.newtuple(w_tuple.wrappeditems[start:stop])
@jit.look_inside_iff(lambda space, w_tuple, w_obj:
- jit.loop_unrolling_heuristic(w_tuple, len(w_tuple.wrappeditems)))
+ jit.loop_unrolling_heuristic(w_tuple, len(w_tuple.wrappeditems), UNROLL_CUTOFF))
def contains__Tuple_ANY(space, w_tuple, w_obj):
for w_item in w_tuple.wrappeditems:
if space.eq_w(w_item, w_obj):
@@ -119,8 +120,8 @@
return mul_tuple_times(space, w_tuple, w_times)
def tuple_unroll_condition(space, w_tuple1, w_tuple2):
- return jit.loop_unrolling_heuristic(w_tuple1, len(w_tuple1.wrappeditems)) or \
- jit.loop_unrolling_heuristic(w_tuple2, len(w_tuple2.wrappeditems))
+ return jit.loop_unrolling_heuristic(w_tuple1, len(w_tuple1.wrappeditems), UNROLL_CUTOFF) or \
+ jit.loop_unrolling_heuristic(w_tuple2, len(w_tuple2.wrappeditems), UNROLL_CUTOFF)
@jit.look_inside_iff(tuple_unroll_condition)
def eq__Tuple_Tuple(space, w_tuple1, w_tuple2):
@@ -173,7 +174,7 @@
return space.wrap(hash_tuple(space, w_tuple.wrappeditems))
@jit.look_inside_iff(lambda space, wrappeditems:
- jit.loop_unrolling_heuristic(wrappeditems, len(wrappeditems)))
+ jit.loop_unrolling_heuristic(wrappeditems, len(wrappeditems), UNROLL_CUTOFF))
def hash_tuple(space, wrappeditems):
# this is the CPython 2.4 algorithm (changed from 2.3)
mult = 1000003
diff --git a/pypy/tool/jitlogparser/parser.py b/pypy/tool/jitlogparser/parser.py
--- a/pypy/tool/jitlogparser/parser.py
+++ b/pypy/tool/jitlogparser/parser.py
@@ -447,6 +447,17 @@
num, count = line.split(':', 2)
mapping[num].count = int(count)
+
+def mangle_descr(descr):
+ if descr.startswith('TargetToken('):
+ return descr[len('TargetToken('):-1]
+ if descr.startswith('<Guard'):
+ return 'bridge-' + str(int(descr[len('<Guard0x'):-1], 16))
+ if descr.startswith('<Loop'):
+ return 'entry-' + descr[len('<Loop'):-1]
+ return descr.replace(" ", '-')
+
+
if __name__ == '__main__':
import_log(sys.argv[1])
diff --git a/pypy/tool/pytest/objspace.py b/pypy/tool/pytest/objspace.py
--- a/pypy/tool/pytest/objspace.py
+++ b/pypy/tool/pytest/objspace.py
@@ -63,6 +63,8 @@
continue
if info is None:
py.test.skip("cannot runappdirect this test on top of CPython")
+ if ('translation.' + key) in info:
+ key = 'translation.' + key
has = info.get(key, None)
if has != value:
#print sys.pypy_translation_info
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -235,7 +235,7 @@
if s_value_or_def in seen:
return
seen.add(s_value_or_def)
- for attr in s_value_or_def.attrs.values():
+ for attr in s_value_or_def.attrs.itervalues():
s_attr = attr.s_value
check_no_flags(s_attr)
elif isinstance(s_value_or_def, ListItem):
diff --git a/rpython/config/translationoption.py b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -115,7 +115,7 @@
("translation.gcrootfinder", DEFL_ROOTFINDER_WITHJIT),
("translation.list_comprehension_operations", True)]),
ChoiceOption("jit_backend", "choose the backend for the JIT",
- ["auto", "x86", "x86-without-sse2", 'arm'],
+ ["auto", "x86", "x86-without-sse2", 'armv7'],
default="auto", cmdline="--jit-backend"),
ChoiceOption("jit_profiler", "integrate profiler support into the JIT",
["off", "oprofile"],
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
@@ -5,7 +5,7 @@
from rpython.jit.backend.arm import conditions as c, registers as r
from rpython.jit.backend.arm.arch import (WORD, DOUBLE_WORD, FUNC_ALIGN,
JITFRAME_FIXED_SIZE)
-from rpython.jit.backend.arm.codebuilder import ARMv7Builder, OverwritingBuilder
+from rpython.jit.backend.arm.codebuilder import InstrBuilder, OverwritingBuilder
from rpython.jit.backend.arm.locations import imm, StackLocation
from rpython.jit.backend.arm.opassembler import ResOpAssembler
from rpython.jit.backend.arm.regalloc import (Regalloc,
@@ -59,14 +59,13 @@
if we_are_translated():
self.debug = False
self.current_clt = looptoken.compiled_loop_token
- self.mc = ARMv7Builder()
+ self.mc = InstrBuilder()
self.pending_guards = []
assert self.datablockwrapper is None
allblocks = self.get_asmmemmgr_blocks(looptoken)
self.datablockwrapper = MachineDataBlockWrapper(self.cpu.asmmemmgr,
allblocks)
self.mc.datablockwrapper = self.datablockwrapper
- self.mc.is_armv6 = self.cpu.backend_name == 'armv6'
self.target_tokens_currently_compiling = {}
def teardown(self):
@@ -157,7 +156,7 @@
if not self.cpu.propagate_exception_descr:
return # not supported (for tests, or non-translated)
#
- mc = ARMv7Builder()
+ mc = InstrBuilder()
self._store_and_reset_exception(mc, r.r0)
ofs = self.cpu.get_ofs_of_frame_field('jf_guard_exc')
# make sure ofs fits into a register
@@ -242,7 +241,7 @@
# | my own retaddr | <-- sp
# +-----------------------+
#
- mc = ARMv7Builder()
+ mc = InstrBuilder()
# save argument registers and return address
mc.PUSH([reg.value for reg in r.argument_regs] + [r.ip.value, r.lr.value])
# stack is aligned here
@@ -283,7 +282,7 @@
# write barriers. It must save all registers, and optionally
# all vfp registers. It takes a single argument which is in r0.
# It must keep stack alignment accordingly.
- mc = ARMv7Builder()
+ mc = InstrBuilder()
#
exc0 = exc1 = None
mc.PUSH([r.ip.value, r.lr.value]) # push two words to keep alignment
@@ -327,7 +326,7 @@
self.wb_slowpath[withcards + 2 * withfloats] = rawstart
def _build_malloc_slowpath(self):
- mc = ARMv7Builder()
+ mc = InstrBuilder()
self._push_all_regs_to_jitframe(mc, [r.r0, r.r1], self.cpu.supports_floats)
ofs = self.cpu.get_ofs_of_frame_field('jf_gcmap')
# store the gc pattern
@@ -439,7 +438,7 @@
self.load_reg(mc, vfpr, r.fp, ofs)
def _build_failure_recovery(self, exc, withfloats=False):
- mc = ARMv7Builder()
+ mc = InstrBuilder()
self._push_all_regs_to_jitframe(mc, [], withfloats)
if exc:
@@ -766,7 +765,7 @@
# f) store the address of the new jitframe in the shadowstack
# c) set the gcmap field to 0 in the new jitframe
# g) restore registers and return
- mc = ARMv7Builder()
+ mc = InstrBuilder()
self._push_all_regs_to_jitframe(mc, [], self.cpu.supports_floats)
# this is the gcmap stored by push_gcmap(mov=True) in _check_stack_frame
# and the expected_size pushed in _check_stack_frame
@@ -826,7 +825,7 @@
self.target_tokens_currently_compiling = None
def _patch_stackadjust(self, adr, allocated_depth):
- mc = ARMv7Builder()
+ mc = InstrBuilder()
mc.gen_load_int(r.lr.value, allocated_depth)
mc.copy_to_raw_memory(adr)
@@ -862,7 +861,7 @@
# patch the guard jumpt to the stub
# overwrite the generate NOP with a B_offs to the pos of the
# stub
- mc = ARMv7Builder()
+ mc = InstrBuilder()
mc.B_offs(relative_offset, c.get_opposite_of(tok.fcond))
mc.copy_to_raw_memory(guard_pos)
else:
@@ -941,7 +940,7 @@
self.mc.ASR_ri(resloc.value, resloc.value, 16)
def patch_trace(self, faildescr, looptoken, bridge_addr, regalloc):
- b = ARMv7Builder()
+ b = InstrBuilder()
patch_addr = faildescr._arm_failure_recovery_block
assert patch_addr != 0
b.B(bridge_addr)
diff --git a/rpython/jit/backend/arm/codebuilder.py b/rpython/jit/backend/arm/codebuilder.py
--- a/rpython/jit/backend/arm/codebuilder.py
+++ b/rpython/jit/backend/arm/codebuilder.py
@@ -7,6 +7,7 @@
from rpython.rlib.objectmodel import we_are_translated
from rpython.rtyper.lltypesystem import lltype, rffi, llmemory
from rpython.tool.udir import udir
+from rpython.jit.backend.detect_cpu import autodetect
clear_cache = rffi.llexternal(
"__clear_cache",
@@ -41,7 +42,11 @@
def PUSH(self, regs, cond=cond.AL):
assert reg.sp.value not in regs
- instr = self._encode_reg_list(cond << 28 | 0x92D << 16, regs)
+ instr = 0
+ if len(regs) == 1:
+ instr = cond << 28 | 0x52D0004 | (regs[0] & 0xF) << 12
+ else:
+ instr = self._encode_reg_list(cond << 28 | 0x92D << 16, regs)
self.write32(instr)
def VPUSH(self, regs, cond=cond.AL):
@@ -245,25 +250,32 @@
def currpos(self):
raise NotImplementedError
+ max_size_of_gen_load_int = 2
def gen_load_int(self, r, value, cond=cond.AL):
"""r is the register number, value is the value to be loaded to the
register"""
- if self.is_armv6:
- from pypy.jit.backend.arm.conditions import AL
- if cond != AL or 0 <= value <= 0xFFFF:
- self._load_by_shifting(r, value, cond)
- else:
- self.LDR_ri(r, reg.pc.value)
- self.MOV_rr(reg.pc.value, reg.pc.value)
- self.write32(value)
- else:
- bottom = value & 0xFFFF
- top = value >> 16
- self.MOVW_ri(r, bottom, cond)
- if top:
- self.MOVT_ri(r, top, cond)
+ bottom = value & 0xFFFF
+ top = value >> 16
+ self.MOVW_ri(r, bottom, cond)
+ if top:
+ self.MOVT_ri(r, top, cond)
- max_size_of_gen_load_int = 2 * WORD
+
+class AbstractARMv6Builder(AbstractARMv7Builder):
+
+ def __init__(self):
+ AbstractARMv7Builder.__init__(self)
+
+ def gen_load_int(self, r, value, cond=cond.AL):
+ from rpython.jit.backend.arm.conditions import AL
+ if cond != AL or 0 <= value <= 0xFFFF:
+ self._load_by_shifting(r, value, cond)
+ else:
+ self.LDR_ri(r, reg.pc.value)
+ self.MOV_rr(reg.pc.value, reg.pc.value)
+ self.write32(value)
+
+ max_size_of_gen_load_int = 4
ofs_shift = zip(range(8, 25, 8), range(12, 0, -4))
def _load_by_shifting(self, r, value, c=cond.AL):
# to be sure it is only called for the correct cases
@@ -276,10 +288,15 @@
t = b | (shift << 8)
self.ORR_ri(r, r, imm=t, cond=c)
+if autodetect().startswith('armv7'):
+ AbstractBuilder = AbstractARMv7Builder
+else:
+ AbstractBuilder = AbstractARMv6Builder
-class OverwritingBuilder(AbstractARMv7Builder):
+
+class OverwritingBuilder(AbstractBuilder):
def __init__(self, cb, start, size):
- AbstractARMv7Builder.__init__(self)
+ AbstractBuilder.__init__(self)
self.cb = cb
self.index = start
self.end = start + size
@@ -293,9 +310,9 @@
self.index += 1
-class ARMv7Builder(BlockBuilderMixin, AbstractARMv7Builder):
+class InstrBuilder(BlockBuilderMixin, AbstractBuilder):
def __init__(self):
- AbstractARMv7Builder.__init__(self)
+ AbstractBuilder.__init__(self)
self.init_block_builder()
#
# ResOperation --> offset in the assembly.
@@ -349,4 +366,4 @@
return self.get_relative_pos()
-define_instructions(AbstractARMv7Builder)
+define_instructions(AbstractBuilder)
diff --git a/rpython/jit/backend/arm/helper/assembler.py b/rpython/jit/backend/arm/helper/assembler.py
--- a/rpython/jit/backend/arm/helper/assembler.py
+++ b/rpython/jit/backend/arm/helper/assembler.py
@@ -1,7 +1,7 @@
from __future__ import with_statement
from rpython.jit.backend.arm import conditions as c
from rpython.jit.backend.arm import registers as r
-from rpython.jit.backend.arm.codebuilder import AbstractARMv7Builder
+from rpython.jit.backend.arm.codebuilder import InstrBuilder
from rpython.jit.metainterp.history import ConstInt, BoxInt, FLOAT
from rpython.rlib.rarithmetic import r_uint, r_longlong, intmask
from rpython.jit.metainterp.resoperation import rop
@@ -34,8 +34,8 @@
return f
def gen_emit_op_ri(name, opname):
- ri_op = getattr(AbstractARMv7Builder, '%s_ri' % opname)
- rr_op = getattr(AbstractARMv7Builder, '%s_rr' % opname)
+ ri_op = getattr(InstrBuilder, '%s_ri' % opname)
+ rr_op = getattr(InstrBuilder, '%s_rr' % opname)
def f(self, op, arglocs, regalloc, fcond):
assert fcond is not None
l0, l1, res = arglocs
@@ -48,7 +48,7 @@
return f
def gen_emit_op_by_helper_call(name, opname):
- helper = getattr(AbstractARMv7Builder, opname)
+ helper = getattr(InstrBuilder, opname)
def f(self, op, arglocs, regalloc, fcond):
assert fcond is not None
if op.result:
@@ -97,7 +97,7 @@
return f
def gen_emit_float_op(name, opname):
- op_rr = getattr(AbstractARMv7Builder, opname)
+ op_rr = getattr(InstrBuilder, opname)
def f(self, op, arglocs, regalloc, fcond):
arg1, arg2, result = arglocs
op_rr(self.mc, result.value, arg1.value, arg2.value)
@@ -105,7 +105,7 @@
f.__name__ = 'emit_op_%s' % name
return f
def gen_emit_unary_float_op(name, opname):
- op_rr = getattr(AbstractARMv7Builder, opname)
+ op_rr = getattr(InstrBuilder, opname)
def f(self, op, arglocs, regalloc, fcond):
arg1, result = arglocs
op_rr(self.mc, result.value, arg1.value)
diff --git a/rpython/jit/backend/arm/helper/regalloc.py b/rpython/jit/backend/arm/helper/regalloc.py
--- a/rpython/jit/backend/arm/helper/regalloc.py
+++ b/rpython/jit/backend/arm/helper/regalloc.py
@@ -1,6 +1,5 @@
from rpython.jit.backend.arm import conditions as c
from rpython.jit.backend.arm import registers as r
-from rpython.jit.backend.arm.codebuilder import AbstractARMv7Builder
from rpython.jit.metainterp.history import ConstInt, BoxInt, Box, FLOAT
from rpython.jit.metainterp.history import ConstInt
from rpython.rlib.objectmodel import we_are_translated
diff --git a/rpython/jit/backend/arm/opassembler.py b/rpython/jit/backend/arm/opassembler.py
--- a/rpython/jit/backend/arm/opassembler.py
+++ b/rpython/jit/backend/arm/opassembler.py
@@ -17,7 +17,7 @@
saved_registers,
count_reg_args)
from rpython.jit.backend.arm.helper.regalloc import check_imm_arg
-from rpython.jit.backend.arm.codebuilder import ARMv7Builder, OverwritingBuilder
+from rpython.jit.backend.arm.codebuilder import InstrBuilder, OverwritingBuilder
from rpython.jit.backend.arm.jump import remap_frame_layout
from rpython.jit.backend.arm.regalloc import TempInt, TempPtr
from rpython.jit.backend.arm.locations import imm
@@ -299,19 +299,10 @@
is_guard_not_invalidated=True)
def emit_op_jump(self, op, arglocs, regalloc, fcond):
- # The backend's logic assumes that the target code is in a piece of
- # assembler that was also called with the same number of arguments,
- # so that the locations [ebp+8..] of the input arguments are valid
- # stack locations both before and after the jump.
- #
target_token = op.getdescr()
+ assert isinstance(target_token, TargetToken)
target = target_token._ll_loop_code
- assert isinstance(target_token, TargetToken)
assert fcond == c.AL
- my_nbargs = self.current_clt._debug_nbargs
- target_nbargs = target_token._arm_clt._debug_nbargs
- assert my_nbargs == target_nbargs
-
if target_token in self.target_tokens_currently_compiling:
self.mc.B_offs(target, fcond)
else:
@@ -576,10 +567,12 @@
def emit_op_cond_call_gc_wb(self, op, arglocs, regalloc, fcond):
self._write_barrier_fastpath(self.mc, op.getdescr(), arglocs, fcond)
+ return fcond
def emit_op_cond_call_gc_wb_array(self, op, arglocs, regalloc, fcond):
self._write_barrier_fastpath(self.mc, op.getdescr(), arglocs,
fcond, array=True)
+ return fcond
def _write_barrier_fastpath(self, mc, descr, arglocs, fcond=c.AL, array=False,
is_frame=False):
@@ -1219,7 +1212,7 @@
baseofs = self.cpu.get_baseofs_of_frame_field()
newlooptoken.compiled_loop_token.update_frame_info(
oldlooptoken.compiled_loop_token, baseofs)
- mc = ARMv7Builder()
+ mc = InstrBuilder()
mc.B(target)
mc.copy_to_raw_memory(oldadr)
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
@@ -752,6 +752,7 @@
# self.frame_manager.hint_frame_locations[box] = loc
def prepare_op_jump(self, op, fcond):
+ assert self.jump_target_descr is None
descr = op.getdescr()
assert isinstance(descr, TargetToken)
self.jump_target_descr = descr
diff --git a/rpython/jit/backend/arm/runner.py b/rpython/jit/backend/arm/runner.py
--- a/rpython/jit/backend/arm/runner.py
+++ b/rpython/jit/backend/arm/runner.py
@@ -86,10 +86,10 @@
possible then to re-call invalidate_loop() on the same looptoken,
which must invalidate all newer GUARD_NOT_INVALIDATED, but not the
old one that already has a bridge attached to it."""
- from rpython.jit.backend.arm.codebuilder import ARMv7Builder
+ from rpython.jit.backend.arm.codebuilder import InstrBuilder
for jmp, tgt in looptoken.compiled_loop_token.invalidate_positions:
- mc = ARMv7Builder()
+ mc = InstrBuilder()
mc.B_offs(tgt)
mc.copy_to_raw_memory(jmp)
# positions invalidated
@@ -106,27 +106,26 @@
return l
def build_regalloc(self):
- ''' for tests'''
- from rpython.jit.backend.arm.regalloc import Regalloc
- assert self.assembler is not None
- return Regalloc(self.assembler)
+ ''' for tests'''
+ from rpython.jit.backend.arm.regalloc import Regalloc
+ assert self.assembler is not None
+ return Regalloc(self.assembler)
class CPU_ARM(AbstractARMCPU):
"""ARM v7 uses softfp ABI, requires vfp"""
- backend_name = "arm"
+ backend_name = "armv7"
ArmCPU = CPU_ARM
class CPU_ARMHF(AbstractARMCPU):
"""ARM v7 uses hardfp ABI, requires vfp"""
use_hf_abi = True
- backend_name = "armhf"
+ backend_name = "armv7hf"
supports_floats = False
supports_singlefloats = False
class CPU_ARMv6(AbstractARMCPU):
""" ARM v6, uses hardfp ABI, requires vfp"""
use_hf_abi = True
- backend_name = "armv6"
+ backend_name = "armv6hf"
supports_floats = False
supports_singlefloats = False
-
diff --git a/rpython/jit/backend/arm/test/conftest.py b/rpython/jit/backend/arm/test/conftest.py
--- a/rpython/jit/backend/arm/test/conftest.py
+++ b/rpython/jit/backend/arm/test/conftest.py
@@ -17,5 +17,5 @@
help="run tests that translate code")
def pytest_runtest_setup(item):
- if cpu not in ('arm', 'armhf'):
+ if not cpu.startswith('arm'):
py.test.skip("ARM(v7) tests skipped: cpu is %r" % (cpu,))
diff --git a/rpython/jit/backend/arm/test/support.py b/rpython/jit/backend/arm/test/support.py
--- a/rpython/jit/backend/arm/test/support.py
+++ b/rpython/jit/backend/arm/test/support.py
@@ -39,6 +39,11 @@
i = commands.getoutput("%s -version </dev/null -o /dev/null 2>&1" % AS)
check_skip(i)
+def get_as_version():
+ import commands
+ i = commands.getoutput("%s -v </dev/null -o /dev/null 2>&1" % AS)
+ return tuple([int(j) for j in i.split()[-1].split('.')])
+
def check_skip(inp, search='arm', msg='only for arm'):
skip = True
try:
diff --git a/rpython/jit/backend/arm/test/test_assembler.py b/rpython/jit/backend/arm/test/test_assembler.py
--- a/rpython/jit/backend/arm/test/test_assembler.py
+++ b/rpython/jit/backend/arm/test/test_assembler.py
@@ -240,9 +240,11 @@
x = 0x60002224
self.a.gen_func_prolog()
self.a.mc.gen_load_int(r.r1.value, x)
+ self.a.mc.SUB_ri(r.sp.value, r.sp.value, 8)
self.a.mc.MOV_ri(r.r3.value, 8)
- self.a.mc.STR_rr(r.r1.value, r.fp.value, r.r3.value)
- self.a.mc.LDR_ri(r.r0.value, r.fp.value, 8)
+ self.a.mc.STR_rr(r.r1.value, r.sp.value, r.r3.value)
+ self.a.mc.LDR_ri(r.r0.value, r.sp.value, 8)
+ self.a.mc.ADD_ri(r.sp.value, r.sp.value, 8)
self.a.gen_func_epilog()
assert run_asm(self.a) == x
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
@@ -1,10 +1,12 @@
+import py
+
from rpython.rtyper.annlowlevel import llhelper
from rpython.jit.metainterp.history import JitCellToken
from rpython.jit.backend.test.calling_convention_test import CallingConvTests, parse
from rpython.rtyper.lltypesystem import lltype
from rpython.jit.codewriter.effectinfo import EffectInfo
-from rpython.jit.backend.arm.codebuilder import ARMv7Builder
+from rpython.jit.backend.arm.codebuilder import InstrBuilder
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
@@ -25,9 +27,9 @@
# ../../test/calling_convention_test.py
def make_function_returning_stack_pointer(self):
- mc = ARMv7Builder()
- mc.MOV_rr(r.r0.value, r.sp.value)
- mc.MOV_rr(r.pc.value, r.lr.value)
+ mc = InstrBuilder()
+ mc.MOV_rr(r.r0.value, r.sp.value)
+ mc.MOV_rr(r.pc.value, r.lr.value)
return mc.materialize(self.cpu.asmmemmgr, [])
def get_alignment_requirements(self):
diff --git a/rpython/jit/backend/arm/test/test_instr_codebuilder.py b/rpython/jit/backend/arm/test/test_instr_codebuilder.py
--- a/rpython/jit/backend/arm/test/test_instr_codebuilder.py
+++ b/rpython/jit/backend/arm/test/test_instr_codebuilder.py
@@ -2,13 +2,16 @@
from rpython.jit.backend.arm import codebuilder
from rpython.jit.backend.arm import conditions
from rpython.jit.backend.arm import instructions
-from rpython.jit.backend.arm.test.support import (requires_arm_as, define_test, gen_test_function)
+from rpython.jit.backend.arm.test.support import requires_arm_as
+from rpython.jit.backend.arm.test.support import get_as_version
+from rpython.jit.backend.arm.test.support import define_test
+from rpython.jit.backend.arm.test.support import gen_test_function
from gen import assemble
import py
requires_arm_as()
-class CodeBuilder(codebuilder.ARMv7Builder):
+class CodeBuilder(codebuilder.InstrBuilder):
def __init__(self):
self.buffer = []
@@ -80,6 +83,9 @@
self.assert_equal('ORR r0, r7, r12, lsl #8')
def test_push_one_reg(self):
+ if get_as_version() < (2, 23):
+ py.test.xfail("GNU as before version 2.23 generates encoding A1 for "
+ "pushing only one register")
self.cb.PUSH([r.r1.value])
self.assert_equal('PUSH {r1}')
diff --git a/rpython/jit/backend/arm/test/test_runner.py b/rpython/jit/backend/arm/test/test_runner.py
--- a/rpython/jit/backend/arm/test/test_runner.py
+++ b/rpython/jit/backend/arm/test/test_runner.py
@@ -27,6 +27,19 @@
bridge_loop_instructions = ['ldr', 'mov', 'nop', 'cmp', 'bge',
'push', 'mov', 'mov', 'push', 'mov', 'mov',
'blx', 'mov', 'mov', 'bx']
+ if CPU.backend_name.startswith('armv7'):
+ bridge_loop_instructions = ['ldr', 'mov', 'nop', 'cmp', 'bge',
+ 'push', 'mov', 'mov', 'push', 'mov', 'mov',
+ 'blx', 'mov', 'mov', 'bx']
+ else:
+ bridge_loop_instructions = ['ldr', 'mov', 'nop', 'nop', 'nop', 'cmp', 'bge',
+ 'push', 'ldr', 'mov',
+ '', # inline constant
+ 'push', 'ldr', 'mov',
+ 'ldrsblt', #inline constant (decodes as instruction)
+ 'blx', 'ldr', 'mov',
+ '', # inline constant
+ 'bx']
def get_cpu(self):
cpu = CPU(rtyper=None, stats=FakeStats())
diff --git a/rpython/jit/backend/llsupport/regalloc.py b/rpython/jit/backend/llsupport/regalloc.py
--- a/rpython/jit/backend/llsupport/regalloc.py
+++ b/rpython/jit/backend/llsupport/regalloc.py
@@ -278,11 +278,11 @@
no_lower_byte_regs = []
save_around_call_regs = []
frame_reg = None
- temp_boxes = []
def __init__(self, longevity, frame_manager=None, assembler=None):
self.free_regs = self.all_regs[:]
self.longevity = longevity
+ self.temp_boxes = []
if not we_are_translated():
self.reg_bindings = OrderedDict()
else:
diff --git a/rpython/jit/backend/llsupport/test/test_regalloc_integration.py b/rpython/jit/backend/llsupport/test/test_regalloc_integration.py
--- a/rpython/jit/backend/llsupport/test/test_regalloc_integration.py
+++ b/rpython/jit/backend/llsupport/test/test_regalloc_integration.py
@@ -515,6 +515,10 @@
# FIXME: Verify that i19 - i23 are removed
class TestRegallocFloats(BaseTestRegalloc):
+ def setup_class(cls):
+ if not cls.cpu.supports_floats:
+ py.test.skip("needs float support")
+
def test_float_add(self):
ops = '''
[f0, f1]
diff --git a/rpython/jit/backend/test/test_zll_stress_0.py b/rpython/jit/backend/test/test_zll_stress_0.py
new file mode 100644
--- /dev/null
+++ b/rpython/jit/backend/test/test_zll_stress_0.py
@@ -0,0 +1,4 @@
+from rpython.jit.backend.test import zll_stress
+
+def test_stress_0():
+ zll_stress.do_test_stress(0)
diff --git a/rpython/jit/backend/test/test_zll_stress_1.py b/rpython/jit/backend/test/test_zll_stress_1.py
new file mode 100644
--- /dev/null
+++ b/rpython/jit/backend/test/test_zll_stress_1.py
@@ -0,0 +1,4 @@
+from rpython.jit.backend.test import zll_stress
+
+def test_stress_1():
+ zll_stress.do_test_stress(1)
diff --git a/rpython/jit/backend/test/test_zll_stress_2.py b/rpython/jit/backend/test/test_zll_stress_2.py
new file mode 100644
--- /dev/null
+++ b/rpython/jit/backend/test/test_zll_stress_2.py
@@ -0,0 +1,4 @@
+from rpython.jit.backend.test import zll_stress
+
+def test_stress_2():
+ zll_stress.do_test_stress(2)
diff --git a/rpython/jit/backend/test/test_zll_stress_3.py b/rpython/jit/backend/test/test_zll_stress_3.py
new file mode 100644
--- /dev/null
+++ b/rpython/jit/backend/test/test_zll_stress_3.py
@@ -0,0 +1,4 @@
+from rpython.jit.backend.test import zll_stress
+
+def test_stress_3():
+ zll_stress.do_test_stress(3)
diff --git a/rpython/jit/backend/test/test_zll_stress.py b/rpython/jit/backend/test/zll_stress.py
rename from rpython/jit/backend/test/test_zll_stress.py
rename to rpython/jit/backend/test/zll_stress.py
--- a/rpython/jit/backend/test/test_zll_stress.py
+++ b/rpython/jit/backend/test/zll_stress.py
@@ -5,14 +5,18 @@
CPU = getcpuclass()
-iterations = 1000
+total_iterations = 1000
if platform.machine().startswith('arm'):
- iterations = 100
+ total_iterations = 100
+pieces = 4
+per_piece = total_iterations / pieces
-def test_stress():
+
+def do_test_stress(piece):
cpu = CPU(None, None)
cpu.setup_once()
r = Random()
- for i in range(iterations):
- check_random_function(cpu, LLtypeOperationBuilder, r, i, iterations)
+ r.jumpahead(piece*per_piece)
+ for i in range(piece*per_piece, (piece+1)*per_piece):
+ check_random_function(cpu, LLtypeOperationBuilder, r, i, total_iterations)
diff --git a/rpython/jit/backend/tool/viewcode.py b/rpython/jit/backend/tool/viewcode.py
--- a/rpython/jit/backend/tool/viewcode.py
+++ b/rpython/jit/backend/tool/viewcode.py
@@ -53,8 +53,8 @@
'x86_32': 'i386',
'x86_64': 'x86-64',
'i386': 'i386',
- 'arm': 'arm',
- 'arm_32': 'arm',
+ 'armv6_32': 'arm',
+ 'armv7_32': 'arm',
}
cmd = find_objdump()
objdump = ('%(command)s -M %(backend)s -b binary -m %(machine)s '
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -7,7 +7,7 @@
from rpython.jit.metainterp.history import AbstractDescr, ConstInt, BoxInt
from rpython.jit.metainterp.history import TreeLoop
from rpython.jit.metainterp import compile, resume
-from rpython.jit.metainterp.resoperation import rop, opname, opargnum
+from rpython.jit.metainterp.resoperation import rop, opname, oparity
from rpython.jit.metainterp.optimizeopt.test.test_optimizebasic import FakeMetaInterpStaticData
def test_build_opt_chain():
@@ -188,7 +188,7 @@
if 'FLOAT' in op:
continue
args = []
More information about the pypy-commit
mailing list