[pypy-commit] pypy release-2.1.x: add the package-tk merge
Author: David Schneider david.schnei...@picle.org Branch: release-2.1.x Changeset: r65420:e021941db0c3 Date: 2013-07-17 10:40 +0200 http://bitbucket.org/pypy/pypy/changeset/e021941db0c3/ Log:add the package-tk merge diff --git a/pypy/doc/whatsnew-2.1.rst b/pypy/doc/whatsnew-2.1.rst --- a/pypy/doc/whatsnew-2.1.rst +++ b/pypy/doc/whatsnew-2.1.rst @@ -76,3 +76,8 @@ .. branch: inline-identityhash Inline the fast path of id() and hash() + +.. branch: package-tk +Adapt package.py script to compile CFFI tk extension. Add a --without-tk switch +to optionally skip it. + 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 @@ -76,3 +76,8 @@ .. branch: inline-identityhash Inline the fast path of id() and hash() + +.. branch: package-tk +Adapt package.py script to compile CFFI tk extension. Add a --without-tk switch +to optionally skip it. + ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: mention package-tk branch in whatsnew-2.1
Author: David Schneider david.schnei...@picle.org Branch: Changeset: r65421:9ba7a3d27c85 Date: 2013-07-17 10:42 +0200 http://bitbucket.org/pypy/pypy/changeset/9ba7a3d27c85/ Log:mention package-tk branch in whatsnew-2.1 diff --git a/pypy/doc/whatsnew-2.1.rst b/pypy/doc/whatsnew-2.1.rst --- a/pypy/doc/whatsnew-2.1.rst +++ b/pypy/doc/whatsnew-2.1.rst @@ -76,3 +76,8 @@ .. branch: inline-identityhash Inline the fast path of id() and hash() + +.. branch: package-tk +Adapt package.py script to compile CFFI tk extension. Add a --without-tk switch +to optionally skip it. + ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy release-2.1.x: import updated _cffi_backend/test/_backend_test_c.py
Author: David Schneider david.schnei...@picle.org Branch: release-2.1.x Changeset: r65423:371a517e6484 Date: 2013-07-17 10:55 +0200 http://bitbucket.org/pypy/pypy/changeset/371a517e6484/ Log:import updated _cffi_backend/test/_backend_test_c.py diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py --- a/pypy/module/_cffi_backend/test/_backend_test_c.py +++ b/pypy/module/_cffi_backend/test/_backend_test_c.py @@ -2760,6 +2760,20 @@ assert wr() is None py.test.raises(RuntimeError, from_handle, cast(BCharP, 0)) +def test_new_handle_cycle(): +import _weakref +BVoidP = new_pointer_type(new_void_type()) +class A(object): +pass +o = A() +o.cycle = newp_handle(BVoidP, o) +wr = _weakref.ref(o) +del o +for i in range(3): +if wr() is not None: +import gc; gc.collect() +assert wr() is None + def _test_bitfield_details(flag): BChar = new_primitive_type(char) BShort = new_primitive_type(short) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: import updated _cffi_backend/test/_backend_test_c.py
Author: David Schneider david.schnei...@picle.org Branch: Changeset: r65422:71da175abf19 Date: 2013-07-17 10:55 +0200 http://bitbucket.org/pypy/pypy/changeset/71da175abf19/ Log:import updated _cffi_backend/test/_backend_test_c.py diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py --- a/pypy/module/_cffi_backend/test/_backend_test_c.py +++ b/pypy/module/_cffi_backend/test/_backend_test_c.py @@ -2760,6 +2760,20 @@ assert wr() is None py.test.raises(RuntimeError, from_handle, cast(BCharP, 0)) +def test_new_handle_cycle(): +import _weakref +BVoidP = new_pointer_type(new_void_type()) +class A(object): +pass +o = A() +o.cycle = newp_handle(BVoidP, o) +wr = _weakref.ref(o) +del o +for i in range(3): +if wr() is not None: +import gc; gc.collect() +assert wr() is None + def _test_bitfield_details(flag): BChar = new_primitive_type(char) BShort = new_primitive_type(short) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy stmgc-c4: fighting layers to make it work
Author: Remi Meier remi.me...@gmail.com Branch: stmgc-c4 Changeset: r65424:8a3c2efecdca Date: 2013-07-17 11:22 +0200 http://bitbucket.org/pypy/pypy/changeset/8a3c2efecdca/ Log:fighting layers to make it work diff --git a/rpython/jit/backend/arm/regalloc.py b/rpython/jit/backend/arm/regalloc.py --- a/rpython/jit/backend/arm/regalloc.py +++ b/rpython/jit/backend/arm/regalloc.py @@ -628,7 +628,7 @@ descr = op.getdescr() fail_descr = cast_instance_to_gcref(descr) # we know it does not move, but well -rgc._make_sure_does_not_move(fail_descr) +fail_descr = rgc._make_sure_does_not_move(fail_descr) fail_descr = rffi.cast(lltype.Signed, fail_descr) if op.numargs() == 1: loc = self.make_sure_var_in_reg(op.getarg(0)) diff --git a/rpython/jit/backend/llsupport/assembler.py b/rpython/jit/backend/llsupport/assembler.py --- a/rpython/jit/backend/llsupport/assembler.py +++ b/rpython/jit/backend/llsupport/assembler.py @@ -222,7 +222,7 @@ raise AssertionError(kind) gcref = cast_instance_to_gcref(value) -rgc._make_sure_does_not_move(gcref) +gcref = rgc._make_sure_does_not_move(gcref) value = rffi.cast(lltype.Signed, gcref) je_location = self._call_assembler_check_descr(value, tmploc) # diff --git a/rpython/jit/backend/llsupport/gc.py b/rpython/jit/backend/llsupport/gc.py --- a/rpython/jit/backend/llsupport/gc.py +++ b/rpython/jit/backend/llsupport/gc.py @@ -107,9 +107,12 @@ gcrefs_output_list.append(new_p) if op.is_guard() or op.getopnum() == rop.FINISH: -llref = cast_instance_to_gcref(op.getdescr()) +# the only ops with descrs that get recorded in a trace +from rpython.jit.metainterp.history import AbstractDescr +descr = op.getdescr() +llref = cast_instance_to_gcref(descr) new_llref = rgc._make_sure_does_not_move(llref) -new_d = rgc.try_cast_gcref_to_instance(llref.__class__, new_llref) +new_d = rgc.try_cast_gcref_to_instance(AbstractDescr, new_llref) op.setdescr(new_d) gcrefs_output_list.append(new_llref) @@ -298,7 +301,7 @@ self.returns_modified_object = False self.gcheaderbuilder = gc_ll_descr.gcheaderbuilder self.HDRPTR = gc_ll_descr.HDRPTR -self.b_slowpath = [0, 0, 0, 0] +self.b_slowpath = [0, 0, 0, 0, 0] def repr_of_descr(self): raise NotImplementedError diff --git a/rpython/jit/backend/x86/regalloc.py b/rpython/jit/backend/x86/regalloc.py --- a/rpython/jit/backend/x86/regalloc.py +++ b/rpython/jit/backend/x86/regalloc.py @@ -368,7 +368,7 @@ descr = op.getdescr() fail_descr = cast_instance_to_gcref(descr) # we know it does not move, but well -rgc._make_sure_does_not_move(fail_descr) +fail_descr = rgc._make_sure_does_not_move(fail_descr) fail_descr = rffi.cast(lltype.Signed, fail_descr) if op.numargs() == 1: loc = self.make_sure_var_in_reg(op.getarg(0)) 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 @@ -65,21 +65,25 @@ return llop.stm_get_tid(llgroup.HALFWORD, obj) def get_hdr_tid(self, addr): -return llmemory.cast_adr_to_int(addr + self.H_TID) +return llmemory.cast_adr_to_ptr(addr + self.H_TID, rffi.SIGNEDP) def get_hdr_revision(self, addr): -return llmemory.cast_adr_to_int(addr + self.H_REVISION) - +return llmemory.cast_adr_to_ptr(addr + self.H_REVISION, rffi.SIGNEDP) + def get_hdr_original(self, addr): -return llmemory.cast_adr_to_int(addr + self.H_ORIGINAL) +return llmemory.cast_adr_to_ptr(addr + self.H_ORIGINAL, rffi.SIGNEDP) -def get_original_object(self, obj): -if bool(self.get_hdr_tid(obj) GCFLAG_PREBUILT_ORIGINAL): +def get_original_copy(self, obj): +addr = llmemory.cast_ptr_to_adr(obj) +if bool(self.get_hdr_tid(addr)[0] GCFLAG_PREBUILT_ORIGINAL): return obj -orig = self.get_hdr_original(obj) +# +orig = self.get_hdr_original(addr)[0] if orig == 0: return obj -return llmemory.cast_int_to_adr(orig) +# +return llmemory.cast_adr_to_ptr(llmemory.cast_int_to_adr(orig), + llmemory.GCREF) def init_gc_object_immortal(self, addr, typeid16, flags=0): assert flags == 0 @@ -117,7 +121,7 @@ def can_move(self, obj): Means the reference will stay valid, except if not seen by the GC, then it can get collected. -tid = self.get_hdr_tid(obj) +tid = self.get_hdr_tid(obj)[0] if bool(tid GCFLAG_OLD): return False return True diff --git
[pypy-commit] pypy default: Might go away again, but: attempting to give app-level code direct
Author: Armin Rigo ar...@tunes.org Branch: Changeset: r65425:b91fe2eeb20d Date: 2013-07-17 12:19 +0200 http://bitbucket.org/pypy/pypy/changeset/b91fe2eeb20d/ Log:Might go away again, but: attempting to give app-level code direct access to the wrap-around C-ish versions of some arithmetic operations. diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py --- a/pypy/module/__pypy__/__init__.py +++ b/pypy/module/__pypy__/__init__.py @@ -36,6 +36,20 @@ } +class IntOpModule(MixedModule): +appleveldefs = {} +interpleveldefs = { +'int_add': 'interp_intop.int_add', +'int_sub': 'interp_intop.int_sub', +'int_mul': 'interp_intop.int_mul', +'int_floordiv':'interp_intop.int_floordiv', +'uint_floordiv': 'interp_intop.uint_floordiv', +'int_mod': 'interp_intop.int_mod', +'int_lshift': 'interp_intop.int_lshift', +'uint_rshift': 'interp_intop.uint_rshift', +} + + class Module(MixedModule): appleveldefs = { } @@ -67,6 +81,7 @@ builders: BuildersModule, time: TimeModule, thread: ThreadModule, +intop: IntOpModule, } def setup_after_space_initialization(self): diff --git a/pypy/module/__pypy__/interp_intop.py b/pypy/module/__pypy__/interp_intop.py new file mode 100644 --- /dev/null +++ b/pypy/module/__pypy__/interp_intop.py @@ -0,0 +1,7 @@ +from pypy.interpreter.gateway import unwrap_spec +from rpython.rlib.rarithmetic import intmask + + +@unwrap_spec(n=int, m=int) +def int_add(space, n, m): +return space.wrap(intmask(n + m)) diff --git a/pypy/module/__pypy__/test/test_intop.py b/pypy/module/__pypy__/test/test_intop.py new file mode 100644 --- /dev/null +++ b/pypy/module/__pypy__/test/test_intop.py @@ -0,0 +1,11 @@ + + +class AppTestIntOp: +spaceconfig = dict(usemodules=['__pypy__']) + +def test_int_add(self): +import sys +from __pypy__ import intop +assert intop.int_add(40, 2) == 42 +assert intop.int_add(sys.maxint, 1) == -sys.maxint-1 +assert intop.int_add(-2, -sys.maxint) == sys.maxint ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: int_mul
Author: Armin Rigo ar...@tunes.org Branch: Changeset: r65427:941cffc3ef01 Date: 2013-07-17 12:26 +0200 http://bitbucket.org/pypy/pypy/changeset/941cffc3ef01/ Log:int_mul diff --git a/pypy/module/__pypy__/interp_intop.py b/pypy/module/__pypy__/interp_intop.py --- a/pypy/module/__pypy__/interp_intop.py +++ b/pypy/module/__pypy__/interp_intop.py @@ -9,3 +9,7 @@ @unwrap_spec(n=int, m=int) def int_sub(space, n, m): return space.wrap(intmask(n - m)) + +@unwrap_spec(n=int, m=int) +def int_mul(space, n, m): +return space.wrap(intmask(n * m)) diff --git a/pypy/module/__pypy__/test/test_intop.py b/pypy/module/__pypy__/test/test_intop.py --- a/pypy/module/__pypy__/test/test_intop.py +++ b/pypy/module/__pypy__/test/test_intop.py @@ -3,6 +3,23 @@ class AppTestIntOp: spaceconfig = dict(usemodules=['__pypy__']) +def w_intmask(self, n): +import sys +n = (sys.maxint*2+1) +if n sys.maxint: +n -= 2*(sys.maxint+1) +return int(n) + +def test_intmask(self): +import sys +assert self.intmask(sys.maxint) == sys.maxint +assert self.intmask(sys.maxint+1) == -sys.maxint-1 +assert self.intmask(-sys.maxint-2) == sys.maxint +N = 2 ** 128 +assert self.intmask(N+sys.maxint) == sys.maxint +assert self.intmask(N+sys.maxint+1) == -sys.maxint-1 +assert self.intmask(N-sys.maxint-2) == sys.maxint + def test_int_add(self): import sys from __pypy__ import intop @@ -16,3 +33,10 @@ assert intop.int_sub(40, -2) == 42 assert intop.int_sub(sys.maxint, -1) == -sys.maxint-1 assert intop.int_sub(-2, sys.maxint) == sys.maxint + +def test_int_mul(self): +import sys +from __pypy__ import intop +assert intop.int_mul(40, -2) == -80 +assert intop.int_mul(-sys.maxint, -sys.maxint) == ( +self.intmask(sys.maxint ** 2)) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: int_sub
Author: Armin Rigo ar...@tunes.org Branch: Changeset: r65426:0d0d42b3bf62 Date: 2013-07-17 12:20 +0200 http://bitbucket.org/pypy/pypy/changeset/0d0d42b3bf62/ Log:int_sub diff --git a/pypy/module/__pypy__/interp_intop.py b/pypy/module/__pypy__/interp_intop.py --- a/pypy/module/__pypy__/interp_intop.py +++ b/pypy/module/__pypy__/interp_intop.py @@ -5,3 +5,7 @@ @unwrap_spec(n=int, m=int) def int_add(space, n, m): return space.wrap(intmask(n + m)) + +@unwrap_spec(n=int, m=int) +def int_sub(space, n, m): +return space.wrap(intmask(n - m)) diff --git a/pypy/module/__pypy__/test/test_intop.py b/pypy/module/__pypy__/test/test_intop.py --- a/pypy/module/__pypy__/test/test_intop.py +++ b/pypy/module/__pypy__/test/test_intop.py @@ -9,3 +9,10 @@ assert intop.int_add(40, 2) == 42 assert intop.int_add(sys.maxint, 1) == -sys.maxint-1 assert intop.int_add(-2, -sys.maxint) == sys.maxint + +def test_int_sub(self): +import sys +from __pypy__ import intop +assert intop.int_sub(40, -2) == 42 +assert intop.int_sub(sys.maxint, -1) == -sys.maxint-1 +assert intop.int_sub(-2, sys.maxint) == sys.maxint ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: int_floordiv
Author: Armin Rigo ar...@tunes.org Branch: Changeset: r65428:ee9c24742973 Date: 2013-07-17 12:32 +0200 http://bitbucket.org/pypy/pypy/changeset/ee9c24742973/ Log:int_floordiv diff --git a/pypy/module/__pypy__/interp_intop.py b/pypy/module/__pypy__/interp_intop.py --- a/pypy/module/__pypy__/interp_intop.py +++ b/pypy/module/__pypy__/interp_intop.py @@ -1,5 +1,7 @@ from pypy.interpreter.gateway import unwrap_spec from rpython.rlib.rarithmetic import intmask +from rpython.rtyper.lltypesystem import lltype +from rpython.rtyper.lltypesystem.lloperation import llop @unwrap_spec(n=int, m=int) @@ -13,3 +15,7 @@ @unwrap_spec(n=int, m=int) def int_mul(space, n, m): return space.wrap(intmask(n * m)) + +@unwrap_spec(n=int, m=int) +def int_floordiv(space, n, m): +return space.wrap(llop.int_floordiv(lltype.Signed, n, m)) diff --git a/pypy/module/__pypy__/test/test_intop.py b/pypy/module/__pypy__/test/test_intop.py --- a/pypy/module/__pypy__/test/test_intop.py +++ b/pypy/module/__pypy__/test/test_intop.py @@ -40,3 +40,13 @@ assert intop.int_mul(40, -2) == -80 assert intop.int_mul(-sys.maxint, -sys.maxint) == ( self.intmask(sys.maxint ** 2)) + +def test_int_floordiv(self): +import sys +from __pypy__ import intop +assert intop.int_floordiv(41, 3) == 13 +assert intop.int_floordiv(41, -3) == -13 +assert intop.int_floordiv(-41, 3) == -13 +assert intop.int_floordiv(-41, -3) == 13 +assert intop.int_floordiv(-sys.maxint, -1) == sys.maxint +assert intop.int_floordiv(sys.maxint, -1) == -sys.maxint ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: int_mod
Author: Armin Rigo ar...@tunes.org Branch: Changeset: r65430:cdd7666ee866 Date: 2013-07-17 12:34 +0200 http://bitbucket.org/pypy/pypy/changeset/cdd7666ee866/ Log:int_mod diff --git a/pypy/module/__pypy__/interp_intop.py b/pypy/module/__pypy__/interp_intop.py --- a/pypy/module/__pypy__/interp_intop.py +++ b/pypy/module/__pypy__/interp_intop.py @@ -19,3 +19,7 @@ @unwrap_spec(n=int, m=int) def int_floordiv(space, n, m): return space.wrap(llop.int_floordiv(lltype.Signed, n, m)) + +@unwrap_spec(n=int, m=int) +def int_mod(space, n, m): +return space.wrap(llop.int_mod(lltype.Signed, n, m)) diff --git a/pypy/module/__pypy__/test/test_intop.py b/pypy/module/__pypy__/test/test_intop.py --- a/pypy/module/__pypy__/test/test_intop.py +++ b/pypy/module/__pypy__/test/test_intop.py @@ -50,3 +50,13 @@ assert intop.int_floordiv(-41, -3) == 13 assert intop.int_floordiv(-sys.maxint, -1) == sys.maxint assert intop.int_floordiv(sys.maxint, -1) == -sys.maxint + +def test_int_mod(self): +import sys +from __pypy__ import intop +assert intop.int_mod(41, 3) == 2 +assert intop.int_mod(41, -3) == 2 +assert intop.int_mod(-41, 3) == -2 +assert intop.int_mod(-41, -3) == -2 +assert intop.int_mod(-sys.maxint, -1) == 0 +assert intop.int_mod(sys.maxint, -1) == 0 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: int_lshift, uint_rshift
Author: Armin Rigo ar...@tunes.org Branch: Changeset: r65432:3e7495dc4215 Date: 2013-07-17 12:42 +0200 http://bitbucket.org/pypy/pypy/changeset/3e7495dc4215/ Log:int_lshift, uint_rshift diff --git a/pypy/module/__pypy__/interp_intop.py b/pypy/module/__pypy__/interp_intop.py --- a/pypy/module/__pypy__/interp_intop.py +++ b/pypy/module/__pypy__/interp_intop.py @@ -1,6 +1,7 @@ from pypy.interpreter.gateway import unwrap_spec from rpython.rtyper.lltypesystem import lltype from rpython.rtyper.lltypesystem.lloperation import llop +from rpython.rlib.rarithmetic import r_uint, intmask @unwrap_spec(n=int, m=int) @@ -22,3 +23,13 @@ @unwrap_spec(n=int, m=int) def int_mod(space, n, m): return space.wrap(llop.int_mod(lltype.Signed, n, m)) + +@unwrap_spec(n=int, m=int) +def int_lshift(space, n, m): +return space.wrap(llop.int_lshift(lltype.Signed, n, m)) + +@unwrap_spec(n=int, m=int) +def uint_rshift(space, n, m): +n = r_uint(n) +x = llop.uint_rshift(lltype.Unsigned, n, m) +return space.wrap(intmask(x)) diff --git a/pypy/module/__pypy__/test/test_intop.py b/pypy/module/__pypy__/test/test_intop.py --- a/pypy/module/__pypy__/test/test_intop.py +++ b/pypy/module/__pypy__/test/test_intop.py @@ -60,3 +60,37 @@ assert intop.int_mod(-41, -3) == -2 assert intop.int_mod(-sys.maxint, -1) == 0 assert intop.int_mod(sys.maxint, -1) == 0 + +def test_int_lshift(self): +import sys +from __pypy__ import intop +if sys.maxint == 2**31-1: +bits = 32 +else: +bits = 64 +assert intop.int_lshift(42, 3) == 42 3 +assert intop.int_lshift(0, ) == 0 +assert intop.int_lshift(1, bits-2) == 1 (bits-2) +assert intop.int_lshift(1, bits-1) == -sys.maxint-1 == (-1) (bits-1) +assert intop.int_lshift(-1, bits-2) == (-1) (bits-2) +assert intop.int_lshift(-1, bits-1) == -sys.maxint-1 +assert intop.int_lshift(sys.maxint // 3, 2) == ( +self.intmask((sys.maxint // 3) 2)) +assert intop.int_lshift(-sys.maxint // 3, 2) == ( +self.intmask((-sys.maxint // 3) 2)) + +def test_uint_rshift(self): +import sys +from __pypy__ import intop +if sys.maxint == 2**31-1: +bits = 32 +else: +bits = 64 +N = 1 bits +assert intop.uint_rshift(42, 3) == 42 3 +assert intop.uint_rshift(-42, 3) == (N-42) 3 +assert intop.uint_rshift(0, ) == 0 +assert intop.uint_rshift(-1, 0) == -1 +assert intop.uint_rshift(-1, 1) == sys.maxint +assert intop.uint_rshift(-1, bits-2) == 3 +assert intop.uint_rshift(-1, bits-1) == 1 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Use a consistent style and avoid intmask()
Author: Armin Rigo ar...@tunes.org Branch: Changeset: r65431:c60b161838a3 Date: 2013-07-17 12:35 +0200 http://bitbucket.org/pypy/pypy/changeset/c60b161838a3/ Log:Use a consistent style and avoid intmask() diff --git a/pypy/module/__pypy__/interp_intop.py b/pypy/module/__pypy__/interp_intop.py --- a/pypy/module/__pypy__/interp_intop.py +++ b/pypy/module/__pypy__/interp_intop.py @@ -1,20 +1,19 @@ from pypy.interpreter.gateway import unwrap_spec -from rpython.rlib.rarithmetic import intmask from rpython.rtyper.lltypesystem import lltype from rpython.rtyper.lltypesystem.lloperation import llop @unwrap_spec(n=int, m=int) def int_add(space, n, m): -return space.wrap(intmask(n + m)) +return space.wrap(llop.int_add(lltype.Signed, n, m)) @unwrap_spec(n=int, m=int) def int_sub(space, n, m): -return space.wrap(intmask(n - m)) +return space.wrap(llop.int_sub(lltype.Signed, n, m)) @unwrap_spec(n=int, m=int) def int_mul(space, n, m): -return space.wrap(intmask(n * m)) +return space.wrap(llop.int_mul(lltype.Signed, n, m)) @unwrap_spec(n=int, m=int) def int_floordiv(space, n, m): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Cannot give uint_floordiv a useful sense without an unsigned type
Author: Armin Rigo ar...@tunes.org Branch: Changeset: r65429:39fb2e0a9f4b Date: 2013-07-17 12:32 +0200 http://bitbucket.org/pypy/pypy/changeset/39fb2e0a9f4b/ Log:Cannot give uint_floordiv a useful sense without an unsigned type diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py --- a/pypy/module/__pypy__/__init__.py +++ b/pypy/module/__pypy__/__init__.py @@ -43,7 +43,6 @@ 'int_sub': 'interp_intop.int_sub', 'int_mul': 'interp_intop.int_mul', 'int_floordiv':'interp_intop.int_floordiv', -'uint_floordiv': 'interp_intop.uint_floordiv', 'int_mod': 'interp_intop.int_mod', 'int_lshift': 'interp_intop.int_lshift', 'uint_rshift': 'interp_intop.uint_rshift', ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy release-2.1.x: update whatsnew
Author: David Schneider david.schnei...@picle.org Branch: release-2.1.x Changeset: r65439:5b8ff324b80a Date: 2013-07-17 14:24 +0200 http://bitbucket.org/pypy/pypy/changeset/5b8ff324b80a/ Log:update whatsnew diff --git a/pypy/doc/whatsnew-2.1.rst b/pypy/doc/whatsnew-2.1.rst --- a/pypy/doc/whatsnew-2.1.rst +++ b/pypy/doc/whatsnew-2.1.rst @@ -84,3 +84,5 @@ .. branch: distutils-cppldflags Copy CPython's implementation of customize_compiler, dont call split on environment variables, honour CFLAGS, CPPFLAGS, LDSHARED and LDFLAGS on Unices. + +.. branch: ssl_moving_write_buffer 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 @@ -85,3 +85,4 @@ Copy CPython's implementation of customize_compiler, dont call split on environment variables, honour CFLAGS, CPPFLAGS, LDSHARED and LDFLAGS on Unices. +.. branch: ssl_moving_write_buffer ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy release-2.1.x: port CPython's implementation of customie_compiler, dont run split on env vars - maybe problematic, support LDSHARED, CPPFLAGS, CFLAGS andLDFLAGS
Author: Pawe? Piotr Przeradowski showerproo...@gmail.com Branch: release-2.1.x Changeset: r65435:0ffbe5bae781 Date: 2013-07-14 17:36 +0200 http://bitbucket.org/pypy/pypy/changeset/0ffbe5bae781/ Log:port CPython's implementation of customie_compiler, dont run split on env vars - maybe problematic, support LDSHARED, CPPFLAGS, CFLAGS andLDFLAGS (transplanted from e52527f04d73593b095f56c33d5e75beaa96ebf9) diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py b/lib-python/2.7/distutils/sysconfig_pypy.py --- a/lib-python/2.7/distutils/sysconfig_pypy.py +++ b/lib-python/2.7/distutils/sysconfig_pypy.py @@ -12,9 +12,9 @@ import sys import os -import shlex from distutils.errors import DistutilsPlatformError +from distutils import log; log.set_verbosity(1) PREFIX = os.path.normpath(sys.prefix) @@ -66,6 +66,12 @@ g['SOABI'] = g['SO'].rsplit('.')[0] g['LIBDIR'] = os.path.join(sys.prefix, 'lib') g['CC'] = gcc -pthread # -pthread might not be valid on OS/X, check +g['OPT'] = +g['CFLAGS'] = +g['CPPFLAGS'] = +g['CCSHARED'] = '-shared -O2 -fPIC -Wimplicit' +g['LDSHARED'] = g['CC'] + ' -shared' + global _config_vars _config_vars = g @@ -123,21 +129,34 @@ optional C speedup components. if compiler.compiler_type == unix: -compiler.compiler_so.extend(['-O2', '-fPIC', '-Wimplicit']) +cc, opt, cflags, ccshared, ldshared = get_config_vars( +'CC', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED') + compiler.shared_lib_extension = get_config_var('SO') -if CPPFLAGS in os.environ: -cppflags = shlex.split(os.environ[CPPFLAGS]) -compiler.compiler.extend(cppflags) -compiler.compiler_so.extend(cppflags) -compiler.linker_so.extend(cppflags) -if CFLAGS in os.environ: -cflags = shlex.split(os.environ[CFLAGS]) -compiler.compiler.extend(cflags) -compiler.compiler_so.extend(cflags) -compiler.linker_so.extend(cflags) -if LDFLAGS in os.environ: -ldflags = shlex.split(os.environ[LDFLAGS]) -compiler.linker_so.extend(ldflags) + +if 'LDSHARED' in os.environ: +ldshared = os.environ['LDSHARED'] +if 'CPP' in os.environ: +cpp = os.environ['CPP'] +else: +cpp = cc + -E # not always +if 'LDFLAGS' in os.environ: +ldshared = ldshared + ' ' + os.environ['LDFLAGS'] +if 'CFLAGS' in os.environ: +cflags = opt + ' ' + os.environ['CFLAGS'] +ldshared = ldshared + ' ' + os.environ['CFLAGS'] +if 'CPPFLAGS' in os.environ: +cpp = cpp + ' ' + os.environ['CPPFLAGS'] +cflags = cflags + ' ' + os.environ['CPPFLAGS'] +ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] + +cc_cmd = cc + ' ' + cflags + +compiler.set_executables( +preprocessor=cpp, +compiler=cc_cmd, +compiler_so=cc_cmd + ' ' + ccshared, +linker_so=ldshared) from sysconfig_cpython import ( ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy release-2.1.x: Add the SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER flag.
Author: Ben Darnell b...@bendarnell.com Branch: release-2.1.x Changeset: r65433:94f8ef1a69a0 Date: 2013-07-13 10:32 -0400 http://bitbucket.org/pypy/pypy/changeset/94f8ef1a69a0/ Log:Add the SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER flag. This disables a sanity check in openssl that can cause problems when it is used in non-blocking mode and the GC causes the address of a str object to change (https://bugs.pypy.org/issue1238). 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 @@ -722,7 +722,10 @@ libssl_SSL_CTX_set_verify(ss.ctx, verification_mode, None) ss.ssl = libssl_SSL_new(ss.ctx) # new ssl struct libssl_SSL_set_fd(ss.ssl, sock_fd) # set the socket for SSL -libssl_SSL_set_mode(ss.ssl, SSL_MODE_AUTO_RETRY) +# The ACCEPT_MOVING_WRITE_BUFFER flag is necessary because the address +# of a str object may be changed by the garbage collector. +libssl_SSL_set_mode(ss.ssl, +SSL_MODE_AUTO_RETRY | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER) # If the socket is in non-blocking mode or timeout mode, set the BIO # to non-blocking mode (blocking is the default) diff --git a/rpython/rlib/ropenssl.py b/rpython/rlib/ropenssl.py --- a/rpython/rlib/ropenssl.py +++ b/rpython/rlib/ropenssl.py @@ -93,6 +93,7 @@ SSL_RECEIVED_SHUTDOWN = rffi_platform.ConstantInteger( SSL_RECEIVED_SHUTDOWN) SSL_MODE_AUTO_RETRY = rffi_platform.ConstantInteger(SSL_MODE_AUTO_RETRY) +SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER = rffi_platform.ConstantInteger(SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER) NID_subject_alt_name = rffi_platform.ConstantInteger(NID_subject_alt_name) GEN_DIRNAME = rffi_platform.ConstantInteger(GEN_DIRNAME) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy release-2.1.x: update whatsnew-2.1
Author: David Schneider david.schnei...@picle.org Branch: release-2.1.x Changeset: r65438:b607f4d7888d Date: 2013-07-17 14:22 +0200 http://bitbucket.org/pypy/pypy/changeset/b607f4d7888d/ Log:update whatsnew-2.1 diff --git a/pypy/doc/whatsnew-2.1.rst b/pypy/doc/whatsnew-2.1.rst --- a/pypy/doc/whatsnew-2.1.rst +++ b/pypy/doc/whatsnew-2.1.rst @@ -81,3 +81,6 @@ Adapt package.py script to compile CFFI tk extension. Add a --without-tk switch to optionally skip it. +.. branch: distutils-cppldflags +Copy CPython's implementation of customize_compiler, dont call split on +environment variables, honour CFLAGS, CPPFLAGS, LDSHARED and LDFLAGS on Unices. ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy release-2.1.x: whatsnew
Author: Pawe? Piotr Przeradowski showerproo...@gmail.com Branch: release-2.1.x Changeset: r65436:f0d5bf1285a3 Date: 2013-07-14 17:46 +0200 http://bitbucket.org/pypy/pypy/changeset/f0d5bf1285a3/ Log:whatsnew (transplanted from 32ef954a6c26b6d8606515af56b4ffb03f453762) 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 @@ -81,3 +81,7 @@ Adapt package.py script to compile CFFI tk extension. Add a --without-tk switch to optionally skip it. +.. branch: distutils-cppldflags +Copy CPython's implementation of customize_compiler, dont call split on +environment variables, honour CFLAGS, CPPFLAGS, LDSHARED and LDFLAGS on Unices. + ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy release-2.1.x: ADD CPPFLAGS and LDFLAGS
Author: Pawe? Piotr Przeradowski showerproo...@gmail.com Branch: release-2.1.x Changeset: r65434:32794dd704b3 Date: 2013-07-13 19:50 +0200 http://bitbucket.org/pypy/pypy/changeset/32794dd704b3/ Log:ADD CPPFLAGS and LDFLAGS (transplanted from d13af1390dae6871df33f602ed984577dc06a4de) diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py b/lib-python/2.7/distutils/sysconfig_pypy.py --- a/lib-python/2.7/distutils/sysconfig_pypy.py +++ b/lib-python/2.7/distutils/sysconfig_pypy.py @@ -12,6 +12,7 @@ import sys import os +import shlex from distutils.errors import DistutilsPlatformError @@ -124,11 +125,19 @@ if compiler.compiler_type == unix: compiler.compiler_so.extend(['-O2', '-fPIC', '-Wimplicit']) compiler.shared_lib_extension = get_config_var('SO') +if CPPFLAGS in os.environ: +cppflags = shlex.split(os.environ[CPPFLAGS]) +compiler.compiler.extend(cppflags) +compiler.compiler_so.extend(cppflags) +compiler.linker_so.extend(cppflags) if CFLAGS in os.environ: -cflags = os.environ[CFLAGS].split() +cflags = shlex.split(os.environ[CFLAGS]) compiler.compiler.extend(cflags) compiler.compiler_so.extend(cflags) compiler.linker_so.extend(cflags) +if LDFLAGS in os.environ: +ldflags = shlex.split(os.environ[LDFLAGS]) +compiler.linker_so.extend(ldflags) from sysconfig_cpython import ( ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy release-2.1.x: oups, didnt intend to commit set_verbosity
Author: Pawe? Piotr Przeradowski showerproo...@gmail.com Branch: release-2.1.x Changeset: r65437:ec326d132dd7 Date: 2013-07-14 17:49 +0200 http://bitbucket.org/pypy/pypy/changeset/ec326d132dd7/ Log:oups, didnt intend to commit set_verbosity (transplanted from 0c6eeae0316c11146f47fcf83e21e24f11378be1) diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py b/lib-python/2.7/distutils/sysconfig_pypy.py --- a/lib-python/2.7/distutils/sysconfig_pypy.py +++ b/lib-python/2.7/distutils/sysconfig_pypy.py @@ -14,7 +14,6 @@ import os from distutils.errors import DistutilsPlatformError -from distutils import log; log.set_verbosity(1) PREFIX = os.path.normpath(sys.prefix) @@ -72,7 +71,6 @@ g['CCSHARED'] = '-shared -O2 -fPIC -Wimplicit' g['LDSHARED'] = g['CC'] + ' -shared' - global _config_vars _config_vars = g ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy jit-threshold-hooks: Start a branch to manually manipulate jit parameters per function
Author: Maciej Fijalkowski fij...@gmail.com Branch: jit-threshold-hooks Changeset: r65440:965c645286ae Date: 2013-07-17 15:20 +0200 http://bitbucket.org/pypy/pypy/changeset/965c645286ae/ Log:Start a branch to manually manipulate jit parameters per function diff --git a/pypy/module/pypyjit/__init__.py b/pypy/module/pypyjit/__init__.py --- a/pypy/module/pypyjit/__init__.py +++ b/pypy/module/pypyjit/__init__.py @@ -18,6 +18,8 @@ 'JitLoopInfo': 'interp_resop.W_JitLoopInfo', 'Box': 'interp_resop.WrappedBox', 'PARAMETER_DOCS': 'space.wrap(rpython.rlib.jit.PARAMETER_DOCS)', +'set_local_threshold': 'interp_jit.set_local_threshold', +'set_local_bridge_threshold': 'interp_jit.set_local_bridge_threshold', } def setup_after_space_initialization(self): diff --git a/pypy/module/pypyjit/interp_jit.py b/pypy/module/pypyjit/interp_jit.py --- a/pypy/module/pypyjit/interp_jit.py +++ b/pypy/module/pypyjit/interp_jit.py @@ -13,6 +13,7 @@ from pypy.interpreter.pycode import PyCode, CO_GENERATOR from pypy.interpreter.pyframe import PyFrame from pypy.interpreter.pyopcode import ExitFrame +from pypy.interpreter.gateway import unwrap_spec from opcode import opmap PyFrame._virtualizable2_ = ['last_instr', 'pycode', @@ -51,11 +52,15 @@ greens = ['next_instr', 'is_being_profiled', 'pycode'] virtualizables = ['frame'] +def start_bridge_threshold(next_instr, is_being_profiled, bytecode): +return bytecode.bridge_init_threshold + pypyjitdriver = PyPyJitDriver(get_printable_location = get_printable_location, get_jitcell_at = get_jitcell_at, set_jitcell_at = set_jitcell_at, should_unroll_one_iteration = should_unroll_one_iteration, + start_bridge_threshold=start_bridge_threshold, name='pypyjit') class __extend__(PyFrame): @@ -117,6 +122,7 @@ def _initialize(self): PyCode__initialize(self) self.jit_cells = {} +self.bridge_init_threshold = 0 def _cleanup_(self): self.jit_cells = {} @@ -162,3 +168,16 @@ '''For testing. Invokes callable(...), but without letting the JIT follow the call.''' return space.call_args(w_callable, __args__) + +@unwrap_spec(w_code=PyCode, pos=int, value=int) +def set_local_threshold(space, w_code, pos, value): + set_local_threshold(code, pos, value) + +For testing. Set the threshold for this code object at position pos +at value given. + +w_code.jit_cells[pos 1] = value # we ignore the profiling case + +@unwrap_spec(w_code=PyCode, value=int) +def set_local_bridge_threshold(space, w_code, value): +w_code.bridge_init_threshold = value diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py --- a/rpython/rlib/jit.py +++ b/rpython/rlib/jit.py @@ -481,6 +481,7 @@ get_jitcell_at=None, set_jitcell_at=None, get_printable_location=None, confirm_enter_jit=None, can_never_inline=None, should_unroll_one_iteration=None, + start_bridge_threshold=None, name='jitdriver', check_untranslated=True): if greens is not None: self.greens = greens @@ -517,6 +518,7 @@ self.can_never_inline = can_never_inline self.should_unroll_one_iteration = should_unroll_one_iteration self.check_untranslated = check_untranslated +self.start_bridge_threshold = start_bridge_threshold def _freeze_(self): return True ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy jit-threshold-hooks: grrr
Author: Maciej Fijalkowski fij...@gmail.com Branch: jit-threshold-hooks Changeset: r65441:fb34a38a0ec4 Date: 2013-07-17 16:39 +0200 http://bitbucket.org/pypy/pypy/changeset/fb34a38a0ec4/ Log:grrr diff --git a/pypy/module/pypyjit/interp_jit.py b/pypy/module/pypyjit/interp_jit.py --- a/pypy/module/pypyjit/interp_jit.py +++ b/pypy/module/pypyjit/interp_jit.py @@ -176,7 +176,7 @@ For testing. Set the threshold for this code object at position pos at value given. -w_code.jit_cells[pos 1] = value # we ignore the profiling case +w_code.jit_cells[pos 1] = r_uint(value) # we ignore the profiling case @unwrap_spec(w_code=PyCode, value=int) def set_local_bridge_threshold(space, w_code, value): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy fast-slowpath: allow a different number of args
Author: Maciej Fijalkowski fij...@gmail.com Branch: fast-slowpath Changeset: r65442:25fdf2bb3fc7 Date: 2013-07-17 17:03 +0200 http://bitbucket.org/pypy/pypy/changeset/25fdf2bb3fc7/ Log:allow a different number of args diff --git a/rpython/jit/backend/test/runner_test.py b/rpython/jit/backend/test/runner_test.py --- a/rpython/jit/backend/test/runner_test.py +++ b/rpython/jit/backend/test/runner_test.py @@ -2267,38 +2267,39 @@ assert s.data.tid == value def test_cond_call(self): -called = [] - -def func_void(arg): -called.append(arg) - -FUNC = self.FuncType([lltype.Signed], lltype.Void) -func_ptr = llhelper(lltype.Ptr(FUNC), func_void) -calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT, - EffectInfo.MOST_GENERAL) - -ops = ''' -[i0, i1, i2, i3, i4, i5, i6, f0, f1] -cond_call(i1, ConstClass(func_ptr), i2, descr=calldescr) -guard_false(i0, descr=faildescr) [i1, i2, i3, i4, i5, i6, f0, f1] -''' -loop = parse(ops, namespace={'faildescr': BasicFailDescr(), - 'func_ptr': func_ptr, - 'calldescr': calldescr}) -looptoken = JitCellToken() -self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken) -frame = self.cpu.execute_token(looptoken, 1, 0, 1, 2, 3, 4, 5, 1.2, 3.4) -assert not called +def func_void(*args): +called.append(args) + for i in range(5): -assert self.cpu.get_int_value(frame, i) == i -assert self.cpu.get_float_value(frame, 6) == 1.2 -assert self.cpu.get_float_value(frame, 7) == 3.4 -frame = self.cpu.execute_token(looptoken, 1, 1, 1, 2, 3, 4, 5, 1.2, 3.4) -assert called == [1] -for i in range(4): -assert self.cpu.get_int_value(frame, i + 1) == i + 1 -assert self.cpu.get_float_value(frame, 6) == 1.2 -assert self.cpu.get_float_value(frame, 7) == 3.4 +called = [] + +FUNC = self.FuncType([lltype.Signed] * i, lltype.Void) +func_ptr = llhelper(lltype.Ptr(FUNC), func_void) +calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT, + EffectInfo.MOST_GENERAL) + +ops = ''' +[i0, i1, i2, i3, i4, i5, i6, f0, f1] +cond_call(i1, ConstClass(func_ptr), %s, descr=calldescr) +guard_false(i0, descr=faildescr) [i1, i2, i3, i4, i5, i6, f0, f1] +''' % ', '.join(['i%d' % (j + 2) for j in range(i)]) +loop = parse(ops, namespace={'faildescr': BasicFailDescr(), + 'func_ptr': func_ptr, + 'calldescr': calldescr}) +looptoken = JitCellToken() +self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken) +frame = self.cpu.execute_token(looptoken, 1, 0, 1, 2, 3, 4, 5, 1.2, 3.4) +assert not called +for j in range(5): +assert self.cpu.get_int_value(frame, j) == j +assert self.cpu.get_float_value(frame, 6) == 1.2 +assert self.cpu.get_float_value(frame, 7) == 3.4 +frame = self.cpu.execute_token(looptoken, 1, 1, 1, 2, 3, 4, 5, 1.2, 3.4) +assert called == [tuple(range(1, i + 1))] +for j in range(4): +assert self.cpu.get_int_value(frame, j + 1) == j + 1 +assert self.cpu.get_float_value(frame, 6) == 1.2 +assert self.cpu.get_float_value(frame, 7) == 3.4 def test_force_operations_returning_void(self): values = [] diff --git a/rpython/jit/backend/x86/regalloc.py b/rpython/jit/backend/x86/regalloc.py --- a/rpython/jit/backend/x86/regalloc.py +++ b/rpython/jit/backend/x86/regalloc.py @@ -56,6 +56,7 @@ no_lower_byte_regs = [] save_around_call_regs = [eax, ecx, edx, esi, edi, r8, r9, r10] +register_arguments = [edi, esi, edx, ecx] class X86XMMRegisterManager(RegisterManager): @@ -800,9 +801,13 @@ def consider_cond_call(self, op): assert op.result is None args = op.getarglist() -assert len(args) == 1 + 2 -self.make_sure_var_in_reg(args[2], selected_reg=edi) +assert 2 = len(args) = 4 + 2 loc_call = self.make_sure_var_in_reg(args[1], args, selected_reg=eax) +args_so_far = [args[1]] +for i in range(2, len(args)): +reg = self.rm.register_arguments[i - 2] +self.make_sure_var_in_reg(args[i], args_so_far, selected_reg=reg) +args_so_far.append(args[i]) loc_cond = self.make_sure_var_in_reg(args[0], args) self.assembler.cond_call(op, self.get_gcmap(), loc_cond, loc_call, [edi]) ___ pypy-commit
[pypy-commit] extradoc extradoc: start london announcement
Author: Carl Friedrich Bolz cfb...@gmx.de Branch: extradoc Changeset: r4989:eb280dd24330 Date: 2013-07-17 17:25 +0200 http://bitbucket.org/pypy/extradoc/changeset/eb280dd24330/ Log:start london announcement diff --git a/sprintinfo/london-2013/announcement.txt b/sprintinfo/london-2013/announcement.txt new file mode 100644 --- /dev/null +++ b/sprintinfo/london-2013/announcement.txt @@ -0,0 +1,64 @@ += + PyPy London Sprint (August 26 - September 1 2013) += + +The next PyPy sprint will be in London, United Kingdom for the first +time. This is a fully public sprint: newcomers and topics other than +those proposed below are welcome. + + +-- +Goals and topics of the sprint +-- + +* whatever attendands find interesting :-) + +* refactoring the JIT optimizations + +* STM and STM-related topics + + +--- +Exact times +--- + +The work days should be August 26 - September 1 2013 (Monday-Sunday). +The official plans are for people to arrive on the 26th, and +to leave on the 2nd. There will be a break day in the middle. +We'll typically start at 10:00 in the morning. + + + +Location + + +The sprint will happen within a room of `King's College's`_ `Strand +Campus`_ in Central London, UK. + +.. _`King's College`: http://www.kcl.ac.uk/ +.. _`Strand Campus`: http://goo.gl/maps/Qz0zz + + +Demo Morning + + +If you don't want to come to the full sprint, but still want to chat a +bit, we are planning to have a demo morning on Tuesday August 27. We +will announce this separately on the blog. If you are interested, please +leave a comment. + +-- +Registration +-- + +If you want to attend, please register by adding yourself to the +people.txt file in Mercurial:: + + https://bitbucket.org/pypy/extradoc/ + https://bitbucket.org/pypy/extradoc/raw/extradoc/sprintinfo/london-2013 + +or on the pypy-dev mailing list if you do not yet have check-in rights: + + http://mail.python.org/mailman/listinfo/pypy-dev + +Remember that you may need a UK-to-(insert country here) power adapter. diff --git a/sprintinfo/london-2013/people.txt b/sprintinfo/london-2013/people.txt new file mode 100644 --- /dev/null +++ b/sprintinfo/london-2013/people.txt @@ -0,0 +1,56 @@ + +People coming to the London sprint 2013 +== + +People who have a ``?`` in their arrive/depart or accomodation +column are known to be coming but there are no details +available from them. + + + == === +Name Arrive/Depart Accomodation + == === +Carl Friedrich Bolz ? ? + == === + + +People on the following list were present at previous sprints: + + == = + Name Arrive/Depart Accomodation + == = +Antonio Cuni ? ? +Michael Foord? ? +Maciej Fijalkowski ? ? +David Schneider ? ? +Jacob Hallen ? ? +Laura Creighton ? ? +Hakan Ardo ? ? +Samuele Pedroni ? ? +Anders Hammarquist ? ? +Christian Tismer ? ? +Niko Matsakis? ? +Toby Watson ? ? +Paul deGrandis ? ? +Michael Hudson ? ? +Anders Lehmann ? ? +Niklaus Haldimann? ? +Lene Wagner ? ? +Amaury Forgeot d'Arc ? ? +Valentino Volonghi ? ? +Boris Feigin? ? +Andrew Thompson ? ? +Bert Freudenberg ? ? +Beatrice Duering ? ? +Richard Emslie ? ? +Johan Hahn ? ? +Stephan Diehl? ? +Alexander Schremmer ? ? +Anders Chrigstroem ? ? +Eric van Riet Paap ? ? +Holger Krekel? ? +Guido Wesdorp? ? +Leonardo Santagada ? ? +Alexandre Fayolle? ? +Sylvain Th#65533;nault ? ? + == = ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy fast-slowpath: gcmap support
Author: Maciej Fijalkowski fij...@gmail.com Branch: fast-slowpath Changeset: r65443:0b84ace95452 Date: 2013-07-17 17:51 +0200 http://bitbucket.org/pypy/pypy/changeset/0b84ace95452/ Log:gcmap support diff --git a/rpython/jit/backend/llsupport/test/test_gc_integration.py b/rpython/jit/backend/llsupport/test/test_gc_integration.py --- a/rpython/jit/backend/llsupport/test/test_gc_integration.py +++ b/rpython/jit/backend/llsupport/test/test_gc_integration.py @@ -690,6 +690,36 @@ item = rffi.cast(lltype.Ptr(S), frame.jf_frame[gcmap[0]]) assert item == new_items[2] +def test_shadowstack_cond_call(self): +cpu = self.cpu +cpu.gc_ll_descr.init_nursery(100) +cpu.setup_once() + +def check(i, frame): +frame = lltype.cast_opaque_ptr(JITFRAMEPTR, frame) +assert frame.jf_gcmap[0] # is not empty is good enough + +CHECK = lltype.FuncType([lltype.Signed, llmemory.GCREF], lltype.Void) +checkptr = llhelper(lltype.Ptr(CHECK), check) +checkdescr = cpu.calldescrof(CHECK, CHECK.ARGS, CHECK.RESULT, + EffectInfo.MOST_GENERAL) + +loop = self.parse( +[i0, p0] +p = force_token() +cond_call(i0, ConstClass(funcptr), i0, p, descr=calldescr) +guard_true(i0, descr=faildescr) [p0] +, namespace={ +'faildescr': BasicFailDescr(), +'funcptr': checkptr, +'calldescr': checkdescr, +}) +token = JitCellToken() +cpu.compile_loop(loop.inputargs, loop.operations, token) +S = self.S +s = lltype.malloc(S) +cpu.execute_token(token, 1, s) + def test_shadowstack_collecting_call_float(self): cpu = self.cpu diff --git a/rpython/jit/backend/x86/assembler.py b/rpython/jit/backend/x86/assembler.py --- a/rpython/jit/backend/x86/assembler.py +++ b/rpython/jit/backend/x86/assembler.py @@ -2145,12 +2145,13 @@ self.mc.TEST(cond_loc, cond_loc) self.mc.J_il8(rx86.Conditions['Z'], 0) # patched later jmp_adr = self.mc.get_relative_pos() -self.push_gcmap(self.mc, gcmap, mov=True) +self.push_gcmap(self.mc, gcmap, store=True) self.mc.CALL(imm(self.cond_call_slowpath[len(arglocs)])) +self.pop_gcmap(self.mc) # never any result value offset = self.mc.get_relative_pos() - jmp_adr assert 0 offset = 127 -self.mc.overwrite(jmp_adr-1, chr(offset)) +self.mc.overwrite(jmp_adr-1, chr(offset)) def malloc_cond(self, nursery_free_adr, nursery_top_adr, size, gcmap): assert size (WORD-1) == 0 # must be correctly aligned ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy fast-slowpath: finish cond_call for x86_64
Author: Maciej Fijalkowski fij...@gmail.com Branch: fast-slowpath Changeset: r65444:1c382497f8eb Date: 2013-07-17 18:04 +0200 http://bitbucket.org/pypy/pypy/changeset/1c382497f8eb/ Log:finish cond_call for x86_64 diff --git a/rpython/jit/backend/llsupport/assembler.py b/rpython/jit/backend/llsupport/assembler.py --- a/rpython/jit/backend/llsupport/assembler.py +++ b/rpython/jit/backend/llsupport/assembler.py @@ -106,7 +106,7 @@ kind='unicode') else: self.malloc_slowpath_unicode = None -self.cond_call_slowpath = [0, self._build_cond_call_slowpath(1)] +self.cond_call_slowpath = self._build_cond_call_slowpath() self._build_stack_check_slowpath() self._build_release_gil(gc_ll_descr.gcrootmap) diff --git a/rpython/jit/backend/x86/assembler.py b/rpython/jit/backend/x86/assembler.py --- a/rpython/jit/backend/x86/assembler.py +++ b/rpython/jit/backend/x86/assembler.py @@ -149,18 +149,22 @@ mc.RET() self._frame_realloc_slowpath = mc.materialize(self.cpu.asmmemmgr, []) -def _build_cond_call_slowpath(self, no_args): +def _build_cond_call_slowpath(self): This builds a general call slowpath, for whatever call happens to come. mc = codebuf.MachineCodeBlockWrapper() self._push_all_regs_to_frame(mc, [], self.cpu.supports_floats, callee_only=False) -assert no_args == 1 +gcrootmap = self.cpu.gc_ll_descr.gcrootmap +if gcrootmap and gcrootmap.is_shadow_stack: +self._call_header_shadowstack(mc, gcrootmap) mc.SUB(esp, imm(WORD)) # first arg is always in edi mc.CALL(eax) mc.ADD(esp, imm(WORD)) +if gcrootmap and gcrootmap.is_shadow_stack: +self._call_footer_shadowstack(mc, gcrootmap) self._pop_all_regs_from_frame(mc, [], self.cpu.supports_floats, callee_only=False) mc.RET() @@ -718,7 +722,7 @@ gcrootmap = self.cpu.gc_ll_descr.gcrootmap if gcrootmap and gcrootmap.is_shadow_stack: -self._call_header_shadowstack(gcrootmap) +self._call_header_shadowstack(self.mc, gcrootmap) def _call_header_with_stack_check(self): self._call_header() @@ -741,7 +745,7 @@ def _call_footer(self): gcrootmap = self.cpu.gc_ll_descr.gcrootmap if gcrootmap and gcrootmap.is_shadow_stack: -self._call_footer_shadowstack(gcrootmap) +self._call_footer_shadowstack(self.mc, gcrootmap) for i in range(len(self.cpu.CALLEE_SAVE_REGISTERS)-1, -1, -1): self.mc.MOV_rs(self.cpu.CALLEE_SAVE_REGISTERS[i].value, @@ -762,23 +766,23 @@ # return rst -def _call_header_shadowstack(self, gcrootmap): -rst = self._load_shadowstack_top_in_ebx(self.mc, gcrootmap) -self.mc.MOV_mr((ebx.value, 0), ebp.value) # MOV [ebx], ebp -self.mc.ADD_ri(ebx.value, WORD) +def _call_header_shadowstack(self, mc, gcrootmap): +rst = self._load_shadowstack_top_in_ebx(mc, gcrootmap) +mc.MOV_mr((ebx.value, 0), ebp.value) # MOV [ebx], ebp +mc.ADD_ri(ebx.value, WORD) if rx86.fits_in_32bits(rst): -self.mc.MOV_jr(rst, ebx.value)# MOV [rootstacktop], ebx +mc.MOV_jr(rst, ebx.value)# MOV [rootstacktop], ebx else: -self.mc.MOV_mr((X86_64_SCRATCH_REG.value, 0), - ebx.value) # MOV [r11], ebx +mc.MOV_mr((X86_64_SCRATCH_REG.value, 0), + ebx.value) # MOV [r11], ebx -def _call_footer_shadowstack(self, gcrootmap): +def _call_footer_shadowstack(self, mc, gcrootmap): rst = gcrootmap.get_root_stack_top_addr() if rx86.fits_in_32bits(rst): -self.mc.SUB_ji8(rst, WORD) # SUB [rootstacktop], WORD +mc.SUB_ji8(rst, WORD) # SUB [rootstacktop], WORD else: -self.mc.MOV_ri(ebx.value, rst) # MOV ebx, rootstacktop -self.mc.SUB_mi8((ebx.value, 0), WORD) # SUB [ebx], WORD +mc.MOV_ri(ebx.value, rst) # MOV ebx, rootstacktop +mc.SUB_mi8((ebx.value, 0), WORD) # SUB [ebx], WORD def redirect_call_assembler(self, oldlooptoken, newlooptoken): # some minimal sanity checking @@ -2146,7 +2150,7 @@ self.mc.J_il8(rx86.Conditions['Z'], 0) # patched later jmp_adr = self.mc.get_relative_pos() self.push_gcmap(self.mc, gcmap, store=True) -self.mc.CALL(imm(self.cond_call_slowpath[len(arglocs)])) +self.mc.CALL(imm(self.cond_call_slowpath)) self.pop_gcmap(self.mc) # never any result value offset = self.mc.get_relative_pos() - jmp_adr ___ pypy-commit mailing list pypy-commit@python.org
[pypy-commit] pypy ndarray-subtype: test, fix call2 for array, non-array
Author: Matti Picus matti.pi...@gmail.com Branch: ndarray-subtype Changeset: r65447:cf08f4e9b3d8 Date: 2013-07-17 20:17 +0300 http://bitbucket.org/pypy/pypy/changeset/cf08f4e9b3d8/ Log:test, fix call2 for array, non-array diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py --- a/pypy/module/micronumpy/loop.py +++ b/pypy/module/micronumpy/loop.py @@ -40,7 +40,6 @@ rhs_type = space.type(w_rhs.base) rhs_for_subtype = w_rhs.base if space.is_w(lhs_type, w_ndarray) and not space.is_w(rhs_type, w_ndarray): -w_lhs, w_rhs = w_rhs, w_lhs lhs_for_subtype = rhs_for_subtype # TODO handle __array_priorities__ and maybe flip the order diff --git a/pypy/module/micronumpy/test/test_subtype.py b/pypy/module/micronumpy/test/test_subtype.py --- a/pypy/module/micronumpy/test/test_subtype.py +++ b/pypy/module/micronumpy/test/test_subtype.py @@ -199,6 +199,9 @@ assert isinstance(c, self.SubType) c = a + b assert isinstance(c, self.NoNew) +d = range(12) +e = a - d +assert isinstance(e, self.NoNew) def test_sub_call1(self): from numpypy import array, sqrt ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ndarray-subtype: fixes from review (amaury)
Author: Matti Picus matti.pi...@gmail.com Branch: ndarray-subtype Changeset: r65446:416b328ff61a Date: 2013-07-17 20:06 +0300 http://bitbucket.org/pypy/pypy/changeset/416b328ff61a/ Log:fixes from review (amaury) diff --git a/pypy/module/micronumpy/base.py b/pypy/module/micronumpy/base.py --- a/pypy/module/micronumpy/base.py +++ b/pypy/module/micronumpy/base.py @@ -33,7 +33,7 @@ self.implementation = implementation @staticmethod -def from_shape(space, shape, dtype, order='C', w_subtype=None): +def from_shape(space, shape, dtype, order='C', w_instance=None): from pypy.module.micronumpy.arrayimpl import concrete, scalar if not shape: @@ -42,12 +42,8 @@ strides, backstrides = calc_strides(shape, dtype.base, order) impl = concrete.ConcreteArray(shape, dtype.base, order, strides, backstrides) -if w_subtype: -w_ret = space.allocate_instance(W_NDimArray, space.type(w_subtype)) -W_NDimArray.__init__(w_ret, impl) -assert isinstance(w_ret, W_NDimArray) -space.call_method(w_ret, '__array_finalize__', w_subtype) -return w_ret +if w_instance: +return wrap_impl(space, space.type(w_instance), w_instance, impl) return W_NDimArray(impl) @staticmethod diff --git a/pypy/module/micronumpy/interp_arrayops.py b/pypy/module/micronumpy/interp_arrayops.py --- a/pypy/module/micronumpy/interp_arrayops.py +++ b/pypy/module/micronumpy/interp_arrayops.py @@ -151,7 +151,7 @@ arr = arr.descr_flatten(space) orig_size = arr.get_shape()[0] shape = [arr.get_shape()[0] * repeats] -w_res = W_NDimArray.from_shape(space, shape, arr.get_dtype(), w_subtype=arr) +w_res = W_NDimArray.from_shape(space, shape, arr.get_dtype(), w_instance=arr) for i in range(repeats): Chunks([Chunk(i, shape[0] - repeats + i, repeats, orig_size)]).apply(space, w_res).implementation.setslice(space, arr) @@ -161,7 +161,7 @@ chunks = [Chunk(0, i, 1, i) for i in shape] orig_size = shape[axis] shape[axis] *= repeats -w_res = W_NDimArray.from_shape(space, shape, arr.get_dtype(), w_subtype=arr) +w_res = W_NDimArray.from_shape(space, shape, arr.get_dtype(), w_instance=arr) for i in range(repeats): chunks[axis] = Chunk(i, shape[axis] - repeats + i, repeats, orig_size) diff --git a/pypy/module/micronumpy/interp_flatiter.py b/pypy/module/micronumpy/interp_flatiter.py --- a/pypy/module/micronumpy/interp_flatiter.py +++ b/pypy/module/micronumpy/interp_flatiter.py @@ -65,7 +65,7 @@ if length == 1: return base_iter.getitem() res = W_NDimArray.from_shape(space, [length], base.get_dtype(), - base.get_order(), w_subtype=base) + base.get_order(), w_instance=base) return loop.flatiter_getitem(res, base_iter, step) def descr_setitem(self, space, w_idx, w_value): diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -85,7 +85,7 @@ res_shape = [size] + self.get_shape()[1:] else: res_shape = [size] -w_res = W_NDimArray.from_shape(space, res_shape, self.get_dtype(), w_subtype=self) +w_res = W_NDimArray.from_shape(space, res_shape, self.get_dtype(), w_instance=self) return loop.getitem_filter(w_res, self, arr) def setitem_filter(self, space, idx, val): @@ -148,7 +148,7 @@ return chunks.apply(space, self) shape = res_shape + self.get_shape()[len(indexes):] w_res = W_NDimArray.from_shape(space, shape, self.get_dtype(), - self.get_order(), w_subtype=self) + self.get_order(), w_instance=self) if not w_res.get_size(): return w_res return loop.getitem_array_int(space, self, w_res, iter_shape, indexes, @@ -482,7 +482,7 @@ loop.byteswap(self.implementation, self.implementation) return self else: -w_res = W_NDimArray.from_shape(space, self.get_shape(), self.get_dtype(), w_subtype=self) +w_res = W_NDimArray.from_shape(space, self.get_shape(), self.get_dtype(), w_instance=self) loop.byteswap(self.implementation, w_res.implementation) return w_res @@ -778,7 +778,7 @@ return W_NDimArray.new_scalar(space, dtype, space.wrap(0)) # Do the dims match? out_shape, other_critical_dim = match_dot_shapes(space, self, other) -w_res = W_NDimArray.from_shape(space, out_shape, dtype, w_subtype=self) +w_res =
[pypy-commit] pypy ndarray-subtype: optimization (amaury)
Author: Matti Picus matti.pi...@gmail.com Branch: ndarray-subtype Changeset: r65445:4b08bbbfbd22 Date: 2013-07-17 19:42 +0300 http://bitbucket.org/pypy/pypy/changeset/4b08bbbfbd22/ Log:optimization (amaury) diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/micronumpy/interp_ufuncs.py --- a/pypy/module/micronumpy/interp_ufuncs.py +++ b/pypy/module/micronumpy/interp_ufuncs.py @@ -539,7 +539,7 @@ if current_guess is complex_type: return complex_type if space.isinstance_w(w_obj, space.w_float): -return interp_dtype.get_dtype_cache(space).w_float64dtype +return float_type elif space.isinstance_w(w_obj, space.w_slice): return long_dtype raise operationerrfmt(space.w_NotImplementedError, ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc weakref: Weakrefs in major collections. Tests are a bit light here given that there
Author: Armin Rigo ar...@tunes.org Branch: weakref Changeset: r407:69291ba64476 Date: 2013-07-17 19:49 +0200 http://bitbucket.org/pypy/stmgc/changeset/69291ba64476/ Log:Weakrefs in major collections. Tests are a bit light here given that there are a lot of possible corner cases. diff --git a/c4/gcpage.c b/c4/gcpage.c --- a/c4/gcpage.c +++ b/c4/gcpage.c @@ -222,11 +222,13 @@ if (!(id_copy-h_tid GCFLAG_PREBUILT_ORIGINAL)) { id_copy-h_tid = ~GCFLAG_PUBLIC_TO_PRIVATE; /* see fix_outdated() */ -id_copy-h_tid |= GCFLAG_VISITED; +if (!(id_copy-h_tid GCFLAG_VISITED)) { +id_copy-h_tid |= GCFLAG_VISITED; -/* XXX: may not always need tracing? */ -if (!(id_copy-h_tid GCFLAG_STUB)) -gcptrlist_insert(objects_to_trace, id_copy); +/* XXX: may not always need tracing? */ +if (!(id_copy-h_tid GCFLAG_STUB)) +gcptrlist_insert(objects_to_trace, id_copy); +} } else { /* prebuilt originals won't get collected anyway @@ -236,6 +238,14 @@ } } +static void visit(gcptr *pobj); + +gcptr stmgcpage_visit(gcptr obj) +{ +visit(obj); +return obj; +} + static void visit(gcptr *pobj) { gcptr obj = *pobj; @@ -275,10 +285,10 @@ keep_original_alive(prev_obj); assert(*pobj == prev_obj); -gcptr obj1 = obj; -visit(obj1); /* recursion, but should be only once */ +/* recursion, but should be only once */ +obj = stmgcpage_visit(obj); assert(prev_obj-h_tid GCFLAG_STUB); -prev_obj-h_revision = ((revision_t)obj1) | 2; +prev_obj-h_revision = ((revision_t)obj) | 2; return; } } @@ -649,8 +659,6 @@ int i; wlog_t *item; -stm_invalidate_old_weakrefs(gcp); - for (i = 1; i GC_SMALL_REQUESTS; i++) { sweep_pages(gcp, i); } @@ -777,9 +785,13 @@ assert(gcptrlist_size(objects_to_trace) == 0); mark_prebuilt_roots(); mark_all_stack_roots(); -visit_all_objects(); +do { +visit_all_objects(); +stm_visit_old_weakrefs(); +} while (gcptrlist_size(objects_to_trace) != 0); gcptrlist_delete(objects_to_trace); clean_up_lists_of_read_objects_and_fix_outdated_flags(); +stm_clean_old_weakrefs(); mc_total_in_use = mc_total_reserved = 0; free_all_unused_local_pages(); diff --git a/c4/gcpage.h b/c4/gcpage.h --- a/c4/gcpage.h +++ b/c4/gcpage.h @@ -84,6 +84,7 @@ void stmgcpage_add_prebuilt_root(gcptr obj); void stmgcpage_possibly_major_collect(int force); long stmgcpage_count(int quantity); +gcptr stmgcpage_visit(gcptr); extern struct GcPtrList stm_prebuilt_gcroots; diff --git a/c4/test/test_weakref.py b/c4/test/test_weakref.py --- a/c4/test/test_weakref.py +++ b/c4/test/test_weakref.py @@ -115,6 +115,6 @@ major_collect() p2b = lib.stm_pop_root() p1 = lib.stm_pop_root() -assert lib.rawgetptr(p1, 0) == p2 +assert lib.rawgetptr(p1, 0) == p2b assert p2b != p2 -assert lib.rawgetlong(p2b, 0) == 912809218 +assert lib.getlong(p2b, 0) == 912809218 diff --git a/c4/weakref.c b/c4/weakref.c --- a/c4/weakref.c +++ b/c4/weakref.c @@ -64,29 +64,140 @@ /* Major collection */ -void stm_invalidate_old_weakrefs(struct tx_public_descriptor *gcp) +static _Bool is_partially_visited(gcptr obj) { -/* walk over list of objects that contain weakrefs. If the - object it references does not survive, invalidate the weakref */ -long i; +/* Based on gcpage.c:visit(). Check the code here if we simplify + visit(). Returns True or False depending on whether we find any + version of 'obj' to be VISITED or not. +*/ + restart: +if (obj-h_tid GCFLAG_VISITED) +return 1; + +if (obj-h_revision 1) { +assert(!(obj-h_tid GCFLAG_PRIVATE_FROM_PROTECTED)); +assert(!(obj-h_tid GCFLAG_STUB)); +return 0; +} +else if (obj-h_tid GCFLAG_PUBLIC) { +/* h_revision is a ptr: we have a more recent version */ +if (!(obj-h_revision 2)) { +/* go visit the more recent version */ +obj = (gcptr)obj-h_revision; +} +else { +/* it's a stub */ +assert(obj-h_tid GCFLAG_STUB); +obj = (gcptr)(obj-h_revision - 2); +} +goto restart; +} +else { +assert(obj-h_tid GCFLAG_PRIVATE_FROM_PROTECTED); +gcptr B = (gcptr)obj-h_revision; +assert(B-h_tid (GCFLAG_PUBLIC | GCFLAG_BACKUP_COPY)); +if (B-h_tid GCFLAG_VISITED) +return 1; +assert(!(obj-h_tid GCFLAG_STUB)); +assert(!(B-h_tid GCFLAG_STUB)); + +if (IS_POINTER(B-h_revision)) { +assert(B-h_tid
[pypy-commit] stmgc weakref: In-progress: move the weakref code in its own file, and start writing
Author: Armin Rigo ar...@tunes.org Branch: weakref Changeset: r406:698e0c3f3413 Date: 2013-07-17 18:47 +0200 http://bitbucket.org/pypy/stmgc/changeset/698e0c3f3413/ Log:In-progress: move the weakref code in its own file, and start writing logic for major collections. diff --git a/c4/Makefile b/c4/Makefile --- a/c4/Makefile +++ b/c4/Makefile @@ -16,10 +16,10 @@ H_FILES = atomic_ops.h stmgc.h stmimpl.h \ et.h lists.h steal.h nursery.h gcpage.h \ - stmsync.h extra.h dbgmem.h fprintcolor.h + stmsync.h extra.h weakref.h dbgmem.h fprintcolor.h C_FILES = et.c lists.c steal.c nursery.c gcpage.c \ - stmsync.c extra.c dbgmem.c fprintcolor.c + stmsync.c extra.c weakref.c dbgmem.c fprintcolor.c DEBUG = -g -DGC_NURSERY=0x1 -D_GC_DEBUG=1 -DDUMP_EXTRA=1 -D_GC_DEBUGPRINTS=1 diff --git a/c4/gcpage.c b/c4/gcpage.c --- a/c4/gcpage.c +++ b/c4/gcpage.c @@ -649,6 +649,8 @@ int i; wlog_t *item; +stm_invalidate_old_weakrefs(gcp); + for (i = 1; i GC_SMALL_REQUESTS; i++) { sweep_pages(gcp, i); } diff --git a/c4/gcpage.h b/c4/gcpage.h --- a/c4/gcpage.h +++ b/c4/gcpage.h @@ -45,7 +45,8 @@ /* These fields are in tx_public_descriptor rather than tx_descriptor. The indirection allows us to keep around the lists of pages even - after the thread finishes, until the next major collection. + after the thread finishes. Such a zombie tx_public_descriptor + is reused by the next thread that starts. */ #define GCPAGE_FIELDS_DECL \ /* The array 'pages_for_size' contains GC_SMALL_REQUESTS\ @@ -65,7 +66,10 @@ /* A set of all non-small objects (outside the nursery).\ We could also have a single global set, but this avoids \ locking in stmgcpage_malloc/free. */ \ -struct G2L nonsmall_objects; +struct G2L nonsmall_objects;\ +\ +/* Weakref support */ \ +struct GcPtrList old_weakrefs; #define LOCAL_GCPAGES() (thread_descriptor-public_descriptor) diff --git a/c4/nursery.c b/c4/nursery.c --- a/c4/nursery.c +++ b/c4/nursery.c @@ -101,15 +101,6 @@ return P; } -gcptr stm_weakref_allocate(size_t size, unsigned long tid, gcptr obj) -{ -gcptr weakref = stm_allocate(size, tid); -assert(stmgc_size(weakref) == size); -WEAKREF_PTR(weakref, size) = obj; -gcptrlist_insert(thread_descriptor-young_weakrefs, weakref); -return weakref; -} - gcptr stmgc_duplicate(gcptr P) { size_t size = stmgc_size(P); @@ -439,27 +430,6 @@ fxcache_clear(d-recent_reads_cache); } -static void move_young_weakrefs(struct tx_descriptor *d) -{ -while (gcptrlist_size(d-young_weakrefs) 0) { -gcptr weakref = gcptrlist_pop(d-young_weakrefs); -if (!(weakref-h_tid GCFLAG_NURSERY_MOVED)) -continue; /* the weakref itself dies */ - -weakref = (gcptr)weakref-h_revision; -size_t size = stmgc_size(weakref); -gcptr obj = WEAKREF_PTR(weakref, size); -if (!is_in_nursery(d, obj)) -continue; /* the pointer does not change */ - -if (obj-h_tid GCFLAG_NURSERY_MOVED) -obj = obj-h_revision; -else -obj = NULL; -WEAKREF_PTR(weakref, size) = obj; -} -} - static void setup_minor_collect(struct tx_descriptor *d) { spinlock_acquire(d-public_descriptor-collection_lock, 'M'); /*minor*/ @@ -507,7 +477,7 @@ surviving young-but-outside-the-nursery objects have been flagged with GCFLAG_OLD */ -move_young_weakrefs(d); +stm_move_young_weakrefs(d); teardown_minor_collect(d); assert(!stm_has_got_any_lock(d)); diff --git a/c4/nursery.h b/c4/nursery.h --- a/c4/nursery.h +++ b/c4/nursery.h @@ -68,7 +68,4 @@ void stmgc_trace(gcptr, void visit(gcptr *)); void stmgc_minor_collect_soon(void); -#define WEAKREF_PTR(wr, sz) (*(gcptr *)(((char *)(wr)) + (sz) - WORD)) - - #endif diff --git a/c4/stmgc.c b/c4/stmgc.c --- a/c4/stmgc.c +++ b/c4/stmgc.c @@ -10,5 +10,6 @@ #include gcpage.c #include stmsync.c #include extra.c +#include weakref.c #include dbgmem.c #include fprintcolor.c diff --git a/c4/stmimpl.h b/c4/stmimpl.h --- a/c4/stmimpl.h +++ b/c4/stmimpl.h @@ -36,5 +36,6 @@ #include steal.h #include stmsync.h #include extra.h +#include weakref.h #endif diff --git a/c4/test/support.py b/c4/test/support.py --- a/c4/test/support.py +++ b/c4/test/support.py @@ -11,11 +11,11 @@ header_files = [os.path.join(parent_dir, _n) for _n in et.h lists.h steal.h nursery.h gcpage.h -stmsync.h extra.h dbgmem.h fprintcolor.h +stmsync.h extra.h weakref.h dbgmem.h fprintcolor.h stmgc.h stmimpl.h atomic_ops.h.split()]
[pypy-commit] buildbot numpy-tests: add builder to master
Author: Matti Picus matti.pi...@gmail.com Branch: numpy-tests Changeset: r830:b37fcd808249 Date: 2013-07-17 23:19 +0300 http://bitbucket.org/pypy/buildbot/changeset/b37fcd808249/ Log:add builder to master diff --git a/bot2/pypybuildbot/builds.py b/bot2/pypybuildbot/builds.py --- a/bot2/pypybuildbot/builds.py +++ b/bot2/pypybuildbot/builds.py @@ -783,23 +783,30 @@ self.addStep(ShellCmd( description=install nose, -command=['download/bin/pip', 'install','nose'], +command=['install/bin/pip', 'install','nose'], workdir='pypy-c')) # obtain a pypy-compatible branch of numpy numpy_url = 'https://github.com/mattip/numpy' numpy_pypy_branch = 'pypy' -update_git(platform, factory, numpy_url, 'numpy_src', use_branch=True, +update_git(platform, self, numpy_url, 'numpy_src', use_branch=True, force_branch=numpy_pypy_branch) +if os.path.exists('pypy_c/download/lib_pypy/numpy.py'): +self.addStep(ShellCmd( +description=delete lib_pypy/numpy.*, +command=['rm', 'download/lib_pypy/numpy.*'], +workdir='pypy-c')) + + self.addStep(ShellCmd( description=install numpy, -command=['download/bin/python', 'setup.py','install'], +command=['install/bin/python', 'setup.py','install'], workdir='numpy_src')) self.addStep(ShellCmd( description=test numpy, -command=['download/bin/python', '-c', 'import numpy;numpy.test()', +command=['install/bin/python', '-c', 'import numpy;numpy.test()', ' pytest-numpy.log','21'], logfiles={'pytestLog': 'pytest-numpy.log'}, timeout=4000, diff --git a/bot2/pypybuildbot/master.py b/bot2/pypybuildbot/master.py --- a/bot2/pypybuildbot/master.py +++ b/bot2/pypybuildbot/master.py @@ -151,6 +151,8 @@ pypyJITBenchmarkFactory64_tannit = pypybuilds.JITBenchmark(platform='linux64', postfix='-64') +pypyNumpyCompatability = pypybuilds.NativeNumpyTests() + # LINUX32 = own-linux-x86-32 @@ -182,7 +184,7 @@ JITBENCH64 = jit-benchmark-linux-x86-64 JITBENCH64_2 = 'jit-benchmark-linux-x86-64-2' CPYTHON_64 = cpython-2-benchmark-x86-64 - +NUMPY_64 = numpy-compatability-linux-x86-64 extra_opts = {'xerxes': {'keepalive_interval': 15}, 'aurora': {'max_builds': 1}, @@ -393,6 +395,12 @@ 'factory': pypyOwnTestFactoryIndiana, 'category': 'openindiana32', }, + {'name': NUMPY_64, + 'slavenames': ['numpy64'], + 'builddir': NUMPY_64, + 'factory': pypyNumpyCompatability, + 'category': 'numpy', + }, ] + ARM.builders, # http://readthedocs.org/docs/buildbot/en/latest/tour.html#debugging-with-manhole ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: compute mindigits based on the base, instead of taking a worst-case number
Author: Carl Friedrich Bolz cfb...@gmx.de Branch: Changeset: r65451:02e7af864e43 Date: 2013-07-17 21:37 +0200 http://bitbucket.org/pypy/pypy/changeset/02e7af864e43/ Log:compute mindigits based on the base, instead of taking a worst-case number diff --git a/rpython/rlib/rbigint.py b/rpython/rlib/rbigint.py --- a/rpython/rlib/rbigint.py +++ b/rpython/rlib/rbigint.py @@ -2060,21 +2060,35 @@ _FORMAT_MINDIGITS = 5 # 36 ** 5 fits in 32 bits, there may be a better choice for this + class _PartsCache(object): def __init__(self): # 36 - 3, because bases 0, 1 make no sense # and 2 is handled differently -self.parts_cache = [None] * 33 +self.parts_cache = [None] * 34 +self.mindigits = [0] * 34 + +for i in range(34): +base = i + 3 +mindigits = 1 +while base ** mindigits sys.maxint: +mindigits += 1 +mindigits -= 1 +self.mindigits[i] = mindigits def get_cached_parts(self, base): -res = self.parts_cache[base - 3] +index = base - 3 +res = self.parts_cache[index] if res is None: rbase = rbigint.fromint(base) -part = rbase.pow(rbigint.fromint(_FORMAT_MINDIGITS)) +part = rbase.pow(rbigint.fromint(self.mindigits[index])) res = [part] self.parts_cache[base - 3] = res return res +def get_mindigits(self, base): +return self.mindigits[base - 3] + _parts_cache = _PartsCache() def _format_int(val, digits): @@ -2087,7 +2101,7 @@ return .join(out) -def _format_recursive(x, i, output, pts, digits, size_prefix): +def _format_recursive(x, i, output, pts, digits, size_prefix, mindigits): # bottomed out with min_digit sized pieces # use str of ints if i 0: @@ -2098,12 +2112,12 @@ output.append(s) else: s = _format_int(x.toint(), digits) -output.append_multiple_char(digits[0], _FORMAT_MINDIGITS - len(s)) +output.append_multiple_char(digits[0], mindigits - len(s)) output.append(s) else: top, bot = x.divmod(pts[i]) # split the number -_format_recursive(top, i-1, output, pts, digits, size_prefix) -_format_recursive(bot, i-1, output, pts, digits, size_prefix) +_format_recursive(top, i-1, output, pts, digits, size_prefix, mindigits) +_format_recursive(bot, i-1, output, pts, digits, size_prefix, mindigits) def _format(x, digits, prefix='', suffix=''): if x.sign == 0: @@ -2119,7 +2133,8 @@ two = rbigint.fromint(2) pts = _parts_cache.get_cached_parts(base) -stringsize = _FORMAT_MINDIGITS +mindigits = _parts_cache.get_mindigits(base) +stringsize = mindigits startindex = 0 for startindex, part in enumerate(pts): if not part.lt(x): @@ -2140,7 +2155,7 @@ if negative: output.append('-') output.append(prefix) -_format_recursive(x, startindex, output, pts, digits, output.getlength()) +_format_recursive(x, startindex, output, pts, digits, output.getlength(), mindigits) output.append(suffix) return output.build() ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: somewhat annoying hack: if digits are the default base 10 ones, use a
Author: Carl Friedrich Bolz cfb...@gmx.de Branch: Changeset: r65452:dee9afbcb403 Date: 2013-07-17 21:45 +0200 http://bitbucket.org/pypy/pypy/changeset/dee9afbcb403/ Log:somewhat annoying hack: if digits are the default base 10 ones, use a specialized recursive function that calls the builtin RPython str method. Helps a lot, though. diff --git a/rpython/rlib/rbigint.py b/rpython/rlib/rbigint.py --- a/rpython/rlib/rbigint.py +++ b/rpython/rlib/rbigint.py @@ -2091,7 +2091,7 @@ _parts_cache = _PartsCache() -def _format_int(val, digits): +def _format_int_general(val, digits): base = len(digits) out = [] while val: @@ -2100,8 +2100,11 @@ out.reverse() return .join(out) +def _format_int10(val, digits): +return str(val) -def _format_recursive(x, i, output, pts, digits, size_prefix, mindigits): +@specialize.arg(7) +def _format_recursive(x, i, output, pts, digits, size_prefix, mindigits, _format_int): # bottomed out with min_digit sized pieces # use str of ints if i 0: @@ -2116,8 +2119,8 @@ output.append(s) else: top, bot = x.divmod(pts[i]) # split the number -_format_recursive(top, i-1, output, pts, digits, size_prefix, mindigits) -_format_recursive(bot, i-1, output, pts, digits, size_prefix, mindigits) +_format_recursive(top, i-1, output, pts, digits, size_prefix, mindigits, _format_int) +_format_recursive(bot, i-1, output, pts, digits, size_prefix, mindigits, _format_int) def _format(x, digits, prefix='', suffix=''): if x.sign == 0: @@ -2155,7 +2158,14 @@ if negative: output.append('-') output.append(prefix) -_format_recursive(x, startindex, output, pts, digits, output.getlength(), mindigits) +if digits == BASE10: +_format_recursive( +x, startindex, output, pts, digits, output.getlength(), mindigits, +_format_int10) +else: +_format_recursive( +x, startindex, output, pts, digits, output.getlength(), mindigits, +_format_int_general) output.append(suffix) return output.build() ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: woops, fix test
Author: Carl Friedrich Bolz cfb...@gmx.de Branch: Changeset: r65450:0b3500b8e331 Date: 2013-07-17 21:27 +0200 http://bitbucket.org/pypy/pypy/changeset/0b3500b8e331/ Log:woops, fix test 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 @@ -518,9 +518,9 @@ def test_format_caching(self): big = rbigint.fromlong(2 ** 1000) -rbigint.pow = None res1 = big.str() oldpow = rbigint.__dict__['pow'] +rbigint.pow = None # make sure pow is not used the second time try: res2 = big.str() ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: make small str(small long) much faster by caching the powers of ten needed
Author: Carl Friedrich Bolz cfb...@gmx.de Branch: Changeset: r65448:7ceb58dbdc24 Date: 2013-07-17 20:24 +0200 http://bitbucket.org/pypy/pypy/changeset/7ceb58dbdc24/ Log:make small str(small long) much faster by caching the powers of ten needed diff --git a/rpython/rlib/rbigint.py b/rpython/rlib/rbigint.py --- a/rpython/rlib/rbigint.py +++ b/rpython/rlib/rbigint.py @@ -2052,6 +2052,23 @@ _FORMAT_MINDIGITS = 5 # 36 ** 5 fits in 32 bits, there may be a better choice for this +class _PartsCache(object): +def __init__(self): +# 36 - 3, because bases 0, 1 make no sense +# and 2 is handled differently +self.parts_cache = [None] * 33 + +def get_cached_parts(self, base): +res = self.parts_cache[base - 3] +if res is None: +rbase = rbigint.fromint(base) +part = rbase.pow(rbigint.fromint(_FORMAT_MINDIGITS)) +res = [part] +self.parts_cache[base - 3] = res +return res + +_parts_cache = _PartsCache() + def _format_int(val, digits): base = len(digits) out = [] @@ -2068,9 +2085,7 @@ if i 0: # this checks whether any digit has been appended yet if output.getlength() == size_prefix: -if x.sign == 0: -pass -else: +if x.sign != 0: s = _format_int(x.toint(), digits) output.append(s) else: @@ -2095,22 +2110,34 @@ rbase = rbigint.fromint(base) two = rbigint.fromint(2) -pts = [rbase.pow(rbigint.fromint(_FORMAT_MINDIGITS))] +pts = _parts_cache.get_cached_parts(base) stringsize = _FORMAT_MINDIGITS -while pts[-1].lt(x): -pts.append(pts[-1].pow(two)) -stringsize *= 2 -pts.pop() # remove first base**2**i greater than x +startindex = 0 +for startindex, part in enumerate(pts): +if not part.lt(x): +break +stringsize *= 2 # XXX can this overflow on 32 bit? +else: +# not enough parts computed yet +while pts[-1].lt(x): +pts.append(pts[-1].pow(two)) +stringsize *= 2 + +startindex = len(pts) - 1 + +# remove first base**2**i greater than x +startindex -= 1 output = StringBuilder(stringsize) if negative: output.append('-') output.append(prefix) -_format_recursive(x, len(pts)-1, output, pts, digits, output.getlength()) +_format_recursive(x, startindex, output, pts, digits, output.getlength()) output.append(suffix) return output.build() + def _bitwise(a, op, b): # '', '|', '^' Bitwise and/or/xor operations 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 @@ -515,7 +515,19 @@ assert x.format('.!') == ( '-!!!..!!..!.!!.!..!...!...!!!!') assert x.format('abcdefghijkl', '', '') == '-cakdkgdijffjf' - + +def test_format_caching(self): +big = rbigint.fromlong(2 ** 1000) +rbigint.pow = None +res1 = big.str() +oldpow = rbigint.__dict__['pow'] +# make sure pow is not used the second time +try: +res2 = big.str() +assert res2 == res1 +finally: +rbigint.pow = oldpow + def test_overzelous_assertion(self): a = rbigint.fromlong(-11) b = rbigint.fromlong(-13000) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: use str if fitting into ints
Author: Carl Friedrich Bolz cfb...@gmx.de Branch: Changeset: r65449:53e2a91724cf Date: 2013-07-17 20:45 +0200 http://bitbucket.org/pypy/pypy/changeset/53e2a91724cf/ Log:use str if fitting into ints diff --git a/rpython/rlib/rbigint.py b/rpython/rlib/rbigint.py --- a/rpython/rlib/rbigint.py +++ b/rpython/rlib/rbigint.py @@ -454,11 +454,19 @@ @jit.elidable def repr(self): -return self.format(BASE10, suffix=L) +try: +x = self.toint() +except OverflowError: +return self.format(BASE10, suffix=L) +return str(x) + L @jit.elidable def str(self): -return self.format(BASE10) +try: +x = self.toint() +except OverflowError: +return self.format(BASE10) +return str(x) @jit.elidable def eq(self, other): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy jit-threshold-hooks: try to please the annotator
Author: Maciej Fijalkowski fij...@gmail.com Branch: jit-threshold-hooks Changeset: r65453:845e217b0aea Date: 2013-07-17 23:43 +0200 http://bitbucket.org/pypy/pypy/changeset/845e217b0aea/ Log:try to please the annotator diff --git a/pypy/module/pypyjit/interp_jit.py b/pypy/module/pypyjit/interp_jit.py --- a/pypy/module/pypyjit/interp_jit.py +++ b/pypy/module/pypyjit/interp_jit.py @@ -4,6 +4,7 @@ from rpython.tool.pairtype import extendabletype +from rpython.rtyper.annlowlevel import cast_base_ptr_to_instance from rpython.rlib.rarithmetic import r_uint, intmask from rpython.rlib.jit import JitDriver, hint, we_are_jitted, dont_look_inside from rpython.rlib import jit @@ -169,14 +170,18 @@ the JIT follow the call.''' return space.call_args(w_callable, __args__) -@unwrap_spec(w_code=PyCode, pos=int, value=int) +@unwrap_spec(w_code=PyCode, pos=r_uint, value=int) def set_local_threshold(space, w_code, pos, value): set_local_threshold(code, pos, value) For testing. Set the threshold for this code object at position pos at value given. -w_code.jit_cells[pos 1] = r_uint(value) # we ignore the profiling case +from rpython.jit.metainterp.warmstate import JitCell + +ref = w_code.jit_cells[pos 1] +jitcell = cast_base_ptr_to_instance(JitCell, ref) +jitcell.counter = value @unwrap_spec(w_code=PyCode, value=int) def set_local_bridge_threshold(space, w_code, value): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit