[pypy-commit] pypy issue-2248: fix for issue #2248, can W_Float.int() be removed?
Author: mattipBranch: issue-2248 Changeset: r82650:64144f654a33 Date: 2016-03-02 00:27 -0500 http://bitbucket.org/pypy/pypy/changeset/64144f654a33/ Log:fix for issue #2248, can W_Float.int() be removed? diff --git a/pypy/module/__builtin__/test/test_classobj.py b/pypy/module/__builtin__/test/test_classobj.py --- a/pypy/module/__builtin__/test/test_classobj.py +++ b/pypy/module/__builtin__/test/test_classobj.py @@ -452,7 +452,6 @@ assert a + 1 == 2 assert a + 1.1 == 2 - def test_binaryop_calls_coerce_always(self): l = [] class A: @@ -1076,6 +1075,16 @@ assert (D() > A()) == 'D:A.gt' assert (D() >= A()) == 'D:A.ge' +def test_override___int__(self): +class F(float): +def __int__(self): +return 666 +f = F(-12.3) +assert int(f) == 666 +# on cpython, this calls float_trunc() in floatobject.c +# which ends up calling PyFloat_AS_DOUBLE((PyFloatObject*) f) +assert float.__int__(f) == -12 + class AppTestOldStyleClassBytesDict(object): def setup_class(cls): 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 @@ -661,7 +661,7 @@ __format__ = interp2app(W_FloatObject.descr_format), __coerce__ = interp2app(W_FloatObject.descr_coerce), __nonzero__ = interp2app(W_FloatObject.descr_nonzero), -__int__ = interp2app(W_FloatObject.int), +__int__ = interp2app(W_FloatObject.descr_trunc), __float__ = interp2app(W_FloatObject.descr_float), __long__ = interp2app(W_FloatObject.descr_long), __trunc__ = interp2app(W_FloatObject.descr_trunc), ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cpyext-ext: fix fix
Author: mattipBranch: cpyext-ext Changeset: r82649:d34b903fd57b Date: 2016-03-01 21:45 -0500 http://bitbucket.org/pypy/pypy/changeset/d34b903fd57b/ Log:fix fix diff --git a/pypy/module/cpyext/unicodeobject.py b/pypy/module/cpyext/unicodeobject.py --- a/pypy/module/cpyext/unicodeobject.py +++ b/pypy/module/cpyext/unicodeobject.py @@ -8,7 +8,7 @@ from pypy.module.cpyext.pyerrors import PyErr_BadArgument from pypy.module.cpyext.pyobject import ( PyObject, PyObjectP, Py_DecRef, make_ref, from_ref, track_reference, -make_typedescr, get_typedescr) +make_typedescr, get_typedescr, as_pyobj) from pypy.module.cpyext.stringobject import PyString_Check from pypy.module.sys.interp_encoding import setdefaultencoding from pypy.module._codecs.interp_codecs import CodecState @@ -59,14 +59,14 @@ py_uni.c_ob_refcnt = 1 py_uni.c_ob_type = pytype if length > 0: -py_uni.c_str = lltype.malloc(rffi.CCHARP.TO, length+1, +py_uni.c_str = lltype.malloc(rffi.CWCHARP.TO, length+1, flavor='raw', zero=True) -py_str.c_length = length +py_uni.c_length = length s = rffi.wcharpsize2unicode(py_uni.c_str, py_uni.c_length) w_obj = space.wrap(s) -py_str.c_ob_shash = space.hash_w(w_obj) -track_reference(space, rffi.cast(PyObject, py_str), w_obj) -return rffi.cast(PyObject, py_str) +py_uni.c_hash = space.hash_w(w_obj) +track_reference(space, rffi.cast(PyObject, py_uni), w_obj) +return rffi.cast(PyObject, py_uni) def new_empty_unicode(space, length): """ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cpyext-ext: test and fix: slot_tp_init
Author: Armin RigoBranch: cpyext-ext Changeset: r82648:51eac7129726 Date: 2016-03-01 22:15 +0100 http://bitbucket.org/pypy/pypy/changeset/51eac7129726/ Log:test and fix: slot_tp_init diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py --- a/pypy/module/cpyext/slotdefs.py +++ b/pypy/module/cpyext/slotdefs.py @@ -329,13 +329,6 @@ w_args_new = space.newtuple(args_w) return space.call(w_func, w_args_new, w_kwds) -@cpython_api([PyObject, PyObject, PyObject], rffi.INT_real, error=-1, header=None) -def slot_tp_init(space, w_self, w_args, w_kwds): -w_descr = space.lookup(w_self, '__init__') -args = Arguments.frompacked(space, w_args, w_kwds) -space.get_and_call_args(w_descr, w_self, args) -return 0 - from rpython.rlib.nonconst import NonConstant SLOTS = {} @@ -456,6 +449,21 @@ return None api_func = slot_tp_iternext.api_func +elif name == 'tp_init': +init_fn = w_type.getdictvalue(space, '__init__') +if init_fn is None: +return + +@cpython_api([PyObject, PyObject, PyObject], rffi.INT_real, error=-1, + header=header) +@func_renamer("cpyext_%s_%s" % (name.replace('.', '_'), typedef.name)) +def slot_tp_init(space, w_self, w_args, w_kwds): +args = Arguments(space, [w_self], + w_stararg=w_args, w_starstararg=w_kwds) +space.call_args(init_fn, args) +return 0 +api_func = slot_tp_init.api_func + else: return diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py --- a/pypy/module/cpyext/test/test_typeobject.py +++ b/pypy/module/cpyext/test/test_typeobject.py @@ -559,6 +559,35 @@ #assert module.tp_call(D, typ1, ()) == "foo! ()" XXX not working so far assert isinstance(module.tp_call(type, typ1, ()), typ1) +def test_tp_init(self): +module = self.import_extension('foo', [ +("tp_init", "METH_VARARGS", + ''' + PyTypeObject *type = (PyTypeObject *)PyTuple_GET_ITEM(args, 0); + PyObject *obj = PyTuple_GET_ITEM(args, 1); + PyObject *c_args = PyTuple_GET_ITEM(args, 2); + if (!type->tp_init) + { + PyErr_SetNone(PyExc_ValueError); + return NULL; + } + if (type->tp_init(obj, c_args, NULL) < 0) + return NULL; + Py_INCREF(Py_None); + return Py_None; + ''' + ) +]) +x = [42] +assert module.tp_init(list, x, ("hi",)) is None +assert x == ["h", "i"] +class LL(list): +def __init__(self, *ignored): +raise Exception +x = LL.__new__(LL) +assert module.tp_init(list, x, ("hi",)) is None +assert x == ["h", "i"] + def test_tp_str(self): module = self.import_extension('foo', [ ("tp_str", "METH_VARARGS", ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cpyext-ext: Rewrite the test in a way independent of issue 2248
Author: Armin RigoBranch: cpyext-ext Changeset: r82647:1c037e8cb40d Date: 2016-03-01 21:20 +0100 http://bitbucket.org/pypy/pypy/changeset/1c037e8cb40d/ Log:Rewrite the test in a way independent of issue 2248 diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py --- a/pypy/module/cpyext/test/test_typeobject.py +++ b/pypy/module/cpyext/test/test_typeobject.py @@ -489,8 +489,11 @@ class F(float): def __int__(self): return 666 -skip("XXX fix issue 2248 first") -assert module.nb_int(float, F(-12.3)) == -12 +# as long as issue 2248 is not fixed, 'expected' is 666 on pypy, +# but it should be -12. This test is not concerned about that, +# but only about getting the same answer with module.nb_int(). +expected = float.__int__(F(-12.3)) +assert module.nb_int(float, F(-12.3)) == expected def test_nb_float(self): module = self.import_extension('foo', [ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cpyext-ext: Test and fix for tp_iter and tp_iternext (also fixes the latter to not
Author: Armin RigoBranch: cpyext-ext Changeset: r82646:3af62800d459 Date: 2016-03-01 21:15 +0100 http://bitbucket.org/pypy/pypy/changeset/3af62800d459/ Log:Test and fix for tp_iter and tp_iternext (also fixes the latter to not raise StopIteration but simply return NULL in case of exhaustion) diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py --- a/pypy/module/cpyext/slotdefs.py +++ b/pypy/module/cpyext/slotdefs.py @@ -336,14 +336,6 @@ space.get_and_call_args(w_descr, w_self, args) return 0 -@cpython_api([PyObject], PyObject, header=None) -def slot_tp_iter(space, w_self): -return space.iter(w_self) - -@cpython_api([PyObject], PyObject, header=None) -def slot_tp_iternext(space, w_self): -return space.next(w_self) - from rpython.rlib.nonconst import NonConstant SLOTS = {} @@ -437,6 +429,33 @@ return space.call_function(str_fn, w_self) api_func = slot_tp_str.api_func +elif name == 'tp_iter': +iter_fn = w_type.getdictvalue(space, '__iter__') +if iter_fn is None: +return + +@cpython_api([PyObject], PyObject, header=header) +@func_renamer("cpyext_%s_%s" % (name.replace('.', '_'), typedef.name)) +def slot_tp_iter(space, w_self): +return space.call_function(iter_fn, w_self) +api_func = slot_tp_iter.api_func + +elif name == 'tp_iternext': +iternext_fn = w_type.getdictvalue(space, 'next') +if iternext_fn is None: +return + +@cpython_api([PyObject], PyObject, header=header) +@func_renamer("cpyext_%s_%s" % (name.replace('.', '_'), typedef.name)) +def slot_tp_iternext(space, w_self): +try: +return space.call_function(iternext_fn, w_self) +except OperationError, e: +if not e.match(space, space.w_StopIteration): +raise +return None +api_func = slot_tp_iternext.api_func + else: return diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py --- a/pypy/module/cpyext/test/test_typeobject.py +++ b/pypy/module/cpyext/test/test_typeobject.py @@ -645,32 +645,49 @@ def test_tp_iter(self): module = self.import_extension('foo', [ - ("tp_iter", "METH_O", + ("tp_iter", "METH_VARARGS", ''' - if (!args->ob_type->tp_iter) + PyTypeObject *type = (PyTypeObject *)PyTuple_GET_ITEM(args, 0); + PyObject *obj = PyTuple_GET_ITEM(args, 1); + if (!type->tp_iter) { PyErr_SetNone(PyExc_ValueError); return NULL; } - return args->ob_type->tp_iter(args); + return type->tp_iter(obj); ''' ), - ("tp_iternext", "METH_O", + ("tp_iternext", "METH_VARARGS", ''' - if (!args->ob_type->tp_iternext) + PyTypeObject *type = (PyTypeObject *)PyTuple_GET_ITEM(args, 0); + PyObject *obj = PyTuple_GET_ITEM(args, 1); + PyObject *result; + if (!type->tp_iternext) { PyErr_SetNone(PyExc_ValueError); return NULL; } - return args->ob_type->tp_iternext(args); + result = type->tp_iternext(obj); + if (!result && !PyErr_Occurred()) + result = PyString_FromString("stop!"); + return result; ''' ) ]) l = [1] -it = module.tp_iter(l) +it = module.tp_iter(list, l) assert type(it) is type(iter([])) -assert module.tp_iternext(it) == 1 -raises(StopIteration, module.tp_iternext, it) +assert module.tp_iternext(type(it), it) == 1 +assert module.tp_iternext(type(it), it) == "stop!" +# +class LL(list): +def __iter__(self): +return iter(()) +ll = LL([1]) +it = module.tp_iter(list, ll) +assert type(it) is type(iter([])) +x = list(it) +assert x == [1] def test_bool(self): module = self.import_extension('foo', [ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cpyext-ext: fix slot_nb_int, and attempt a test, but blocked by issue 2248
Author: Armin RigoBranch: cpyext-ext Changeset: r82645:11338c928fad Date: 2016-03-01 21:07 +0100 http://bitbucket.org/pypy/pypy/changeset/11338c928fad/ Log:fix slot_nb_int, and attempt a test, but blocked by issue 2248 diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py --- a/pypy/module/cpyext/slotdefs.py +++ b/pypy/module/cpyext/slotdefs.py @@ -337,10 +337,6 @@ return 0 @cpython_api([PyObject], PyObject, header=None) -def slot_nb_int(space, w_self): -return space.int(w_self) - -@cpython_api([PyObject], PyObject, header=None) def slot_tp_iter(space, w_self): return space.iter(w_self) @@ -395,6 +391,17 @@ return space.call_function(getattr_fn, w_self, w_name) api_func = slot_tp_getattro.api_func +elif name == 'tp_as_number.c_nb_int': +int_fn = w_type.getdictvalue(space, '__int__') +if int_fn is None: +return + +@cpython_api([PyObject], PyObject, header=header) +@func_renamer("cpyext_%s_%s" % (name.replace('.', '_'), typedef.name)) +def slot_nb_int(space, w_self): +return space.call_function(int_fn, w_self) +api_func = slot_nb_int.api_func + elif name == 'tp_as_number.c_nb_float': float_fn = w_type.getdictvalue(space, '__float__') if float_fn is None: diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py --- a/pypy/module/cpyext/test/test_typeobject.py +++ b/pypy/module/cpyext/test/test_typeobject.py @@ -469,21 +469,28 @@ def test_nb_int(self): module = self.import_extension('foo', [ -("nb_int", "METH_O", +("nb_int", "METH_VARARGS", ''' - if (!args->ob_type->tp_as_number || - !args->ob_type->tp_as_number->nb_int) + PyTypeObject *type = (PyTypeObject *)PyTuple_GET_ITEM(args, 0); + PyObject *obj = PyTuple_GET_ITEM(args, 1); + if (!type->tp_as_number || + !type->tp_as_number->nb_int) { PyErr_SetNone(PyExc_ValueError); return NULL; } - return args->ob_type->tp_as_number->nb_int(args); + return type->tp_as_number->nb_int(obj); ''' ) ]) -assert module.nb_int(10) == 10 -assert module.nb_int(-12.3) == -12 -raises(ValueError, module.nb_int, "123") +assert module.nb_int(int, 10) == 10 +assert module.nb_int(float, -12.3) == -12 +raises(ValueError, module.nb_int, str, "123") +class F(float): +def __int__(self): +return 666 +skip("XXX fix issue 2248 first") +assert module.nb_int(float, F(-12.3)) == -12 def test_nb_float(self): module = self.import_extension('foo', [ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cpyext-ext: test and fix: slot_tp_str
Author: Armin RigoBranch: cpyext-ext Changeset: r82644:b530a83f16e8 Date: 2016-03-01 20:53 +0100 http://bitbucket.org/pypy/pypy/changeset/b530a83f16e8/ Log:test and fix: slot_tp_str diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py --- a/pypy/module/cpyext/slotdefs.py +++ b/pypy/module/cpyext/slotdefs.py @@ -337,10 +337,6 @@ return 0 @cpython_api([PyObject], PyObject, header=None) -def slot_tp_str(space, w_self): -return space.str(w_self) - -@cpython_api([PyObject], PyObject, header=None) def slot_nb_int(space, w_self): return space.int(w_self) @@ -423,6 +419,17 @@ return space.call_args(call_fn, args) api_func = slot_tp_call.api_func +elif name == 'tp_str': +str_fn = w_type.getdictvalue(space, '__str__') +if str_fn is None: +return + +@cpython_api([PyObject], PyObject, header=header) +@func_renamer("cpyext_%s_%s" % (name.replace('.', '_'), typedef.name)) +def slot_tp_str(space, w_self): +return space.call_function(str_fn, w_self) +api_func = slot_tp_str.api_func + else: return diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py --- a/pypy/module/cpyext/test/test_typeobject.py +++ b/pypy/module/cpyext/test/test_typeobject.py @@ -551,21 +551,27 @@ def test_tp_str(self): module = self.import_extension('foo', [ - ("tp_str", "METH_O", + ("tp_str", "METH_VARARGS", ''' - if (!args->ob_type->tp_str) + PyTypeObject *type = (PyTypeObject *)PyTuple_GET_ITEM(args, 0); + PyObject *obj = PyTuple_GET_ITEM(args, 1); + if (!type->tp_str) { PyErr_SetNone(PyExc_ValueError); return NULL; } - return args->ob_type->tp_str(args); + return type->tp_str(obj); ''' ) ]) class C: def __str__(self): return "text" -assert module.tp_str(C()) == "text" +assert module.tp_str(type(C()), C()) == "text" +class D(int): +def __str__(self): +return "more text" +assert module.tp_str(int, D(42)) == "42" def test_mp_ass_subscript(self): module = self.import_extension('foo', [ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cpyext-ext: test and fix: slot_tp_call
Author: Armin RigoBranch: cpyext-ext Changeset: r82643:df19cf072629 Date: 2016-03-01 20:49 +0100 http://bitbucket.org/pypy/pypy/changeset/df19cf072629/ Log:test and fix: slot_tp_call diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py --- a/pypy/module/cpyext/slotdefs.py +++ b/pypy/module/cpyext/slotdefs.py @@ -336,10 +336,6 @@ space.get_and_call_args(w_descr, w_self, args) return 0 -@cpython_api([PyObject, PyObject, PyObject], PyObject, header=None) -def slot_tp_call(space, w_self, w_args, w_kwds): -return space.call(w_self, w_args, w_kwds) - @cpython_api([PyObject], PyObject, header=None) def slot_tp_str(space, w_self): return space.str(w_self) @@ -402,6 +398,7 @@ def slot_tp_getattro(space, w_self, w_name): return space.call_function(getattr_fn, w_self, w_name) api_func = slot_tp_getattro.api_func + elif name == 'tp_as_number.c_nb_float': float_fn = w_type.getdictvalue(space, '__float__') if float_fn is None: @@ -412,6 +409,20 @@ def slot_nb_float(space, w_self): return space.call_function(float_fn, w_self) api_func = slot_nb_float.api_func + +elif name == 'tp_call': +call_fn = w_type.getdictvalue(space, '__call__') +if call_fn is None: +return + +@cpython_api([PyObject, PyObject, PyObject], PyObject, header=header) +@func_renamer("cpyext_%s_%s" % (name.replace('.', '_'), typedef.name)) +def slot_tp_call(space, w_self, w_args, w_kwds): +args = Arguments(space, [w_self], + w_stararg=w_args, w_starstararg=w_kwds) +return space.call_args(call_fn, args) +api_func = slot_tp_call.api_func + else: return diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py --- a/pypy/module/cpyext/test/test_typeobject.py +++ b/pypy/module/cpyext/test/test_typeobject.py @@ -526,21 +526,28 @@ module = self.import_extension('foo', [ ("tp_call", "METH_VARARGS", ''' - PyObject *obj = PyTuple_GET_ITEM(args, 0); - PyObject *c_args = PyTuple_GET_ITEM(args, 1); - if (!obj->ob_type->tp_call) + PyTypeObject *type = (PyTypeObject *)PyTuple_GET_ITEM(args, 0); + PyObject *obj = PyTuple_GET_ITEM(args, 1); + PyObject *c_args = PyTuple_GET_ITEM(args, 2); + if (!type->tp_call) { PyErr_SetNone(PyExc_ValueError); return NULL; } - return obj->ob_type->tp_call(obj, c_args, NULL); + return type->tp_call(obj, c_args, NULL); ''' ) ]) class C: def __call__(self, *args): return args -assert module.tp_call(C(), ('x', 2)) == ('x', 2) +assert module.tp_call(type(C()), C(), ('x', 2)) == ('x', 2) +class D(type): +def __call__(self, *args): +return "foo! %r" % (args,) +typ1 = D('d', (), {}) +#assert module.tp_call(D, typ1, ()) == "foo! ()" XXX not working so far +assert isinstance(module.tp_call(type, typ1, ()), typ1) def test_tp_str(self): module = self.import_extension('foo', [ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cpyext-ext: Add an XXX
Author: Armin RigoBranch: cpyext-ext Changeset: r82642:d290ba429283 Date: 2016-03-01 20:04 +0100 http://bitbucket.org/pypy/pypy/changeset/d290ba429283/ Log:Add an XXX diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py --- a/pypy/module/cpyext/test/test_typeobject.py +++ b/pypy/module/cpyext/test/test_typeobject.py @@ -517,6 +517,10 @@ assert float(F(10.5)) == -66.66 assert module.nb_float(int, I(10)) == 10.0 assert module.nb_float(float, F(10.5)) == 10.5 +# XXX but the subtype's tp_as_number->nb_float(x) should really invoke +# the user-defined __float__(); it doesn't so far +#assert module.nb_float(I, I(10)) == -55.55 +#assert module.nb_float(F, F(10.5)) == -66.66 def test_tp_call(self): module = self.import_extension('foo', [ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cpyext-ext: Test and fix (for nb_float only for now)
Author: Armin RigoBranch: cpyext-ext Changeset: r82641:359d2065421a Date: 2016-03-01 20:03 +0100 http://bitbucket.org/pypy/pypy/changeset/359d2065421a/ Log:Test and fix (for nb_float only for now) diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py --- a/pypy/module/cpyext/slotdefs.py +++ b/pypy/module/cpyext/slotdefs.py @@ -349,10 +349,6 @@ return space.int(w_self) @cpython_api([PyObject], PyObject, header=None) -def slot_nb_float(space, w_self): -return space.float(w_self) - -@cpython_api([PyObject], PyObject, header=None) def slot_tp_iter(space, w_self): return space.iter(w_self) @@ -406,6 +402,16 @@ def slot_tp_getattro(space, w_self, w_name): return space.call_function(getattr_fn, w_self, w_name) api_func = slot_tp_getattro.api_func +elif name == 'tp_as_number.c_nb_float': +float_fn = w_type.getdictvalue(space, '__float__') +if float_fn is None: +return + +@cpython_api([PyObject], PyObject, header=header) +@func_renamer("cpyext_%s_%s" % (name.replace('.', '_'), typedef.name)) +def slot_nb_float(space, w_self): +return space.call_function(float_fn, w_self) +api_func = slot_nb_float.api_func else: return diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py --- a/pypy/module/cpyext/test/test_typeobject.py +++ b/pypy/module/cpyext/test/test_typeobject.py @@ -487,21 +487,36 @@ def test_nb_float(self): module = self.import_extension('foo', [ -("nb_float", "METH_O", +("nb_float", "METH_VARARGS", ''' - if (!args->ob_type->tp_as_number || - !args->ob_type->tp_as_number->nb_float) + PyTypeObject *type = (PyTypeObject *)PyTuple_GET_ITEM(args, 0); + PyObject *obj = PyTuple_GET_ITEM(args, 1); + if (!type->tp_as_number || + !type->tp_as_number->nb_float) { PyErr_SetNone(PyExc_ValueError); return NULL; } - return args->ob_type->tp_as_number->nb_float(args); + return type->tp_as_number->nb_float(obj); ''' ) ]) -assert module.nb_float(10) == 10.0 -assert module.nb_float(-12.3) == -12.3 -raises(ValueError, module.nb_float, "123") +assert module.nb_float(int, 10) == 10.0 +assert module.nb_float(float, -12.3) == -12.3 +raises(ValueError, module.nb_float, str, "123") +# +# check that calling PyInt_Type->tp_as_number->nb_float(x) +# does not invoke a user-defined __float__() +class I(int): +def __float__(self): +return -55.55 +class F(float): +def __float__(self): +return -66.66 +assert float(I(10)) == -55.55 +assert float(F(10.5)) == -66.66 +assert module.nb_float(int, I(10)) == 10.0 +assert module.nb_float(float, F(10.5)) == 10.5 def test_tp_call(self): module = self.import_extension('foo', [ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy s390x-backend: bytecode and constants are correctly passed, need to modify hypothesis to generate correct programs
Author: Richard PlanggerBranch: s390x-backend Changeset: r82640:b9cd7126874f Date: 2016-03-01 17:57 +0100 http://bitbucket.org/pypy/pypy/changeset/b9cd7126874f/ Log:bytecode and constants are correctly passed, need to modify hypothesis to generate correct programs diff --git a/rpython/jit/backend/llsupport/tl/interp.py b/rpython/jit/backend/llsupport/tl/interp.py --- a/rpython/jit/backend/llsupport/tl/interp.py +++ b/rpython/jit/backend/llsupport/tl/interp.py @@ -63,8 +63,8 @@ return consts def entry_point(argv): -bytecode = _read_bytecode_from_file(argv[0]) -consts = _read_consts_from_file(argv[1]) +bytecode = _read_bytecode_from_file(argv[1]) +consts = _read_consts_from_file(argv[2]) print(bytecode) print(consts) pc = 0 diff --git a/rpython/jit/backend/llsupport/tl/test/zrpy_gc_hypo_test.py b/rpython/jit/backend/llsupport/tl/test/zrpy_gc_hypo_test.py --- a/rpython/jit/backend/llsupport/tl/test/zrpy_gc_hypo_test.py +++ b/rpython/jit/backend/llsupport/tl/test/zrpy_gc_hypo_test.py @@ -57,4 +57,6 @@ def test_execute_single_bytecode(self, program): clazz, bytecode, consts, stack = program result, out, err = self.execute(bytecode, consts) -assert result == 0 +if result != 0: +raise Exception(("could not run program. returned %d" +" stderr:\n%s\nstdout:\n%s\n") % (result, err, out)) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Test rdict also with char, unicode, unichar
Author: Ronan LamyBranch: Changeset: r82639:b8922598b1c9 Date: 2016-03-01 16:52 + http://bitbucket.org/pypy/pypy/changeset/b8922598b1c9/ Log:Test rdict also with char, unicode, unichar diff --git a/rpython/rtyper/test/test_rdict.py b/rpython/rtyper/test/test_rdict.py --- a/rpython/rtyper/test/test_rdict.py +++ b/rpython/rtyper/test/test_rdict.py @@ -3,26 +3,35 @@ import signal from rpython.translator.translator import TranslationContext -from rpython.annotator.model import SomeInteger, SomeString +from rpython.annotator.model import ( +SomeInteger, SomeString, SomeChar, SomeUnicodeString, SomeUnicodeCodePoint) from rpython.annotator.dictdef import DictKey, DictValue from rpython.rtyper.lltypesystem import lltype, rffi -from rpython.rtyper.lltypesystem.rstr import string_repr -from rpython.rtyper import rint -from rpython.rtyper.lltypesystem import rdict, rstr +from rpython.rtyper.lltypesystem import rdict from rpython.rtyper.test.tool import BaseRtypingTest from rpython.rlib.objectmodel import r_dict from rpython.rlib.rarithmetic import r_int, r_uint, r_longlong, r_ulonglong import py -from hypothesis.strategies import builds, sampled_from, binary, just, integers +from hypothesis.strategies import ( +builds, sampled_from, binary, just, integers, text, characters) from hypothesis.stateful import GenericStateMachine, run_state_machine_as_test def ann2strategy(s_value): -if isinstance(s_value, SomeString): +if isinstance(s_value, SomeChar): +return builds(chr, integers(min_value=0, max_value=255)) +elif isinstance(s_value, SomeString): if s_value.can_be_None: return binary() | just(None) else: return binary() +elif isinstance(s_value, SomeUnicodeCodePoint): +return characters() +elif isinstance(s_value, SomeUnicodeString): +if s_value.can_be_None: +return text() | just(None) +else: +return text() elif isinstance(s_value, SomeInteger): return integers(min_value=~sys.maxint, max_value=sys.maxint) else: @@ -239,9 +248,8 @@ def test_dict_copy(self): def func(): -# XXX this does not work if we use chars, only! dic = self.newdict() -dic['ab'] = 1 +dic['a'] = 1 dic['b'] = 2 d2 = dic.copy() ok = 1 @@ -1146,9 +1154,9 @@ # XXX: None keys crash the test, but translation sort-of allows it @py.test.mark.parametrize('s_key', -[SomeString(), SomeInteger()]) +[SomeString(), SomeInteger(), SomeChar(), SomeUnicodeString(), SomeUnicodeCodePoint()]) @py.test.mark.parametrize('s_value', -[SomeString(can_be_None=True), SomeString(), SomeInteger()]) +[SomeString(can_be_None=True), SomeString(), SomeChar(), SomeInteger(), SomeUnicodeString(), SomeUnicodeCodePoint()]) def test_hypothesis(s_key, s_value): rtyper = PseudoRTyper() r_key = s_key.rtyper_makerepr(rtyper) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy s390x-backend: translating the interpreter and feeding it with hypothesis, it compiles but does not correctly enter the dispatch loop
Author: Richard PlanggerBranch: s390x-backend Changeset: r82638:ae5c221a741c Date: 2016-03-01 17:25 +0100 http://bitbucket.org/pypy/pypy/changeset/ae5c221a741c/ Log:translating the interpreter and feeding it with hypothesis, it compiles but does not correctly enter the dispatch loop diff --git a/rpython/jit/backend/llsupport/tl/interp.py b/rpython/jit/backend/llsupport/tl/interp.py --- a/rpython/jit/backend/llsupport/tl/interp.py +++ b/rpython/jit/backend/llsupport/tl/interp.py @@ -2,6 +2,7 @@ from rpython.rlib.objectmodel import specialize, always_inline from rpython.jit.backend.llsupport.tl import code from rpython.jit.backend.llsupport.tl.stack import Stack +from rpython.rlib import rstring class W_Root(object): pass @@ -48,14 +49,28 @@ return W_ListObject(val) raise NotImplementedError("cannot handle: " + str(val)) +def _read_all_from_file(file): +with open(file, 'rb') as fd: +return fd.read() + +_read_bytecode_from_file = _read_all_from_file + +def _read_consts_from_file(file): +consts = [] +bytestring = _read_all_from_file(file) +for line in bytestring.splitlines(): +consts.append(rstring.replace(line, "\\n", "\n")) +return consts + def entry_point(argv): -bytecode = argv[0] +bytecode = _read_bytecode_from_file(argv[0]) +consts = _read_consts_from_file(argv[1]) +print(bytecode) +print(consts) pc = 0 end = len(bytecode) stack = Stack(16) space = Space() -consts = ["hello"] * 100 -consts[0] = "world" while pc < end: pc = dispatch_once(space, pc, bytecode, consts, stack) return 0 @@ -106,5 +121,6 @@ del w_lst.items[w_idx.value] # index error, just crash the machine!! else: +print("opcode %d is not implemented" % opcode) raise NotImplementedError return i + 1 diff --git a/rpython/jit/backend/llsupport/tl/test/zrpy_gc_hypo_test.py b/rpython/jit/backend/llsupport/tl/test/zrpy_gc_hypo_test.py --- a/rpython/jit/backend/llsupport/tl/test/zrpy_gc_hypo_test.py +++ b/rpython/jit/backend/llsupport/tl/test/zrpy_gc_hypo_test.py @@ -1,19 +1,35 @@ -from rpython.jit.backend.detect_cpu import getcpuclass -from rpython.jit.tool.oparser import parse -from rpython.jit.metainterp.history import JitCellToken, NoStats -from rpython.jit.metainterp.history import BasicFinalDescr, BasicFailDescr -from rpython.jit.metainterp.gc import get_description +import py +from hypothesis import given +from rpython.tool.udir import udir from rpython.jit.metainterp.optimize import SpeculativeError from rpython.annotator.listdef import s_list_of_strings -from rpython.rtyper.lltypesystem import lltype, llmemory, rffi -from rpython.rtyper.rclass import getclassrepr, getinstancerepr -from rpython.translator.unsimplify import call_initial_function from rpython.translator.translator import TranslationContext from rpython.translator.c import genc from rpython.jit.backend.llsupport.tl import interp +from rpython.jit.backend.llsupport.tl.test import code_strategies as st + +def persist(type, contents): +dir = udir.ensure(type) +print "written", type, "to", dir +with open(dir.strpath, 'wb') as fd: +fd.write(contents) +return dir.strpath + +def persist_constants(consts): +contents = "" +for string in consts: +contents += string.replace("\n", "\\n") + "\n" +return persist('constants', contents) + +def persist_bytecode(bc): +return persist('bytecode', bc) class GCHypothesis(object): -def setup_class(self): +builder = None +def setup_method(self, name): +if self.builder: +return + t = TranslationContext() t.config.translation.gc = "incminimark" t.config.translation.gcremovetypeptr = True @@ -22,12 +38,23 @@ rtyper = t.buildrtyper() rtyper.specialize() -cbuilder = genc.CStandaloneBuilder(t, f, t.config) +cbuilder = genc.CStandaloneBuilder(t, interp.entry_point, t.config) cbuilder.generate_source(defines=cbuilder.DEBUG_DEFINES) cbuilder.compile() +# prevent from rebuilding the c object! +self.builder = cbuilder -import pdb; pdb.set_trace() +def execute(self, bytecode, consts): +exe = self.builder.executable_name +bc_file = persist_bytecode(bytecode) +consts_file = persist_constants(consts) +args = [bc_file, consts_file] +env = {} +res = self.builder.translator.platform.execute(exe, args, env=env) +return res.returncode, res.out, res.err - -def test_void(self): -pass +@given(st.single_bytecode()) +def test_execute_single_bytecode(self, program): +clazz, bytecode, consts, stack = program +result, out, err = self.execute(bytecode, consts) +assert result == 0 diff --git a/rpython/jit/backend/x86/test/test_zrpy_gc_hypo.py
[pypy-commit] pypy s390x-backend: trying to translate the current interpreter in a test and later feed it with hypothesis.
Author: Richard PlanggerBranch: s390x-backend Changeset: r82637:9eab49cb6677 Date: 2016-03-01 15:45 +0100 http://bitbucket.org/pypy/pypy/changeset/9eab49cb6677/ Log:trying to translate the current interpreter in a test and later feed it with hypothesis. in addition fixed a bug that occurs while emitting jump. the assembled loop is too long, and BRC could not reach the top. thus BRCL is emitted if needed diff --git a/rpython/jit/backend/llsupport/tl/interp.py b/rpython/jit/backend/llsupport/tl/interp.py --- a/rpython/jit/backend/llsupport/tl/interp.py +++ b/rpython/jit/backend/llsupport/tl/interp.py @@ -1,6 +1,7 @@ from rpython.rlib.rstruct.runpack import runpack from rpython.rlib.objectmodel import specialize, always_inline -from rpython.jit.backend.llsupport.tl import code, stack +from rpython.jit.backend.llsupport.tl import code +from rpython.jit.backend.llsupport.tl.stack import Stack class W_Root(object): pass @@ -9,25 +10,28 @@ def __init__(self, items): self.items = items -def concat(self, w_lst): +def concat(self, space, w_lst): assert isinstance(w_lst, W_ListObject) -return self.items + w_lst.items +return space.wrap(self.items + w_lst.items) class W_IntObject(W_Root): def __init__(self, value): self.value = value -def compare(self, w_int): +def compare(self, space, w_int): assert isinstance(w_int, W_IntObject) -return cmp(self.value, w_int.value) +return space.wrap(self.value - w_int.value) + +def concat(self, space, w_obj): +raise NotImplementedError("cannot concat int with object") class W_StrObject(W_Root): def __init__(self, value): self.value = value -def concat(self, w_str): +def concat(self, space, w_str): assert isinstance(w_str, W_StrObject) -return self.value + w_str.value +return space.wrap(self.value + w_str.value) class Space(object): @specialize.argtype(1) @@ -42,17 +46,18 @@ return W_StrObject(val.encode('utf-8')) if isinstance(val, list): return W_ListObject(val) -raise NotImplementedError("cannot handle: " + str(val) + str(type(val))) +raise NotImplementedError("cannot handle: " + str(val)) def entry_point(argv): bytecode = argv[0] pc = 0 end = len(bytecode) stack = Stack(16) -space = space.Space() -consts = [] -while i < end: -i = dispatch_once(space, i, bytecode, consts, stack) +space = Space() +consts = ["hello"] * 100 +consts[0] = "world" +while pc < end: +pc = dispatch_once(space, pc, bytecode, consts, stack) return 0 @always_inline @@ -65,8 +70,7 @@ elif opcode == code.CompareInt.BYTE_CODE: w_int2 = stack.pop() w_int1 = stack.pop() -w_int3 = space.wrap(w_int1.compare(w_int2)) -stack.append(w_int3) +stack.append(w_int1.compare(space, w_int2)) elif opcode == code.LoadStr.BYTE_CODE: pos = runpack('h', bytecode[i+1:i+3]) w_str = space.wrap(consts[pos]) @@ -75,11 +79,11 @@ elif opcode == code.AddStr.BYTE_CODE: w_str2 = stack.pop() w_str1 = stack.pop() -stack.append(space.wrap(w_str1.concat(w_str2))) +stack.append(w_str1.concat(space, w_str2)) elif opcode == code.AddList.BYTE_CODE: w_lst2 = stack.pop() w_lst1 = stack.pop() -stack.append(space.wrap(w_lst1.concat(w_lst2))) +stack.append(w_lst1.concat(space, w_lst2)) elif opcode == code.CreateList.BYTE_CODE: size = runpack('h', bytecode[i+1:i+3]) stack.append(space.wrap([None] * size)) @@ -91,11 +95,13 @@ elif opcode == code.InsertList.BYTE_CODE: w_val = stack.pop() w_idx = stack.pop() +assert isinstance(w_idx, W_IntObject) w_lst = stack.peek(0) w_lst.items[w_idx.value] = w_val # index error, just crash here! elif opcode == code.DelList.BYTE_CODE: w_idx = stack.pop() +assert isinstance(w_idx, W_IntObject) w_lst = stack.peek(0) del w_lst.items[w_idx.value] # index error, just crash the machine!! diff --git a/rpython/jit/backend/llsupport/tl/stack.py b/rpython/jit/backend/llsupport/tl/stack.py --- a/rpython/jit/backend/llsupport/tl/stack.py +++ b/rpython/jit/backend/llsupport/tl/stack.py @@ -5,7 +5,7 @@ def __init__(self, size): self = hint(self, access_directly=True, fresh_virtualizable=True) -self.stack = [0] * size +self.stack = [None] * size self.stackpos = 0# always store a known-nonneg integer here def size(self): diff --git a/rpython/jit/backend/llsupport/tl/test/zrpy_gc_hypo_test.py b/rpython/jit/backend/llsupport/tl/test/zrpy_gc_hypo_test.py --- a/rpython/jit/backend/llsupport/tl/test/zrpy_gc_hypo_test.py +++
[pypy-commit] pypy s390x-backend: removed the function field _arguments_, a new function rebuilds the information needed for the auto encoding test
Author: Richard PlanggerBranch: s390x-backend Changeset: r82636:a5ef58cc Date: 2016-03-01 15:02 +0100 http://bitbucket.org/pypy/pypy/changeset/a5ef58cc/ Log:removed the function field _arguments_, a new function rebuilds the information needed for the auto encoding test diff --git a/rpython/jit/backend/zarch/instruction_builder.py b/rpython/jit/backend/zarch/instruction_builder.py --- a/rpython/jit/backend/zarch/instruction_builder.py +++ b/rpython/jit/backend/zarch/instruction_builder.py @@ -585,6 +585,21 @@ def is_branch_relative(name): return name.startswith('BR') or name.endswith('J') +def get_arg_types_of(mnemonic): +""" NOT_RPYTHON """ +params = all_mnemonic_codes[mnemonic.split("_")[0]] +if len(params) == 2: +argtypes = None +(instrtype, args) = params +else: +(instrtype, args, argtypes) = params +builder = globals()['build_' + instrtype] +if argtypes: +func = builder(mnemonic, args, argtypes) +else: +func = builder(mnemonic, args) +return func._arguments_ + def build_instr_codes(clazz): for mnemonic, params in all_mnemonic_codes.items(): argtypes = None diff --git a/rpython/jit/backend/zarch/test/test_auto_encoding.py b/rpython/jit/backend/zarch/test/test_auto_encoding.py --- a/rpython/jit/backend/zarch/test/test_auto_encoding.py +++ b/rpython/jit/backend/zarch/test/test_auto_encoding.py @@ -167,9 +167,8 @@ methname = '?' def get_func_arg_types(self, methodname): -from rpython.jit.backend.zarch.codebuilder import AbstractZARCHBuilder -func = getattr(AbstractZARCHBuilder, methodname) -return func._arguments_ +from rpython.jit.backend.zarch.instruction_builder import get_arg_types_of +return get_arg_types_of(methodname) def operand_combinations(self, methodname, modes, arguments): mapping = { ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy jit-leaner-frontend: progress, pass the first own test of opencoder
Author: fijal Branch: jit-leaner-frontend Changeset: r82634:ae45cb0da255 Date: 2016-03-01 14:02 +0100 http://bitbucket.org/pypy/pypy/changeset/ae45cb0da255/ Log:progress, pass the first own test of opencoder diff --git a/rpython/jit/metainterp/opencoder.py b/rpython/jit/metainterp/opencoder.py --- a/rpython/jit/metainterp/opencoder.py +++ b/rpython/jit/metainterp/opencoder.py @@ -4,6 +4,7 @@ from rpython.jit.metainterp.resoperation import AbstractResOp, AbstractInputArg,\ ResOperation, oparity, opname, rop, ResOperation, opwithdescr from rpython.rlib.rarithmetic import intmask +from rpython.jit.metainterp import resume TAGINT, TAGCONST, TAGBOX = range(3) TAGMASK = 0x3 @@ -46,8 +47,20 @@ else: +def read_resume(self, op): +jc_index = self._next() +pc = self._next() +f = resume.FrameInfo(None, jc_index, pc) +op.rd_frame_info_list = f +lgt = self._next() +box_list = [] +for i in range(lgt): +box = self._get(self._next()) +assert box +box_list.append(box) +op.rd_snapshot = resume.Snapshot(None, box_list) + def next(self): -pos = self.pos opnum = self._next() if oparity[opnum] == -1: argnum = self._next() @@ -65,6 +78,8 @@ else: descr = None res = ResOperation(opnum, args, -1, descr=descr) +if rop.is_guard(opnum): +self.read_resume(res) self._cache[self._count] = res self._count += 1 return res @@ -138,6 +153,14 @@ def record_op_tag(self, opnum, tagged_args, descr=None): return tag(TAGBOX, self._record_raw(opnum, tagged_args, descr)) +def record_snapshot(self, jitcode, pc, active_boxes): +self._ops.append(jitcode.index) +self._ops.append(pc) +self._ops.append(len(active_boxes)) # unnecessary, can be read from +# jitcode +for box in active_boxes: +self._ops.append(box.position) # not tagged, as it must be boxes + def get_iter(self): return TraceIterator(self, len(self._ops)) diff --git a/rpython/jit/metainterp/resume.py b/rpython/jit/metainterp/resume.py --- a/rpython/jit/metainterp/resume.py +++ b/rpython/jit/metainterp/resume.py @@ -39,9 +39,9 @@ class FrameInfo(object): __slots__ = ('prev', 'packed_jitcode_pc') -def __init__(self, prev, jitcode, pc): +def __init__(self, prev, jitcode_index, pc): self.prev = prev -self.packed_jitcode_pc = combine_uint(jitcode.index, pc) +self.packed_jitcode_pc = combine_uint(jitcode_index, pc) class VectorInfo(object): """ @@ -123,8 +123,7 @@ back.parent_resumedata_snapshot, back.get_list_of_active_boxes(True)) -def capture_resumedata(framestack, virtualizable_boxes, virtualref_boxes, - snapshot_storage): +def capture_resumedata(framestack, virtualizable_boxes, virtualref_boxes, t): n = len(framestack) - 1 if virtualizable_boxes is not None: boxes = virtualref_boxes + virtualizable_boxes @@ -132,15 +131,19 @@ boxes = virtualref_boxes[:] if n >= 0: top = framestack[n] -_ensure_parent_resumedata(framestack, n) -frame_info_list = FrameInfo(top.parent_resumedata_frame_info_list, -top.jitcode, top.pc) -snapshot_storage.rd_frame_info_list = frame_info_list -snapshot = Snapshot(top.parent_resumedata_snapshot, -top.get_list_of_active_boxes(False)) -snapshot = Snapshot(snapshot, boxes) -snapshot_storage.rd_snapshot = snapshot +#_ensure_parent_resumedata(framestack, n) +t.record_snapshot(top.jitcode, top.pc, + top.get_list_of_active_boxes(False)) +#XXX +#frame_info_list = FrameInfo(top.parent_resumedata_frame_info_list, +#top.jitcode, top.pc) +#snapshot_storage.rd_frame_info_list = frame_info_list +#snapshot = Snapshot(top.parent_resumedata_snapshot, +#top.get_list_of_active_boxes(False)) +#snapshot = Snapshot(snapshot, boxes) +#snapshot_storage.rd_snapshot = snapshot else: +yyy snapshot_storage.rd_frame_info_list = None snapshot_storage.rd_snapshot = Snapshot(None, boxes) diff --git a/rpython/jit/metainterp/test/test_opencoder.py b/rpython/jit/metainterp/test/test_opencoder.py --- a/rpython/jit/metainterp/test/test_opencoder.py +++ b/rpython/jit/metainterp/test/test_opencoder.py @@ -56,4 +56,4 @@ virutalref_boxes, t) (i0, i1), l = self.unpack(t) assert l[1].opnum == rop.GUARD_FALSE -assert l[1].rd_snapshot == [i0, i1] +assert l[1].rd_snapshot.boxes == [i0, i1]
[pypy-commit] pypy jit-leaner-frontend: merge default
Author: fijal Branch: jit-leaner-frontend Changeset: r82635:3d2c4e4fc169 Date: 2016-03-01 14:04 +0100 http://bitbucket.org/pypy/pypy/changeset/3d2c4e4fc169/ Log:merge default diff too long, truncating to 2000 out of 12385 lines diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -22,6 +22,7 @@ ^pypy/module/cpyext/test/.+\.obj$ ^pypy/module/cpyext/test/.+\.manifest$ ^pypy/module/test_lib_pypy/ctypes_tests/.+\.o$ +^pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test\.o$ ^pypy/module/cppyy/src/.+\.o$ ^pypy/module/cppyy/bench/.+\.so$ ^pypy/module/cppyy/bench/.+\.root$ @@ -35,7 +36,6 @@ ^pypy/module/test_lib_pypy/cffi_tests/__pycache__.+$ ^pypy/doc/.+\.html$ ^pypy/doc/config/.+\.rst$ -^pypy/doc/basicblock\.asc$ ^pypy/doc/.+\.svninfo$ ^rpython/translator/c/src/libffi_msvc/.+\.obj$ ^rpython/translator/c/src/libffi_msvc/.+\.dll$ @@ -45,53 +45,33 @@ ^rpython/translator/c/src/cjkcodecs/.+\.obj$ ^rpython/translator/c/src/stacklet/.+\.o$ ^rpython/translator/c/src/.+\.o$ -^rpython/translator/jvm/\.project$ -^rpython/translator/jvm/\.classpath$ -^rpython/translator/jvm/eclipse-bin$ -^rpython/translator/jvm/src/pypy/.+\.class$ -^rpython/translator/benchmark/docutils$ -^rpython/translator/benchmark/templess$ -^rpython/translator/benchmark/gadfly$ -^rpython/translator/benchmark/mako$ -^rpython/translator/benchmark/bench-custom\.benchmark_result$ -^rpython/translator/benchmark/shootout_benchmarks$ +^rpython/translator/llvm/.+\.so$ ^rpython/translator/goal/target.+-c$ ^rpython/translator/goal/.+\.exe$ ^rpython/translator/goal/.+\.dll$ ^pypy/goal/pypy-translation-snapshot$ ^pypy/goal/pypy-c -^pypy/goal/pypy-jvm -^pypy/goal/pypy-jvm.jar ^pypy/goal/.+\.exe$ ^pypy/goal/.+\.dll$ ^pypy/goal/.+\.lib$ ^pypy/_cache$ -^pypy/doc/statistic/.+\.html$ -^pypy/doc/statistic/.+\.eps$ -^pypy/doc/statistic/.+\.pdf$ -^rpython/translator/cli/src/pypylib\.dll$ -^rpython/translator/cli/src/query\.exe$ -^rpython/translator/cli/src/main\.exe$ +^lib-python/2.7/lib2to3/.+\.pickle$ ^lib_pypy/__pycache__$ ^lib_pypy/ctypes_config_cache/_.+_cache\.py$ ^lib_pypy/ctypes_config_cache/_.+_.+_\.py$ ^lib_pypy/_libmpdec/.+.o$ -^rpython/translator/cli/query-descriptions$ ^pypy/doc/discussion/.+\.html$ ^include/.+\.h$ ^include/.+\.inl$ ^pypy/doc/_build/.*$ ^pypy/doc/config/.+\.html$ ^pypy/doc/config/style\.css$ -^pypy/doc/jit/.+\.html$ -^pypy/doc/jit/style\.css$ ^pypy/doc/image/lattice1\.png$ ^pypy/doc/image/lattice2\.png$ ^pypy/doc/image/lattice3\.png$ ^pypy/doc/image/stackless_informal\.png$ ^pypy/doc/image/parsing_example.+\.png$ ^rpython/doc/_build/.*$ -^pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test\.o$ ^compiled ^.git/ ^release/ diff --git a/LICENSE b/LICENSE --- a/LICENSE +++ b/LICENSE @@ -41,29 +41,29 @@ Amaury Forgeot d'Arc Antonio Cuni Samuele Pedroni + Matti Picus Alex Gaynor Brian Kearns - Matti Picus Philip Jenvey Michael Hudson + Ronan Lamy David Schneider + Manuel Jacob Holger Krekel Christian Tismer Hakan Ardo - Manuel Jacob - Ronan Lamy Benjamin Peterson + Richard Plangger Anders Chrigstrom Eric van Riet Paap Wim Lavrijsen - Richard Plangger Richard Emslie Alexander Schremmer Dan Villiom Podlaski Christiansen + Remi Meier Lukas Diekmann Sven Hager Anders Lehmann - Remi Meier Aurelien Campeas Niklaus Haldimann Camillo Bruni @@ -72,8 +72,8 @@ Romain Guillebert Leonardo Santagada Seo Sanghyeon + Ronny Pfannschmidt Justin Peel - Ronny Pfannschmidt David Edelsohn Anders Hammarquist Jakub Gustak @@ -95,6 +95,7 @@ Tyler Wade Michael Foord Stephan Diehl + Vincent Legoll Stefan Schwarzer Valentino Volonghi Tomek Meka @@ -105,9 +106,9 @@ Jean-Paul Calderone Timo Paulssen Squeaky + Marius Gedminas Alexandre Fayolle Simon Burton - Marius Gedminas Martin Matusiak Konstantin Lopuhin Wenzhu Man @@ -116,16 +117,20 @@ Ivan Sichmann Freitas Greg Price Dario Bertini + Stefano Rivera Mark Pearse Simon Cross Andreas Sthrk - Stefano Rivera + Edd Barrett Jean-Philippe St. Pierre Guido van Rossum Pavel Vinogradov + Jeremy Thurgood Pawe Piotr Przeradowski + Spenser Bauman Paul deGrandis Ilya Osadchiy + marky1991 Tobias Oberstein Adrian Kuhn Boris Feigin @@ -134,14 +139,12 @@ Georg Brandl Bert Freudenberg Stian Andreassen - Edd Barrett + Tobias Pape Wanja Saatkamp Gerald Klix Mike Blume - Tobias Pape Oscar Nierstrasz Stefan H. Muller - Jeremy Thurgood Rami Chowdhury Eugene Oden Henry Mason @@ -153,6 +156,8 @@ Lukas Renggli Guenter Jantzen Ned Batchelder + Tim Felgentreff + Anton Gulenko Amit Regmi Ben Young Nicolas Chauvat @@ -162,12 +167,12 @@ Nicholas Riley Jason Chu Igor Trindade Oliveira - Tim Felgentreff + Yichao Yu Rocco Moretti Gintautas Miliauskas Michael Twomey Lucian Branescu Mihaila - Yichao Yu + Devin
[pypy-commit] pypy default: fix typo
Author: Carl Friedrich BolzBranch: Changeset: r82631:8855d18e3957 Date: 2016-02-27 11:37 +0100 http://bitbucket.org/pypy/pypy/changeset/8855d18e3957/ Log:fix typo 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 @@ -1076,7 +1076,7 @@ if self is w_other.strategy: strategy = self if w_set.length() > w_other.length(): -# swap operants +# swap operands storage = self._intersect_unwrapped(w_other, w_set) else: storage = self._intersect_unwrapped(w_set, w_other) @@ -1086,7 +1086,7 @@ else: strategy = self.space.fromcache(ObjectSetStrategy) if w_set.length() > w_other.length(): -# swap operants +# swap operands storage = w_other.strategy._intersect_wrapped(w_other, w_set) else: storage = self._intersect_wrapped(w_set, w_other) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merge
Author: Carl Friedrich BolzBranch: Changeset: r82633:cb435db64836 Date: 2016-03-01 13:33 +0100 http://bitbucket.org/pypy/pypy/changeset/cb435db64836/ Log:merge 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 @@ -1076,7 +1076,7 @@ if self is w_other.strategy: strategy = self if w_set.length() > w_other.length(): -# swap operants +# swap operands storage = self._intersect_unwrapped(w_other, w_set) else: storage = self._intersect_unwrapped(w_set, w_other) @@ -1086,7 +1086,7 @@ else: strategy = self.space.fromcache(ObjectSetStrategy) if w_set.length() > w_other.length(): -# swap operants +# swap operands storage = w_other.strategy._intersect_wrapped(w_other, w_set) else: storage = self._intersect_wrapped(w_set, w_other) diff --git a/rpython/rtyper/lltypesystem/rstr.py b/rpython/rtyper/lltypesystem/rstr.py --- a/rpython/rtyper/lltypesystem/rstr.py +++ b/rpython/rtyper/lltypesystem/rstr.py @@ -717,10 +717,7 @@ return cls.ll_count_char(s1, s2.chars[0], start, end) res = cls.ll_search(s1, s2, start, end, FAST_COUNT) -# For a few cases ll_search can return -1 to indicate an "impossible" -# condition for a string match, count just returns 0 in these cases. -if res < 0: -res = 0 +assert res >= 0 return res @staticmethod @@ -741,6 +738,8 @@ w = n - m if w < 0: +if mode == FAST_COUNT: +return 0 return -1 mlast = m - 1 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: remove a guard from str.count
Author: Carl Friedrich BolzBranch: Changeset: r82632:8d422c65fe9a Date: 2016-02-27 16:52 +0100 http://bitbucket.org/pypy/pypy/changeset/8d422c65fe9a/ Log:remove a guard from str.count diff --git a/rpython/rtyper/lltypesystem/rstr.py b/rpython/rtyper/lltypesystem/rstr.py --- a/rpython/rtyper/lltypesystem/rstr.py +++ b/rpython/rtyper/lltypesystem/rstr.py @@ -717,10 +717,7 @@ return cls.ll_count_char(s1, s2.chars[0], start, end) res = cls.ll_search(s1, s2, start, end, FAST_COUNT) -# For a few cases ll_search can return -1 to indicate an "impossible" -# condition for a string match, count just returns 0 in these cases. -if res < 0: -res = 0 +assert res >= 0 return res @staticmethod @@ -741,6 +738,8 @@ w = n - m if w < 0: +if mode == FAST_COUNT: +return 0 return -1 mlast = m - 1 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy s390x-backend: undo some of the changes of memop-simplify3 and pass length to the length parameter instead of byte size
Author: Richard PlanggerBranch: s390x-backend Changeset: r82630:2ea190038b88 Date: 2016-03-01 12:43 +0100 http://bitbucket.org/pypy/pypy/changeset/2ea190038b88/ Log:undo some of the changes of memop-simplify3 and pass length to the length parameter instead of byte size diff --git a/rpython/jit/backend/llsupport/rewrite.py b/rpython/jit/backend/llsupport/rewrite.py --- a/rpython/jit/backend/llsupport/rewrite.py +++ b/rpython/jit/backend/llsupport/rewrite.py @@ -204,15 +204,15 @@ NOT_SIGNED = 0 CINT_ZERO = ConstInt(0) opnum = op.getopnum() -if opnum == rop.CALL_MALLOC_NURSERY_VARSIZE: -v_length = op.getarg(2) -scale = op.getarg(1).getint() -if scale not in self.cpu.load_supported_factors: -scale, offset, v_length = \ - self._emit_mul_if_factor_offset_not_supported(v_length, scale, 0) -op.setarg(1, ConstInt(scale)) -op.setarg(2, v_length) -elif op.is_getarrayitem() or \ +#if opnum == rop.CALL_MALLOC_NURSERY_VARSIZE: +#v_length = op.getarg(2) +#scale = op.getarg(1).getint() +#if scale not in self.cpu.load_supported_factors: +#scale, offset, v_length = \ +# self._emit_mul_if_factor_offset_not_supported(v_length, scale, 0) +#op.setarg(1, ConstInt(scale)) +#op.setarg(2, v_length) +if op.is_getarrayitem() or \ opnum in (rop.GETARRAYITEM_RAW_I, rop.GETARRAYITEM_RAW_F): self.handle_getarrayitem(op) @@ -793,12 +793,12 @@ arraydescr.lendescr.offset != gc_descr.standard_array_length_ofs)): return False self.emitting_an_operation_that_can_collect() -scale = itemsize -if scale not in self.cpu.load_supported_factors: -scale, offset, v_length = \ -self._emit_mul_if_factor_offset_not_supported(v_length, scale, 0) +#scale = itemsize +#if scale not in self.cpu.load_supported_factors: +#scale, offset, v_length = \ +#self._emit_mul_if_factor_offset_not_supported(v_length, scale, 0) op = ResOperation(rop.CALL_MALLOC_NURSERY_VARSIZE, - [ConstInt(kind), ConstInt(scale), v_length], + [ConstInt(kind), ConstInt(itemsize), v_length], descr=arraydescr) self.replace_op_with(v_result, op) self.emit_op(op) diff --git a/rpython/jit/backend/zarch/assembler.py b/rpython/jit/backend/zarch/assembler.py --- a/rpython/jit/backend/zarch/assembler.py +++ b/rpython/jit/backend/zarch/assembler.py @@ -432,7 +432,7 @@ return mc.materialize(self.cpu, []) def _build_malloc_slowpath(self, kind): -""" While arriving on slowpath, we have a gcmap in SCRATCH. +""" While arriving on slowpath, we have a gcmap in r1. The arguments are passed in r.RES and r.RSZ, as follows: kind == 'fixed': nursery_head in r.RES and the size in r.RSZ - r.RES. @@ -440,7 +440,7 @@ kind == 'str/unicode': length of the string to allocate in r.RES. kind == 'var': itemsize in r.RES, length to allocate in r.RSZ, - and tid in r.SCRATCH2. + and tid in r.r0. This function must preserve all registers apart from r.RES and r.RSZ. On return, SCRATCH must contain the address of nursery_free. @@ -480,7 +480,7 @@ # arguments to the called function are [itemsize, tid, length] # itemsize is already in r2 mc.LGR(r.r4, r.RSZ)# length -mc.LGR(r.r3, r.SCRATCH2) # tid +mc.LGR(r.r3, r.r0) # tid # Do the call addr = rffi.cast(lltype.Signed, addr) @@ -1355,6 +1355,26 @@ mc.STG(r.RSZ, l.addr(0, r.r1))# store into nursery_free +SIZE2SCALE = dict([(1<<_i, _i) for _i in range(32)]) +def _multiply_by_constant(self, loc, multiply_by, scratch_loc): +# XXX should die together with _apply_scale() but can't because +# of emit_zero_array() and malloc_cond_varsize() at the moment +assert loc.is_reg() +if multiply_by == 1: +return loc +try: +scale = self.SIZE2SCALE[multiply_by] +except KeyError: +if check_imm_value(multiply_by, lower_bound=-2**31, upper_bound=2**31-1): +self.mc.LGR(scratch_loc, loc) +self.mc.MSGFI(scratch_loc, l.imm(multiply_by)) +else: +self.mc.load_imm(scratch_loc, multiply_by) +self.mc.MSGR(scratch_loc, loc) +else: +self.mc.SLLG(scratch_loc, loc, l.addr(scale)) +return scratch_loc + def malloc_cond_varsize(self, kind, nursery_free_adr, nursery_top_adr,
[pypy-commit] pypy jit-leaner-frontend: start writing a test
Author: fijal Branch: jit-leaner-frontend Changeset: r82629:aaad0add05ac Date: 2016-03-01 10:38 +0100 http://bitbucket.org/pypy/pypy/changeset/aaad0add05ac/ Log:start writing a test diff --git a/rpython/jit/metainterp/test/test_opencoder.py b/rpython/jit/metainterp/test/test_opencoder.py --- a/rpython/jit/metainterp/test/test_opencoder.py +++ b/rpython/jit/metainterp/test/test_opencoder.py @@ -28,6 +28,22 @@ assert l[0].getarg(1) is i1 def test_rd_snapshot(self): +class JitCode(object): +def __init__(self, index): +self.index = index + +class FakeFrame(object): +parent_resumedata_frame_info_list = None +parent_resumedata_snapshot = None + +def __init__(self, pc, jitcode, boxes): +self.pc = pc +self.jitcode = jitcode +self.boxes = boxes + +def get_list_of_active_boxes(self, flag): +return self.boxes + i0, i1 = InputArgInt(), InputArgInt() t = Trace([i0, i1]) add = t.record_op(rop.INT_ADD, [i0, i1]) @@ -35,10 +51,9 @@ # now we write rd_snapshot and friends virtualizable_boxes = [] virutalref_boxes = [] -framestack = [] -framestack.xxx +framestack = [FakeFrame(1, JitCode(2), [i0, i1])] resume.capture_resumedata(framestack, virtualizable_boxes, virutalref_boxes, t) (i0, i1), l = self.unpack(t) assert l[1].opnum == rop.GUARD_FALSE -assert l[1].rd_snapshot == [i0, i1] \ No newline at end of file +assert l[1].rd_snapshot == [i0, i1] ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Fix import_cffi to also copy the .c and .h files. Re-run it to import
Author: Armin RigoBranch: Changeset: r82628:cca076442762 Date: 2016-03-01 10:35 +0100 http://bitbucket.org/pypy/pypy/changeset/cca076442762/ Log:Fix import_cffi to also copy the .c and .h files. Re-run it to import cffi/5d4960993342. diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_zintegration.py b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_zintegration.py --- a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_zintegration.py +++ b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_zintegration.py @@ -12,7 +12,7 @@ def create_venv(name): tmpdir = udir.join(name) try: -subprocess.check_call(['virtualenv', '--distribute', +subprocess.check_call(['virtualenv', '--never-download', '-p', os.path.abspath(sys.executable), str(tmpdir)]) except OSError as e: diff --git a/pypy/module/test_lib_pypy/cffi_tests/embedding/add1-test.c b/pypy/module/test_lib_pypy/cffi_tests/embedding/add1-test.c --- a/pypy/module/test_lib_pypy/cffi_tests/embedding/add1-test.c +++ b/pypy/module/test_lib_pypy/cffi_tests/embedding/add1-test.c @@ -1,3 +1,4 @@ +/* Generated by pypy/tool/import_cffi.py */ #include extern int add1(int, int); diff --git a/pypy/module/test_lib_pypy/cffi_tests/embedding/add2-test.c b/pypy/module/test_lib_pypy/cffi_tests/embedding/add2-test.c --- a/pypy/module/test_lib_pypy/cffi_tests/embedding/add2-test.c +++ b/pypy/module/test_lib_pypy/cffi_tests/embedding/add2-test.c @@ -1,3 +1,4 @@ +/* Generated by pypy/tool/import_cffi.py */ #include extern int add1(int, int); diff --git a/pypy/module/test_lib_pypy/cffi_tests/embedding/add_recursive-test.c b/pypy/module/test_lib_pypy/cffi_tests/embedding/add_recursive-test.c --- a/pypy/module/test_lib_pypy/cffi_tests/embedding/add_recursive-test.c +++ b/pypy/module/test_lib_pypy/cffi_tests/embedding/add_recursive-test.c @@ -1,3 +1,4 @@ +/* Generated by pypy/tool/import_cffi.py */ #include #ifdef _MSC_VER diff --git a/pypy/module/test_lib_pypy/cffi_tests/embedding/perf-test.c b/pypy/module/test_lib_pypy/cffi_tests/embedding/perf-test.c --- a/pypy/module/test_lib_pypy/cffi_tests/embedding/perf-test.c +++ b/pypy/module/test_lib_pypy/cffi_tests/embedding/perf-test.c @@ -1,10 +1,12 @@ +/* Generated by pypy/tool/import_cffi.py */ #include #include #include #ifdef PTEST_USE_THREAD # include -# include -static sem_t done; +static pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; +static pthread_cond_t cond1 = PTHREAD_COND_INITIALIZER; +static int remaining; #endif @@ -54,8 +56,11 @@ printf("time per call: %.3g\n", t); #ifdef PTEST_USE_THREAD -int status = sem_post(); -assert(status == 0); +pthread_mutex_lock(); +remaining -= 1; +if (!remaining) +pthread_cond_signal(); +pthread_mutex_unlock(); #endif return arg; @@ -68,19 +73,19 @@ start_routine(0); #else pthread_t th; -int i, status = sem_init(, 0, 0); -assert(status == 0); +int i, status; add1(0, 0); /* this is the main thread */ +remaining = PTEST_USE_THREAD; for (i = 0; i < PTEST_USE_THREAD; i++) { status = pthread_create(, NULL, start_routine, NULL); assert(status == 0); } -for (i = 0; i < PTEST_USE_THREAD; i++) { -status = sem_wait(); -assert(status == 0); -} +pthread_mutex_lock(); +while (remaining) +pthread_cond_wait(, ); +pthread_mutex_unlock(); #endif return 0; } diff --git a/pypy/module/test_lib_pypy/cffi_tests/embedding/thread-test.h b/pypy/module/test_lib_pypy/cffi_tests/embedding/thread-test.h --- a/pypy/module/test_lib_pypy/cffi_tests/embedding/thread-test.h +++ b/pypy/module/test_lib_pypy/cffi_tests/embedding/thread-test.h @@ -1,10 +1,45 @@ +/* Generated by pypy/tool/import_cffi.py */ // #ifndef _MSC_VER // #include -#include + +/* don't include , it is not available on OS/X */ + +typedef struct { +pthread_mutex_t mutex1; +pthread_cond_t cond1; +unsigned int value; +} sem_t; + +static int sem_init(sem_t *sem, int pshared, unsigned int value) +{ +assert(pshared == 0); +sem->value = value; +return (pthread_mutex_init(>mutex1, NULL) || +pthread_cond_init(>cond1, NULL)); +} + +static int sem_post(sem_t *sem) +{ +pthread_mutex_lock(>mutex1); +sem->value += 1; +pthread_cond_signal(>cond1); +pthread_mutex_unlock(>mutex1); +return 0; +} + +static int sem_wait(sem_t *sem) +{ +pthread_mutex_lock(>mutex1); +while (sem->value == 0) +pthread_cond_wait(>cond1, >mutex1); +sem->value -= 1; +pthread_mutex_unlock(>mutex1); +return 0; +} // @@ -22,7 +57,7 @@ typedef HANDLE sem_t; typedef HANDLE pthread_t; -int
[pypy-commit] pypy default: hg backout 38deea741bed
Author: Armin RigoBranch: Changeset: r82627:2523cc45c5d9 Date: 2016-03-01 10:27 +0100 http://bitbucket.org/pypy/pypy/changeset/2523cc45c5d9/ Log:hg backout 38deea741bed Causes failures on Linux. Looks easy to fix, but first backing this out, because fixes should go to cffi/cffi in the testing/embedding directory and then be copied here (there is the script pypy/tool/import_cffi.py for that). diff --git a/pypy/module/test_lib_pypy/cffi_tests/embedding/perf-test.c b/pypy/module/test_lib_pypy/cffi_tests/embedding/perf-test.c --- a/pypy/module/test_lib_pypy/cffi_tests/embedding/perf-test.c +++ b/pypy/module/test_lib_pypy/cffi_tests/embedding/perf-test.c @@ -1,12 +1,10 @@ #include #include -#include #include -#include #ifdef PTEST_USE_THREAD # include # include -sem_t *done; +static sem_t done; #endif @@ -56,7 +54,7 @@ printf("time per call: %.3g\n", t); #ifdef PTEST_USE_THREAD -int status = sem_post(done); +int status = sem_post(); assert(status == 0); #endif @@ -70,8 +68,8 @@ start_routine(0); #else pthread_t th; -done = sem_open("perf-test", O_CREAT, 0777, 0); -int i, status; +int i, status = sem_init(, 0, 0); +assert(status == 0); add1(0, 0); /* this is the main thread */ @@ -80,9 +78,7 @@ assert(status == 0); } for (i = 0; i < PTEST_USE_THREAD; i++) { -status = sem_wait(done); -if (status) -fprintf(stderr, "%s\n", strerror(errno)); +status = sem_wait(); assert(status == 0); } #endif diff --git a/pypy/module/test_lib_pypy/cffi_tests/embedding/thread1-test.c b/pypy/module/test_lib_pypy/cffi_tests/embedding/thread1-test.c --- a/pypy/module/test_lib_pypy/cffi_tests/embedding/thread1-test.c +++ b/pypy/module/test_lib_pypy/cffi_tests/embedding/thread1-test.c @@ -7,7 +7,7 @@ extern int add1(int, int); -static sem_t* done; +static sem_t done; static void *start_routine(void *arg) @@ -16,7 +16,7 @@ x = add1(40, 2); assert(x == 42); -status = sem_post(done); +status = sem_post(); assert(status == 0); return arg; @@ -25,8 +25,8 @@ int main(void) { pthread_t th; -int i, status; -done = sem_open("thread1-test", O_CREAT, 0777, 0); +int i, status = sem_init(, 0, 0); +assert(status == 0); printf("starting\n"); fflush(stdout); @@ -35,7 +35,7 @@ assert(status == 0); } for (i = 0; i < NTHREADS; i++) { -status = sem_wait(done); +status = sem_wait(); assert(status == 0); } printf("done\n"); diff --git a/pypy/module/test_lib_pypy/cffi_tests/embedding/thread2-test.c b/pypy/module/test_lib_pypy/cffi_tests/embedding/thread2-test.c --- a/pypy/module/test_lib_pypy/cffi_tests/embedding/thread2-test.c +++ b/pypy/module/test_lib_pypy/cffi_tests/embedding/thread2-test.c @@ -5,7 +5,7 @@ extern int add1(int, int); extern int add2(int, int, int); -static sem_t* done; +static sem_t done; static void *start_routine_1(void *arg) @@ -14,7 +14,7 @@ x = add1(40, 2); assert(x == 42); -status = sem_post(done); +status = sem_post(); assert(status == 0); return arg; @@ -29,7 +29,7 @@ x = add2(1000, 200, 30); assert(x == 1230); -status = sem_post(done); +status = sem_post(); assert(status == 0); return arg; @@ -38,8 +38,8 @@ int main(void) { pthread_t th; -int i, status; -done = sem_open("thread2-test", O_CREAT, 0777, 0); +int i, status = sem_init(, 0, 0); +assert(status == 0); printf("starting\n"); fflush(stdout); @@ -49,7 +49,7 @@ assert(status == 0); for (i = 0; i < 2; i++) { -status = sem_wait(done); +status = sem_wait(); assert(status == 0); } printf("done\n"); diff --git a/pypy/module/test_lib_pypy/cffi_tests/embedding/thread3-test.c b/pypy/module/test_lib_pypy/cffi_tests/embedding/thread3-test.c --- a/pypy/module/test_lib_pypy/cffi_tests/embedding/thread3-test.c +++ b/pypy/module/test_lib_pypy/cffi_tests/embedding/thread3-test.c @@ -5,7 +5,7 @@ extern int add2(int, int, int); extern int add3(int, int, int, int); -static sem_t* done; +static sem_t done; static void *start_routine_2(void *arg) @@ -14,7 +14,7 @@ x = add2(40, 2, 100); assert(x == 142); -status = sem_post(done); +status = sem_post(); assert(status == 0); return arg; @@ -26,7 +26,7 @@ x = add3(1000, 200, 30, 4); assert(x == 1234); -status = sem_post(done); +status = sem_post(); assert(status == 0); return arg; @@ -35,8 +35,8 @@ int main(void) { pthread_t th; -int i, status; -done = sem_open("thread-test3", O_CREAT, 0777, 0); +int i, status = sem_init(, 0, 0); +assert(status == 0); printf("starting\n"); fflush(stdout); @@ -47,7 +47,7 @@ assert(status == 0); } for (i =
[pypy-commit] pypy.org extradoc: update the values
Author: Armin RigoBranch: extradoc Changeset: r713:0d8788f07836 Date: 2016-03-01 10:18 +0100 http://bitbucket.org/pypy/pypy.org/changeset/0d8788f07836/ Log:update the values diff --git a/don1.html b/don1.html --- a/don1.html +++ b/don1.html @@ -15,7 +15,7 @@ - $62984 of $105000 (60.0%) + $63003 of $105000 (60.0%) @@ -23,7 +23,7 @@ This donation goes towards supporting Python 3 in PyPy. Current status: -we have $8136 left +we have $8153 left in the account. Read proposal diff --git a/don4.html b/don4.html --- a/don4.html +++ b/don4.html @@ -9,7 +9,7 @@ $(function() { $("#progressbar").progressbar({ - value: 38.0 + value: 38.2 }); }); @@ -17,7 +17,7 @@ 2nd call: - $30423 of $8 (38.0%) + $30524 of $8 (38.2%) @@ -25,7 +25,7 @@ This donation goes towards supporting the Transactional Memory in PyPy. Current status: -we have $23143 left +we have $23230 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: RISBGN use RISBG (does alter the cc), changed parameter of build_rie_f (signed to unsigned). removed some unnecessay asserts (check now for each parameter)
Author: Richard PlanggerBranch: s390x-backend Changeset: r82626:9fc4da160aeb Date: 2016-03-01 09:56 +0100 http://bitbucket.org/pypy/pypy/changeset/9fc4da160aeb/ Log:RISBGN use RISBG (does alter the cc), changed parameter of build_rie_f (signed to unsigned). removed some unnecessay asserts (check now for each parameter) diff --git a/rpython/jit/backend/zarch/assembler.py b/rpython/jit/backend/zarch/assembler.py --- a/rpython/jit/backend/zarch/assembler.py +++ b/rpython/jit/backend/zarch/assembler.py @@ -1158,8 +1158,6 @@ for reg in includes: v = r.ALL_REG_INDEXES[reg] offset = base_ofs + v * WORD -assert offset >= 0 -assert offset <= 2**16-1 mc.STD(reg, l.addr(offset, r.SPP)) def _pop_fp_regs_from_jitframe(self, mc, includes=r.MANAGED_FP_REGS): @@ -1167,8 +1165,6 @@ for reg in includes: v = r.ALL_REG_INDEXES[reg] offset = base_ofs + v * WORD -assert offset >= 0 -assert offset <= 2**16-1 mc.LD(reg, l.addr(offset, r.SPP)) @@ -1399,7 +1395,7 @@ mc.AGHIK(r.RSZ, lengthloc, l.imm(constsize)) if force_realignment: # "& ~(WORD-1)" -mc.RISBGN(r.RSZ, r.RSZ, l.imm(0), l.imm(0x80 | 60), l.imm(0)) +mc.RISBG(r.RSZ, r.RSZ, l.imm(0), l.imm(0x80 | 60), l.imm(0)) mc.AGRK(r.RSZ, r.RES, r.RSZ) # now RSZ contains the total size in bytes, rounded up to a multiple diff --git a/rpython/jit/backend/zarch/instruction_builder.py b/rpython/jit/backend/zarch/instruction_builder.py --- a/rpython/jit/backend/zarch/instruction_builder.py +++ b/rpython/jit/backend/zarch/instruction_builder.py @@ -341,7 +341,7 @@ return encode_rie_e def build_rie_f(mnemonic, (opcode1,opcode2)): -@builder.arguments('r,r,i8,i8,i8') +@builder.arguments('r,r,u8,u8,u8') def encode_rie_f(self, reg1, reg2, i1, i2, i3): self.writechar(opcode1) byte = (reg1 & BIT_MASK_4) << 4 | (reg2 & BIT_MASK_4) @@ -496,7 +496,6 @@ if type == 'h32': value = arg.value assert -2**31 <= value <= 2**31-1 -assert value & 0x1 == 0 @always_inline def unpack_arg(arg, argtype): check_arg_type(arg, argtype) diff --git a/rpython/jit/backend/zarch/instructions.py b/rpython/jit/backend/zarch/instructions.py --- a/rpython/jit/backend/zarch/instructions.py +++ b/rpython/jit/backend/zarch/instructions.py @@ -42,11 +42,6 @@ 'SLLG':('rsy_a', ['\xEB','\x0D']), # rotating -# rotate, then insert selected bits -# on the VM the miscellaneous-instruction-extensions -# does not seem to be installed -# cpu fails at this instruction, and gnu assembler -# does not recognize mnemonic 'RISBG': ('rie_f', ['\xEC','\x55']), 'RISBGN': ('rie_f', ['\xEC','\x59']), diff --git a/rpython/jit/backend/zarch/opassembler.py b/rpython/jit/backend/zarch/opassembler.py --- a/rpython/jit/backend/zarch/opassembler.py +++ b/rpython/jit/backend/zarch/opassembler.py @@ -568,14 +568,13 @@ # compute in SCRATCH the index of the bit inside the byte: #scratch = (index >> card_page_shift) & 7 # 0x80 sets zero flag. will store 0 into all not selected bits -mc.RISBGN(r.SCRATCH, loc_index, l.imm(61), l.imm(0x80 | 63), l.imm(64-n)) +mc.RISBG(r.SCRATCH, loc_index, l.imm(61), l.imm(0x80 | 63), l.imm(64-n)) mc.XG(tmp_loc, l.pool(self.pool.constant_64_ones)) # set SCRATCH2 to 1 << r1 mc.LGHI(r.SCRATCH2, l.imm(1)) mc.SLLG(r.SCRATCH2, r.SCRATCH2, l.addr(0,r.SCRATCH)) - # set this bit inside the byte of interest addr = l.addr(0, loc_base, tmp_loc) mc.LLGC(r.SCRATCH, addr) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy s390x-backend: assembly instructions now check the immediate values, asserting if a value too big/small is passed
Author: Richard PlanggerBranch: s390x-backend Changeset: r82625:1e7875e46f1c Date: 2016-03-01 09:47 +0100 http://bitbucket.org/pypy/pypy/changeset/1e7875e46f1c/ Log:assembly instructions now check the immediate values, asserting if a value too big/small is passed diff --git a/rpython/jit/backend/zarch/assembler.py b/rpython/jit/backend/zarch/assembler.py --- a/rpython/jit/backend/zarch/assembler.py +++ b/rpython/jit/backend/zarch/assembler.py @@ -1369,6 +1369,7 @@ assert lengthloc is not r.RES and lengthloc is not r.RSZ assert lengthloc.is_reg() +assert maxlength >= 0 if maxlength > 2**16-1: maxlength = 2**16-1 # makes things easier mc = self.mc diff --git a/rpython/jit/backend/zarch/instruction_builder.py b/rpython/jit/backend/zarch/instruction_builder.py --- a/rpython/jit/backend/zarch/instruction_builder.py +++ b/rpython/jit/backend/zarch/instruction_builder.py @@ -461,7 +461,45 @@ def build_unpack_func(mnemonic, func): @always_inline +def check_arg_type(arg, type): +#iX - immediate X bits (signed) +if type.startswith('i'): +value = arg.value +if type == 'i8': assert -2**7 <= value <= 2**7-1 +if type == 'i12': assert -2**11 <= value <= 2**11-1 +if type == 'i16': assert -2**15 <= value <= 2**15-1 +if type == 'i20': assert -2**19 <= value <= 2**19-1 +if type == 'i32': assert -2**31 <= value <= 2**31-1 +#uX - immediate X bits (unsigend) +if type.startswith('u'): +value = arg.value +if type == 'u8': assert 0 <= value <= 2**8-1 +if type == 'u12': assert 0 <= value <= 2**12-1 +if type == 'u16': assert 0 <= value <= 2**16-1 +if type == 'u20': assert 0 <= value <= 2**20-1 +if type == 'u32': assert 0 <= value <= 2**32-1 +#bd - base displacement (unsigned 12 bit) +#bid- index base displacement (unsigned 12 bit) +if type == 'bd' or type == 'bid': +value = arg.displace +assert 0 <= value <= 2**12-1 +#bdl- base displacement long (20 bit) +#bidl - index base displacement (20 bit) +if type == 'bdl' or type == 'bidl': +value = arg.displace +assert -2**19 <= value <= 2**19-1 +#l4bd - length base displacement (4 bit) +if type == 'l4db': +value = arg.displace +assert 0 <= value <= 2**4-1 +#h32- halfwords 32 bit (e.g. LARL, or other relative instr.) +if type == 'h32': +value = arg.value +assert -2**31 <= value <= 2**31-1 +assert value & 0x1 == 0 +@always_inline def unpack_arg(arg, argtype): +check_arg_type(arg, argtype) if argtype == '-': return 0 elif argtype == 'r' or argtype == 'r/m' or \ @@ -565,3 +603,4 @@ setattr(clazz, mnemonic, build_unpack_func(mnemonic, func)) setattr(clazz, mnemonic + '_byte_count', func._byte_count) del func._byte_count +del func._arguments_ diff --git a/rpython/jit/backend/zarch/instructions.py b/rpython/jit/backend/zarch/instructions.py --- a/rpython/jit/backend/zarch/instructions.py +++ b/rpython/jit/backend/zarch/instructions.py @@ -182,6 +182,7 @@ 'STE': ('rx',['\x70']), # note displacement is UNsigned 12 bit 'STD': ('rx',['\x60']), +# here it is 20 bit signed 'STDY':('rxy', ['\xED','\x67']), 'SPM': ('rr',['\x04'], 'r,-'), diff --git a/rpython/jit/backend/zarch/opassembler.py b/rpython/jit/backend/zarch/opassembler.py --- a/rpython/jit/backend/zarch/opassembler.py +++ b/rpython/jit/backend/zarch/opassembler.py @@ -454,7 +454,8 @@ [lengthloc] = arglocs arraydescr = op.getdescr() itemsize = op.getarg(1).getint() -maxlength = (gc_ll_descr.max_size_of_young_obj - WORD * 2) / itemsize +assert itemsize == 1 +maxlength = (gc_ll_descr.max_size_of_young_obj - WORD * 2) gcmap = regalloc.get_gcmap([r.RES, r.RSZ]) self.malloc_cond_varsize( op.getarg(0).getint(), diff --git a/rpython/jit/backend/zarch/regalloc.py b/rpython/jit/backend/zarch/regalloc.py --- a/rpython/jit/backend/zarch/regalloc.py +++ b/rpython/jit/backend/zarch/regalloc.py @@ -803,6 +803,7 @@ # sure it is in a register different from r.RES and r.RSZ. (It # should not be a ConstInt at all.) length_box = op.getarg(2) +assert not isinstance(length_box, Const) lengthloc = self.ensure_reg(length_box) return [lengthloc] ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit