[pypy-commit] pypy s390x-backend: two more dtype tests fixed (endian issues)
Author: Richard PlanggerBranch: s390x-backend Changeset: r81909:272b467ba7dd Date: 2016-01-22 10:24 +0100 http://bitbucket.org/pypy/pypy/changeset/272b467ba7dd/ Log:two more dtype tests fixed (endian issues) diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py --- a/pypy/module/micronumpy/test/test_dtypes.py +++ b/pypy/module/micronumpy/test/test_dtypes.py @@ -924,6 +924,7 @@ def test_dtype_str(self): from numpy import dtype +import sys byteorder = self.native_prefix assert dtype('i8').str == byteorder + 'i8' assert dtype(' ')+'U7' assert dtype([('', 'f8')]).str == "|V8" assert dtype(('f8', 2)).str == "|V16" @@ -976,8 +978,12 @@ def test_isnative(self): from numpy import dtype +import sys assert dtype('i4').isnative == True -assert dtype('>i8').isnative == False +if sys.byteorder == 'big': +assert dtype(' i8').isnative == False def test_any_all_nonzero(self): import numpy ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy value-profiling: test that found the problem of the previous commit
Author: Carl Friedrich BolzBranch: value-profiling Changeset: r81903:7e6dd66f2318 Date: 2016-01-22 09:17 +0100 http://bitbucket.org/pypy/pypy/changeset/7e6dd66f2318/ Log:test that found the problem of the previous commit diff --git a/pypy/objspace/std/test/test_mapdict.py b/pypy/objspace/std/test/test_mapdict.py --- a/pypy/objspace/std/test/test_mapdict.py +++ b/pypy/objspace/std/test/test_mapdict.py @@ -931,6 +931,21 @@ d = x.__dict__ assert list(__pypy__.reversed_dict(d)) == d.keys()[::-1] +def test_bug_two_attributes(self): +class A(object): +def __setitem__(self, key, value): +self.setkey = key +self.setvalue = value +a1 = A() +a2 = A() +a1[a2] = 42 +assert a1.setkey is a2 +assert a1.setvalue == 42 +# +a1[42] = a2 +assert a1.setkey == 42 +assert a1.setvalue is a2 + class AppTestWithMapDictAndCounters(object): spaceconfig = {"objspace.std.withmapdict": True, ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy value-profiling: test and fix for write_necessary logic when mixing ints and objects
Author: Carl Friedrich BolzBranch: value-profiling Changeset: r81902:c1866643eecd Date: 2016-01-22 09:13 +0100 http://bitbucket.org/pypy/pypy/changeset/c1866643eecd/ Log:test and fix for write_necessary logic when mixing ints and objects diff --git a/rpython/rlib/heapprof.py b/rpython/rlib/heapprof.py --- a/rpython/rlib/heapprof.py +++ b/rpython/rlib/heapprof.py @@ -108,8 +108,9 @@ # call write_necessary if there is already a value there assert not status == SEEN_NOTHING if status == SEEN_CONSTANT_INT: -return (self.is_int(w_value) and -self.read_constant_int() != self.get_int_val(w_value)) +if not self.is_int(w_value): +return True +return self.read_constant_int() != self.get_int_val(w_value) elif status == SEEN_CONSTANT_OBJ: prev_obj = self.try_read_constant_obj() return prev_obj is not w_value diff --git a/rpython/rlib/test/test_heapprof.py b/rpython/rlib/test/test_heapprof.py --- a/rpython/rlib/test/test_heapprof.py +++ b/rpython/rlib/test/test_heapprof.py @@ -143,6 +143,13 @@ res = v.write_necessary(ValueInt(1)) assert res +v = HeapProf() +assert v._hprof_status == SEEN_NOTHING +v.see_write(ValueInt(1)) +res = v.write_necessary(Value()) +assert res + + def test_write_not_necessary_obj(): v = HeapProf() assert v._hprof_status == SEEN_NOTHING @@ -159,3 +166,4 @@ v.see_write(Value()) res = v.write_necessary(Value()) assert res + ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy s390x-backend: the same for the UTF32 test
Author: Richard PlanggerBranch: s390x-backend Changeset: r81906:9df502324ca5 Date: 2016-01-22 09:36 +0100 http://bitbucket.org/pypy/pypy/changeset/9df502324ca5/ Log:the same for the UTF32 test diff --git a/pypy/module/cpyext/test/test_unicodeobject.py b/pypy/module/cpyext/test/test_unicodeobject.py --- a/pypy/module/cpyext/test/test_unicodeobject.py +++ b/pypy/module/cpyext/test/test_unicodeobject.py @@ -423,7 +423,10 @@ test("\x61\x00\x00\x00\x62\x00\x00\x00", -1) -test("\x61\x00\x00\x00\x62\x00\x00\x00", None) +if sys.byteorder == 'big': +test("\x00\x00\x00\x61\x00\x00\x00\x62", None) +else: +test("\x61\x00\x00\x00\x62\x00\x00\x00", None) test("\x00\x00\x00\x61\x00\x00\x00\x62", 1) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy s390x-backend: endian test issue marshal, test decoded value using platform endianess (not desired for marshall module)
Author: Richard PlanggerBranch: s390x-backend Changeset: r81907:359e329036d5 Date: 2016-01-22 09:59 +0100 http://bitbucket.org/pypy/pypy/changeset/359e329036d5/ Log:endian test issue marshal, test decoded value using platform endianess (not desired for marshall module) diff --git a/pypy/module/marshal/test/test_marshalimpl.py b/pypy/module/marshal/test/test_marshalimpl.py --- a/pypy/module/marshal/test/test_marshalimpl.py +++ b/pypy/module/marshal/test/test_marshalimpl.py @@ -64,14 +64,17 @@ import marshal, struct class FakeM: +# NOTE: marshal is platform independent, running this test must assume +# that seen gets values from the endianess of the marshal module. +# (which is little endian!) def __init__(self): self.seen = [] def start(self, code): self.seen.append(code) def put_int(self, value): -self.seen.append(struct.pack("i", value)) +self.seen.append(struct.pack("
[pypy-commit] pypy s390x-backend: numpy dtype fixes in the test suite
Author: Richard PlanggerBranch: s390x-backend Changeset: r81908:6b28800745be Date: 2016-01-22 10:21 +0100 http://bitbucket.org/pypy/pypy/changeset/6b28800745be/ Log:numpy dtype fixes in the test suite diff --git a/pypy/module/marshal/test/test_marshalimpl.py b/pypy/module/marshal/test/test_marshalimpl.py --- a/pypy/module/marshal/test/test_marshalimpl.py +++ b/pypy/module/marshal/test/test_marshalimpl.py @@ -65,7 +65,7 @@ class FakeM: # NOTE: marshal is platform independent, running this test must assume -# that seen gets values from the endianess of the marshal module. +# that self.seen gets values from the endianess of the marshal module. # (which is little endian!) def __init__(self): self.seen = [] diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py --- a/pypy/module/micronumpy/test/test_dtypes.py +++ b/pypy/module/micronumpy/test/test_dtypes.py @@ -351,7 +351,10 @@ assert np.dtype(xyz).name == 'xyz' # another obscure API, used in numpy record.py a = np.dtype((xyz, [('x', 'int32'), ('y', 'float32')])) -assert "[('x', ' i4'), ('y', '>f4')]" in repr(a) +else: +assert "[('x', ' i4" +E = '<' if sys.byteorder == 'little' else '>' +b = np.dtype((xyz, [("col1", E+"i4"), ("col2", E+"i4"), ("col3", E+"i4")])) data = [(1, 2,3), (4, 5, 6)] a = np.array(data, dtype=b) x = pickle.loads(pickle.dumps(a)) @@ -423,18 +429,20 @@ assert hash(t5) != hash(t6) def test_pickle(self): +import sys import numpy as np from numpy import array, dtype from cPickle import loads, dumps a = array([1,2,3]) +E = '<' if sys.byteorder == 'little' else '>' if self.ptr_size == 8: -assert a.dtype.__reduce__() == (dtype, ('i8', 0, 1), (3, '<', None, None, None, -1, -1, 0)) +assert a.dtype.__reduce__() == (dtype, ('i8', 0, 1), (3, E, None, None, None, -1, -1, 0)) else: -assert a.dtype.__reduce__() == (dtype, ('i4', 0, 1), (3, '<', None, None, None, -1, -1, 0)) +assert a.dtype.__reduce__() == (dtype, ('i4', 0, 1), (3, E, None, None, None, -1, -1, 0)) assert loads(dumps(a.dtype)) == a.dtype assert np.dtype('bool').__reduce__() == (dtype, ('b1', 0, 1), (3, '|', None, None, None, -1, -1, 0)) assert np.dtype('|V16').__reduce__() == (dtype, ('V16', 0, 1), (3, '|', None, None, None, 16, 1, 0)) -assert np.dtype((' ' d = np.dtype('f8') d.__setstate__((3, '|', (np.dtype('float64'), (2,)), None, None, 20, 1, 0)) assert d.str == ('<' if sys.byteorder == 'little' else '>') + 'f8' @@ -1201,7 +1210,7 @@ assert d.shape == (2,) assert d.itemsize == 8 assert d.subdtype is not None -assert repr(d) == "dtype(('
[pypy-commit] pypy s390x-backend: half way through the ndarray tests (endian issues)
Author: Richard PlanggerBranch: s390x-backend Changeset: r81910:d1a60e575946 Date: 2016-01-22 10:56 +0100 http://bitbucket.org/pypy/pypy/changeset/d1a60e575946/ Log:half way through the ndarray tests (endian issues) diff --git a/pypy/module/micronumpy/test/test_ndarray.py b/pypy/module/micronumpy/test/test_ndarray.py --- a/pypy/module/micronumpy/test/test_ndarray.py +++ b/pypy/module/micronumpy/test/test_ndarray.py @@ -1791,6 +1791,7 @@ def test_scalar_view(self): from numpy import array +import sys a = array(3, dtype='int32') b = a.view(dtype='float32') assert b.shape == () @@ -1799,17 +1800,27 @@ assert exc.value[0] == "new type not compatible with array." exc = raises(TypeError, a.view, 'string') assert exc.value[0] == "data-type must not be 0-sized" -assert a.view('S4') == '\x03' +if sys.byteorder == 'big': +assert a.view('S4') == '\x00\x00\x00\x03' +else: +assert a.view('S4') == '\x03' a = array('abc1', dtype='c') assert (a == ['a', 'b', 'c', '1']).all() assert a.view('S4') == 'abc1' b = a.view([('a', 'i2'), ('b', 'i2')]) assert b.shape == (1,) -assert b[0][0] == 25185 -assert b[0][1] == 12643 +if sys.byteorder == 'big': +assert b[0][0] == 0x6162 +assert b[0][1] == 0x6331 +else: +assert b[0][0] == 25185 +assert b[0][1] == 12643 a = array([(1, 2)], dtype=[('a', 'int64'), ('b', 'int64')])[0] assert a.shape == () -assert a.view('S16') == '\x01' + '\x00' * 7 + '\x02' +if sys.byteorder == 'big': +assert a.view('S16') == '\x00' * 7 + '\x01' + '\x00' * 7 + '\x02' +else: +assert a.view('S16') == '\x01' + '\x00' * 7 + '\x02' a = array(2, dtype='
[pypy-commit] pypy s390x-backend: and the other part of the bigendian issues (micronumpy tests)
Author: Richard PlanggerBranch: s390x-backend Changeset: r81911:47a85e21bb1b Date: 2016-01-22 12:00 +0100 http://bitbucket.org/pypy/pypy/changeset/47a85e21bb1b/ Log:and the other part of the bigendian issues (micronumpy tests) diff --git a/pypy/module/micronumpy/test/test_ndarray.py b/pypy/module/micronumpy/test/test_ndarray.py --- a/pypy/module/micronumpy/test/test_ndarray.py +++ b/pypy/module/micronumpy/test/test_ndarray.py @@ -3500,7 +3500,11 @@ BaseNumpyAppTest.setup_class.im_func(cls) cls.w_data = cls.space.wrap(struct.pack('', 1, 2, 3, 4)) cls.w_fdata = cls.space.wrap(struct.pack('f', 2.3)) -cls.w_float16val = cls.space.wrap('\x00E') # 5.0 in float16 +import sys +if sys.byteorder == 'big': +cls.w_float16val = cls.space.wrap('E\x00') # 5.0 in float16 +else: +cls.w_float16val = cls.space.wrap('\x00E') # 5.0 in float16 cls.w_float32val = cls.space.wrap(struct.pack('f', 5.2)) cls.w_float64val = cls.space.wrap(struct.pack('d', 300.4)) cls.w_ulongval = cls.space.wrap(struct.pack('L', 12)) @@ -3608,9 +3612,15 @@ assert (t == []).all() u = fromstring("\x01\x00\x00\x00\x00\x00\x00\x00", dtype=int) if sys.maxint > 2 ** 31 - 1: -assert (u == [1]).all() +if sys.byteorder == 'big': +assert (u == [0x0100]).all() +else: +assert (u == [1]).all() else: -assert (u == [1, 0]).all() +if sys.byteorder == 'big': +assert (u == [0x0100, 0]).all() +else: +assert (u == [1, 0]).all() v = fromstring("abcd", dtype="|S2") assert v[0] == "ab" assert v[1] == "cd" @@ -3667,9 +3677,15 @@ k = fromstring(self.float16val, dtype='float16') assert k[0] == dtype('float16').type(5.) dt = array([5], dtype='longfloat').dtype +print(dt.itemsize) if dt.itemsize == 8: -m = fromstring('\x00\x00\x00\x00\x00\x00\x14@', - dtype='float64') +import sys +if sys.byteorder == 'big': +m = fromstring('@\x14\x00\x00\x00\x00\x00\x00', + dtype='float64') +else: +m = fromstring('\x00\x00\x00\x00\x00\x00\x14@', + dtype='float64') elif dt.itemsize == 12: m = fromstring('\x00\x00\x00\x00\x00\x00\x00\xa0\x01@\x00\x00', dtype='float96') @@ -3691,8 +3707,13 @@ def test_tostring(self): from numpy import array -assert array([1, 2, 3], 'i2').tostring() == '\x01\x00\x02\x00\x03\x00' -assert array([1, 2, 3], 'i2')[::2].tostring() == '\x01\x00\x03\x00' +import sys +if sys.byteorder == 'big': +assert array([1, 2, 3], 'i2').tostring() == '\x00\x01\x00\x02\x00\x03' +assert array([1, 2, 3], 'i2')[::2].tostring() == '\x00\x01\x00\x03' +else: +assert array([1, 2, 3], 'i2').tostring() == '\x01\x00\x02\x00\x03\x00' +assert array([1, 2, 3], 'i2')[::2].tostring() == '\x01\x00\x03\x00' assert array([1, 2, 3], ' i2')[::2].tostring() == '\x00\x01\x00\x03' assert array(0, dtype='i2').tostring() == '\x00\x00' @@ -4188,7 +4209,10 @@ v = a.view(('float32', 4)) assert v.dtype == np.dtype('float32') assert v.shape == (10, 4) -assert v[0][-1] == 2.53125 +if sys.byteorder == 'big': +assert v[0][-2] == 2.53125 +else: +assert v[0][-1] == 2.53125 exc = raises(ValueError, "a.view(('float32', 2))") assert exc.value[0] == 'new type not compatible with array.' diff --git a/pypy/module/micronumpy/test/test_scalar.py b/pypy/module/micronumpy/test/test_scalar.py --- a/pypy/module/micronumpy/test/test_scalar.py +++ b/pypy/module/micronumpy/test/test_scalar.py @@ -109,6 +109,7 @@ def test_pickle(self): from numpy import dtype, zeros +import sys try: from numpy.core.multiarray import scalar except ImportError: @@ -119,9 +120,11 @@ f = dtype('float64').type(13.37) c = dtype('complex128').type(13 + 37.j) -assert i.__reduce__() == (scalar, (dtype('int32'), '9\x05\x00\x00')) -assert f.__reduce__() == (scalar, (dtype('float64'), '=\n\xd7\xa3p\xbd*@')) -assert c.__reduce__() == (scalar, (dtype('complex128'), '\x00\x00\x00\x00\x00\x00*@\x00\x00\x00\x00\x00\x80B@')) +swap = lambda s: (''.join(reversed(s))) if sys.byteorder == 'big' else s +assert i.__reduce__() == (scalar, (dtype('int32'), swap('9\x05\x00\x00'))) +assert f.__reduce__() == (scalar, (dtype('float64'),
[pypy-commit] pypy s390x-backend: big endian issue while testing cpyext (PyUnicode_DecodeUTF16)
Author: Richard PlanggerBranch: s390x-backend Changeset: r81905:b1b31c094879 Date: 2016-01-22 09:34 +0100 http://bitbucket.org/pypy/pypy/changeset/b1b31c094879/ Log:big endian issue while testing cpyext (PyUnicode_DecodeUTF16) diff --git a/pypy/module/cpyext/test/test_arraymodule.py b/pypy/module/cpyext/test/test_arraymodule.py --- a/pypy/module/cpyext/test/test_arraymodule.py +++ b/pypy/module/cpyext/test/test_arraymodule.py @@ -57,7 +57,6 @@ buf = buffer(arr) exc = raises(TypeError, "buf[1] = '1'") assert str(exc.value) == "buffer is read-only" -# XXX big-endian if sys.byteorder == 'big': assert str(buf) == ('\0\0\0\x01' '\0\0\0\x02' diff --git a/pypy/module/cpyext/test/test_unicodeobject.py b/pypy/module/cpyext/test/test_unicodeobject.py --- a/pypy/module/cpyext/test/test_unicodeobject.py +++ b/pypy/module/cpyext/test/test_unicodeobject.py @@ -386,11 +386,11 @@ lltype.free(pendian, flavor='raw') test("\x61\x00\x62\x00\x63\x00\x64\x00", -1) - -test("\x61\x00\x62\x00\x63\x00\x64\x00", None) - +if sys.byteorder == 'big': +test("\x00\x61\x00\x62\x00\x63\x00\x64", None) +else: +test("\x61\x00\x62\x00\x63\x00\x64\x00", None) test("\x00\x61\x00\x62\x00\x63\x00\x64", 1) - test("\xFE\xFF\x00\x61\x00\x62\x00\x63\x00\x64", 0, 1) test("\xFF\xFE\x61\x00\x62\x00\x63\x00\x64\x00", 0, -1) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy s390x-backend: big endian test issue cpyext
Author: Richard PlanggerBranch: s390x-backend Changeset: r81904:43c90f2f520e Date: 2016-01-22 09:20 +0100 http://bitbucket.org/pypy/pypy/changeset/43c90f2f520e/ Log:big endian test issue cpyext diff --git a/pypy/module/cpyext/test/test_arraymodule.py b/pypy/module/cpyext/test/test_arraymodule.py --- a/pypy/module/cpyext/test/test_arraymodule.py +++ b/pypy/module/cpyext/test/test_arraymodule.py @@ -51,13 +51,20 @@ assert arr.tolist() == [1, 23, 4] def test_buffer(self): +import sys module = self.import_module(name='array') arr = module.array('i', [1,2,3,4]) buf = buffer(arr) exc = raises(TypeError, "buf[1] = '1'") assert str(exc.value) == "buffer is read-only" # XXX big-endian -assert str(buf) == ('\x01\0\0\0' -'\x02\0\0\0' -'\x03\0\0\0' -'\x04\0\0\0') +if sys.byteorder == 'big': +assert str(buf) == ('\0\0\0\x01' +'\0\0\0\x02' +'\0\0\0\x03' +'\0\0\0\x04') +else: +assert str(buf) == ('\x01\0\0\0' +'\x02\0\0\0' +'\x03\0\0\0' +'\x04\0\0\0') ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy.org extradoc: update the values
Author: Armin RigoBranch: extradoc Changeset: r694:50a0e13fff46 Date: 2016-01-22 12:47 +0100 http://bitbucket.org/pypy/pypy.org/changeset/50a0e13fff46/ Log:update the values diff --git a/don1.html b/don1.html --- a/don1.html +++ b/don1.html @@ -9,13 +9,13 @@ $(function() { $("#progressbar").progressbar({ - value: 59.7 + value: 59.8 }); }); - $62736 of $105000 (59.7%) + $62755 of $105000 (59.8%) @@ -23,7 +23,7 @@ This donation goes towards supporting Python 3 in PyPy. Current status: -we have $7914 left +we have $7931 left in the account. Read proposal diff --git a/don4.html b/don4.html --- a/don4.html +++ b/don4.html @@ -17,7 +17,7 @@ 2nd call: - $30344 of $8 (37.9%) + $30354 of $8 (37.9%) @@ -25,7 +25,7 @@ This donation goes towards supporting the Transactional Memory in PyPy. Current status: -we have $23076 left +we have $23084 left in the account. Read proposal (2nd call) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy s390x-backend: fixed callsite of clibffi with the same big endian issues as found yesterday evening
Author: Richard PlanggerBranch: s390x-backend Changeset: r81912:6840459f9b22 Date: 2016-01-22 12:51 +0100 http://bitbucket.org/pypy/pypy/changeset/6840459f9b22/ Log:fixed callsite of clibffi with the same big endian issues as found yesterday evening diff --git a/pypy/module/micronumpy/test/test_ndarray.py b/pypy/module/micronumpy/test/test_ndarray.py --- a/pypy/module/micronumpy/test/test_ndarray.py +++ b/pypy/module/micronumpy/test/test_ndarray.py @@ -4209,6 +4209,7 @@ v = a.view(('float32', 4)) assert v.dtype == np.dtype('float32') assert v.shape == (10, 4) +import sys if sys.byteorder == 'big': assert v[0][-2] == 2.53125 else: diff --git a/rpython/rlib/clibffi.py b/rpython/rlib/clibffi.py --- a/rpython/rlib/clibffi.py +++ b/rpython/rlib/clibffi.py @@ -597,6 +597,9 @@ size = adjust_return_size(intmask(restype.c_size)) self.ll_result = lltype.malloc(rffi.VOIDP.TO, size, flavor='raw') +self.restype_size = intmask(restype.c_size) +else: +self.restype_size = -1 def push_arg(self, value): #if self.pushed_args == self.argnum: @@ -633,7 +636,12 @@ rffi.cast(VOIDPP, self.ll_args)) if RES_TP is not lltype.Void: TP = lltype.Ptr(rffi.CArray(RES_TP)) -res = rffi.cast(TP, self.ll_result)[0] +ptr = self.ll_result +if _BIG_ENDIAN and self.restype_size != -1: +# we get a 8 byte value in big endian +n = rffi.sizeof(lltype.Signed) - self.restype_size +ptr = rffi.ptradd(ptr, n) +res = rffi.cast(TP, ptr)[0] else: res = None self._clean_args() diff --git a/rpython/rlib/rstruct/test/test_runpack.py b/rpython/rlib/rstruct/test/test_runpack.py --- a/rpython/rlib/rstruct/test/test_runpack.py +++ b/rpython/rlib/rstruct/test/test_runpack.py @@ -6,11 +6,13 @@ class TestRStruct(BaseRtypingTest): def test_unpack(self): +import sys pad = '\x00' * (LONG_BIT//8-1)# 3 or 7 null bytes def fn(): return runpack('sll', 'a'+pad+'\x03'+pad+'\x04'+pad)[1] -assert fn() == 3 -assert self.interpret(fn, []) == 3 +result = 3 if sys.byteorder == 'little' else 3 << (LONG_BIT-8) +assert fn() == result +assert self.interpret(fn, []) == result def test_unpack_2(self): data = struct.pack('', 0, 1, 2, 4) diff --git a/rpython/rlib/test/test_clibffi.py b/rpython/rlib/test/test_clibffi.py --- a/rpython/rlib/test/test_clibffi.py +++ b/rpython/rlib/test/test_clibffi.py @@ -181,11 +181,12 @@ p_a2 = rffi.cast(rffi.VOIDPP, ll_args[1])[0] a1 = rffi.cast(rffi.INTP, p_a1)[0] a2 = rffi.cast(rffi.INTP, p_a2)[0] -res = rffi.cast(rffi.INTP, ll_res) +res = rffi.cast(rffi.SIGNEDP, ll_res) +# must store a full ffi arg! if a1 > a2: -res[0] = rffi.cast(rffi.INT, 1) +res[0] = 1 else: -res[0] = rffi.cast(rffi.INT, -1) +res[0] = -1 ptr = CallbackFuncPtr([ffi_type_pointer, ffi_type_pointer], ffi_type_sint, callback) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy value-profiling: fix interaction of known class lists and cpyext
Author: Carl Friedrich BolzBranch: value-profiling Changeset: r81923:f66ef9ad7656 Date: 2016-01-22 17:47 +0100 http://bitbucket.org/pypy/pypy/changeset/f66ef9ad7656/ Log:fix interaction of known class lists and cpyext 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 @@ -88,6 +88,10 @@ return space.fromcache(EmptyListStrategy) w_firstobj = list_w[0] +if w_firstobj is None: +# this is done by cpyext: +return space.fromcache(ObjectListStrategy) + check_int_or_float = False if type(w_firstobj) is W_IntObject: diff --git a/pypy/objspace/std/test/test_listobject.py b/pypy/objspace/std/test/test_listobject.py --- a/pypy/objspace/std/test/test_listobject.py +++ b/pypy/objspace/std/test/test_listobject.py @@ -417,6 +417,13 @@ assert isinstance(w_lst.strategy, SizeListStrategy) assert w_lst.strategy.sizehint == 13 +def test_newlist_with_interplevel_None(self): +# needed for cpyext +space = self.space +w_lst = space.newlist([None] * 10) +assert w_lst.strategy._known_cls is None + + def test_find_fast_on_intlist(self, monkeypatch): monkeypatch.setattr(self.space, "eq_w", None) w = self.space.wrap ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy s390x-backend: added comment to my last commit
Author: Richard PlanggerBranch: s390x-backend Changeset: r81922:dcf9b353608e Date: 2016-01-22 18:03 +0100 http://bitbucket.org/pypy/pypy/changeset/dcf9b353608e/ Log:added comment to my last commit diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py --- a/rpython/rlib/rposix.py +++ b/rpython/rlib/rposix.py @@ -871,6 +871,9 @@ lltype.free(status_p, flavor='raw') def _make_waitmacro(name): +# note that rffi.INT as first parameter type is intentional. +# on s390x providing a lltype.Signed as param type, the +# macro wrapper function will always return 0 c_func = external(name, [rffi.INT], lltype.Signed, macro=_MACRO_ON_POSIX) returning_int = name in ('WEXITSTATUS', 'WSTOPSIG', 'WTERMSIG') ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vmprof-newstack: change pdb to some asserts
Author: fijal Branch: vmprof-newstack Changeset: r81917:ffec42c76f43 Date: 2016-01-22 15:18 +0100 http://bitbucket.org/pypy/pypy/changeset/ffec42c76f43/ Log:change pdb to some asserts diff --git a/rpython/jit/backend/llsupport/test/zrpy_vmprof_test.py b/rpython/jit/backend/llsupport/test/zrpy_vmprof_test.py --- a/rpython/jit/backend/llsupport/test/zrpy_vmprof_test.py +++ b/rpython/jit/backend/llsupport/test/zrpy_vmprof_test.py @@ -74,8 +74,8 @@ tmpfile = str(udir.join('test_rvmprof')) stats = read_profile(tmpfile) t = stats.get_tree() -import pdb -pdb.set_trace() +assert t.name == 'py:x:foo:3' +assert len(t.children) == 1 # jit self.meta_interp(f, [100], inline=True) try: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vmprof-newstack: import os x related hacks for threads & vmprof
Author: fijal Branch: vmprof-newstack Changeset: r81916:670f46cb2434 Date: 2016-01-22 15:12 +0100 http://bitbucket.org/pypy/pypy/changeset/670f46cb2434/ Log:import os x related hacks for threads & vmprof diff --git a/rpython/rlib/rvmprof/src/vmprof_common.h b/rpython/rlib/rvmprof/src/vmprof_common.h new file mode 100644 --- /dev/null +++ b/rpython/rlib/rvmprof/src/vmprof_common.h @@ -0,0 +1,71 @@ +#include + +#define MAX_FUNC_NAME 1024 + +static int profile_file = -1; +static long prepare_interval_usec = 0; +static long profile_interval_usec = 0; +static int opened_profile(char *interp_name); + +#define MAX_STACK_DEPTH \ +((SINGLE_BUF_SIZE - sizeof(struct prof_stacktrace_s)) / sizeof(void *)) + +#define MARKER_STACKTRACE '\x01' +#define MARKER_VIRTUAL_IP '\x02' +#define MARKER_TRAILER '\x03' +#define MARKER_INTERP_NAME '\x04' /* deprecated */ +#define MARKER_HEADER '\x05' + +#define VERSION_BASE '\x00' +#define VERSION_THREAD_ID '\x01' + +typedef struct prof_stacktrace_s { +char padding[sizeof(long) - 1]; +char marker; +long count, depth; +void *stack[]; +} prof_stacktrace_s; + + +RPY_EXTERN +char *vmprof_init(int fd, double interval, char *interp_name) +{ +if (interval < 1e-6 || interval >= 1.0) +return "bad value for 'interval'"; +prepare_interval_usec = (int)(interval * 100.0); + +if (prepare_concurrent_bufs() < 0) +return "out of memory"; + +assert(fd >= 0); +profile_file = fd; +if (opened_profile(interp_name) < 0) { +profile_file = -1; +return strerror(errno); +} +return NULL; +} + +static int _write_all(const char *buf, size_t bufsize); + +static int opened_profile(char *interp_name) +{ +struct { +long hdr[5]; +char interp_name[259]; +} header; + +size_t namelen = strnlen(interp_name, 255); + +header.hdr[0] = 0; +header.hdr[1] = 3; +header.hdr[2] = 0; +header.hdr[3] = prepare_interval_usec; +header.hdr[4] = 0; +header.interp_name[0] = MARKER_HEADER; +header.interp_name[1] = '\x00'; +header.interp_name[2] = VERSION_THREAD_ID; +header.interp_name[3] = namelen; +memcpy(_name[4], interp_name, namelen); +return _write_all((char*), 5 * sizeof(long) + 4 + namelen); +} diff --git a/rpython/rlib/rvmprof/src/vmprof_main.h b/rpython/rlib/rvmprof/src/vmprof_main.h --- a/rpython/rlib/rvmprof/src/vmprof_main.h +++ b/rpython/rlib/rvmprof/src/vmprof_main.h @@ -35,11 +35,12 @@ #include "vmprof_getpc.h" #include "vmprof_mt.h" #include "vmprof_stack.h" +#include "vmprof_common.h" // -static int profile_file = -1; static long prepare_interval_usec; +static long saved_profile_file; static struct profbuf_s *volatile current_codes; static void *(*mainloop_get_virtual_ip)(char *) = 0; @@ -47,26 +48,6 @@ static void flush_codes(void); - -RPY_EXTERN -char *vmprof_init(int fd, double interval, char *interp_name) -{ -if (interval < 1e-6 || interval >= 1.0) -return "bad value for 'interval'"; -prepare_interval_usec = (int)(interval * 100.0); - -if (prepare_concurrent_bufs() < 0) -return "out of memory"; - -assert(fd >= 0); -profile_file = fd; -if (opened_profile(interp_name) < 0) { -profile_file = -1; -return strerror(errno); -} -return NULL; -} - // /* value: last bit is 1 if signals must be ignored; all other bits @@ -94,28 +75,6 @@ * * */ -#define MAX_FUNC_NAME 128 -#define MAX_STACK_DEPTH \ -((SINGLE_BUF_SIZE - sizeof(struct prof_stacktrace_s)) / sizeof(void *)) - -#define MARKER_STACKTRACE '\x01' -#define MARKER_VIRTUAL_IP '\x02' -#define MARKER_TRAILER '\x03' -#define MARKER_INTERP_NAME '\x04' /* deprecated */ -#define MARKER_HEADER '\x05' - -#define VERSION_BASE '\x00' -#define VERSION_THREAD_ID '\x01' -#define VERSION_TAG '\x02' - -struct prof_stacktrace_s { -char padding[sizeof(long) - 1]; -char marker; -long count, depth; -intptr_t stack[]; -}; - -static long profile_interval_usec = 0; static char atfork_hook_installed = 0; @@ -194,8 +153,43 @@ * * */ +#include + +volatile int spinlock; +jmp_buf restore_point; + +static void segfault_handler(int arg) +{ +longjmp(restore_point, SIGSEGV); +} + static void sigprof_handler(int sig_nr, siginfo_t* info, void *ucontext) { +#ifdef __APPLE__ +// TERRIBLE HACK AHEAD +// on OS X, the thread local storage is sometimes uninitialized +// when the signal handler runs - it means it's impossible to read errno +// or call any syscall or read PyThread_Current or pthread_self. Additionally, +// it seems impossible to read the register gs. +// here we register segfault handler (all guarded by a spinlock) and call +//
[pypy-commit] pypy vmprof-newstack: we can have is_recursive but no get_unique_id
Author: fijal Branch: vmprof-newstack Changeset: r81913:9fcd011d9607 Date: 2016-01-22 14:28 +0100 http://bitbucket.org/pypy/pypy/changeset/9fcd011d9607/ Log:we can have is_recursive but no get_unique_id diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py --- a/rpython/rlib/jit.py +++ b/rpython/rlib/jit.py @@ -623,8 +623,8 @@ raise AttributeError("no 'greens' or 'reds' supplied") if virtualizables is not None: self.virtualizables = virtualizables -if get_unique_id is not None or is_recursive: -assert get_unique_id is not None and is_recursive, "get_unique_id and is_recursive must be specified at the same time" +if get_unique_id is not None: +assert is_recursive, "get_unique_id and is_recursive must be specified at the same time" for v in self.virtualizables: assert v in self.reds # if reds are automatic, they won't be passed to jit_merge_point, so ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy s390x-backend: macros (e.g. WCOREDUMP) got parameter type Signed, on little endian this does not make a difference, but it does on big endian. changed to rffi.INT
Author: Richard PlanggerBranch: s390x-backend Changeset: r81914:43db866bfbb3 Date: 2016-01-22 14:56 +0100 http://bitbucket.org/pypy/pypy/changeset/43db866bfbb3/ Log:macros (e.g. WCOREDUMP) got parameter type Signed, on little endian this does not make a difference, but it does on big endian. changed to rffi.INT diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py --- a/rpython/rlib/rposix.py +++ b/rpython/rlib/rposix.py @@ -871,7 +871,7 @@ lltype.free(status_p, flavor='raw') def _make_waitmacro(name): -c_func = external(name, [lltype.Signed], lltype.Signed, +c_func = external(name, [rffi.INT], lltype.Signed, macro=_MACRO_ON_POSIX) returning_int = name in ('WEXITSTATUS', 'WSTOPSIG', 'WTERMSIG') ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vmprof-newstack: fix that test
Author: fijal Branch: vmprof-newstack Changeset: r81915:900de81cdc5e Date: 2016-01-22 15:11 +0100 http://bitbucket.org/pypy/pypy/changeset/900de81cdc5e/ Log:fix that test diff --git a/rpython/jit/metainterp/test/test_recursive.py b/rpython/jit/metainterp/test/test_recursive.py --- a/rpython/jit/metainterp/test/test_recursive.py +++ b/rpython/jit/metainterp/test/test_recursive.py @@ -1312,7 +1312,7 @@ return (code + 1) * 2 driver = JitDriver(greens=["pc", "code"], reds='auto', - get_unique_id=get_unique_id) + get_unique_id=get_unique_id, is_recursive=True) def f(pc, code): i = 0 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vmprof-newstack: fix the test
Author: fijal Branch: vmprof-newstack Changeset: r81920:b5543f370125 Date: 2016-01-22 17:33 +0100 http://bitbucket.org/pypy/pypy/changeset/b5543f370125/ Log:fix the test diff --git a/rpython/jit/metainterp/test/test_jitdriver.py b/rpython/jit/metainterp/test/test_jitdriver.py --- a/rpython/jit/metainterp/test/test_jitdriver.py +++ b/rpython/jit/metainterp/test/test_jitdriver.py @@ -193,7 +193,7 @@ return pc + 1 driver = JitDriver(greens=["pc"], reds='auto', - get_unique_id=get_unique_id) + get_unique_id=get_unique_id, is_recursive=True) def f(arg): i = 0 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vmprof-newstack: merge
Author: fijal Branch: vmprof-newstack Changeset: r81921:4b79f234a111 Date: 2016-01-22 17:45 +0100 http://bitbucket.org/pypy/pypy/changeset/4b79f234a111/ Log:merge diff --git a/rpython/jit/codewriter/test/test_jtransform.py b/rpython/jit/codewriter/test/test_jtransform.py --- a/rpython/jit/codewriter/test/test_jtransform.py +++ b/rpython/jit/codewriter/test/test_jtransform.py @@ -1332,7 +1332,7 @@ tlfield = ThreadLocalField(lltype.Signed, 'foobar_test_', loop_invariant=loop_inv) OS_THREADLOCALREF_GET = effectinfo.EffectInfo.OS_THREADLOCALREF_GET -c = const(tlfield.offset) +c = const(tlfield.getoffset()) v = varoftype(lltype.Signed) op = SpaceOperation('threadlocalref_get', [c], v) cc = FakeBuiltinCallControl() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vmprof-newstack: Fix for some tests: don't use .offset directly, call .getoffset()
Author: Armin RigoBranch: vmprof-newstack Changeset: r81918:fba43bc13dda Date: 2016-01-22 16:41 +0100 http://bitbucket.org/pypy/pypy/changeset/fba43bc13dda/ Log:Fix for some tests: don't use .offset directly, call .getoffset() diff --git a/rpython/jit/backend/x86/assembler.py b/rpython/jit/backend/x86/assembler.py --- a/rpython/jit/backend/x86/assembler.py +++ b/rpython/jit/backend/x86/assembler.py @@ -857,7 +857,8 @@ # eax = address in the stack of a 3-words struct vmprof_stack_s self.mc.LEA_rs(eax.value, (FRAME_FIXED_SIZE - 4) * WORD) # old = current value of vmprof_tl_stack -self.mc.MOV_rm(old.value, (tloc.value, cintf.vmprof_tl_stack.offset)) +offset = cintf.vmprof_tl_stack.getoffset() +self.mc.MOV_rm(old.value, (tloc.value, offset)) # eax->next = old self.mc.MOV_mr((eax.value, 0), old.value) # eax->value = my esp @@ -865,7 +866,7 @@ # eax->kind = VMPROF_JITTED_TAG self.mc.MOV_mi((eax.value, WORD * 2), VMPROF_JITTED_TAG) # save in vmprof_tl_stack the new eax -self.mc.MOV_mr((tloc.value, cintf.vmprof_tl_stack.offset), eax.value) +self.mc.MOV_mr((tloc.value, offset), eax.value) def _call_footer_vmprof(self): from rpython.rlib.rvmprof.rvmprof import cintf @@ -874,7 +875,8 @@ # eax = (our local vmprof_tl_stack).next self.mc.MOV_rs(eax.value, (FRAME_FIXED_SIZE - 4 + 0) * WORD) # save in vmprof_tl_stack the value eax -self.mc.MOV_mr((edx.value, cintf.vmprof_tl_stack.offset), eax.value) +offset = cintf.vmprof_tl_stack.getoffset() +self.mc.MOV_mr((edx.value, offset), eax.value) def _call_header(self): self.mc.SUB_ri(esp.value, FRAME_FIXED_SIZE * WORD) diff --git a/rpython/rlib/rthread.py b/rpython/rlib/rthread.py --- a/rpython/rlib/rthread.py +++ b/rpython/rlib/rthread.py @@ -308,7 +308,7 @@ offset = CDefinedIntSymbolic('RPY_TLOFS_%s' % self.fieldname, default='?') offset.loop_invariant = loop_invariant -self.offset = offset +self._offset = offset def getraw(): if we_are_translated(): @@ -364,7 +364,7 @@ ThreadLocalField.__init__(self, lltype.Signed, 'tlref%d' % unique_id, loop_invariant=loop_invariant) setraw = self.setraw -offset = self.offset +offset = self._offset def get(): if we_are_translated(): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vmprof-newstack: fix
Author: Armin RigoBranch: vmprof-newstack Changeset: r81919:e45af82e0252 Date: 2016-01-22 17:31 +0100 http://bitbucket.org/pypy/pypy/changeset/e45af82e0252/ Log:fix diff --git a/rpython/jit/codewriter/test/test_jtransform.py b/rpython/jit/codewriter/test/test_jtransform.py --- a/rpython/jit/codewriter/test/test_jtransform.py +++ b/rpython/jit/codewriter/test/test_jtransform.py @@ -1332,7 +1332,7 @@ tlfield = ThreadLocalField(lltype.Signed, 'foobar_test_', loop_invariant=loop_inv) OS_THREADLOCALREF_GET = effectinfo.EffectInfo.OS_THREADLOCALREF_GET -c = const(tlfield.offset) +c = const(tlfield.getoffset()) v = varoftype(lltype.Signed) op = SpaceOperation('threadlocalref_get', [c], v) cc = FakeBuiltinCallControl() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit