[pypy-commit] pypy bigint-with-int-ops: better tests for int comparisons
Author: Carl Friedrich Bolz cfb...@gmx.de Branch: bigint-with-int-ops Changeset: r73983:1118cad5d291 Date: 2014-10-16 23:39 +0200 http://bitbucket.org/pypy/pypy/changeset/1118cad5d291/ Log:better tests for int comparisons diff --git a/rpython/rlib/test/test_rbigint.py b/rpython/rlib/test/test_rbigint.py --- a/rpython/rlib/test/test_rbigint.py +++ b/rpython/rlib/test/test_rbigint.py @@ -379,12 +379,16 @@ f2 = rbigint.fromlong(y) assert (x y) == f1.lt(f2) -def test_int_lt(self): -val = [0, 0x, 0x1112] -for x in gen_signs(val): -for y in gen_signs(val): +def test_int_comparison(self): +for x in [0, 0x, 0x1112, 12345678912345678900L, 1 100, 3 ** 1]: +for y in [0, 1, 0x, 0x1112, , sys.maxint, 2 ** 19, 2 ** 18 - 1]: f1 = rbigint.fromlong(x) assert (x y) == f1.int_lt(y) +assert (x = y) == f1.int_le(y) +assert (x y) == f1.int_gt(y) +assert (x = y) == f1.int_ge(y) +assert (x == y) == f1.int_eq(y) +assert (x != y) == f1.int_ne(y) def test_order(self): f6 = rbigint.fromint(6) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy bigint-with-int-ops: generally improve test coverage
Author: Carl Friedrich Bolz cfb...@gmx.de Branch: bigint-with-int-ops Changeset: r73984:8b67154fe24d Date: 2014-10-17 08:50 +0200 http://bitbucket.org/pypy/pypy/changeset/8b67154fe24d/ Log:generally improve test coverage diff --git a/rpython/rlib/test/test_rbigint.py b/rpython/rlib/test/test_rbigint.py --- a/rpython/rlib/test/test_rbigint.py +++ b/rpython/rlib/test/test_rbigint.py @@ -2,6 +2,7 @@ import operator import sys +import math from random import random, randint, sample, seed import py @@ -14,6 +15,14 @@ from rpython.rtyper.test.test_llinterp import interpret from rpython.translator.c.test.test_standalone import StandaloneTests +long_vals_not_too_big = range(17) + [ +37, 50, +127, 128, 129, 511, 512, 513, sys.maxint, sys.maxint + 1, +12345678912345678900L, +] + +long_vals = long_vals_not_too_big + [ +1 100, 3 ** 1] class TestRLong(object): def test_simple(self): @@ -43,19 +52,23 @@ assert r2.str() == str(-n) def test_floordiv(self): -for op1 in [-12, -2, -1, 1, 2, 50]: -for op2 in [-4, -2, -1, 1, 2, 8]: -rl_op1 = rbigint.fromint(op1) -rl_op2 = rbigint.fromint(op2) +for op1 in gen_signs(long_vals): +for op2 in gen_signs(long_vals): +if not op2: +continue +rl_op1 = rbigint.fromlong(op1) +rl_op2 = rbigint.fromlong(op2) r1 = rl_op1.floordiv(rl_op2) r2 = op1 // op2 assert r1.tolong() == r2 def test_truediv(self): -for op1 in [-12, -2, -1, 1, 2, 50]: -for op2 in [-4, -2, -1, 1, 2, 8]: -rl_op1 = rbigint.fromint(op1) -rl_op2 = rbigint.fromint(op2) +for op1 in gen_signs(long_vals_not_too_big): +for op2 in gen_signs(long_vals): +if not op2: +continue +rl_op1 = rbigint.fromlong(op1) +rl_op2 = rbigint.fromlong(op2) r1 = rl_op1.truediv(rl_op2) r2 = op1 / op2 assert r1 == r2 @@ -98,32 +111,29 @@ assert f == -1.7976931348623157e+308 # exactly def test_mod(self): -for op1 in [-50, -12, -2, -1, 1, 2, 50, 52]: -for op2 in [-4, -2, -1, 1, 2, 8]: -rl_op1 = rbigint.fromint(op1) -rl_op2 = rbigint.fromint(op2) +for op1 in gen_signs(long_vals): +for op2 in gen_signs(long_vals): +if not op2: +continue +rl_op1 = rbigint.fromlong(op1) +rl_op2 = rbigint.fromlong(op2) r1 = rl_op1.mod(rl_op2) r2 = op1 % op2 print op1, op2 assert r1.tolong() == r2 def test_int_mod(self): -for x in [1, 2, 12, 50, 52, 12345678912345678900L, 1 100, 3 ** 1]: -for y in [1, 2, 4, 8, , sys.maxint, 2 ** 19, 2 ** 18 - 1]: -for i in [-1, 1]: -for j in [-1, 1]: -op1 = x * i -op2 = y * j -rl_op1 = rbigint.fromlong(op1) -r1 = rl_op1.int_mod(op2) -r2 = op1 % op2 -print op1, op2 -assert r1.tolong() == r2 +for x in gen_signs(long_vals): +for y in gen_signs([1, 2, 4, 8, , sys.maxint, 2 ** 19, 2 ** 18 - 1]): +op1 = rbigint.fromlong(x) +r1 = op1.int_mod(y) +r2 = x % y +assert r1.tolong() == r2 def test_pow(self): -for op1 in [-50, -12, -2, -1, 1, 2, 50, 52]: +for op1 in gen_signs(long_vals_not_too_big): for op2 in [0, 1, 2, 8, 9, 10, 11]: -rl_op1 = rbigint.fromint(op1) +rl_op1 = rbigint.fromlong(op1) rl_op2 = rbigint.fromint(op2) r1 = rl_op1.pow(rl_op2) r2 = op1 ** op2 @@ -252,14 +262,11 @@ assert result.tolong() == x * i + y * j def test_int_add(self): -for x in [12345678912345678900L, 1 100, 3 ** 1]: -for y in [0, 1, , sys.maxint, 2 ** 19, 2 ** 18 - 1]: -for i in [-1, 1]: -for j in [-1, 1]: -f1 = rbigint.fromlong(x * i) -f2 = y * j -result = f1.int_add(f2) -assert result.tolong() == x * i + y * j +for x in gen_signs(long_vals): +for y in gen_signs([0, 1, , sys.maxint, 2 ** 19, 2 ** 18 - 1]): +f1 = rbigint.fromlong(x) +result = f1.int_add(y) +assert result.tolong() == x + y def test_sub(self): x = 12378959520302182384345L @@ -272,39 +279,33 @@
[pypy-commit] pypy default: merge bigint-with-int-ops
Author: Carl Friedrich Bolz cfb...@gmx.de Branch: Changeset: r73985:d5cec19910a1 Date: 2014-10-17 08:53 +0200 http://bitbucket.org/pypy/pypy/changeset/d5cec19910a1/ Log:merge bigint-with-int-ops this is only for the rbigint changes, leaving the branch open to at some point be able to do the objspace stuff diff --git a/rpython/rlib/rbigint.py b/rpython/rlib/rbigint.py --- a/rpython/rlib/rbigint.py +++ b/rpython/rlib/rbigint.py @@ -44,6 +44,25 @@ MASK = int((1 SHIFT) - 1) FLOAT_MULTIPLIER = float(1 SHIFT) +# For BIGINT and INT mix. +# +# The VALID range of an int is different than a valid range of a bigint of length one. +# -1 LONG_BIT is actually TWO digits, because they are stored without the sign. +if SHIFT == LONG_BIT - 1: +MIN_INT_VALUE = -1 SHIFT +def int_in_valid_range(x): +if x == MIN_INT_VALUE: +return False +return True +else: +# Means we don't have INT128 on 64bit. +def int_in_valid_range(x): +if x MASK or x -MASK: +return False +return True + +int_in_valid_range._always_inline_ = True + # Debugging digit array access. # # False == no checking at all @@ -485,10 +504,27 @@ i += 1 return True +@jit.elidable +def int_eq(self, other): + eq with int + +if not int_in_valid_range(other): +# Fallback to Long. +return self.eq(rbigint.fromint(other)) + +if self.numdigits() 1: +return False + +return (self.sign * self.digit(0)) == other + @jit.look_inside def ne(self, other): return not self.eq(other) +@jit.look_inside +def int_ne(self, other): +return not self.int_eq(other) + @jit.elidable def lt(self, other): if self.sign other.sign: @@ -524,18 +560,67 @@ i -= 1 return False +@jit.elidable +def int_lt(self, other): + lt where other is an int + +if not int_in_valid_range(other): +# Fallback to Long. +return self.lt(rbigint.fromint(other)) + +osign = 1 +if other == 0: +osign = 0 +elif other 0: +osign = -1 + +if self.sign osign: +return False +elif self.sign osign: +return True + +digits = self.numdigits() + +if digits 1: +if osign == 1: +return False +else: +return True + +d1 = self.sign * self.digit(0) +if d1 other: +return True +return False + @jit.look_inside def le(self, other): return not other.lt(self) @jit.look_inside +def int_le(self, other): +# Alternative that might be faster, reimplant this. as a check with other + 1. But we got to check for overflow +# or reduce valid range. + +if self.int_eq(other): +return True +return self.int_lt(other) + +@jit.look_inside def gt(self, other): return other.lt(self) @jit.look_inside +def int_gt(self, other): +return not self.int_le(other) + +@jit.look_inside def ge(self, other): return not self.lt(other) +@jit.look_inside +def int_ge(self, other): +return not self.int_lt(other) + @jit.elidable def hash(self): return _hash(self) @@ -554,12 +639,31 @@ return result @jit.elidable +def int_add(self, other): +if not int_in_valid_range(other): +# Fallback to long. +return self.add(rbigint.fromint(other)) +elif self.sign == 0: +return rbigint.fromint(other) +elif other == 0: +return self + +sign = -1 if other 0 else 1 +if self.sign == sign: +result = _x_int_add(self, other) +else: +result = _x_int_sub(self, other) +result.sign *= -1 +result.sign *= sign +return result + +@jit.elidable def sub(self, other): if other.sign == 0: return self -if self.sign == 0: +elif self.sign == 0: return rbigint(other._digits[:other.size], -other.sign, other.size) -if self.sign == other.sign: +elif self.sign == other.sign: result = _x_sub(self, other) else: result = _x_add(self, other) @@ -567,6 +671,22 @@ return result @jit.elidable +def int_sub(self, other): +if not int_in_valid_range(other): +# Fallback to long. +return self.sub(rbigint.fromint(other)) +elif other == 0: +return self +elif self.sign == 0: +return rbigint.fromint(-other) +elif self.sign == (-1 if other 0 else 1): +result = _x_int_sub(self, other) +else: +result = _x_int_add(self, other) +
[pypy-commit] pypy default: try like this
Author: Maciej Fijalkowski fij...@gmail.com Branch: Changeset: r73986:5df2c45dbb44 Date: 2014-10-17 09:12 +0200 http://bitbucket.org/pypy/pypy/changeset/5df2c45dbb44/ Log:try like this diff --git a/rpython/translator/platform/posix.py b/rpython/translator/platform/posix.py --- a/rpython/translator/platform/posix.py +++ b/rpython/translator/platform/posix.py @@ -182,7 +182,7 @@ 'int main(int argc, char* argv[]) ' '{ return $(PYPY_MAIN_FUNCTION)(argc, argv); } $@') m.rule('$(DEFAULT_TARGET)', ['$(TARGET)', 'main.o'], - '$(CC_LINK) $(LDFLAGS_LINK) main.o -L. -l$(SHARED_IMPORT_LIB) -o $@ -Wl,-rpath=$ORIGIN/') + '$(CC_LINK) $(LDFLAGS_LINK) main.o -L. -l$(SHARED_IMPORT_LIB) -o $@ -Wl,-rpath=\'$$ORIGIN/\'') return m ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merge
Author: Maciej Fijalkowski fij...@gmail.com Branch: Changeset: r73987:d1bd6dc1f32f Date: 2014-10-17 09:13 +0200 http://bitbucket.org/pypy/pypy/changeset/d1bd6dc1f32f/ Log:merge diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py --- a/rpython/annotator/annrpython.py +++ b/rpython/annotator/annrpython.py @@ -249,10 +249,6 @@ assert s_value.contains(s_old) arg.annotation = s_value -def transfer_binding(self, v_target, v_source): -assert v_source.annotation is not None -v_target.annotation = v_source.annotation - def warning(self, msg, pos=None): if pos is None: try: @@ -579,7 +575,7 @@ for arg in op.args: if isinstance(self.annotation(arg), annmodel.SomeImpossibleValue): raise BlockedInference(self, op, -1) -resultcell = op.consider(self, *op.args) +resultcell = op.consider(self) if resultcell is None: resultcell = annmodel.s_ImpossibleValue elif resultcell == annmodel.s_ImpossibleValue: diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py --- a/rpython/annotator/bookkeeper.py +++ b/rpython/annotator/bookkeeper.py @@ -559,10 +559,6 @@ assert self.annotator.binding(op.args[pos]) == s_type return op -def ondegenerated(self, what, s_value, where=None, called_from_graph=None): -self.annotator.ondegenerated(what, s_value, where=where, - called_from_graph=called_from_graph) - def whereami(self): return self.annotator.whereami(self.position_key) diff --git a/rpython/annotator/description.py b/rpython/annotator/description.py --- a/rpython/annotator/description.py +++ b/rpython/annotator/description.py @@ -14,7 +14,6 @@ objects, where the equivalence relation is the transitive closure of 'd1~d2 if d1 and d2 might be called at the same call site'. -overridden = False normalized = False modified = True @@ -175,7 +174,6 @@ class FunctionDesc(Desc): knowntype = types.FunctionType -overridden = False def __init__(self, bookkeeper, pyobj=None, name=None, signature=None, defaults=None, diff --git a/rpython/flowspace/operation.py b/rpython/flowspace/operation.py --- a/rpython/flowspace/operation.py +++ b/rpython/flowspace/operation.py @@ -96,10 +96,10 @@ def constfold(self): return None -def consider(self, annotator, *args): -args_s = [annotator.annotation(arg) for arg in args] +def consider(self, annotator): +args_s = [annotator.annotation(arg) for arg in self.args] spec = type(self).get_specialization(*args_s) -return spec(annotator, *args) +return spec(annotator, *self.args) def get_can_only_throw(self, annotator): return None @@ -447,7 +447,7 @@ opname = 'newdict' canraise = [] -def consider(self, annotator, *args): +def consider(self, annotator): return annotator.bookkeeper.newdict() @@ -456,16 +456,17 @@ pyfunc = staticmethod(lambda *args: args) canraise = [] -def consider(self, annotator, *args): -return SomeTuple(items=[annotator.annotation(arg) for arg in args]) +def consider(self, annotator): +return SomeTuple(items=[annotator.annotation(arg) for arg in self.args]) class NewList(HLOperation): opname = 'newlist' canraise = [] -def consider(self, annotator, *args): -return annotator.bookkeeper.newlist(*[annotator.annotation(arg) for arg in args]) +def consider(self, annotator): +return annotator.bookkeeper.newlist( +*[annotator.annotation(arg) for arg in self.args]) class Pow(PureOperation): diff --git a/rpython/rlib/rbigint.py b/rpython/rlib/rbigint.py --- a/rpython/rlib/rbigint.py +++ b/rpython/rlib/rbigint.py @@ -44,6 +44,25 @@ MASK = int((1 SHIFT) - 1) FLOAT_MULTIPLIER = float(1 SHIFT) +# For BIGINT and INT mix. +# +# The VALID range of an int is different than a valid range of a bigint of length one. +# -1 LONG_BIT is actually TWO digits, because they are stored without the sign. +if SHIFT == LONG_BIT - 1: +MIN_INT_VALUE = -1 SHIFT +def int_in_valid_range(x): +if x == MIN_INT_VALUE: +return False +return True +else: +# Means we don't have INT128 on 64bit. +def int_in_valid_range(x): +if x MASK or x -MASK: +return False +return True + +int_in_valid_range._always_inline_ = True + # Debugging digit array access. # # False == no checking at all @@ -71,7 +90,6 @@ FIVEARY_CUTOFF = 8 - def _mask_digit(x): return UDIGIT_MASK(x MASK) _mask_digit._annspecialcase_ = 'specialize:argtype(0)' @@ -384,12 +402,17 @@ digits = ''.join([digits[i] for i in range(length-1, -1, -1)]) return digits -@jit.elidable def
[pypy-commit] extradoc extradoc: shuffle shuffle shuffle
Author: Maciej Fijalkowski fij...@gmail.com Branch: extradoc Changeset: r5436:0fd97dbab92d Date: 2014-10-17 10:21 +0200 http://bitbucket.org/pypy/extradoc/changeset/0fd97dbab92d/ Log:shuffle shuffle shuffle diff --git a/talk/pyconpl-2014/author.latex b/talk/pyconpl-2014/author.latex --- a/talk/pyconpl-2014/author.latex +++ b/talk/pyconpl-2014/author.latex @@ -2,8 +2,9 @@ \title[PyPy]{PyPy} \author[arigo, fijal] -{Armin Rigo, Maciej Fija#322;kovski\\ -\includegraphics[width=80px]{../img/py-web-new.png}} - +{Armin Rigo, Maciej Fija#322;kowski\\ +\includegraphics[width=80px]{../img/py-web-new.png} +\hspace{1em} +\includegraphics[width=80px]{../img/baroquesoftware.png}} \institute{PyCon PL} \date{October 2014} diff --git a/talk/pyconpl-2014/talk.rst b/talk/pyconpl-2014/talk.rst --- a/talk/pyconpl-2014/talk.rst +++ b/talk/pyconpl-2014/talk.rst @@ -56,7 +56,52 @@ * Numpy more complete (but still not done) - - also, no scipy +Status +- + +- Python code just works + + * generally much faster than with CPython + +- C code: improving support + + * cpyext: tries to load CPython C extension modules, slowly + + * CFFI: the future + + * cppyy for C++ + + * A very small native PyPy C API for embedding, WIP + +- Lots of CFFI modules around: + + * pyopenssl, pygame_cffi, psycopg2cffi, lxml... + +Fundraising Campaign +- + +- py3k: 55'000 $ of 105'000 $ (52%) + +- numpy: 48'000 $ of 60'000 $ (80%) + +- STM, 1st call: 38'000 $ + +- STM, 2nd call: 17'000 $ of 80'000 $ (22%) + +- Thanks to all donors! + +Commercial support +-- + +- We offer commercial support for PyPy + +- Consultancy and training + +- Performance issues for open- or closed-source programs, porting, + improving support in parts of the Python or non-Python interpreters, + etc. + +- http://baroquesoftware.com Recent developments (2) @@ -107,86 +152,6 @@ * Inspired by LuaJIT's FFI -Status -- - -- Python code just works - - * generally much faster than with CPython - -- C code: improving support - - * cpyext: tries to load CPython C extension modules, slowly - - * CFFI: the future - - * cppyy for C++ - - * A very small native PyPy C API for embedding, WIP - -- Lots of CFFI modules around: - - * pyopenssl, pygame_cffi, psycopg2cffi, lxml... - -Fundraising Campaign -- - -- py3k: 55'000 $ of 105'000 $ (52%) - -- numpy: 48'000 $ of 60'000 $ (80%) - -- STM, 1st call: 38'000 $ - -- STM, 2nd call: 17'000 $ of 80'000 $ (22%) - -- Thanks to all donors! - -Commercial support --- - -- We offer commercial support for PyPy - -- Consultancy and training - -- Performance issues for open- or closed-source programs, porting, - improving support in parts of the Python or non-Python interpreters, - etc. - -- http://baroquesoftware.com - -PyPy and RPython - -* PyPy is an interpreter/JIT-compiled for Python - -* PyPy is written in RPython - -* RPython is a language for writing interpreters: - it provides GC-for-free, JIT-for-free, etc. - -* Ideal for writing VMs for dynamic languages - -More PyPy-Powered Languages - - -- Topaz: implementing Ruby - - * most of the language implemented - - * definitely faster than MRI - - * https://github.com/topazproject/topaz - -- HippyVM: implementing PHP - - * ~7x faster than standard PHP - - * comparable speed as HHVM - - * http://hippyvm.com/ - -- And more - Work in Progress: STM - @@ -255,6 +220,39 @@ STM (Demo) -- +PyPy and RPython +--- + +* PyPy is an interpreter/JIT-compiled for Python + +* PyPy is written in RPython + +* RPython is a language for writing interpreters: + it provides GC-for-free, JIT-for-free, etc. + +* Ideal for writing VMs for dynamic languages + +More PyPy-Powered Languages + + +- Topaz: implementing Ruby + + * most of the language implemented + + * definitely faster than MRI + + * https://github.com/topazproject/topaz + +- HippyVM: implementing PHP + + * ~7x faster than standard PHP + + * comparable speed as HHVM + + * http://hippyvm.com/ + +- And more + Future -- ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] extradoc extradoc: pic
Author: Maciej Fijalkowski fij...@gmail.com Branch: extradoc Changeset: r5437:f951fe804b97 Date: 2014-10-17 10:22 +0200 http://bitbucket.org/pypy/extradoc/changeset/f951fe804b97/ Log:pic diff --git a/talk/img/baroquesoftware.png b/talk/img/baroquesoftware.png new file mode 100644 index ..038e80b25722d7917a1fbecb581ce25b54707ab2 GIT binary patch [cut] ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] extradoc extradoc: one more pic
Author: Maciej Fijalkowski fij...@gmail.com Branch: extradoc Changeset: r5438:87b54de43a8a Date: 2014-10-17 10:23 +0200 http://bitbucket.org/pypy/extradoc/changeset/87b54de43a8a/ Log:one more pic diff --git a/talk/pyconpl-2014/standards.png b/talk/pyconpl-2014/standards.png new file mode 100644 index ..5d38303773dd4f1b798a91bec62d05e0423a6a0d GIT binary patch [cut] ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] extradoc extradoc: center this image
Author: Armin Rigo ar...@tunes.org Branch: extradoc Changeset: r5439:4e488e19aa69 Date: 2014-10-17 10:30 +0200 http://bitbucket.org/pypy/extradoc/changeset/4e488e19aa69/ Log:center this image diff --git a/talk/pyconpl-2014/talk.rst b/talk/pyconpl-2014/talk.rst --- a/talk/pyconpl-2014/talk.rst +++ b/talk/pyconpl-2014/talk.rst @@ -29,6 +29,7 @@ .. image:: speed.png :scale: 44% + :align: center Demo ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc finalizer: Extra tests
Author: Armin Rigo ar...@tunes.org Branch: finalizer Changeset: r1473:8727aa2547c5 Date: 2014-10-17 11:01 +0200 http://bitbucket.org/pypy/stmgc/changeset/8727aa2547c5/ Log:Extra tests diff --git a/c7/test/test_list.py b/c7/test/test_list.py --- a/c7/test/test_list.py +++ b/c7/test/test_list.py @@ -6,6 +6,12 @@ ffi = cffi.FFI() ffi.cdef( struct list_s *list_create(void); +void list_free(struct list_s *lst); +struct list_s *list_append(struct list_s *lst, uintptr_t item); +uintptr_t list_count(struct list_s *lst); +uintptr_t list_item(struct list_s *lst, uintptr_t index); +struct list_s *list_extend(struct list_s *lst, struct list_s *lst2, + uintptr_t slicestart); struct tree_s *tree_create(void); void tree_free(struct tree_s *tree); @@ -127,3 +133,16 @@ def test_hash_permutation(): hashes = [((n ^ (n 4)) 0xFF0) for n in range(256)] assert set(hashes) == set(range(0, 4096, 16)) + +def test_list_extend(): +a = lib.list_create() +b = lib.list_create() +for i in range(100, 120): +b = lib.list_append(b, i) +a = lib.list_extend(a, b, 3) +a = lib.list_extend(a, b, 13) +assert lib.list_count(a) == 17 + 7 +for i, expected in enumerate(range(103, 120) + range(113, 120)): +assert lib.list_item(a, i) == expected +lib.list_free(b) +lib.list_free(a) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc finalizer: update comments
Author: Armin Rigo ar...@tunes.org Branch: finalizer Changeset: r1474:1ff20d0478c9 Date: 2014-10-17 11:34 +0200 http://bitbucket.org/pypy/stmgc/changeset/1ff20d0478c9/ Log:update comments diff --git a/c7/stmgc.h b/c7/stmgc.h --- a/c7/stmgc.h +++ b/c7/stmgc.h @@ -516,11 +516,15 @@ stmcb_finalizer() is called after the major GC. If there are several objects with finalizers that reference each other in a well-defined order (i.e. there are no cycles), then they are - finalized in order from outermost to innermost (i.e. starting with - the ones that are unreachable even from others). The finalizer is - called in a random thread, except for objects that have been - created by the current transaction in a thread; in that case, only - that thread can call the finalizer. */ + finalized in order from outermost to innermost (i.e. starting with + the ones that are unreachable even from others). + + For objects that have been created by the current transaction, if a + major GC runs while that transaction is alive and finds the object + unreachable, the finalizer is called immediately in the same + transaction. For older objects, the finalizer is called from a + random thread between regular transactions, in a new custom + transaction. */ void (*stmcb_finalizer)(object_t *); object_t *stm_allocate_with_finalizer(ssize_t size_rounded_up); ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc finalizer: Tweak invocation of same-transaction finalizers
Author: Armin Rigo ar...@tunes.org Branch: finalizer Changeset: r1475:512c75ab693f Date: 2014-10-17 11:59 +0200 http://bitbucket.org/pypy/stmgc/changeset/512c75ab693f/ Log:Tweak invocation of same-transaction finalizers diff --git a/c7/stm/core.c b/c7/stm/core.c --- a/c7/stm/core.c +++ b/c7/stm/core.c @@ -808,6 +808,9 @@ void stm_commit_transaction(void) { + restart_all: +exec_local_finalizers(); + assert(!_has_mutex()); assert(STM_PSEGMENT-safe_point == SP_RUNNING); assert(STM_PSEGMENT-running_pthread == pthread_self()); @@ -825,6 +828,11 @@ Important: we should not call cond_wait() in the meantime. */ synchronize_all_threads(STOP_OTHERS_UNTIL_MUTEX_UNLOCK); +if (any_local_finalizers()) { +s_mutex_unlock(); +goto restart_all; +} + /* detect conflicts */ if (detect_write_read_conflicts()) goto restart; diff --git a/c7/stm/finalizer.c b/c7/stm/finalizer.c --- a/c7/stm/finalizer.c +++ b/c7/stm/finalizer.c @@ -345,9 +345,9 @@ LIST_FREE(_finalizer_emptystack); } -static void execute_finalizers(struct finalizers_s *f) +static void _execute_finalizers(struct finalizers_s *f) { -if (f == NULL || f-run_finalizers == NULL) +if (f-run_finalizers == NULL) return; /* nothing to do */ restart: @@ -395,7 +395,7 @@ stm_rewind_jmp_enterframe(tl, rjbuf); stm_start_transaction(tl); -execute_finalizers(g_finalizers); +_execute_finalizers(g_finalizers); stm_commit_transaction(); stm_rewind_jmp_leaveframe(tl, rjbuf); diff --git a/c7/stm/finalizer.h b/c7/stm/finalizer.h --- a/c7/stm/finalizer.h +++ b/c7/stm/finalizer.h @@ -37,4 +37,11 @@ _invoke_general_finalizers(tl); \ } while (0) -static void execute_finalizers(struct finalizers_s *f); +static void _execute_finalizers(struct finalizers_s *f); + +#define any_local_finalizers() (STM_PSEGMENT-finalizers != NULL \ + STM_PSEGMENT-finalizers-run_finalizers != NULL) +#define exec_local_finalizers() do { \ +if (any_local_finalizers()) \ +_execute_finalizers(STM_PSEGMENT-finalizers); \ +} while (0) diff --git a/c7/stm/gcpage.c b/c7/stm/gcpage.c --- a/c7/stm/gcpage.c +++ b/c7/stm/gcpage.c @@ -153,8 +153,7 @@ } s_mutex_unlock(); - -execute_finalizers(STM_PSEGMENT-finalizers); +exec_local_finalizers(); } diff --git a/c7/stm/sync.c b/c7/stm/sync.c --- a/c7/stm/sync.c +++ b/c7/stm/sync.c @@ -228,6 +228,7 @@ assert(_stm_in_transaction(tl)); set_gs_register(get_segment_base(tl-associated_segment_num)); assert(STM_SEGMENT-running_thread == tl); +exec_local_finalizers(); } #if STM_TESTS diff --git a/c7/test/test_finalizer.py b/c7/test/test_finalizer.py --- a/c7/test/test_finalizer.py +++ b/c7/test/test_finalizer.py @@ -167,3 +167,18 @@ self.expect_finalized([]) self.commit_transaction() self.expect_finalized([lp1]) + +def test_run_cb_for_all_threads(self): +self.start_transaction() +lp1 = stm_allocate_with_finalizer(48) +print lp1 +# +self.switch(1) +self.start_transaction() +lp2 = stm_allocate_with_finalizer(56) +print lp2 + +self.expect_finalized([]) +stm_major_collect() +self.switch(0) +self.expect_finalized([lp2, lp1]) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc finalizer: Seems to work, but needs large-scale testing. I'll try it with pypy
Author: Armin Rigo ar...@tunes.org Branch: finalizer Changeset: r1476:3a97b7bfd88f Date: 2014-10-17 12:03 +0200 http://bitbucket.org/pypy/stmgc/changeset/3a97b7bfd88f/ Log:Seems to work, but needs large-scale testing. I'll try it with pypy ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc default: hg merge finalizer
Author: Armin Rigo ar...@tunes.org Branch: Changeset: r1477:3a8ef5f741ab Date: 2014-10-17 12:03 +0200 http://bitbucket.org/pypy/stmgc/changeset/3a8ef5f741ab/ Log:hg merge finalizer Finalizers. Yay. diff --git a/c7/stm/core.c b/c7/stm/core.c --- a/c7/stm/core.c +++ b/c7/stm/core.c @@ -374,6 +374,7 @@ assert(tree_is_cleared(STM_PSEGMENT-callbacks_on_commit_and_abort[1])); assert(STM_PSEGMENT-objects_pointing_to_nursery == NULL); assert(STM_PSEGMENT-large_overflow_objects == NULL); +assert(STM_PSEGMENT-finalizers == NULL); #ifndef NDEBUG /* this should not be used when objects_pointing_to_nursery == NULL */ STM_PSEGMENT-modified_old_objects_markers_num_old = 9L; @@ -807,6 +808,9 @@ void stm_commit_transaction(void) { + restart_all: +exec_local_finalizers(); + assert(!_has_mutex()); assert(STM_PSEGMENT-safe_point == SP_RUNNING); assert(STM_PSEGMENT-running_pthread == pthread_self()); @@ -824,6 +828,11 @@ Important: we should not call cond_wait() in the meantime. */ synchronize_all_threads(STOP_OTHERS_UNTIL_MUTEX_UNLOCK); +if (any_local_finalizers()) { +s_mutex_unlock(); +goto restart_all; +} + /* detect conflicts */ if (detect_write_read_conflicts()) goto restart; @@ -845,6 +854,8 @@ push_modified_to_other_segments(); _verify_cards_cleared_in_all_lists(get_priv_segment(STM_SEGMENT-segment_num)); +commit_finalizers(); + /* update 'overflow_number' if needed */ if (STM_PSEGMENT-overflow_number_has_been_used) { highest_overflow_number += GCFLAG_OVERFLOW_NUMBER_bit0; @@ -865,10 +876,13 @@ } /* done */ +stm_thread_local_t *tl = STM_SEGMENT-running_thread; _finish_transaction(STM_TRANSACTION_COMMIT); /* cannot access STM_SEGMENT or STM_PSEGMENT from here ! */ s_mutex_unlock(); + +invoke_general_finalizers(tl); } void stm_abort_transaction(void) @@ -1046,6 +1060,8 @@ /* invoke the callbacks */ invoke_and_clear_user_callbacks(1); /* for abort */ +abort_finalizers(); + if (is_abort(STM_SEGMENT-nursery_end)) { /* done aborting */ STM_SEGMENT-nursery_end = pause_signalled ? NSE_SIGPAUSE diff --git a/c7/stm/core.h b/c7/stm/core.h --- a/c7/stm/core.h +++ b/c7/stm/core.h @@ -198,6 +198,13 @@ /* marker where this thread became inevitable */ stm_loc_marker_t marker_inev; + +/* light finalizers */ +struct list_s *young_objects_with_light_finalizers; +struct list_s *old_objects_with_light_finalizers; + +/* regular finalizers (objs from the current transaction only) */ +struct finalizers_s *finalizers; }; enum /* safe_point */ { diff --git a/c7/stm/finalizer.c b/c7/stm/finalizer.c new file mode 100644 --- /dev/null +++ b/c7/stm/finalizer.c @@ -0,0 +1,404 @@ + + +/* callbacks */ +void (*stmcb_light_finalizer)(object_t *); +void (*stmcb_finalizer)(object_t *); + + +static void init_finalizers(struct finalizers_s *f) +{ +f-objects_with_finalizers = list_create(); +f-count_non_young = 0; +f-run_finalizers = NULL; +f-running_next = NULL; +} + +static void setup_finalizer(void) +{ +init_finalizers(g_finalizers); +} + +static void teardown_finalizer(void) +{ +if (g_finalizers.run_finalizers != NULL) +list_free(g_finalizers.run_finalizers); +list_free(g_finalizers.objects_with_finalizers); +memset(g_finalizers, 0, sizeof(g_finalizers)); +} + +static void _commit_finalizers(void) +{ +if (STM_PSEGMENT-finalizers-run_finalizers != NULL) { +/* copy 'STM_PSEGMENT-finalizers-run_finalizers' into + 'g_finalizers.run_finalizers', dropping any initial NULLs + (finalizers already called) */ +struct list_s *src = STM_PSEGMENT-finalizers-run_finalizers; +uintptr_t frm = 0; +if (STM_PSEGMENT-finalizers-running_next != NULL) { +frm = *STM_PSEGMENT-finalizers-running_next; +assert(frm = list_count(src)); +*STM_PSEGMENT-finalizers-running_next = (uintptr_t)-1; +} +if (frm list_count(src)) { +g_finalizers.run_finalizers = list_extend( +g_finalizers.run_finalizers, +src, frm); +} +list_free(src); +} + +/* copy the whole 'STM_PSEGMENT-finalizers-objects_with_finalizers' + into 'g_finalizers.objects_with_finalizers' */ +g_finalizers.objects_with_finalizers = list_extend( +g_finalizers.objects_with_finalizers, +STM_PSEGMENT-finalizers-objects_with_finalizers, 0); +list_free(STM_PSEGMENT-finalizers-objects_with_finalizers); + +free(STM_PSEGMENT-finalizers); +STM_PSEGMENT-finalizers = NULL; +} + +static void _abort_finalizers(void) +{ +/* like _commit_finalizers(), but forget everything from the + current transaction */ +if (STM_PSEGMENT-finalizers-run_finalizers != NULL) { +if
[pypy-commit] pypy stmgc-c7: import stmgc/3a8ef5f741ab
Author: Armin Rigo ar...@tunes.org Branch: stmgc-c7 Changeset: r73988:b2f9c698970e Date: 2014-10-17 12:37 +0200 http://bitbucket.org/pypy/pypy/changeset/b2f9c698970e/ Log:import stmgc/3a8ef5f741ab diff --git a/rpython/translator/stm/src_stm/revision b/rpython/translator/stm/src_stm/revision --- a/rpython/translator/stm/src_stm/revision +++ b/rpython/translator/stm/src_stm/revision @@ -1,1 +1,1 @@ -32dbfbd04b6f +3a8ef5f741ab diff --git a/rpython/translator/stm/src_stm/stm/core.c b/rpython/translator/stm/src_stm/stm/core.c --- a/rpython/translator/stm/src_stm/stm/core.c +++ b/rpython/translator/stm/src_stm/stm/core.c @@ -375,6 +375,7 @@ assert(tree_is_cleared(STM_PSEGMENT-callbacks_on_commit_and_abort[1])); assert(STM_PSEGMENT-objects_pointing_to_nursery == NULL); assert(STM_PSEGMENT-large_overflow_objects == NULL); +assert(STM_PSEGMENT-finalizers == NULL); #ifndef NDEBUG /* this should not be used when objects_pointing_to_nursery == NULL */ STM_PSEGMENT-modified_old_objects_markers_num_old = 9L; @@ -808,6 +809,9 @@ void stm_commit_transaction(void) { + restart_all: +exec_local_finalizers(); + assert(!_has_mutex()); assert(STM_PSEGMENT-safe_point == SP_RUNNING); assert(STM_PSEGMENT-running_pthread == pthread_self()); @@ -825,6 +829,11 @@ Important: we should not call cond_wait() in the meantime. */ synchronize_all_threads(STOP_OTHERS_UNTIL_MUTEX_UNLOCK); +if (any_local_finalizers()) { +s_mutex_unlock(); +goto restart_all; +} + /* detect conflicts */ if (detect_write_read_conflicts()) goto restart; @@ -846,6 +855,8 @@ push_modified_to_other_segments(); _verify_cards_cleared_in_all_lists(get_priv_segment(STM_SEGMENT-segment_num)); +commit_finalizers(); + /* update 'overflow_number' if needed */ if (STM_PSEGMENT-overflow_number_has_been_used) { highest_overflow_number += GCFLAG_OVERFLOW_NUMBER_bit0; @@ -866,10 +877,13 @@ } /* done */ +stm_thread_local_t *tl = STM_SEGMENT-running_thread; _finish_transaction(STM_TRANSACTION_COMMIT); /* cannot access STM_SEGMENT or STM_PSEGMENT from here ! */ s_mutex_unlock(); + +invoke_general_finalizers(tl); } void stm_abort_transaction(void) @@ -1047,6 +1061,8 @@ /* invoke the callbacks */ invoke_and_clear_user_callbacks(1); /* for abort */ +abort_finalizers(); + if (is_abort(STM_SEGMENT-nursery_end)) { /* done aborting */ STM_SEGMENT-nursery_end = pause_signalled ? NSE_SIGPAUSE diff --git a/rpython/translator/stm/src_stm/stm/core.h b/rpython/translator/stm/src_stm/stm/core.h --- a/rpython/translator/stm/src_stm/stm/core.h +++ b/rpython/translator/stm/src_stm/stm/core.h @@ -199,6 +199,13 @@ /* marker where this thread became inevitable */ stm_loc_marker_t marker_inev; + +/* light finalizers */ +struct list_s *young_objects_with_light_finalizers; +struct list_s *old_objects_with_light_finalizers; + +/* regular finalizers (objs from the current transaction only) */ +struct finalizers_s *finalizers; }; enum /* safe_point */ { diff --git a/rpython/translator/stm/src_stm/stm/finalizer.c b/rpython/translator/stm/src_stm/stm/finalizer.c new file mode 100644 --- /dev/null +++ b/rpython/translator/stm/src_stm/stm/finalizer.c @@ -0,0 +1,405 @@ +/* Imported by rpython/translator/stm/import_stmgc.py */ + + +/* callbacks */ +void (*stmcb_light_finalizer)(object_t *); +void (*stmcb_finalizer)(object_t *); + + +static void init_finalizers(struct finalizers_s *f) +{ +f-objects_with_finalizers = list_create(); +f-count_non_young = 0; +f-run_finalizers = NULL; +f-running_next = NULL; +} + +static void setup_finalizer(void) +{ +init_finalizers(g_finalizers); +} + +static void teardown_finalizer(void) +{ +if (g_finalizers.run_finalizers != NULL) +list_free(g_finalizers.run_finalizers); +list_free(g_finalizers.objects_with_finalizers); +memset(g_finalizers, 0, sizeof(g_finalizers)); +} + +static void _commit_finalizers(void) +{ +if (STM_PSEGMENT-finalizers-run_finalizers != NULL) { +/* copy 'STM_PSEGMENT-finalizers-run_finalizers' into + 'g_finalizers.run_finalizers', dropping any initial NULLs + (finalizers already called) */ +struct list_s *src = STM_PSEGMENT-finalizers-run_finalizers; +uintptr_t frm = 0; +if (STM_PSEGMENT-finalizers-running_next != NULL) { +frm = *STM_PSEGMENT-finalizers-running_next; +assert(frm = list_count(src)); +*STM_PSEGMENT-finalizers-running_next = (uintptr_t)-1; +} +if (frm list_count(src)) { +g_finalizers.run_finalizers = list_extend( +g_finalizers.run_finalizers, +src, frm); +} +list_free(src); +} + +/* copy the whole 'STM_PSEGMENT-finalizers-objects_with_finalizers' +
[pypy-commit] pypy stmgc-c7: Be careful here
Author: Armin Rigo ar...@tunes.org Branch: stmgc-c7 Changeset: r73989:8ee8f761ca9d Date: 2014-10-17 12:39 +0200 http://bitbucket.org/pypy/pypy/changeset/8ee8f761ca9d/ Log:Be careful here diff --git a/rpython/translator/stm/src_stm/extracode.h b/rpython/translator/stm/src_stm/extracode.h --- a/rpython/translator/stm/src_stm/extracode.h +++ b/rpython/translator/stm/src_stm/extracode.h @@ -117,9 +117,15 @@ line += ((unsigned char *)lnotab)[i + 1]; } -return snprintf(outputbuf, outputbufsize, -File \%s%.*s\, line %ld, in %.*s%s, -fntrunc, (int)fnlen, fn, line, (int)nlen, name, ntrunc); +int result; +result = snprintf(outputbuf, outputbufsize, + File \%s%.*s\, line %ld, in %.*s%s, + fntrunc, (int)fnlen, fn, line, (int)nlen, name, ntrunc); +if (result = outputbufsize) +result = outputbufsize - 1; +if (result 0) +result = 0; +return result; } void pypy_stm_setup_expand_marker(long co_filename_ofs, ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy stmgc-c7: (fijal, arigo)
Author: Armin Rigo ar...@tunes.org Branch: stmgc-c7 Changeset: r73990:f626a453d3e4 Date: 2014-10-17 12:51 +0200 http://bitbucket.org/pypy/pypy/changeset/f626a453d3e4/ Log:(fijal, arigo) Reintroduce a direct test for _stm_expand_marker_for_pypy diff --git a/rpython/translator/stm/funcgen.py b/rpython/translator/stm/funcgen.py --- a/rpython/translator/stm/funcgen.py +++ b/rpython/translator/stm/funcgen.py @@ -222,7 +222,7 @@ def stm_expand_marker(funcgen, op): result = funcgen.expr(op.result) -return '%s = _stm_expand_marker();' % (result,) +return '%s = _pypy_stm_test_expand_marker();' % (result,) def stm_setup_expand_marker_for_pypy(funcgen, op): # hack hack hack diff --git a/rpython/translator/stm/src_stm/extracode.h b/rpython/translator/stm/src_stm/extracode.h --- a/rpython/translator/stm/src_stm/extracode.h +++ b/rpython/translator/stm/src_stm/extracode.h @@ -128,6 +128,28 @@ return result; } +char *_pypy_stm_test_expand_marker(void) +{ +/* only for tests: XXX fishing */ +stm_loc_marker_t marker; +marker.tl = stm_thread_local; +marker.segment_base = STM_SEGMENT-segment_base; + +struct stm_shadowentry_s *_ss = stm_thread_local.shadowstack - 2; +while (!(((uintptr_t)(_ss-ss)) 1)) { +_ss--; +assert(_ss = stm_thread_local.shadowstack_base); +} +marker.odd_number = (uintptr_t)(_ss-ss); +marker.object = (_ss + 1)-ss; + +static char buffer[80]; +int length = _stm_expand_marker_for_pypy(marker, buffer, 80); +assert(length = 0 length 80); +buffer[length] = 0; +return buffer; +} + void pypy_stm_setup_expand_marker(long co_filename_ofs, long co_name_ofs, long co_firstlineno_ofs, ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy stmgc-c7: Fix tests
Author: Armin Rigo ar...@tunes.org Branch: stmgc-c7 Changeset: r73992:6a7a800b08d1 Date: 2014-10-17 14:30 +0200 http://bitbucket.org/pypy/pypy/changeset/6a7a800b08d1/ Log:Fix tests diff --git a/rpython/rlib/rstm.py b/rpython/rlib/rstm.py --- a/rpython/rlib/rstm.py +++ b/rpython/rlib/rstm.py @@ -76,6 +76,8 @@ @specialize.arg(0) def should_break_transaction(keep): +# 'keep' should be true at the end of the loops, and false otherwise +# (it only matters for the JIT) return we_are_translated() and ( llop.stm_should_break_transaction(lltype.Bool, keep)) @@ -154,6 +156,9 @@ def pop_marker(): llop.stm_pop_marker(lltype.Void) +def stm_count(): # for tests +return llop.stm_count(lltype.Signed) + # class _Entry(ExtRegistryEntry): diff --git a/rpython/translator/stm/test/targetdemo2.py b/rpython/translator/stm/test/targetdemo2.py --- a/rpython/translator/stm/test/targetdemo2.py +++ b/rpython/translator/stm/test/targetdemo2.py @@ -88,7 +88,7 @@ def do_run_really(self): value = 0 while True: -rstm.possible_transaction_break() +rstm.possible_transaction_break(True) if not self.run_really(value): break value += 1 @@ -109,7 +109,7 @@ return (value+1) glob.LENGTH def do_check_ptr_equality(self): -rstm.possible_transaction_break() +rstm.possible_transaction_break(True) self.check_ptr_equality(0) def check_ptr_equality(self, foo): @@ -123,7 +123,7 @@ def do_check_inev(self): value = 0 while True: -rstm.possible_transaction_break() +rstm.possible_transaction_break(True) if not self.check_inev(value): break value += 1 @@ -151,7 +151,7 @@ def do_check_hash(self): value = 0 while True: -rstm.possible_transaction_break() +rstm.possible_transaction_break(True) value = self.check_hash(value) if value = glob.LENGTH: break diff --git a/rpython/translator/stm/test/test_ztranslated.py b/rpython/translator/stm/test/test_ztranslated.py --- a/rpython/translator/stm/test/test_ztranslated.py +++ b/rpython/translator/stm/test/test_ztranslated.py @@ -91,11 +91,11 @@ def test_should_break_transaction(self): def entry_point(argv): rstm.hint_commit_soon() -print '', int(rstm.should_break_transaction()), '' +print '', int(rstm.should_break_transaction(True)), '' return 0 t, cbuilder = self.compile(entry_point) data = cbuilder.cmdexec('') -assert ' 1 \n' in data +assert ' 0 \n' in data def test_set_transaction_length(self): def entry_point(argv): @@ -131,38 +131,13 @@ data, dataerr = cbuilder.cmdexec('4 5000', err=True) assert 'check ok!' in data -def test_retry_counter_starts_at_zero(self): -# -def check(foobar, retry_counter): -print '', retry_counter, '' -return 0 -# -S = lltype.GcStruct('S', ('got_exception', OBJECTPTR)) -PS = lltype.Ptr(S) -perform_transaction = rstm.make_perform_transaction(check, PS) -def entry_point(argv): -perform_transaction(lltype.malloc(S)) -return 0 -# -t, cbuilder = self.compile(entry_point, backendopt=True) -data = cbuilder.cmdexec('a b c d') -assert ' 0 \n' in data - def test_bug1(self): -# -def check(foobar, retry_counter): -rgc.collect(0) -return 0 -# -S = lltype.GcStruct('S', ('got_exception', OBJECTPTR)) -PS = lltype.Ptr(S) -perform_transaction = rstm.make_perform_transaction(check, PS) class X: def __init__(self, count): self.count = count def g(): x = X(1000) -perform_transaction(lltype.malloc(S)) +rgc.collect(0) return x def entry_point(argv): x = X(len(argv)) @@ -174,38 +149,6 @@ data = cbuilder.cmdexec('a b c d') assert ' 5 1000 ' in data, got: %r % (data,) -def test_bug2(self): -# -def check(foobar, retry_counter): -return 0# do nothing -# -class X2: -pass -prebuilt2 = [X2(), X2()] -# -S = lltype.GcStruct('S', ('got_exception', OBJECTPTR)) -PS = lltype.Ptr(S) -perform_transaction = rstm.make_perform_transaction(check, PS) -def bug2(count): -x = prebuilt2[count] -x.foobar = 2# 'x' becomes a local -# -perform_transaction(lltype.malloc(S)) -# 'x' becomes the global again -
[pypy-commit] pypy stmgc-c7: Kill a test
Author: Armin Rigo ar...@tunes.org Branch: stmgc-c7 Changeset: r73991:0908ab4fcaad Date: 2014-10-17 14:11 +0200 http://bitbucket.org/pypy/pypy/changeset/0908ab4fcaad/ Log:Kill a test diff --git a/rpython/rtyper/lltypesystem/lloperation.py b/rpython/rtyper/lltypesystem/lloperation.py --- a/rpython/rtyper/lltypesystem/lloperation.py +++ b/rpython/rtyper/lltypesystem/lloperation.py @@ -456,6 +456,8 @@ 'stm_expand_marker': LLOp(), 'stm_setup_expand_marker_for_pypy': LLOp(), +'stm_count': LLOp(), + # __ address operations __ 'boehm_malloc': LLOp(), diff --git a/rpython/translator/stm/funcgen.py b/rpython/translator/stm/funcgen.py --- a/rpython/translator/stm/funcgen.py +++ b/rpython/translator/stm/funcgen.py @@ -250,3 +250,7 @@ return '%s = rjbuf1;' % (funcgen.expr(op.result),) else: assert False, op.args[0].value + +def stm_count(funcgen, op): +result = funcgen.expr(op.result) +return '%s = _pypy_stm_count();' % (result,) diff --git a/rpython/translator/stm/src_stm/stmgcintf.c b/rpython/translator/stm/src_stm/stmgcintf.c --- a/rpython/translator/stm/src_stm/stmgcintf.c +++ b/rpython/translator/stm/src_stm/stmgcintf.c @@ -220,3 +220,10 @@ } stm_become_globally_unique_transaction(stm_thread_local, for the JIT); } + +long _pypy_stm_count(void) +{ +/* for tests */ +static long value = 0; +return value++; +} diff --git a/rpython/translator/stm/src_stm/stmgcintf.h b/rpython/translator/stm/src_stm/stmgcintf.h --- a/rpython/translator/stm/src_stm/stmgcintf.h +++ b/rpython/translator/stm/src_stm/stmgcintf.h @@ -31,11 +31,14 @@ void _pypy_stm_become_inevitable(const char *); void pypy_stm_become_globally_unique_transaction(void); +char *_pypy_stm_test_expand_marker(void); void pypy_stm_setup_expand_marker(long co_filename_ofs, long co_name_ofs, long co_firstlineno_ofs, long co_lnotab_ofs); +long _pypy_stm_count(void); + static inline void pypy_stm_become_inevitable(const char *msg) { diff --git a/rpython/translator/stm/test/test_ztranslated.py b/rpython/translator/stm/test/test_ztranslated.py --- a/rpython/translator/stm/test/test_ztranslated.py +++ b/rpython/translator/stm/test/test_ztranslated.py @@ -559,45 +559,3 @@ assert ('starting some_extremely_longish_and_boring_function_name\n' 'File bla/br/project/foobaz.py, line 81,' ' in some_extremely_longish_a\n') in data - -def test_pypy_marker_2(self): -import time -class PyCode(object): -def __init__(self, co_filename, co_name, - co_firstlineno, co_lnotab): -self.co_filename = co_filename -self.co_name = co_name -self.co_firstlineno = co_firstlineno -self.co_lnotab = co_lnotab -# -def check(foobar, retry_counter): -if retry_counter = 1: -rstm.push_marker(29, lltype.nullptr(rffi.CCHARP.TO)) -start = time.time() -while abs(time.time() - start) 0.1: -pass -rstm.abort_and_retry() -return 0 -# -S = lltype.GcStruct('S', ('got_exception', OBJECTPTR)) -PS = lltype.Ptr(S) -perform_transaction = rstm.make_perform_transaction(check, PS) -def entry_point(argv): -pycode1 = PyCode(/tmp/foobar.py, baz, 40, \x00\x01\x05\x01) -llop.stm_setup_expand_marker_for_pypy( -lltype.Void, pycode1, -co_filename, co_name, co_firstlineno, co_lnotab) - -# make sure perform_transaction breaks the transaction: -rstm.hint_commit_soon() -assert rstm.should_break_transaction() - -perform_transaction(lltype.malloc(S)) -return 0 -# -t, cbuilder = self.compile(entry_point, backendopt=True) -data, err = cbuilder.cmdexec('a b c d', err=True, - env={'PYPYLOG': 'stm-report:-'}) -assert '0# File ?, line 0, in ?\n' in err -assert '0#0.1' in err -assert 's: run aborted other\n' in err ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy stmgc-c7: Comment
Author: Armin Rigo ar...@tunes.org Branch: stmgc-c7 Changeset: r73993:b8579875b4ed Date: 2014-10-17 15:02 +0200 http://bitbucket.org/pypy/pypy/changeset/b8579875b4ed/ Log:Comment diff --git a/rpython/jit/backend/llsupport/test/zrpy_gc_test.py b/rpython/jit/backend/llsupport/test/zrpy_gc_test.py --- a/rpython/jit/backend/llsupport/test/zrpy_gc_test.py +++ b/rpython/jit/backend/llsupport/test/zrpy_gc_test.py @@ -356,6 +356,11 @@ def __del__(self): counter.cnt -= 1 def before(n, x): +# we set 'cnt' to the number of Z instances that will be created, +# then run f() this number of times, then rgc.collect() is +# called. Then we repeat the whole thing, so here we check +# _first_ that almost all Z instances have had their __del__ +# invoked in the previous run. debug_print('counter.cnt =', counter.cnt) check(counter.cnt 5) counter.cnt = n // x.foo ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ufuncapi: merge default into branch
Author: mattip matti.pi...@gmail.com Branch: ufuncapi Changeset: r73995:f5247fd471a9 Date: 2014-10-16 08:59 -0500 http://bitbucket.org/pypy/pypy/changeset/f5247fd471a9/ Log:merge default into branch diff too long, truncating to 2000 out of 6186 lines diff --git a/LICENSE b/LICENSE --- a/LICENSE +++ b/LICENSE @@ -3,8 +3,8 @@ Except when otherwise stated (look for LICENSE files in directories or information at the beginning of each file) all software and documentation in -the 'rpython', 'pypy', 'ctype_configure', 'dotviewer', 'demo', and 'lib_pypy' -directories is licensed as follows: +the 'rpython', 'pypy', 'ctype_configure', 'dotviewer', 'demo', 'lib_pypy', +'py', and '_pytest' directories is licensed as follows: The MIT License diff --git a/pypy/doc/release-pypy3-2.4.0.rst b/pypy/doc/release-pypy3-2.4.0.rst new file mode 100644 --- /dev/null +++ b/pypy/doc/release-pypy3-2.4.0.rst @@ -0,0 +1,126 @@ += +PyPy3 2.4 - Snow White += + +We're pleased to announce PyPy3 2.4, which contains significant performance +enhancements and bug fixes. + +You can download the PyPy3 2.4.0 release here: + +http://pypy.org/download.html + +We would like to thank our donors for the continued support of the PyPy +project, and for those who donate to our three sub-projects. +We've shown quite a bit of progress, but we're slowly running out of funds. +Please consider donating more, or even better convince your employer to donate, +so we can finish those projects! The three sub-projects are: + +* `Py3k`_ (supporting Python 3.x): This is a Python 3.2.5 compatible + version we call PyPy3 2.4, and we are working toward a Python 3.3 + compatible version + +* `STM`_ (software transactional memory): We have released a first working version, + and continue to try out new promising paths of achieving a fast multithreaded Python + +* `NumPy`_ which requires installation of our fork of upstream numpy, + available `on bitbucket`_ + +.. _`Py3k`: http://pypy.org/py3donate.html +.. _`STM`: http://pypy.org/tmdonate2.html +.. _`NumPy`: http://pypy.org/numpydonate.html +.. _`on bitbucket`: https://www.bitbucket.org/pypy/numpy + +What is PyPy? += + +PyPy is a very compliant Python interpreter, almost a drop-in replacement for +CPython 2.7 or 3.2.5. It's fast (`pypy 2.4 and cpython 2.7.x`_ performance +comparison) due to its integrated tracing JIT compiler. + +This release supports **x86** machines on most common operating systems +(Linux 32/64, Mac OS X 64, Windows, and OpenBSD), +as well as newer **ARM** hardware (ARMv6 or ARMv7, with VFPv3) running Linux. + +While we support 32 bit python on Windows, work on the native Windows 64 +bit python is still stalling, we would welcome a volunteer +to `handle that`_. + +.. _`pypy 2.4 and cpython 2.7.x`: http://speed.pypy.org +.. _`handle that`: http://doc.pypy.org/en/latest/windows.html#what-is-missing-for-a-full-64-bit-translation + +PyPy3 Highlights + + +Issues reported with our previous release were fixed after reports from users on +our new issue tracker at https://bitbucket.org/pypy/pypy/issues or on IRC at +#pypy. Here is a summary of the user-facing PyPy3 specific changes: + +* Better Windows compatibility, e.g. the nt module functions _getfinalpathname + _getfileinformation are now supported (the former is required for the + popular pathlib library for example) + +* Various fsencode PEP 383 related fixes to the posix module (readlink, uname, + ttyname and ctermid) and improved locale handling + +* Switched default binary name os POSIX distributions to 'pypy3' (which + symlinks to to 'pypy3.2') + +* Fixed a couple different crashes related to parsing Python 3 source code + +Further Highlights (shared w/ PyPy2) + + +Benchmarks improved after internal enhancements in string and +bytearray handling, and a major rewrite of the GIL handling. This means +that external calls are now a lot faster, especially the CFFI ones. It also +means better performance in a lot of corner cases with handling strings or +bytearrays. The main bugfix is handling of many socket objects in your +program which in the long run used to leak memory. + +We fixed a memory leak in IO in the sandbox_ code + +We welcomed more than 12 new contributors, and conducted two Google +Summer of Code projects, as well as other student projects not +directly related to Summer of Code. + +* Reduced internal copying of bytearray operations + +* Tweak the internal structure of StringBuilder to speed up large string + handling, which becomes advantageous on large programs at the cost of slightly + slower small *benchmark* type programs. + +* Boost performance of thread-local variables in both unjitted and jitted code, + this mostly affects errno handling on linux, which makes external calls + faster. + +* Move to a mixed polling and mutex GIL
[pypy-commit] pypy ufuncapi: do enough parsing, start iterator creation
Author: mattip matti.pi...@gmail.com Branch: ufuncapi Changeset: r73994:0acd1768b6b6 Date: 2014-10-16 08:27 -0500 http://bitbucket.org/pypy/pypy/changeset/0acd1768b6b6/ Log:do enough parsing, start iterator creation diff --git a/pypy/module/micronumpy/nditer.py b/pypy/module/micronumpy/nditer.py --- a/pypy/module/micronumpy/nditer.py +++ b/pypy/module/micronumpy/nditer.py @@ -347,6 +347,8 @@ return space.wrap(self) def getitem(self, it, st, op_flags): +# TODO: push op_flags and the array onto the iterator +# so we can avoid creating a new W_NDimArray each iteration if op_flags.rw == 'r': impl = concrete.ConcreteNonWritableArrayWithBase else: diff --git a/pypy/module/micronumpy/test/test_ufuncs.py b/pypy/module/micronumpy/test/test_ufuncs.py --- a/pypy/module/micronumpy/test/test_ufuncs.py +++ b/pypy/module/micronumpy/test/test_ufuncs.py @@ -160,6 +160,21 @@ af2 = ufunc(af) assert all(af2 == af * 2) +def test_frompyfunc_2d_sig(self): +def times_2(in_array, out_array): +in_flat = in_array.flat +out_flat = out_array.flat +for i in range(in_array.size): +out_flat[i] = in_flat[i] * 2 +from numpy import frompyfunc, dtype, arange +ufunc = frompyfunc([times_2], 1, 1, +signature='(m,m)-(m,m)', +dtypes=[dtype(int), dtype(int)], + ) +ai = arange(18, dtype=int).reshape(2,3,3) +ai2 = ufunc(ai) +assert all(ai1 == ai * 2) + def test_ufunc_kwargs(self): from numpy import ufunc, frompyfunc, arange, dtype def adder(a, b): diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py --- a/pypy/module/micronumpy/ufuncs.py +++ b/pypy/module/micronumpy/ufuncs.py @@ -580,8 +580,6 @@ if not self.core_enabled: # func is going to do all the work, it must accept W_NDimArray args arglist = space.newlist(list(inargs + outargs)) -if not isinstance(func, W_GenericUFuncCaller): -raise oefmt(space.w_RuntimeError, cannot do core_enabled frompyfunc) space.call_args(func, Arguments.frompacked(space, arglist)) if len(outargs) 2: return outargs[0] @@ -607,7 +605,7 @@ # into the array 'inner_dimensions[1:]'. Initialize them to # 1, for example in the case where the operand broadcasts # to a core dimension, it won't be visited. -inner_dimensions = [1] * (self.core_num_dim_ix + 1) +inner_dimensions = [1] * (self.core_num_dim_ix + 2) idim = 0 for i in range(self.nin): curarg = inargs[i] @@ -656,7 +654,7 @@ (size %d is different from %d), self.name, i, idim, self.signature, op_dim_size, inner_dimensions[1 + core_dim_index]) idim += 1 -iter_shape = [-1] * (broadcast_ndim + len(outargs)) +iter_shape = [-1] * (broadcast_ndim + (len(outargs) * num_dims)) j = broadcast_ndim core_dim_ixs_size = 0 firstdim = broadcast_ndim @@ -681,13 +679,13 @@ for idim in range(broadcast_ndim): if idim = broadcast_ndim -n: op_axes_arrays[idim][iout] = idim - (broadcast_ndim -n) -dim_offset = self.core_offsets[iout] -num_dims = self.core_num_dims[iout] -for idim in range(num_dims): -cdi = self.core_dim_ixs[dim_offset + idim] -iter_shape[j] = inner_dimensions[1 + cdi] -op_axes_arrays[j][iout] = n + idim -j += 1 +dim_offset = self.core_offsets[iout] +num_dims = self.core_num_dims[iout] +for idim in range(num_dims): +cdi = self.core_dim_ixs[dim_offset + idim] +iter_shape[j] = inner_dimensions[1 + cdi] +op_axes_arrays[j][iout] = n + idim +j += 1 core_dim_ixs_size += self.core_num_dims[iout]; # TODO once we support obejct dtypes, # FAIL with NotImplemented if the other object has @@ -696,6 +694,8 @@ # TODO parse and handle subok +# mimic NpyIter_AdvancedNew with a nditer + if isinstance(func, W_GenericUFuncCaller): pass # xxx rdo what needs to be done to inner-loop indexing ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ufuncapi: fix translation
Author: mattip matti.pi...@gmail.com Branch: ufuncapi Changeset: r73996:a1ea0f790591 Date: 2014-10-16 11:34 -0500 http://bitbucket.org/pypy/pypy/changeset/a1ea0f790591/ Log:fix translation diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py --- a/pypy/module/micronumpy/ufuncs.py +++ b/pypy/module/micronumpy/ufuncs.py @@ -654,7 +654,7 @@ (size %d is different from %d), self.name, i, idim, self.signature, op_dim_size, inner_dimensions[1 + core_dim_index]) idim += 1 -iter_shape = [-1] * (broadcast_ndim + (len(outargs) * num_dims)) +iter_shape = [-1] * (broadcast_ndim + (len(outargs) * iter_ndim)) j = broadcast_ndim core_dim_ixs_size = 0 firstdim = broadcast_ndim @@ -1218,14 +1218,12 @@ def __init__(self, func, data): self.func = func self.data = data -self.dims = None -self.steps = None +self.dims = alloc_raw_storage(0, track_allocation=False) +self.steps = alloc_raw_storage(0, track_allocation=False) def __del__(self): -if self.dims is not None: -free_raw_storage(self.dims, track_allocation=False) -if self.steps is not None: -free_raw_storage(self.steps, track_allocation=False) +free_raw_storage(self.dims, track_allocation=False) +free_raw_storage(self.steps, track_allocation=False) def descr_call(self, space, __args__): args_w, kwds_w = __args__.unpack() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ufuncapi: progress toward using nditer, discover missing functionality
Author: mattip matti.pi...@gmail.com Branch: ufuncapi Changeset: r73997:8b581c9fd1d1 Date: 2014-10-17 08:57 -0500 http://bitbucket.org/pypy/pypy/changeset/8b581c9fd1d1/ Log:progress toward using nditer, discover missing functionality diff --git a/pypy/module/cpyext/ndarrayobject.py b/pypy/module/cpyext/ndarrayobject.py --- a/pypy/module/cpyext/ndarrayobject.py +++ b/pypy/module/cpyext/ndarrayobject.py @@ -278,5 +278,5 @@ w_name = rffi.charp2str(name) w_identity = space.wrap(identity) ufunc_generic = ufuncs.frompyfunc(space, w_funcs, nin, nout, w_dtypes, - w_signature, w_identity, w_name, w_doc) + w_signature, w_identity, w_name, w_doc, stack_inputs=True) return ufunc_generic diff --git a/pypy/module/micronumpy/test/test_ufuncs.py b/pypy/module/micronumpy/test/test_ufuncs.py --- a/pypy/module/micronumpy/test/test_ufuncs.py +++ b/pypy/module/micronumpy/test/test_ufuncs.py @@ -170,8 +170,11 @@ ufunc = frompyfunc([times_2], 1, 1, signature='(m,m)-(m,m)', dtypes=[dtype(int), dtype(int)], +stack_inputs=True, ) ai = arange(18, dtype=int).reshape(2,3,3) +exc = raises(ValueError, ufunc, ai[:,:,0]) +assert mismatch in its core dimension 1 in exc.value.message ai2 = ufunc(ai) assert all(ai1 == ai * 2) diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py --- a/pypy/module/micronumpy/ufuncs.py +++ b/pypy/module/micronumpy/ufuncs.py @@ -9,6 +9,7 @@ from pypy.module.micronumpy import boxes, descriptor, loop, constants as NPY from pypy.module.micronumpy.base import convert_to_array, W_NDimArray from pypy.module.micronumpy.ctors import numpify +from pypy.module.micronumpy.nditer import W_NDIter from pypy.module.micronumpy.strides import shape_agreement from pypy.module.micronumpy.support import _parse_signature from rpython.rlib.rawstorage import (raw_storage_setitem, free_raw_storage, @@ -516,7 +517,7 @@ ''' _immutable_fields_ = [funcs, dtypes, data, match_dtypes] -def __init__(self, space, funcs, name, identity, nin, nout, dtypes, signature, match_dtypes=False): +def __init__(self, space, funcs, name, identity, nin, nout, dtypes, signature, match_dtypes=False, stack_inputs=False): # XXX make sure funcs, signature, dtypes, nin, nout are consistent # These don't matter, we use the signature and dtypes for determining @@ -540,6 +541,7 @@ self.signature = signature #These will be filled in by _parse_signature self.core_enabled = True# False for scalar ufunc, True for generalized ufunc +self.stack_inputs = stack_inputs self.core_num_dim_ix = 0 # number of distinct dimention names in signature self.core_num_dims = [0] * self.nargs # number of core dimensions of each nargs self.core_offsets = [0] * self.nargs @@ -620,13 +622,14 @@ while(idim num_dims): core_dim_index = self.core_dim_ixs[dim_offset + idim] op_dim_size = curarg.get_shape()[core_start_dim + idim] -if inner_dimensions[i + 1] == 1: -inner_dimensions[i + 1] = op_dim_size +if inner_dimensions[core_dim_index + 1] == 1: +inner_dimensions[core_dim_index + 1] = op_dim_size elif op_dim_size != 1 and inner_dimensions[1 + core_dim_index] != op_dim_size: -oefmt(space.w_ValueError, %s: Operand %d has a mismatch in - its core dimension %d, with gufunc signature %s -(size %d is different from %d), self.name, i, idim, -self.signature, op_dim_size, inner_dimensions[1 + core_dim_index]) +raise oefmt(space.w_ValueError, %s: Operand %d has a +mismatch in its core dimension %d, with gufunc +signature %s (size %d is different from %d), + self.name, i, idim, self.signature, op_dim_size, + inner_dimensions[1 + core_dim_index]) idim += 1 for i in range(len(outargs)): curarg = outargs[i] @@ -635,10 +638,10 @@ num_dims = self.core_num_dims[i] core_start_dim = curarg.ndims() - num_dims if core_start_dim 0: -oefmt(space.w_ValueError, %s: Output operand %d does not -have enough dimensions (has %d, gufunc with signature -%s requires %d), self.name, i, curarg.ndims(), -self.signature, num_dims) +raise oefmt(space.w_ValueError, %s: Output operand %d does +not have enough dimensions (has %d, gufunc with +signature %s requires %d), self.name, i, +
[pypy-commit] pypy stmgc-c7: Finalizers, step 1
Author: Armin Rigo ar...@tunes.org Branch: stmgc-c7 Changeset: r73998:3159fb66123b Date: 2014-10-17 16:16 +0200 http://bitbucket.org/pypy/pypy/changeset/3159fb66123b/ Log:Finalizers, step 1 diff --git a/rpython/memory/gc/stmgc.py b/rpython/memory/gc/stmgc.py --- a/rpython/memory/gc/stmgc.py +++ b/rpython/memory/gc/stmgc.py @@ -73,13 +73,13 @@ needs_finalizer=False, is_finalizer_light=False, contains_weakptr=False): -# XXX finalizers are ignored for now -#ll_assert(not needs_finalizer, 'XXX needs_finalizer') -#ll_assert(not is_finalizer_light, 'XXX is_finalizer_light') if size 16: size = 16 # minimum size (test usually constant-folded) if contains_weakptr:# check constant-folded return llop.stm_allocate_weakref(llmemory.GCREF, size, typeid16) +if needs_finalizer: +#is_finalizer_light XXX ignored now +return llop.stm_allocate_finalizer(llmemory.GCREF, size, typeid16) return llop.stm_allocate_tid(llmemory.GCREF, size, typeid16) def malloc_varsize_clear(self, typeid16, length, size, itemsize, diff --git a/rpython/memory/gctransform/framework.py b/rpython/memory/gctransform/framework.py --- a/rpython/memory/gctransform/framework.py +++ b/rpython/memory/gctransform/framework.py @@ -1257,8 +1257,6 @@ super(TransformerLayoutBuilder, self).__init__(GCClass, lltype2vtable) def has_finalizer(self, TYPE): -if self.translator.config.translation.stm: -return False # XXX no finalizer support for now rtti = get_rtti(TYPE) return rtti is not None and getattr(rtti._obj, 'destructor_funcptr', None) @@ -1275,22 +1273,24 @@ def make_finalizer_funcptr_for_type(self, TYPE): if not self.has_finalizer(TYPE): return None, False +stm = self.translator.config.translation.stm rtti = get_rtti(TYPE) destrptr = rtti._obj.destructor_funcptr DESTR_ARG = lltype.typeOf(destrptr).TO.ARGS[0] typename = TYPE.__name__ def ll_finalizer(addr): -v = llmemory.cast_adr_to_ptr(addr, DESTR_ARG) +if stm: +from rpython.rtyper.lltypesystem.lloperation import llop +v = llop.stm_really_force_cast_ptr(DESTR_ARG, addr) +else: +v = llmemory.cast_adr_to_ptr(addr, DESTR_ARG) ll_call_destructor(destrptr, v, typename) fptr = self.transformer.annotate_finalizer(ll_finalizer, [llmemory.Address], lltype.Void) try: g = destrptr._obj.graph -if self.translator.config.translation.stm: -light = False# XXX no working finalizers with STM so far -else: -analyzer = FinalizerAnalyzer(self.translator) -light = not analyzer.analyze_light_finalizer(g) +analyzer = FinalizerAnalyzer(self.translator) +light = not analyzer.analyze_light_finalizer(g) except lltype.DelayedPointer: light = False# XXX bah, too bad return fptr, light diff --git a/rpython/memory/gctransform/stmframework.py b/rpython/memory/gctransform/stmframework.py --- a/rpython/memory/gctransform/stmframework.py +++ b/rpython/memory/gctransform/stmframework.py @@ -1,7 +1,8 @@ from rpython.annotator import model as annmodel -from rpython.rtyper.lltypesystem import lltype, llmemory, rffi +from rpython.rtyper.lltypesystem import lltype, llmemory, rffi, llgroup from rpython.rtyper.lltypesystem.lloperation import llop -from rpython.memory.gctransform.framework import ( TYPE_ID, +from rpython.memory.gctransform.support import get_rtti +from rpython.memory.gctransform.framework import (TYPE_ID, BaseFrameworkGCTransformer, BaseRootWalker, sizeofaddr) from rpython.memory.gctypelayout import WEAKREF, WEAKREFPTR from rpython.rtyper import rmodel, llannotation @@ -66,6 +67,15 @@ [llannotation.SomeAddress(), llannotation.SomePtr(rffi.CArrayPtr(lltype.Unsigned))], annmodel.s_None)) +# +def pypy_stmcb_fetch_finalizer(typeid): +typeid = lltype.cast_primitive(llgroup.HALFWORD, typeid) +return llmemory.cast_ptr_to_adr(gc.getfinalizer(typeid)) +pypy_stmcb_fetch_finalizer.c_name = ( +pypy_stmcb_fetch_finalizer) +self.autoregister_ptrs.append( +getfn(pypy_stmcb_fetch_finalizer, + [annmodel.s_Int], llannotation.SomeAddress())) def build_root_walker(self): return StmRootWalker(self) diff --git a/rpython/rtyper/lltypesystem/lloperation.py b/rpython/rtyper/lltypesystem/lloperation.py --- a/rpython/rtyper/lltypesystem/lloperation.py +++ b/rpython/rtyper/lltypesystem/lloperation.py @@
[pypy-commit] extradoc extradoc: Add the pdf
Author: Armin Rigo ar...@tunes.org Branch: extradoc Changeset: r5440:4e3f810db002 Date: 2014-10-17 16:19 +0200 http://bitbucket.org/pypy/extradoc/changeset/4e3f810db002/ Log:Add the pdf diff --git a/talk/pyconpl-2014/talk.pdf b/talk/pyconpl-2014/talk.pdf new file mode 100644 index ..96cfd649da81c326dec0dbe7d92087b9864229d7 GIT binary patch [cut] ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy stmgc-c7: Add a light finalizer test (not passing yet)
Author: Armin Rigo ar...@tunes.org Branch: stmgc-c7 Changeset: r73999:abb8d87229ef Date: 2014-10-17 16:46 +0200 http://bitbucket.org/pypy/pypy/changeset/abb8d87229ef/ Log:Add a light finalizer test (not passing yet) diff --git a/rpython/translator/backendopt/finalizer.py b/rpython/translator/backendopt/finalizer.py --- a/rpython/translator/backendopt/finalizer.py +++ b/rpython/translator/backendopt/finalizer.py @@ -18,7 +18,7 @@ ok_operations = ['ptr_nonzero', 'ptr_eq', 'ptr_ne', 'free', 'same_as', 'direct_ptradd', 'force_cast', 'track_alloc_stop', - 'raw_free'] + 'raw_free', 'debug_print'] def analyze_light_finalizer(self, graph): result = self.analyze_direct_call(graph) diff --git a/rpython/translator/stm/test/test_ztranslated.py b/rpython/translator/stm/test/test_ztranslated.py --- a/rpython/translator/stm/test/test_ztranslated.py +++ b/rpython/translator/stm/test/test_ztranslated.py @@ -523,11 +523,29 @@ X() def main(argv): +x1 = X() g() rgc.collect() print 'destructors called:', g_counter.num +objectmodel.keepalive_until_here(x1) return 0 t, cbuilder = self.compile(main) data = cbuilder.cmdexec('') assert 'destructors called: 1\n' in data + +def test_light_finalizer(self): +class X: +@rgc.must_be_light_finalizer +def __del__(self): +debug_print(del) +def g(): +X() +def main(argv): +g() +rgc.collect(0) +return 0 + +t, cbuilder = self.compile(main) +data, err = cbuilder.cmdexec('', err=True) +assert 'del' in err ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy online-transforms: add 2 failing tests
Author: Ronan Lamy ronan.l...@gmail.com Branch: online-transforms Changeset: r74000:3dba6d6cf053 Date: 2014-10-16 21:33 +0100 http://bitbucket.org/pypy/pypy/changeset/3dba6d6cf053/ Log:add 2 failing tests diff --git a/rpython/annotator/test/test_annrpython.py b/rpython/annotator/test/test_annrpython.py --- a/rpython/annotator/test/test_annrpython.py +++ b/rpython/annotator/test/test_annrpython.py @@ -416,7 +416,27 @@ s_constmeth = iv(constmeth) assert isinstance(s_constmeth, annmodel.SomeBuiltin) s_meth = s_example.getattr(iv(methname)) -assert isinstance(s_constmeth, annmodel.SomeBuiltin) +assert isinstance(s_meth, annmodel.SomeBuiltin) + +def test_unbound_methods(self): +a = self.RPythonAnnotator() +iv = a.bookkeeper.immutablevalue +# this checks that some unbound built-in methods are really supported by +# the annotator (it doesn't check that they operate property, though) +for example, methname, s_example in [ +('', 'join',annmodel.SomeString()), +([], 'append', somelist(annmodel.s_Int)), +([], 'extend', somelist(annmodel.s_Int)), +([], 'reverse', somelist(annmodel.s_Int)), +([], 'insert', somelist(annmodel.s_Int)), +([], 'pop', somelist(annmodel.s_Int)), +]: +constmeth = getattr(type(example), methname) +s_constmeth = iv(constmeth) +assert isinstance(s_constmeth, annmodel.SomeObject) +assert s_constmeth.getKind() == 0 +s_meth = iv(example).getattr(iv(methname)) +assert isinstance(s_meth, annmodel.SomeObject) def test_str_join(self): a = self.RPythonAnnotator() @@ -430,6 +450,18 @@ assert s.knowntype == str assert s.no_nul +def test_str_join_unbound(self): +a = self.RPythonAnnotator() +def g(n): +if n: +return [foo, bar] +def f(n): +g(0) +return str.join('', g(n)) +s = a.build_types(f, [int]) +assert s.knowntype == str +assert s.no_nul + def test_str_split(self): a = self.RPythonAnnotator() def g(n): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy online-transforms: progress
Author: Ronan Lamy ronan.l...@gmail.com Branch: online-transforms Changeset: r74001:3b7f29937dd9 Date: 2014-10-17 16:18 +0100 http://bitbucket.org/pypy/pypy/changeset/3b7f29937dd9/ Log:progress diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py --- a/rpython/annotator/bookkeeper.py +++ b/rpython/annotator/bookkeeper.py @@ -317,6 +317,9 @@ s_self = self.immutablevalue(x.__self__) result = s_self.find_method(x.__name__) assert result is not None +elif hasattr(x, '__objclass__'): +s_type = self.valueoftype(x.__objclass__) +result = s_type.find_unboundmethod(x.__name__) else: result = None if result is None: diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py --- a/rpython/annotator/model.py +++ b/rpython/annotator/model.py @@ -558,6 +558,18 @@ return False +class SomeUnboundMethod(SomeBuiltin): +Stands for an unbound built-in method. +def __init__(self, analyser, methodname=None): +if isinstance(analyser, MethodType): +analyser = descriptor.InstanceMethod( +analyser.im_func, +analyser.im_self, +analyser.im_class) +self.analyser = analyser +self.methodname = methodname + + class SomeBuiltinMethod(SomeBuiltin): Stands for a built-in method which has got special meaning diff --git a/rpython/annotator/test/test_annrpython.py b/rpython/annotator/test/test_annrpython.py --- a/rpython/annotator/test/test_annrpython.py +++ b/rpython/annotator/test/test_annrpython.py @@ -434,7 +434,6 @@ constmeth = getattr(type(example), methname) s_constmeth = iv(constmeth) assert isinstance(s_constmeth, annmodel.SomeObject) -assert s_constmeth.getKind() == 0 s_meth = iv(example).getattr(iv(methname)) assert isinstance(s_meth, annmodel.SomeObject) diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py --- a/rpython/annotator/unaryop.py +++ b/rpython/annotator/unaryop.py @@ -8,7 +8,7 @@ from rpython.flowspace.model import const from rpython.annotator.model import (SomeObject, SomeInteger, SomeBool, SomeString, SomeChar, SomeList, SomeDict, SomeTuple, SomeImpossibleValue, -SomeUnicodeCodePoint, SomeInstance, SomeBuiltin, SomeBuiltinMethod, +SomeUnicodeCodePoint, SomeInstance, SomeBuiltin, SomeUnboundMethod, SomeBuiltinMethod, SomeFloat, SomeIterator, SomePBC, SomeNone, SomeType, s_ImpossibleValue, s_Bool, s_None, unionof, add_knowntypedata, HarmlesslyBlocked, SomeWeakRef, SomeUnicodeString, SomeByteArray) @@ -119,6 +119,15 @@ else: return SomeBuiltinMethod(analyser, self, name) +def find_unboundmethod(self, name): +Look for a special-case implementation for the named method. +try: +analyser = getattr(self.__class__, 'method_' + name) +except AttributeError: +return None +else: +return SomeUnboundMethod(analyser, name) + def getattr(self, s_attr): # get a SomeBuiltin if the SomeObject has # a corresponding method to handle it ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy online-transforms: pass the tests on CPython
Author: Ronan Lamy ronan.l...@gmail.com Branch: online-transforms Changeset: r74002:230d0daa9f89 Date: 2014-10-17 17:22 +0100 http://bitbucket.org/pypy/pypy/changeset/230d0daa9f89/ Log:pass the tests on CPython diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py --- a/rpython/annotator/bookkeeper.py +++ b/rpython/annotator/bookkeeper.py @@ -32,6 +32,9 @@ return ann_func return wrapped +CONTAINERS_S = [SomeList, SomeDict, SomeOrderedDict, SomeTuple] +_cls2Some = {cls.knowntype: cls for cls in CONTAINERS_S} + class Bookkeeper(object): The log of choices that have been made while analysing the operations. It ensures that the same 'choice objects' will be returned if we ask @@ -318,8 +321,8 @@ result = s_self.find_method(x.__name__) assert result is not None elif hasattr(x, '__objclass__'): -s_type = self.valueoftype(x.__objclass__) -result = s_type.find_unboundmethod(x.__name__) +cls_s = self.annotationclass(x.__objclass__) +result = cls_s.find_unboundmethod(x.__name__) else: result = None if result is None: @@ -440,6 +443,12 @@ def valueoftype(self, t): return annotationoftype(t, self) +def annotationclass(self, cls): +try: +return _cls2Some[cls] +except KeyError: +return type(self.valueoftype(cls)) + def get_classpbc_attr_families(self, attrname): Return the UnionFind for the ClassAttrFamilies corresponding to attributes of the given name. diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py --- a/rpython/annotator/unaryop.py +++ b/rpython/annotator/unaryop.py @@ -119,10 +119,11 @@ else: return SomeBuiltinMethod(analyser, self, name) -def find_unboundmethod(self, name): +@classmethod +def find_unboundmethod(cls, name): Look for a special-case implementation for the named method. try: -analyser = getattr(self.__class__, 'method_' + name) +analyser = getattr(cls, 'method_' + name) except AttributeError: return None else: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pypy3-release-2.4.x: adjust per the new pypy3 exe name
Author: Philip Jenvey pjen...@underboss.org Branch: pypy3-release-2.4.x Changeset: r74005:5552600c8b97 Date: 2014-10-16 16:50 -0700 http://bitbucket.org/pypy/pypy/changeset/5552600c8b97/ Log:adjust per the new pypy3 exe name (grafted from 5ac508b99502933d3f86d5fb3be2743fef715486) diff --git a/pypy/tool/release/test/test_package.py b/pypy/tool/release/test/test_package.py --- a/pypy/tool/release/test/test_package.py +++ b/pypy/tool/release/test/test_package.py @@ -1,4 +1,4 @@ - +import os import py from pypy.conftest import pypydir from pypy.tool.release import package, package @@ -13,12 +13,12 @@ exe_name_in_archive = 'pypy-c.exe' else: basename = 'pypy-c' -rename_pypy_c = 'pypy' -exe_name_in_archive = 'bin/pypy' +rename_pypy_c = package.POSIX_EXE +exe_name_in_archive = os.path.join('bin', package.POSIX_EXE) pypy_c = py.path.local(pypydir).join('goal', basename) if not pypy_c.check(): if sys.platform == 'win32': -import os, shutil +import shutil for d in os.environ['PATH'].split(';'): if os.path.exists(os.path.join(d, 'cmd.exe')): shutil.copy(os.path.join(d, 'cmd.exe'), str(pypy_c)) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pypy3-release-2.4.x: fix _SSLContext invalid protocol errors not ensuring a self.ctx, leading to a
Author: Philip Jenvey pjen...@underboss.org Branch: pypy3-release-2.4.x Changeset: r74006:b2091e973da6 Date: 2014-10-17 13:09 -0700 http://bitbucket.org/pypy/pypy/changeset/b2091e973da6/ Log:fix _SSLContext invalid protocol errors not ensuring a self.ctx, leading to a potential crash in its destructor (grafted from c1ddf2d919a18fa4ebec03ce84e1a0457f4396ad) diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py --- a/pypy/module/_ssl/interp_ssl.py +++ b/pypy/module/_ssl/interp_ssl.py @@ -90,6 +90,8 @@ class SSLContext(W_Root): +ctx = lltype.nullptr(SSL_CTX.TO) + def __init__(self, space, protocol): if protocol == PY_SSL_VERSION_TLS1: method = libssl_TLSv1_method() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: fix _SSLContext invalid protocol errors not ensuring a self.ctx, leading to a
Author: Philip Jenvey pjen...@underboss.org Branch: py3k Changeset: r74003:c1ddf2d919a1 Date: 2014-10-17 13:09 -0700 http://bitbucket.org/pypy/pypy/changeset/c1ddf2d919a1/ Log:fix _SSLContext invalid protocol errors not ensuring a self.ctx, leading to a potential crash in its destructor diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py --- a/pypy/module/_ssl/interp_ssl.py +++ b/pypy/module/_ssl/interp_ssl.py @@ -90,6 +90,8 @@ class SSLContext(W_Root): +ctx = lltype.nullptr(SSL_CTX.TO) + def __init__(self, space, protocol): if protocol == PY_SSL_VERSION_TLS1: method = libssl_TLSv1_method() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pypy3-release-2.4.x: this workaround is no longer needed
Author: Philip Jenvey pjen...@underboss.org Branch: pypy3-release-2.4.x Changeset: r74004:bfc266fad6e7 Date: 2014-10-14 12:51 -0700 http://bitbucket.org/pypy/pypy/changeset/bfc266fad6e7/ Log:this workaround is no longer needed (grafted from c377769fa159b855076be8cb7f5483acbc5f4e16) diff --git a/rpython/rtyper/lltypesystem/ll2ctypes.py b/rpython/rtyper/lltypesystem/ll2ctypes.py --- a/rpython/rtyper/lltypesystem/ll2ctypes.py +++ b/rpython/rtyper/lltypesystem/ll2ctypes.py @@ -361,9 +361,7 @@ functype = ctypes.CFUNCTYPE if sys.platform == 'win32': from rpython.rlib.clibffi import FFI_STDCALL, FFI_DEFAULT_ABI -# XXX: -#if getattr(T.TO, 'ABI', FFI_DEFAULT_ABI) == FFI_STDCALL: -if getattr(T.TO, 'ABI', FFI_DEFAULT_ABI) == 'FFI_STDCALL': +if getattr(T.TO, 'ABI', FFI_DEFAULT_ABI) == FFI_STDCALL: # for win32 system call functype = ctypes.WINFUNCTYPE argtypes = [get_ctypes_type(ARG) for ARG in T.TO.ARGS ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: merge default
Author: Philip Jenvey pjen...@underboss.org Branch: py3k Changeset: r74007:dfd4a9093328 Date: 2014-10-17 15:45 -0700 http://bitbucket.org/pypy/pypy/changeset/dfd4a9093328/ Log:merge default diff too long, truncating to 2000 out of 3968 lines diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -19,3 +19,6 @@ .. branch: var-in-Some Store annotations on the Variable objects, rather than in a big dict. Introduce a new framework for double-dispatched annotation implementations. + +.. branch: ClassRepr +Refactor ClassRepr and make normalizecalls independent of the rtyper. diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py --- a/pypy/goal/targetpypystandalone.py +++ b/pypy/goal/targetpypystandalone.py @@ -258,6 +258,7 @@ enable_translationmodules(config) config.translation.suggest(check_str_without_nul=True) +config.translation.suggest(shared=True) if config.translation.thread: config.objspace.usemodules.thread = True diff --git a/pypy/module/pypyjit/interp_resop.py b/pypy/module/pypyjit/interp_resop.py --- a/pypy/module/pypyjit/interp_resop.py +++ b/pypy/module/pypyjit/interp_resop.py @@ -7,7 +7,7 @@ from pypy.interpreter.error import OperationError from rpython.rtyper.lltypesystem import lltype from rpython.rtyper.annlowlevel import cast_base_ptr_to_instance, hlstr -from rpython.rtyper.lltypesystem.rclass import OBJECT +from rpython.rtyper.rclass import OBJECT from rpython.jit.metainterp.resoperation import rop from rpython.rlib.nonconst import NonConstant from rpython.rlib import jit_hooks diff --git a/pypy/module/pypyjit/test/test_jit_hook.py b/pypy/module/pypyjit/test/test_jit_hook.py --- a/pypy/module/pypyjit/test/test_jit_hook.py +++ b/pypy/module/pypyjit/test/test_jit_hook.py @@ -9,7 +9,7 @@ from rpython.rtyper.annlowlevel import (cast_instance_to_base_ptr, cast_base_ptr_to_instance) from rpython.rtyper.lltypesystem import lltype, llmemory -from rpython.rtyper.lltypesystem.rclass import OBJECT +from rpython.rtyper.rclass import OBJECT from pypy.module.pypyjit.interp_jit import pypyjitdriver from pypy.module.pypyjit.policy import pypy_hooks from rpython.jit.tool.oparser import parse diff --git a/pypy/objspace/std/bytearrayobject.py b/pypy/objspace/std/bytearrayobject.py --- a/pypy/objspace/std/bytearrayobject.py +++ b/pypy/objspace/std/bytearrayobject.py @@ -4,6 +4,7 @@ import_from_mixin, newlist_hint, resizelist_hint, specialize) from rpython.rlib.buffer import Buffer from rpython.rlib.rstring import StringBuilder, ByteListBuilder +from rpython.rlib.debug import check_list_of_chars from pypy.interpreter.baseobjspace import W_Root from pypy.interpreter.error import OperationError, oefmt @@ -23,6 +24,7 @@ import_from_mixin(StringMethods) def __init__(self, data): +check_list_of_chars(data) self.data = data def __repr__(self): diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py --- a/rpython/annotator/annrpython.py +++ b/rpython/annotator/annrpython.py @@ -249,10 +249,6 @@ assert s_value.contains(s_old) arg.annotation = s_value -def transfer_binding(self, v_target, v_source): -assert v_source.annotation is not None -v_target.annotation = v_source.annotation - def warning(self, msg, pos=None): if pos is None: try: @@ -579,7 +575,7 @@ for arg in op.args: if isinstance(self.annotation(arg), annmodel.SomeImpossibleValue): raise BlockedInference(self, op, -1) -resultcell = op.consider(self, *op.args) +resultcell = op.consider(self) if resultcell is None: resultcell = annmodel.s_ImpossibleValue elif resultcell == annmodel.s_ImpossibleValue: diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py --- a/rpython/annotator/bookkeeper.py +++ b/rpython/annotator/bookkeeper.py @@ -559,10 +559,6 @@ assert self.annotator.binding(op.args[pos]) == s_type return op -def ondegenerated(self, what, s_value, where=None, called_from_graph=None): -self.annotator.ondegenerated(what, s_value, where=where, - called_from_graph=called_from_graph) - def whereami(self): return self.annotator.whereami(self.position_key) diff --git a/rpython/annotator/classdef.py b/rpython/annotator/classdef.py --- a/rpython/annotator/classdef.py +++ b/rpython/annotator/classdef.py @@ -154,6 +154,8 @@ self.subdefs = [] self.attr_sources = {} # {name: list-of-sources} self.read_locations_of__class__ = {} +self.repr = None +self.extra_access_sets = {} if classdesc.basedesc: self.basedef =
[pypy-commit] pypy py3.3: bump this for now, blah
Author: Philip Jenvey pjen...@underboss.org Branch: py3.3 Changeset: r74009:dc0742bdf5d6 Date: 2014-10-17 15:46 -0700 http://bitbucket.org/pypy/pypy/changeset/dc0742bdf5d6/ Log:bump this for now, blah diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py --- a/pypy/tool/release/package.py +++ b/pypy/tool/release/package.py @@ -27,7 +27,7 @@ STDLIB_VER = 3 # XXX: don't hardcode the version -POSIX_EXE = 'pypy3.2' +POSIX_EXE = 'pypy3.3' def ignore_patterns(*patterns): Function that can be used as copytree() ignore parameter. ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: merge py3k
Author: Philip Jenvey pjen...@underboss.org Branch: py3.3 Changeset: r74008:02cf2f6a3032 Date: 2014-10-17 15:46 -0700 http://bitbucket.org/pypy/pypy/changeset/02cf2f6a3032/ Log:merge py3k diff too long, truncating to 2000 out of 18832 lines diff --git a/LICENSE b/LICENSE --- a/LICENSE +++ b/LICENSE @@ -3,8 +3,8 @@ Except when otherwise stated (look for LICENSE files in directories or information at the beginning of each file) all software and documentation in -the 'rpython', 'pypy', 'ctype_configure', 'dotviewer', 'demo', and 'lib_pypy' -directories is licensed as follows: +the 'rpython', 'pypy', 'ctype_configure', 'dotviewer', 'demo', 'lib_pypy', +'py', and '_pytest' directories is licensed as follows: The MIT License @@ -367,3 +367,43 @@ Detailed license information is contained in the NOTICE file in the directory. + +Licenses and Acknowledgements for Incorporated Software +=== + +This section is an incomplete, but growing list of licenses and +acknowledgements for third-party software incorporated in the PyPy +distribution. + +License for 'Tcl/Tk' + + +This copy of PyPy contains library code that may, when used, result in +the Tcl/Tk library to be loaded. PyPy also includes code that may be +regarded as being a copy of some parts of the Tcl/Tk header files. +You may see a copy of the License for Tcl/Tk in the file +`lib_pypy/_tkinter/license.terms` included here. + +License for 'bzip2' +--- + +This copy of PyPy may be linked (dynamically or statically) with the +bzip2 library. You may see a copy of the License for bzip2/libbzip2 at + +http://www.bzip.org/1.0.5/bzip2-manual-1.0.5.html + +License for 'openssl' +- + +This copy of PyPy may be linked (dynamically or statically) with the +openssl library. You may see a copy of the License for OpenSSL at + +https://www.openssl.org/source/license.html + +License for '_gdbm' +-- + +The _gdbm module includes code from gdbm.h, which is distributed under +the terms of the GPL license version 2 or any later version. Thus the +_gdbm module, provided in the file lib_pypy/_gdbm.py, is redistributed +under the terms of the GPL license as well. diff --git a/lib-python/2.7/test/test_select.py b/lib-python/2.7/test/test_select.py --- a/lib-python/2.7/test/test_select.py +++ b/lib-python/2.7/test/test_select.py @@ -57,7 +57,17 @@ del a[-1] return sys.__stdout__.fileno() a[:] = [F()] * 10 -self.assertEqual(select.select([], a, []), ([], a[:5], [])) +result = select.select([], a, []) +# CPython: 'a' ends up with 5 items, because each fileno() +# removes an item and at the middle the iteration stops. +# PyPy: 'a' ends up empty, because the iteration is done on +# a copy of the original list: fileno() is called 10 times. +if test_support.check_impl_detail(cpython=True): +self.assertEqual(len(result[1]), 5) +self.assertEqual(len(a), 5) +if test_support.check_impl_detail(pypy=True): +self.assertEqual(len(result[1]), 10) +self.assertEqual(len(a), 0) def test_main(): test_support.run_unittest(SelectTestCase) diff --git a/lib-python/3/test/test_select.py b/lib-python/3/test/test_select.py --- a/lib-python/3/test/test_select.py +++ b/lib-python/3/test/test_select.py @@ -73,7 +73,17 @@ del a[-1] return sys.__stdout__.fileno() a[:] = [F()] * 10 -self.assertEqual(select.select([], a, []), ([], a[:5], [])) +result = select.select([], a, []) +# CPython: 'a' ends up with 5 items, because each fileno() +# removes an item and at the middle the iteration stops. +# PyPy: 'a' ends up empty, because the iteration is done on +# a copy of the original list: fileno() is called 10 times. +if support.check_impl_detail(cpython=True): +self.assertEqual(len(result[1]), 5) +self.assertEqual(len(a), 5) +if support.check_impl_detail(pypy=True): +self.assertEqual(len(result[1]), 10) +self.assertEqual(len(a), 0) def test_main(): support.run_unittest(SelectTestCase) diff --git a/lib_pypy/_curses.py b/lib_pypy/_curses.py --- a/lib_pypy/_curses.py +++ b/lib_pypy/_curses.py @@ -286,6 +286,13 @@ lib = ffi.verify( +#ifdef __APPLE__ +/* the following define is necessary for OS X 10.6+; without it, the + Apple-supplied ncurses.h sets NCURSES_OPAQUE to 1, and then Python + can't get at the WINDOW flags field. */ +#define NCURSES_OPAQUE 0 +#endif + #include ncurses.h #include panel.h #include term.h diff --git a/pypy/doc/how-to-release.rst b/pypy/doc/how-to-release.rst --- a/pypy/doc/how-to-release.rst +++ b/pypy/doc/how-to-release.rst @@ -38,14 +38,16 @@ no JIT: windows, linux, os/x sandbox: linux, os/x +*