[pypy-commit] pypy reverse-debugger: A second place with hide/reveal
Author: Armin RigoBranch: reverse-debugger Changeset: r85510:0b7b98628f9f Date: 2016-07-02 00:19 +0200 http://bitbucket.org/pypy/pypy/changeset/0b7b98628f9f/ Log:A second place with hide/reveal diff --git a/pypy/module/_cffi_backend/ccallback.py b/pypy/module/_cffi_backend/ccallback.py --- a/pypy/module/_cffi_backend/ccallback.py +++ b/pypy/module/_cffi_backend/ccallback.py @@ -13,7 +13,7 @@ from pypy.module._cffi_backend.ctypefunc import SIZE_OF_FFI_ARG, W_CTypeFunc from pypy.module._cffi_backend.ctypeprim import W_CTypePrimitiveSigned from pypy.module._cffi_backend.ctypevoid import W_CTypeVoid -from pypy.module._cffi_backend.hide_reveal import hide_reveal +from pypy.module._cffi_backend.hide_reveal import hide_reveal1 BIG_ENDIAN = sys.byteorder == 'big' @@ -31,7 +31,7 @@ return cdata def reveal_callback(raw_ptr): -return hide_reveal().reveal_object(W_ExternPython, raw_ptr) +return hide_reveal1().reveal_object(W_ExternPython, raw_ptr) class Closure(object): @@ -91,7 +91,7 @@ return ctype def hide_object(self): -return hide_reveal().hide_object(self) +return hide_reveal1().hide_object(rffi.VOIDP, self) def _repr_extra(self): space = self.space diff --git a/pypy/module/_cffi_backend/handle.py b/pypy/module/_cffi_backend/handle.py --- a/pypy/module/_cffi_backend/handle.py +++ b/pypy/module/_cffi_backend/handle.py @@ -3,8 +3,9 @@ from pypy.interpreter.gateway import unwrap_spec from pypy.interpreter.baseobjspace import W_Root from pypy.module._cffi_backend import ctypeobj, ctypeptr, cdataobj +from pypy.module._cffi_backend.hide_reveal import hide_reveal2 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi -from rpython.rlib import rgc, objectmodel, jit +from rpython.rlib import objectmodel, jit # @@ -15,9 +16,7 @@ # we can cast the CCHARP back to a W_CDataHandle with reveal_gcref(). new_cdataobj = objectmodel.instantiate(cdataobj.W_CDataHandle, nonmovable=True) -gcref = rgc.cast_instance_to_gcref(new_cdataobj) -_cdata = rgc.hide_nonmovable_gcref(gcref) -_cdata = rffi.cast(rffi.CCHARP, _cdata) +_cdata = hide_reveal2().hide_object(rffi.CCHARP, new_cdataobj) cdataobj.W_CDataHandle.__init__(new_cdataobj, space, _cdata, w_ctype, w_x) return new_cdataobj @@ -43,11 +42,10 @@ @jit.dont_look_inside def _reveal(space, ptr): addr = rffi.cast(llmemory.Address, ptr) -gcref = rgc.reveal_gcref(addr) -if not gcref: +if not addr: raise oefmt(space.w_RuntimeError, "cannot use from_handle() on NULL pointer") -cd = rgc.try_cast_gcref_to_instance(cdataobj.W_CDataHandle, gcref) +cd = hide_reveal2().reveal_object(cdataobj.W_CDataHandle, addr) if cd is None: raise oefmt(space.w_SystemError, "ffi.from_handle(): dead or bogus object handle") diff --git a/pypy/module/_cffi_backend/hide_reveal.py b/pypy/module/_cffi_backend/hide_reveal.py --- a/pypy/module/_cffi_backend/hide_reveal.py +++ b/pypy/module/_cffi_backend/hide_reveal.py @@ -9,44 +9,58 @@ def __init__(self): class GlobGcrefs(RWeakListMixin): pass -self.glob_gcrefs = GlobGcrefs() -self.glob_gcrefs.initialize() +glob_gcrefs = GlobGcrefs() +glob_gcrefs.initialize() + +def hide_object(PTR, obj): +# XXX leaks if we call this function often on the same object +index = glob_gcrefs.add_handle(obj) +return rffi.cast(PTR, index + 1) + +def reveal_object(Class, addr): +index = rffi.cast(lltype.Signed, addr) - 1 +return glob_gcrefs.fetch_handle(index) + +self.hide_object = hide_object +self.reveal_object = reveal_object def _freeze_(self): return True -def hide_object(self, obj): -# XXX leaks if we call this function often on the same object -index = self.glob_gcrefs.add_handle(obj) -return rffi.cast(rffi.VOIDP, index) - -def reveal_object(self, Class, addr): -index = rffi.cast(lltype.Signed, addr) -return self.glob_gcrefs.fetch_handle(index) - class HideRevealCast: """Fast implementation of HideReveal: just a cast.""" +def __init__(self): + +def hide_object(PTR, obj): +gcref = rgc.cast_instance_to_gcref(obj) +raw = rgc.hide_nonmovable_gcref(gcref) +return rffi.cast(PTR, raw) + +def reveal_object(Class, raw_ptr): +addr = rffi.cast(llmemory.Address, raw_ptr) +gcref = rgc.reveal_gcref(addr) +return rgc.try_cast_gcref_to_instance(Class, gcref) + +self.hide_object = hide_object +self.reveal_object = reveal_object + def _freeze_(self): return True -def hide_object(self, obj): -gcref
[pypy-commit] pypy reverse-debugger: fix (port from stmgc-c8)
Author: Armin RigoBranch: reverse-debugger Changeset: r85507:2c199ada1854 Date: 2016-07-01 23:29 +0200 http://bitbucket.org/pypy/pypy/changeset/2c199ada1854/ Log:fix (port from stmgc-c8) diff --git a/rpython/rlib/rrawarray.py b/rpython/rlib/rrawarray.py --- a/rpython/rlib/rrawarray.py +++ b/rpython/rlib/rrawarray.py @@ -1,6 +1,6 @@ from rpython.rtyper.llannotation import lltype_to_annotation from rpython.rlib.objectmodel import specialize -from rpython.rlib import jit +from rpython.rlib import jit, rgc from rpython.rtyper.lltypesystem import lltype, llmemory from rpython.rtyper.extregistry import ExtRegistryEntry from rpython.tool.pairtype import pair @@ -50,6 +50,10 @@ @jit.dont_look_inside def ll_copy_list_to_raw_array(ll_list, dst_ptr): +if rgc.must_split_gc_address_space(): +for i in range(ll_list.ll_length()): +dst_ptr[i] = ll_list.ll_getitem_fast(i) +return # this code is delicate: we must ensure that there are no GC operations # around the call to raw_memcopy # @@ -64,9 +68,13 @@ @jit.dont_look_inside def ll_populate_list_from_raw_array(ll_list, src_ptr, length): +ll_list._ll_resize(length) +if rgc.must_split_gc_address_space(): +for i in range(length): +ll_list.ll_setitem_fast(i, src_ptr[i]) +return ITEM = lltype.typeOf(src_ptr).TO.OF size = llmemory.sizeof(ITEM) * length -ll_list._ll_resize(length) # start of no-GC section src_adr = get_raw_buf(src_ptr) dst_adr = get_raw_buf(ll_list.ll_items()) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reverse-debugger: fixes
Author: Armin RigoBranch: reverse-debugger Changeset: r85506:e5e2c4c6d62f Date: 2016-07-01 23:29 +0200 http://bitbucket.org/pypy/pypy/changeset/e5e2c4c6d62f/ Log:fixes diff --git a/pypy/module/_cffi_backend/hide_reveal.py b/pypy/module/_cffi_backend/hide_reveal.py --- a/pypy/module/_cffi_backend/hide_reveal.py +++ b/pypy/module/_cffi_backend/hide_reveal.py @@ -1,6 +1,5 @@ from rpython.rlib import rgc from rpython.rlib.rweaklist import RWeakListMixin -from rpython.rlib.objectmodel import fetch_translated_config from rpython.rtyper.lltypesystem import lltype, llmemory, rffi @@ -19,7 +18,7 @@ def hide_object(self, obj): # XXX leaks if we call this function often on the same object index = self.glob_gcrefs.add_handle(obj) -return rffi.cast(llmemory.Address, index) +return rffi.cast(rffi.VOIDP, index) def reveal_object(self, Class, addr): index = rffi.cast(lltype.Signed, addr) @@ -47,8 +46,7 @@ hide_reveal_fast = HideRevealCast() def hide_reveal(): -config = fetch_translated_config() -if config is not None and config.translation.split_gc_address_space: +if rgc.must_split_gc_address_space(): return hide_reveal_slow else: return hide_reveal_fast ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reverse-debugger: fix for tests
Author: Armin RigoBranch: reverse-debugger Changeset: r85509:5bcd3e5d3eda Date: 2016-07-01 23:34 +0200 http://bitbucket.org/pypy/pypy/changeset/5bcd3e5d3eda/ Log:fix for tests diff --git a/rpython/memory/gctransform/boehm.py b/rpython/memory/gctransform/boehm.py --- a/rpython/memory/gctransform/boehm.py +++ b/rpython/memory/gctransform/boehm.py @@ -48,7 +48,7 @@ self.WEAKLINK, self.convert_weakref_to ) = build_weakref(self.translator.config) self.weakref_create_ptr = self.inittime_helper( -ll_weakref_create, [llmemory.Address], llmemory.WeakRefPtr, +ll_weakref_create, [llmemory.GCREF], llmemory.WeakRefPtr, inline=False) self.weakref_deref_ptr = self.inittime_helper( ll_weakref_deref, [llmemory.WeakRefPtr], llmemory.GCREF) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reverse-debugger: hg merge default
Author: Armin RigoBranch: reverse-debugger Changeset: r85508:496ddf1997fe Date: 2016-07-01 23:33 +0200 http://bitbucket.org/pypy/pypy/changeset/496ddf1997fe/ Log:hg merge default diff --git a/rpython/translator/tool/make_dot.py b/rpython/translator/tool/make_dot.py --- a/rpython/translator/tool/make_dot.py +++ b/rpython/translator/tool/make_dot.py @@ -51,7 +51,7 @@ ports=None, ): d = locals() -attrs = [('%s="%s"' % (x, _quote(d[x]))) +attrs = [('%s="%s"' % (x, d[x].replace('"', '\\"').replace('\n', '\\n'))) for x in ['label', 'style', 'color', 'dir', 'weight']] self.emit('edge [%s];' % ", ".join(attrs)) if ports: @@ -69,7 +69,7 @@ width="0.75", ): d = locals() -attrs = [('%s="%s"' % (x, _quote(d[x]))) +attrs = [('%s="%s"' % (x, d[x].replace('"', '\\"').replace('\n', '\\n'))) for x in ['shape', 'label', 'color', 'fillcolor', 'style', 'width']] self.emit('%s [%s];' % (safename(name), ", ".join(attrs))) @@ -193,7 +193,7 @@ name2 = self.blockname(link.target) label = " ".join(map(repr, link.args)) if link.exitcase is not None: -label = "%s: %s" %(_quote(repr(link.exitcase)), label) +label = "%s: %s" %(repr(link.exitcase).replace('\\', ''), label) self.emit_edge(name, name2, label, style="dotted", color="red") else: self.emit_edge(name, name2, label, style="solid") @@ -237,6 +237,3 @@ # not a keyword name = ''.join([CHAR_MAP[c] for c in name]) return '_' + name - -def _quote(s): -return s.replace('\\', '').replace('"', '\\"').replace('\n', '\\n') ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Backed out changeset 850a4e0a56cc
Author: Armin RigoBranch: Changeset: r85505:3a1612568705 Date: 2016-07-01 23:29 +0200 http://bitbucket.org/pypy/pypy/changeset/3a1612568705/ Log:Backed out changeset 850a4e0a56cc Seems that we end up with big one-line blocks with '\n' written in the middle diff --git a/rpython/translator/tool/make_dot.py b/rpython/translator/tool/make_dot.py --- a/rpython/translator/tool/make_dot.py +++ b/rpython/translator/tool/make_dot.py @@ -51,7 +51,7 @@ ports=None, ): d = locals() -attrs = [('%s="%s"' % (x, _quote(d[x]))) +attrs = [('%s="%s"' % (x, d[x].replace('"', '\\"').replace('\n', '\\n'))) for x in ['label', 'style', 'color', 'dir', 'weight']] self.emit('edge [%s];' % ", ".join(attrs)) if ports: @@ -69,7 +69,7 @@ width="0.75", ): d = locals() -attrs = [('%s="%s"' % (x, _quote(d[x]))) +attrs = [('%s="%s"' % (x, d[x].replace('"', '\\"').replace('\n', '\\n'))) for x in ['shape', 'label', 'color', 'fillcolor', 'style', 'width']] self.emit('%s [%s];' % (safename(name), ", ".join(attrs))) @@ -193,7 +193,7 @@ name2 = self.blockname(link.target) label = " ".join(map(repr, link.args)) if link.exitcase is not None: -label = "%s: %s" %(_quote(repr(link.exitcase)), label) +label = "%s: %s" %(repr(link.exitcase).replace('\\', ''), label) self.emit_edge(name, name2, label, style="dotted", color="red") else: self.emit_edge(name, name2, label, style="solid") @@ -237,6 +237,3 @@ # not a keyword name = ''.join([CHAR_MAP[c] for c in name]) return '_' + name - -def _quote(s): -return s.replace('\\', '').replace('"', '\\"').replace('\n', '\\n') ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Only allow dicts in map_unpack_with_call
Author: Raffael TfirstBranch: py3.5 Changeset: r85504:a8f99affbbfd Date: 2016-07-01 20:42 +0200 http://bitbucket.org/pypy/pypy/changeset/a8f99affbbfd/ Log:Only allow dicts in map_unpack_with_call diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -1358,6 +1358,9 @@ w_dict = self.space.newdict() for i in range(num_maps, 0, -1): w_item = self.peekvalue(i-1) +if not issubclass(w_item.__class__, self.space.newdict().__class__): +raise oefmt(self.space.w_TypeError, +"%s is not a mapping", w_item.__class__.__name__) num_items = w_item.length() for j in range(num_items): (w_key, w_value) = w_item.popitem() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reverse-debugger: Write down both implementations for cffi callbacks: the old one which
Author: Armin RigoBranch: reverse-debugger Changeset: r85503:59aff804be9c Date: 2016-07-01 20:22 +0200 http://bitbucket.org/pypy/pypy/changeset/59aff804be9c/ Log:Write down both implementations for cffi callbacks: the old one which uses RWeakList, and the new one which uses direct casts of gc pointers to addresses (but doesn't work e.g. with the reverse debugger) diff --git a/pypy/module/_cffi_backend/ccallback.py b/pypy/module/_cffi_backend/ccallback.py --- a/pypy/module/_cffi_backend/ccallback.py +++ b/pypy/module/_cffi_backend/ccallback.py @@ -3,9 +3,9 @@ """ import sys, os, py -from rpython.rlib import clibffi, jit, rgc, objectmodel +from rpython.rlib import clibffi, jit, objectmodel from rpython.rlib.objectmodel import keepalive_until_here -from rpython.rtyper.lltypesystem import lltype, llmemory, rffi +from rpython.rtyper.lltypesystem import lltype, rffi from pypy.interpreter.error import OperationError, oefmt from pypy.module._cffi_backend import cerrno, misc, parse_c_type @@ -13,6 +13,7 @@ from pypy.module._cffi_backend.ctypefunc import SIZE_OF_FFI_ARG, W_CTypeFunc from pypy.module._cffi_backend.ctypeprim import W_CTypePrimitiveSigned from pypy.module._cffi_backend.ctypevoid import W_CTypeVoid +from pypy.module._cffi_backend.hide_reveal import hide_reveal BIG_ENDIAN = sys.byteorder == 'big' @@ -30,9 +31,7 @@ return cdata def reveal_callback(raw_ptr): -addr = rffi.cast(llmemory.Address, raw_ptr) -gcref = rgc.reveal_gcref(addr) -return rgc.try_cast_gcref_to_instance(W_ExternPython, gcref) +return hide_reveal().reveal_object(W_ExternPython, raw_ptr) class Closure(object): @@ -92,9 +91,7 @@ return ctype def hide_object(self): -gcref = rgc.cast_instance_to_gcref(self) -raw = rgc.hide_nonmovable_gcref(gcref) -return rffi.cast(rffi.VOIDP, raw) +return hide_reveal().hide_object(self) def _repr_extra(self): space = self.space diff --git a/pypy/module/_cffi_backend/hide_reveal.py b/pypy/module/_cffi_backend/hide_reveal.py new file mode 100644 --- /dev/null +++ b/pypy/module/_cffi_backend/hide_reveal.py @@ -0,0 +1,54 @@ +from rpython.rlib import rgc +from rpython.rlib.rweaklist import RWeakListMixin +from rpython.rlib.objectmodel import fetch_translated_config +from rpython.rtyper.lltypesystem import lltype, llmemory, rffi + + +class HideRevealRWeakList: +"""Slow implementation of HideReveal: uses a RWeakListMixin.""" + +def __init__(self): +class GlobGcrefs(RWeakListMixin): +pass +self.glob_gcrefs = GlobGcrefs() +self.glob_gcrefs.initialize() + +def _freeze_(self): +return True + +def hide_object(self, obj): +# XXX leaks if we call this function often on the same object +index = self.glob_gcrefs.add_handle(obj) +return rffi.cast(llmemory.Address, index) + +def reveal_object(self, Class, addr): +index = rffi.cast(lltype.Signed, addr) +return self.glob_gcrefs.fetch_handle(index) + + +class HideRevealCast: +"""Fast implementation of HideReveal: just a cast.""" + +def _freeze_(self): +return True + +def hide_object(self, obj): +gcref = rgc.cast_instance_to_gcref(obj) +raw = rgc.hide_nonmovable_gcref(gcref) +return rffi.cast(rffi.VOIDP, raw) + +def reveal_object(self, Class, raw_ptr): +addr = rffi.cast(llmemory.Address, raw_ptr) +gcref = rgc.reveal_gcref(addr) +return rgc.try_cast_gcref_to_instance(Class, gcref) + + +hide_reveal_slow = HideRevealRWeakList() +hide_reveal_fast = HideRevealCast() + +def hide_reveal(): +config = fetch_translated_config() +if config is not None and config.translation.split_gc_address_space: +return hide_reveal_slow +else: +return hide_reveal_fast ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Show only value of unicodeobject in case of non-empty intersection
Author: Raffael TfirstBranch: py3.5 Changeset: r85502:53b6c2e3609c Date: 2016-07-01 19:59 +0200 http://bitbucket.org/pypy/pypy/changeset/53b6c2e3609c/ Log:Show only value of unicodeobject in case of non-empty intersection diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -1363,7 +1363,7 @@ (w_key, w_value) = w_item.popitem() if self.space.is_true(self.space.contains(w_dict,w_key)): raise oefmt(self.space.w_TypeError, -"got multiple values for keyword argument %s", w_key) +"got multiple values for keyword argument %s", self.space.unicode_w(w_key)) self.space.setitem(w_dict, w_key, w_value) while num_maps != 0: self.popvalue() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Check multiple values for keyword in map_unpack_with_call
Author: Raffael TfirstBranch: py3.5 Changeset: r85501:17c11ede8071 Date: 2016-07-01 19:46 +0200 http://bitbucket.org/pypy/pypy/changeset/17c11ede8071/ Log:Check multiple values for keyword in map_unpack_with_call diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -1356,8 +1356,19 @@ def BUILD_MAP_UNPACK_WITH_CALL(self, itemcount, next_instr): num_maps = itemcount & 0xff w_dict = self.space.newdict() -import pdb; pdb.set_trace() -self.BUILD_MAP_UNPACK(num_maps, next_instr) +for i in range(num_maps, 0, -1): +w_item = self.peekvalue(i-1) +num_items = w_item.length() +for j in range(num_items): +(w_key, w_value) = w_item.popitem() +if self.space.is_true(self.space.contains(w_dict,w_key)): +raise oefmt(self.space.w_TypeError, +"got multiple values for keyword argument %s", w_key) +self.space.setitem(w_dict, w_key, w_value) +while num_maps != 0: +self.popvalue() +num_maps -= 1 +self.pushvalue(w_dict) def BUILD_MAP_UNPACK(self, itemcount, next_instr): w_dict = self.space.newdict() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reverse-debugger: hg merge default
Author: Armin RigoBranch: reverse-debugger Changeset: r85500:600dfa2a7206 Date: 2016-07-01 19:38 +0200 http://bitbucket.org/pypy/pypy/changeset/600dfa2a7206/ Log:hg merge default diff too long, truncating to 2000 out of 4923 lines diff --git a/lib_pypy/datetime.py b/lib_pypy/datetime.py --- a/lib_pypy/datetime.py +++ b/lib_pypy/datetime.py @@ -839,7 +839,7 @@ month = self._month if day is None: day = self._day -return date(year, month, day) +return date.__new__(type(self), year, month, day) # Comparisons of date objects with other. @@ -1356,7 +1356,8 @@ microsecond = self.microsecond if tzinfo is True: tzinfo = self.tzinfo -return time(hour, minute, second, microsecond, tzinfo) +return time.__new__(type(self), +hour, minute, second, microsecond, tzinfo) def __nonzero__(self): if self.second or self.microsecond: @@ -1566,8 +1567,9 @@ microsecond = self.microsecond if tzinfo is True: tzinfo = self.tzinfo -return datetime(year, month, day, hour, minute, second, microsecond, -tzinfo) +return datetime.__new__(type(self), +year, month, day, hour, minute, second, +microsecond, tzinfo) def astimezone(self, tz): if not isinstance(tz, tzinfo): diff --git a/pypy/doc/config/commandline.txt b/pypy/doc/config/commandline.txt --- a/pypy/doc/config/commandline.txt +++ b/pypy/doc/config/commandline.txt @@ -9,7 +9,7 @@ PyPy Python interpreter options --- -The following options can be used after ``translate.py +The following options can be used after ``rpython targetpypystandalone`` or as options to ``py.py``. .. GENERATE: objspace @@ -22,7 +22,7 @@ General translation options --- -The following are options of ``translate.py``. They must be +The following are options of ``bin/rpython``. They must be given before the ``targetxxx`` on the command line. * `--opt -O:`__ set the optimization level `[0, 1, size, mem, 2, 3]` diff --git a/pypy/doc/config/index.rst b/pypy/doc/config/index.rst --- a/pypy/doc/config/index.rst +++ b/pypy/doc/config/index.rst @@ -15,12 +15,12 @@ ./py.py <`objspace options`_> -and the ``translate.py`` translation entry +and the ``rpython/bin/rpython`` translation entry point which takes arguments of this form: .. parsed-literal:: -./translate.py <`translation options`_> +./rpython/bin/rpython <`translation options`_> For the common case of being ``targetpypystandalone.py``, you can then pass the `object space options`_ after @@ -28,7 +28,7 @@ .. parsed-literal:: -./translate.py <`translation options`_> targetpypystandalone.py <`objspace options`_> +./rpython/bin/rpython <`translation options`_> targetpypystandalone.py <`objspace options`_> There is an `overview`_ of all command line arguments that can be passed in either position. diff --git a/pypy/doc/config/opt.rst b/pypy/doc/config/opt.rst --- a/pypy/doc/config/opt.rst +++ b/pypy/doc/config/opt.rst @@ -4,8 +4,8 @@ This meta-option selects a default set of optimization settings to use during a translation. Usage:: -translate.py --opt=# -translate.py -O# +bin/rpython --opt=# +bin/rpython -O# where ``#`` is the desired optimization level. The valid choices are: diff --git a/pypy/doc/config/translation.dont_write_c_files.txt b/pypy/doc/config/translation.dont_write_c_files.txt --- a/pypy/doc/config/translation.dont_write_c_files.txt +++ b/pypy/doc/config/translation.dont_write_c_files.txt @@ -1,4 +1,4 @@ write the generated C files to ``/dev/null`` instead of to the disk. Useful if -you want to use translate.py as a benchmark and don't want to access the disk. +you want to use translation as a benchmark and don't want to access the disk. .. _`translation documentation`: ../translation.html diff --git a/pypy/doc/config/translation.fork_before.txt b/pypy/doc/config/translation.fork_before.txt --- a/pypy/doc/config/translation.fork_before.txt +++ b/pypy/doc/config/translation.fork_before.txt @@ -1,4 +1,4 @@ This is an option mostly useful when working on the PyPy toolchain. If you use -it, translate.py will fork before the specified phase. If the translation +it, translation will fork before the specified phase. If the translation crashes after that fork, you can fix the bug in the toolchain, and continue translation at the fork-point. diff --git a/pypy/doc/cppyy.rst b/pypy/doc/cppyy.rst --- a/pypy/doc/cppyy.rst +++ b/pypy/doc/cppyy.rst @@ -122,7 +122,7 @@ $ hg up reflex-support # optional # This example shows python, but using pypy-c is faster and uses less memory -$ python rpython/translator/goal/translate.py --opt=jit
[pypy-commit] pypy default: Support backslashes inside strings passed to dot
Author: Armin RigoBranch: Changeset: r85499:850a4e0a56cc Date: 2016-07-01 19:37 +0200 http://bitbucket.org/pypy/pypy/changeset/850a4e0a56cc/ Log:Support backslashes inside strings passed to dot diff --git a/rpython/translator/tool/make_dot.py b/rpython/translator/tool/make_dot.py --- a/rpython/translator/tool/make_dot.py +++ b/rpython/translator/tool/make_dot.py @@ -51,7 +51,7 @@ ports=None, ): d = locals() -attrs = [('%s="%s"' % (x, d[x].replace('"', '\\"').replace('\n', '\\n'))) +attrs = [('%s="%s"' % (x, _quote(d[x]))) for x in ['label', 'style', 'color', 'dir', 'weight']] self.emit('edge [%s];' % ", ".join(attrs)) if ports: @@ -69,7 +69,7 @@ width="0.75", ): d = locals() -attrs = [('%s="%s"' % (x, d[x].replace('"', '\\"').replace('\n', '\\n'))) +attrs = [('%s="%s"' % (x, _quote(d[x]))) for x in ['shape', 'label', 'color', 'fillcolor', 'style', 'width']] self.emit('%s [%s];' % (safename(name), ", ".join(attrs))) @@ -193,7 +193,7 @@ name2 = self.blockname(link.target) label = " ".join(map(repr, link.args)) if link.exitcase is not None: -label = "%s: %s" %(repr(link.exitcase).replace('\\', ''), label) +label = "%s: %s" %(_quote(repr(link.exitcase)), label) self.emit_edge(name, name2, label, style="dotted", color="red") else: self.emit_edge(name, name2, label, style="solid") @@ -237,3 +237,6 @@ # not a keyword name = ''.join([CHAR_MAP[c] for c in name]) return '_' + name + +def _quote(s): +return s.replace('\\', '').replace('"', '\\"').replace('\n', '\\n') ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Improve the test, and fix:
Author: Amaury Forgeot d'ArcBranch: Changeset: r85498:f616e095f87e Date: 2016-07-01 19:34 +0200 http://bitbucket.org/pypy/pypy/changeset/f616e095f87e/ Log:Improve the test, and fix: The subclass __init__ and __new__ should not be called. Thanks Armin! diff --git a/lib_pypy/datetime.py b/lib_pypy/datetime.py --- a/lib_pypy/datetime.py +++ b/lib_pypy/datetime.py @@ -839,7 +839,7 @@ month = self._month if day is None: day = self._day -return type(self)(year, month, day) +return date.__new__(type(self), year, month, day) # Comparisons of date objects with other. @@ -1356,7 +1356,8 @@ microsecond = self.microsecond if tzinfo is True: tzinfo = self.tzinfo -return type(self)(hour, minute, second, microsecond, tzinfo) +return time.__new__(type(self), +hour, minute, second, microsecond, tzinfo) def __nonzero__(self): if self.second or self.microsecond: @@ -1566,8 +1567,9 @@ microsecond = self.microsecond if tzinfo is True: tzinfo = self.tzinfo -return type(self)(year, month, day, hour, minute, second, microsecond, -tzinfo) +return datetime.__new__(type(self), +year, month, day, hour, minute, second, +microsecond, tzinfo) def astimezone(self, tz): if not isinstance(tz, tzinfo): diff --git a/pypy/module/test_lib_pypy/test_datetime.py b/pypy/module/test_lib_pypy/test_datetime.py --- a/pypy/module/test_lib_pypy/test_datetime.py +++ b/pypy/module/test_lib_pypy/test_datetime.py @@ -315,13 +315,50 @@ class sub(datetime.timedelta): pass assert type(+sub()) is datetime.timedelta -def test_subclass(self): -class MyDate(datetime.date): pass -class MyTime(datetime.time): pass -class MyDateTime(datetime.datetime): pass -assert type(MyDate.today().replace(day=1)) is MyDate -assert type(MyTime().replace(hour=1)) is MyTime -assert type(MyDateTime.now().replace(day=1, hour=1)) is MyDateTime +def test_subclass_date(self): +# replace() should return a subclass but not call __new__ or __init__. +class MyDate(datetime.date): +forbidden = False +def __new__(cls): +if cls.forbidden: FAIL +return datetime.date.__new__(cls, 2016, 2, 3) +def __init__(self, *args): +if self.forbidden: FAIL +d = MyDate() +d.forbidden = True +d2 = d.replace(day=5) +assert type(d2) is MyDate +assert d2 == datetime.date(2016, 2, 5) + +def test_subclass_time(self): +# replace() should return a subclass but not call __new__ or __init__. +class MyTime(datetime.time): +forbidden = False +def __new__(cls): +if cls.forbidden: FAIL +return datetime.time.__new__(cls, 1, 2, 3) +def __init__(self, *args): +if self.forbidden: FAIL +d = MyTime() +d.forbidden = True +d2 = d.replace(hour=5) +assert type(d2) is MyTime +assert d2 == datetime.time(5, 2, 3) + +def test_subclass_datetime(self): +# replace() should return a subclass but not call __new__ or __init__. +class MyDatetime(datetime.datetime): +forbidden = False +def __new__(cls): +if cls.forbidden: FAIL +return datetime.datetime.__new__(cls, 2016, 4, 5, 1, 2, 3) +def __init__(self, *args): +if self.forbidden: FAIL +d = MyDatetime() +d.forbidden = True +d2 = d.replace(hour=7) +assert type(d2) is MyDatetime +assert d2 == datetime.datetime(2016, 4, 5, 7, 2, 3) class TestDatetimeHost(BaseTestDatetime): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Like CPython, use type(self) to create new instances in datetime.replace().
Author: Amaury Forgeot d'ArcBranch: Changeset: r85497:7a86c69fafb6 Date: 2016-07-01 18:56 +0200 http://bitbucket.org/pypy/pypy/changeset/7a86c69fafb6/ Log:Like CPython, use type(self) to create new instances in datetime.replace(). diff --git a/lib_pypy/datetime.py b/lib_pypy/datetime.py --- a/lib_pypy/datetime.py +++ b/lib_pypy/datetime.py @@ -839,7 +839,7 @@ month = self._month if day is None: day = self._day -return date(year, month, day) +return type(self)(year, month, day) # Comparisons of date objects with other. @@ -1356,7 +1356,7 @@ microsecond = self.microsecond if tzinfo is True: tzinfo = self.tzinfo -return time(hour, minute, second, microsecond, tzinfo) +return type(self)(hour, minute, second, microsecond, tzinfo) def __nonzero__(self): if self.second or self.microsecond: @@ -1566,7 +1566,7 @@ microsecond = self.microsecond if tzinfo is True: tzinfo = self.tzinfo -return datetime(year, month, day, hour, minute, second, microsecond, +return type(self)(year, month, day, hour, minute, second, microsecond, tzinfo) def astimezone(self, tz): diff --git a/pypy/module/test_lib_pypy/test_datetime.py b/pypy/module/test_lib_pypy/test_datetime.py --- a/pypy/module/test_lib_pypy/test_datetime.py +++ b/pypy/module/test_lib_pypy/test_datetime.py @@ -315,6 +315,14 @@ class sub(datetime.timedelta): pass assert type(+sub()) is datetime.timedelta +def test_subclass(self): +class MyDate(datetime.date): pass +class MyTime(datetime.time): pass +class MyDateTime(datetime.datetime): pass +assert type(MyDate.today().replace(day=1)) is MyDate +assert type(MyTime().replace(hour=1)) is MyTime +assert type(MyDateTime.now().replace(day=1, hour=1)) is MyDateTime + class TestDatetimeHost(BaseTestDatetime): def setup_class(cls): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reverse-debugger: Minor clean-up, and don't trace hidden_applevel bytecodes at all
Author: Armin RigoBranch: reverse-debugger Changeset: r85496:0210f3ef956a Date: 2016-07-01 18:55 +0200 http://bitbucket.org/pypy/pypy/changeset/0210f3ef956a/ Log:Minor clean-up, and don't trace hidden_applevel bytecodes at all (previously it would still trigger at bytecode index 0). diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -53,14 +53,10 @@ ### opcode dispatch ### def dispatch(self, pycode, next_instr, ec): -if self.space.config.translation.reverse_debugger: -from pypy.interpreter.reverse_debugging import prepare_code -prepare_code(pycode) -# # For the sequel, force 'next_instr' to be unsigned for performance next_instr = r_uint(next_instr) co_code = pycode.co_code -# + try: while True: next_instr = self.handle_bytecode(co_code, next_instr, ec) diff --git a/pypy/interpreter/reverse_debugging.py b/pypy/interpreter/reverse_debugging.py --- a/pypy/interpreter/reverse_debugging.py +++ b/pypy/interpreter/reverse_debugging.py @@ -26,7 +26,7 @@ # invariant: "f_revdb_nextline_instr" is the bytecode offset of # the start of the line that follows "last_instr". -pyframe.PyFrame.f_revdb_nextline_instr = 0 +pyframe.PyFrame.f_revdb_nextline_instr = -1 # @@ -69,6 +69,10 @@ if dbstate.breakpoint_stack_id != 0 and caller_frame is not None: if dbstate.breakpoint_stack_id == revdb.get_unique_id(caller_frame): revdb.breakpoint(-1) +# +code = callee_frame.pycode +if code.co_revdb_linestarts is None: +build_co_revdb_linestarts(code) def leave_call(caller_frame, callee_frame): if dbstate.breakpoint_stack_id != 0 and caller_frame is not None: @@ -172,10 +176,6 @@ code.co_revdb_linestarts = lstart return lstart -def prepare_code(code): -if code.co_revdb_linestarts is None: -build_co_revdb_linestarts(code) - def get_final_lineno(code): lineno = code.co_firstlineno lnotab = code.co_lnotab ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reverse-debugger: Signals work with a little tweak
Author: Armin RigoBranch: reverse-debugger Changeset: r85495:6d53b2a13d23 Date: 2016-07-01 18:47 +0200 http://bitbucket.org/pypy/pypy/changeset/6d53b2a13d23/ Log:Signals work with a little tweak diff --git a/pypy/interpreter/reverse_debugging.py b/pypy/interpreter/reverse_debugging.py --- a/pypy/interpreter/reverse_debugging.py +++ b/pypy/interpreter/reverse_debugging.py @@ -7,6 +7,7 @@ from pypy.interpreter.baseobjspace import W_Root from pypy.interpreter import gateway, typedef, pycode, pytraceback, pyframe from pypy.module.marshal import interp_marshal +from pypy.interpreter.executioncontext import AbstractActionFlag class DBState: @@ -21,6 +22,16 @@ dbstate = DBState() +pycode.PyCode.co_revdb_linestarts = None # or a string: see below + +# invariant: "f_revdb_nextline_instr" is the bytecode offset of +# the start of the line that follows "last_instr". +pyframe.PyFrame.f_revdb_nextline_instr = 0 + + +# + + def setup_revdb(space): """Called at run-time, before the space is set up. @@ -47,11 +58,7 @@ revdb.register_debug_command(revdb.CMD_WATCHVALUES, lambda_watchvalues) -pycode.PyCode.co_revdb_linestarts = None # or a string: see below - -# invariant: "f_revdb_nextline_instr" is the bytecode offset of -# the start of the line that follows "last_instr". -pyframe.PyFrame.f_revdb_nextline_instr = 0 +# def enter_call(caller_frame, callee_frame): @@ -221,6 +228,9 @@ dbstate.metavars[index] = w_obj +# + + def fetch_cur_frame(): ec = dbstate.space.getexecutioncontext() frame = ec.topframeref() @@ -526,3 +536,46 @@ w_dict = space.builtin.w_dict w_res = prog.exec_code(space, w_dict, w_dict) return space.str_w(space.repr(w_res)) + + +# + + +class RDBSignalActionFlag(AbstractActionFlag): +# Used instead of pypy.module.signal.interp_signal.SignalActionFlag +# when we have reverse-debugging. That other class would work too, +# but inefficiently: it would generate two words of data per bytecode. +# This class is tweaked to generate one byte per _SIG_TICKER_COUNT +# bytecodes, at the expense of not reacting to signals instantly. + +_SIG_TICKER_COUNT = 100 +_ticker_cache = 0 +_ticker_count = _SIG_TICKER_COUNT * 10 + +def get_ticker(self): +return self._ticker_cache + +def reset_ticker(self, value): +self._ticker_cache = value + +def rearm_ticker(self): +self._ticker_cache = -1 + +def decrement_ticker(self, by): +if we_are_translated(): +c = self._ticker_count - 1 +if c < 0: +c = self._update_ticker_from_signals() +self._ticker_count = c +if self.has_bytecode_counter:# this 'if' is constant-folded +print ("RDBSignalActionFlag: has_bytecode_counter: " + "not supported for now") +raise NotImplementedError +return self._ticker_cache + +def _update_ticker_from_signals(self): +from rpython.rlib import rsignal +if rsignal.pypysig_check_and_reset(): +self.rearm_ticker() +return self._SIG_TICKER_COUNT +_update_ticker_from_signals._dont_inline_ = True diff --git a/pypy/module/signal/__init__.py b/pypy/module/signal/__init__.py --- a/pypy/module/signal/__init__.py +++ b/pypy/module/signal/__init__.py @@ -46,7 +46,11 @@ space.check_signal_action = interp_signal.CheckSignalAction(space) space.actionflag.register_periodic_action(space.check_signal_action, use_bytecode_counter=False) -space.actionflag.__class__ = interp_signal.SignalActionFlag +if space.config.translation.reverse_debugger: +from pypy.interpreter.reverse_debugging import RDBSignalActionFlag +space.actionflag.__class__ = RDBSignalActionFlag +else: +space.actionflag.__class__ = interp_signal.SignalActionFlag # xxx yes I know the previous line is a hack def startup(self, space): diff --git a/rpython/rlib/rsignal.py b/rpython/rlib/rsignal.py --- a/rpython/rlib/rsignal.py +++ b/rpython/rlib/rsignal.py @@ -87,6 +87,8 @@ pypysig_getaddr_occurred = external('pypysig_getaddr_occurred', [], lltype.Ptr(LONG_STRUCT), _nowrapper=True, elidable_function=True) +pypysig_check_and_reset = external('pypysig_check_and_reset', [], + lltype.Bool, _nowrapper=True) c_alarm = external('alarm', [rffi.INT], rffi.INT) c_pause = external('pause', [], rffi.INT, releasegil=True) c_siginterrupt = external('siginterrupt', [rffi.INT, rffi.INT], rffi.INT, diff --git
[pypy-commit] pypy call-via-pyobj: fix for translation
Author: Matti PicusBranch: call-via-pyobj Changeset: r85494:1b1bf8ef2fb6 Date: 2016-07-01 18:21 +0300 http://bitbucket.org/pypy/pypy/changeset/1b1bf8ef2fb6/ Log:fix for translation diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py --- a/pypy/module/cpyext/typeobject.py +++ b/pypy/module/cpyext/typeobject.py @@ -304,6 +304,7 @@ struct = getattr(pto, slot_names[0]) if not struct: continue +assert isinstance(struct, lltype._ptr) offset.append(rffi.offsetof(struct._T, slot_names[1])) func = getattr(struct, slot_names[1]) func_voidp = rffi.cast(rffi.VOIDP, func) @@ -818,7 +819,6 @@ base_pyo = rffi.cast(PyObject, pto.c_tp_base) if base and not base.c_tp_flags & Py_TPFLAGS_READY: name = rffi.charp2str(base.c_tp_name) -print 'realizing base while creating child', type_realize(space, base_pyo) if base and not pto.c_ob_type: # will be filled later pto.c_ob_type = base.c_ob_type ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reverse-debugger: test fix
Author: Armin RigoBranch: reverse-debugger Changeset: r85493:ae8134681b8c Date: 2016-07-01 17:11 +0200 http://bitbucket.org/pypy/pypy/changeset/ae8134681b8c/ Log:test fix diff --git a/rpython/translator/revdb/test/test_process.py b/rpython/translator/revdb/test/test_process.py --- a/rpython/translator/revdb/test/test_process.py +++ b/rpython/translator/revdb/test/test_process.py @@ -68,7 +68,7 @@ group.active.expect(ANSWER_READY, 1, Ellipsis) e = py.test.raises(Breakpoint, group.go_forward, 10, 'b') assert e.value.time == 7 -assert e.value.num == 99 +assert e.value.nums == [99] group._check_current_time(7) def test_breakpoint_r(self): @@ -77,8 +77,8 @@ group.active.expect(42, 100, -43, -44, 'set-breakpoint') group.active.expect(ANSWER_READY, 1, Ellipsis) e = py.test.raises(Breakpoint, group.go_forward, 10, 'r') -assert e.value.time == 8 -assert e.value.num == 99 +assert e.value.time == 7 +assert e.value.nums == [99] group._check_current_time(10) def test_breakpoint_i(self): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy.org extradoc: update the values
Author: Armin RigoBranch: extradoc Changeset: r764:9b074671829e Date: 2016-07-01 16:41 +0200 http://bitbucket.org/pypy/pypy.org/changeset/9b074671829e/ Log:update the values diff --git a/don1.html b/don1.html --- a/don1.html +++ b/don1.html @@ -9,13 +9,13 @@ $(function() { $("#progressbar").progressbar({ - value: 61.5 + value: 61.6 }); }); - $64624 of $105000 (61.5%) + $64643 of $105000 (61.6%) @@ -23,7 +23,7 @@ This donation goes towards supporting Python 3 in PyPy. Current status: -we have $9625 left +we have $6282 left in the account. Read proposal ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reverse-debugger: Clean up, fixes reverse-watchpoints stopping one step too far in the past
Author: Armin RigoBranch: reverse-debugger Changeset: r85492:bbb6f37c65f4 Date: 2016-07-01 16:39 +0200 http://bitbucket.org/pypy/pypy/changeset/bbb6f37c65f4/ Log:Clean up, fixes reverse-watchpoints stopping one step too far in the past diff --git a/rpython/translator/revdb/interact.py b/rpython/translator/revdb/interact.py --- a/rpython/translator/revdb/interact.py +++ b/rpython/translator/revdb/interact.py @@ -189,12 +189,8 @@ 'Reverse-hit' if backward else 'Hit', kind, num, name)) self.print_extra_pending_info = '\n'.join(printing) -target_time = b.time -if backward: -target_time -= 1 # when going backwards, we stop just before - # the breakpoint time, as opposed to just after -if self.pgroup.get_current_time() != target_time: -self.pgroup.jump_in_time(target_time) +if self.pgroup.get_current_time() != b.time: +self.pgroup.jump_in_time(b.time) def remove_tainting(self): if self.pgroup.is_tainted(): diff --git a/rpython/translator/revdb/src-revdb/revdb.c b/rpython/translator/revdb/src-revdb/revdb.c --- a/rpython/translator/revdb/src-revdb/revdb.c +++ b/rpython/translator/revdb/src-revdb/revdb.c @@ -1106,8 +1106,8 @@ return; /* ignored breakpoints */ case 'r': /* record the breakpoint but continue */ -if (last_recorded_breakpoint_loc != rpy_revdb.stop_point_seen + 1) { -last_recorded_breakpoint_loc = rpy_revdb.stop_point_seen + 1; +if (last_recorded_breakpoint_loc != rpy_revdb.stop_point_seen) { +last_recorded_breakpoint_loc = rpy_revdb.stop_point_seen; n_last_recorded_breakpoints = 0; } if (n_last_recorded_breakpoints < RECORD_BKPT_NUM) { ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ppc-vsx-support: changes vec_guard to pass more tests (work in progress)
Author: Richard PlanggerBranch: ppc-vsx-support Changeset: r85491:dd3b78c15f4f Date: 2016-07-01 16:25 +0200 http://bitbucket.org/pypy/pypy/changeset/dd3b78c15f4f/ Log:changes vec_guard to pass more tests (work in progress) diff --git a/rpython/jit/backend/ppc/vector_ext.py b/rpython/jit/backend/ppc/vector_ext.py --- a/rpython/jit/backend/ppc/vector_ext.py +++ b/rpython/jit/backend/ppc/vector_ext.py @@ -267,10 +267,10 @@ else: notimplemented("[ppc/assembler] float neg for size %d" % size) -def emit_guard_vec_guard_true(self, guard_op, guard_token, arglocs, regalloc): +def emit_vec_guard_true(self, guard_op, arglocs, regalloc): self._emit_guard(guard_op, arglocs) -def emit_guard_vec_guard_false(self, guard_op, guard_token, arglocs, regalloc): +def emit_vec_guard_false(self, guard_op, arglocs, regalloc): self.guard_success_cc = c.negate(self.guard_success_cc) self._emit_guard(guard_op, arglocs) @@ -374,7 +374,7 @@ def emit_vec_int_is_true(self, op, arglocs, regalloc): resloc, argloc, sizeloc = arglocs size = sizeloc.value -tmp = regalloc.get_scratch_reg().value +tmp = regalloc.ivrm.get_scratch_reg().value self.mc.vxor(tmp, tmp, tmp) # argloc[i] > 0: # For an unsigned integer that is equivalent to argloc[i] != 0 @@ -521,24 +521,18 @@ srcidx = srcidxloc.value residx = residxloc.value count = countloc.value -# for small data type conversion this can be quite costy -# NOTE there might be some combinations that can be handled -# more efficiently! e.g. -# v2 = pack(v0,v1,4,4) res = resultloc.value vector = vloc.value src = sourceloc.value size = op.bytesize if size == 8: -if resultloc.is_vector_reg() and sourceloc.is_vector_reg(): # both vector -notimplemented("[ppc/vec_pack_i]") -elif resultloc.is_vector_reg(): # vector <- reg +if resultloc.is_vector_reg(): # vector <- reg self.mc.load_imm(r.SCRATCH, PARAM_SAVE_AREA_OFFSET) self.mc.stvx(vector, r.SCRATCH2.value, r.SP.value) self.mc.store(src, r.SP.value, PARAM_SAVE_AREA_OFFSET+8*residx) self.mc.lvx(res, r.SCRATCH2.value, r.SP.value) else: -notimplemented("[ppc/vec_pack_i]") +notimplemented("[ppc/vec_pack_i] 64 bit float") elif size == 4: notimplemented("[ppc/vec_pack_i]") elif size == 2: @@ -546,9 +540,22 @@ elif size == 1: notimplemented("[ppc/vec_pack_i]") -# TODO emit_vec_unpack_i = emit_vec_pack_i +def emit_vec_unpack_i(self, op, arglocs, regalloc): +resloc, srcloc, idxloc, countloc = arglocs +idx = idxloc.value +res = resloc.value +src = srcloc.value +size = op.bytesize +if size == 8: +if srcloc.is_vector_reg(): # reg <- vector +assert not resloc.is_vector_reg() +self.mc.load_imm(r.SCRATCH, PARAM_SAVE_AREA_OFFSET) +self.mc.stvx(src, r.SCRATCH2.value, r.SP.value) +self.mc.load(res, r.SP.value, PARAM_SAVE_AREA_OFFSET+8*idx) +else: +notimplemented("[ppc/vec_unpack_i] 64 bit integer") -def emit_vec_pack_f(self, op, arglocs, resultloc): +def emit_vec_pack_f(self, op, arglocs, regalloc): resloc, vloc, srcloc, residxloc, srcidxloc, countloc = arglocs vec = vloc.value res = resloc.value @@ -590,7 +597,9 @@ else: self.mc.xxspltd(res, vec, src, 0b01) -emit_vec_unpack_f = emit_vec_pack_f +def emit_vec_unpack_f(self, op, arglocs, regalloc): +resloc, srcloc, idxloc, countloc = arglocs +self.emit_vec_pack_f(op, [resloc, srcloc, srcloc, imm(0), idxloc, countloc], regalloc) # needed as soon as PPC's support_singlefloat is implemented! #def genop_vec_cast_float_to_int(self, op, arglocs, regalloc): @@ -750,7 +759,7 @@ count = op.getarg(3) assert isinstance(index, ConstInt) assert isinstance(count, ConstInt) -assert not arg.is_vector_reg() +assert not arg.is_vector() srcloc = self.ensure_reg(arg) vloc = self.ensure_vector_reg(op.getarg(0)) resloc = self.force_allocate_vector_reg(op) @@ -758,29 +767,28 @@ srcidx = 0 return [resloc, vloc, srcloc, imm(residx), imm(srcidx), imm(count.value)] -#def prepare_vec_unpack_i(self, op): -#assert isinstance(op, VectorOp) -#index = op.getarg(1) -#count = op.getarg(2) -#assert isinstance(index, ConstInt) -#assert isinstance(count, ConstInt) -#args = op.getarglist() -#srcloc = self.make_sure_var_in_reg(op.getarg(0), args) -#if
[pypy-commit] pypy reverse-debugger: Tweak again the breakpoint detection code and the "next" and "bnext" commands
Author: Armin RigoBranch: reverse-debugger Changeset: r85490:b5ea52f65b84 Date: 2016-07-01 16:10 +0200 http://bitbucket.org/pypy/pypy/changeset/b5ea52f65b84/ Log:Tweak again the breakpoint detection code and the "next" and "bnext" commands diff --git a/pypy/interpreter/reverse_debugging.py b/pypy/interpreter/reverse_debugging.py --- a/pypy/interpreter/reverse_debugging.py +++ b/pypy/interpreter/reverse_debugging.py @@ -59,14 +59,14 @@ name = callee_frame.getcode().co_name if name in dbstate.breakpoint_funcnames: revdb.breakpoint(dbstate.breakpoint_funcnames[name]) -if dbstate.breakpoint_stack_id != 0: +if dbstate.breakpoint_stack_id != 0 and caller_frame is not None: if dbstate.breakpoint_stack_id == revdb.get_unique_id(caller_frame): revdb.breakpoint(-1) def leave_call(caller_frame, callee_frame): -if dbstate.breakpoint_stack_id != 0: +if dbstate.breakpoint_stack_id != 0 and caller_frame is not None: if dbstate.breakpoint_stack_id == revdb.get_unique_id(caller_frame): -revdb.breakpoint(-1) +revdb.breakpoint(-2) def jump_backward(frame, jumpto): diff --git a/rpython/translator/revdb/interact.py b/rpython/translator/revdb/interact.py --- a/rpython/translator/revdb/interact.py +++ b/rpython/translator/revdb/interact.py @@ -170,28 +170,31 @@ self.pgroup.go_forward(steps) return None except Breakpoint as b: -self.hit_breakpoint(b) +self.hit_breakpoints(b) return b -def move_backward(self, steps, rel_stop_at=-1): -ignore_bkpt = steps == 1 and rel_stop_at == -1 +def move_backward(self, steps): try: -self.pgroup.go_backward(steps, ignore_breakpoints=ignore_bkpt, -rel_stop_at=rel_stop_at) +self.pgroup.go_backward(steps) return None except Breakpoint as b: -self.hit_breakpoint(b, backward=True) +self.hit_breakpoints(b, backward=True) return b -def hit_breakpoint(self, b, backward=False): -if b.num != -1: -kind, name = self._bp_kind(b.num) -self.print_extra_pending_info = 'Hit %s %d: %s' % (kind, b.num, - name) -elif backward: -b.time -= 1 -if self.pgroup.get_current_time() != b.time: -self.pgroup.jump_in_time(b.time) +def hit_breakpoints(self, b, backward=False): +printing = [] +for num in b.regular_breakpoint_nums(): +kind, name = self._bp_kind(num) +printing.append('%s %s %d: %s' % ( +'Reverse-hit' if backward else 'Hit', +kind, num, name)) +self.print_extra_pending_info = '\n'.join(printing) +target_time = b.time +if backward: +target_time -= 1 # when going backwards, we stop just before + # the breakpoint time, as opposed to just after +if self.pgroup.get_current_time() != target_time: +self.pgroup.jump_in_time(target_time) def remove_tainting(self): if self.pgroup.is_tainted(): @@ -226,33 +229,44 @@ stack_id = self.pgroup.get_stack_id(is_parent=False) with self._stack_id_break(stack_id): b = self.move_forward(1) -if b is None: -return# no breakpoint hit, and no frame just entered: done -elif b.num != -1: -return# a regular breakpoint was hit -else: -# we entered a frame. Continue running until we leave that -# frame again +while b is not None: +# if we hit a regular breakpoint, stop +if any(b.regular_breakpoint_nums()): +return +# we hit only calls and returns inside stack_id. If the +# last one of these is a "return", then we're now back inside +# stack_id, so stop +if b.nums[-1] == -2: +return +# else, the last one is a "call", so we entered another frame. +# Continue running until the next call/return event occurs +# inside stack_id with self._stack_id_break(stack_id): -self.command_continue("") +b = self.move_forward(self.pgroup.get_max_time() - + self.pgroup.get_current_time()) +# and then look at that 'b' again (closes the loop) command_n = command_next def command_bnext(self, argument): """Run backward for one step, skipping calls""" stack_id = self.pgroup.get_stack_id(is_parent=False) with self._stack_id_break(stack_id): -b = self.move_backward(1, rel_stop_at=0) -if b is None: -return# no breakpoint hit, and
[pypy-commit] pypy ppc-vsx-support: finished accum reduce function for f64/i64 + and * (ppc)
Author: Richard PlanggerBranch: ppc-vsx-support Changeset: r85489:89ec178c8b17 Date: 2016-07-01 15:37 +0200 http://bitbucket.org/pypy/pypy/changeset/89ec178c8b17/ Log:finished accum reduce function for f64/i64 + and * (ppc) diff --git a/rpython/jit/backend/ppc/codebuilder.py b/rpython/jit/backend/ppc/codebuilder.py --- a/rpython/jit/backend/ppc/codebuilder.py +++ b/rpython/jit/backend/ppc/codebuilder.py @@ -612,7 +612,7 @@ # mul xvmuldp = XX3(60, XO9=112) xvmulsp = XX3(60, XO9=80) -xsmuldp = XX3(60, XO9=46) +xsmuldp = XX3(60, XO9=48) # div xvdivdp = XX3(60, XO9=102) xvdivsp = XX3(60, XO9=88) diff --git a/rpython/jit/backend/ppc/vector_ext.py b/rpython/jit/backend/ppc/vector_ext.py --- a/rpython/jit/backend/ppc/vector_ext.py +++ b/rpython/jit/backend/ppc/vector_ext.py @@ -333,38 +333,40 @@ if not scalar_loc.is_reg(): scalar_loc = regalloc.force_allocate_reg(scalar_arg) assert scalar_arg is not None -if accum_info.accum_operation == '+': -self._accum_reduce_sum(scalar_arg, vector_loc, scalar_loc) -elif accum_info.accum_operation == '*': -self._accum_reduce_mul(scalar_arg, vector_loc, scalar_loc) -else: -not_implemented("accum operator %s not implemented" % -(accum_info.accum_operation)) +op = accum_info.accum_operation +self._accum_reduce(op, scalar_arg, vector_loc, scalar_loc) accum_info = accum_info.next() -def _accum_reduce_mul(self, arg, accumloc, targetloc): -notimplemented("[ppc reduce mul]") -#scratchloc = X86_64_XMM_SCRATCH_REG -#self.mov(accumloc, scratchloc) -## swap the two elements -#self.mc.SHUFPD_xxi(scratchloc.value, scratchloc.value, 0x01) -#self.mc.MULSD(accumloc, scratchloc) -#if accumloc is not targetloc: -#self.mov(accumloc, targetloc) - -def _accum_reduce_sum(self, arg, accumloc, targetloc): +def _accum_reduce(self, op, arg, accumloc, targetloc): # Currently the accumulator can ONLY be the biggest # 64 bit float/int tgt = targetloc.value acc = accumloc.value if arg.type == FLOAT: # r = (r[0]+r[1],r[0]+r[1]) -self.mc.xvmr(tgt, acc, acc) if IS_BIG_ENDIAN: self.mc.xxspltd(tgt, acc, acc, 0b00) else: -self.mc.xxspltd(tgt, acc, acc, 0b01) -self.mc.xsadddp(tgt, tgt, acc) +self.mc.xxspltd(tgt, acc, acc, 0b10) +if op == '+': +self.mc.xsadddp(tgt, tgt, acc) +elif op == '*': +self.mc.xsmuldp(tgt, tgt, acc) +else: +not_implemented("sum not implemented") +return +else: +assert arg.type == INT +self.mc.load_imm(r.SCRATCH2, PARAM_SAVE_AREA_OFFSET) +self.mc.stvx(acc, r.SCRATCH2.value, r.SP.value) +self.mc.load(tgt, r.SP.value, PARAM_SAVE_AREA_OFFSET) +self.mc.load(r.SCRATCH.value, r.SP.value, PARAM_SAVE_AREA_OFFSET+8) +if op == '+': +self.mc.add(tgt, tgt, acc) +elif op == '*': +self.mc.mul(tgt, tgt, acc) +else: +not_implemented("sum not implemented") return not_implemented("reduce sum for %s not impl." % arg) @@ -514,59 +516,37 @@ else: notimplemented("[expand int size not impl]") -#def genop_vec_pack_i(self, op, arglocs, regalloc): -#resultloc, sourceloc, residxloc, srcidxloc, countloc, sizeloc = arglocs -#assert isinstance(resultloc, RegLoc) -#assert isinstance(sourceloc, RegLoc) -#size = sizeloc.value -#srcidx = srcidxloc.value -#residx = residxloc.value -#count = countloc.value -## for small data type conversion this can be quite costy -## NOTE there might be some combinations that can be handled -## more efficiently! e.g. -## v2 = pack(v0,v1,4,4) -#si = srcidx -#ri = residx -#k = count -#while k > 0: -#if size == 8: -#if resultloc.is_xmm and sourceloc.is_xmm: # both xmm -#self.mc.PEXTRQ_rxi(X86_64_SCRATCH_REG.value, sourceloc.value, si) -#self.mc.PINSRQ_xri(resultloc.value, X86_64_SCRATCH_REG.value, ri) -#elif resultloc.is_xmm: # xmm <- reg -#self.mc.PINSRQ_xri(resultloc.value, sourceloc.value, ri) -#else: # reg <- xmm -#self.mc.PEXTRQ_rxi(resultloc.value, sourceloc.value, si) -#elif size == 4: -#if resultloc.is_xmm and sourceloc.is_xmm: -#self.mc.PEXTRD_rxi(X86_64_SCRATCH_REG.value,
[pypy-commit] pypy call-via-pyobj: use a list to make the offset lookup work (test passes)
Author: Matti PicusBranch: call-via-pyobj Changeset: r85488:02ab445bf7f9 Date: 2016-07-01 16:01 +0300 http://bitbucket.org/pypy/pypy/changeset/02ab445bf7f9/ Log:use a list to make the offset lookup work (test passes) diff --git a/pypy/module/cpyext/methodobject.py b/pypy/module/cpyext/methodobject.py --- a/pypy/module/cpyext/methodobject.py +++ b/pypy/module/cpyext/methodobject.py @@ -152,7 +152,7 @@ class W_PyCWrapperObject(W_Root): def __init__(self, space, pto, method_name, wrapper_func, - wrapper_func_kwds, doc, func, offset=-1): + wrapper_func_kwds, doc, func, offset=None): self.space = space self.method_name = method_name self.wrapper_func = wrapper_func @@ -174,15 +174,15 @@ raise oefmt(space.w_TypeError, "wrapper %s doesn't take any keyword arguments", self.method_name) -if self.offset >= 0: -pto = rffi.cast(PyTypeObjectPtr, as_pyobj(space, self.w_objclass)) -pto_func_as_int = lltype.cast_ptr_to_int(pto) + self.offset -# XXX make pto_func the equivalent of this line -#lltype.cast_int_to_ptr(pto_func_as_int) -func_to_call = rffi.cast(rffi.VOIDP, pto.c_tp_as_number.c_nb_multiply) -# print '\ncalling', func_to_call, 'not', self.func +if self.offset: +ptr = pto = rffi.cast(PyTypeObjectPtr, as_pyobj(space, self.w_objclass)) +# make ptr the equivalent of this, using the offsets +#func_to_call = rffi.cast(rffi.VOIDP, pto.c_tp_as_number.c_nb_multiply) +for o in self.offset: +ptr_as_int = lltype.cast_ptr_to_int(ptr) +ptr = rffi.cast(rffi.VOIDPP, ptr_as_int + o)[0] +func_to_call = ptr else: -# print 'calling', self.method_name,'with no offset' func_to_call = self.func return self.wrapper_func(space, w_self, w_args, func_to_call) diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py --- a/pypy/module/cpyext/typeobject.py +++ b/pypy/module/cpyext/typeobject.py @@ -296,7 +296,7 @@ for method_name, slot_names, wrapper_func, wrapper_func_kwds, doc in slotdefs_for_wrappers: if method_name in dict_w: continue -offset = rffi.offsetof(pto._T, slot_names[0]) +offset = [rffi.offsetof(pto._T, slot_names[0])] if len(slot_names) == 1: func = getattr(pto, slot_names[0]) else: @@ -304,21 +304,13 @@ struct = getattr(pto, slot_names[0]) if not struct: continue -offset += rffi.offsetof(struct._T, slot_names[1]) +offset.append(rffi.offsetof(struct._T, slot_names[1])) func = getattr(struct, slot_names[1]) func_voidp = rffi.cast(rffi.VOIDP, func) if not func: continue if wrapper_func is None and wrapper_func_kwds is None: continue -name = rffi.charp2str(pto.c_tp_name) -if method_name in ('__mul__', '__rmul__') and 'array' in name: -# print '\nsetting', name, method_name, 'from', slot_names -# print 'pto is', pto -# print 'func_voidp is', func_voidp -pass -else: -offset = -1 w_obj = W_PyCWrapperObject(space, pto, method_name, wrapper_func, wrapper_func_kwds, doc, func_voidp, offset=offset) dict_w[method_name] = space.wrap(w_obj) @@ -744,7 +736,6 @@ w_obj = _type_realize(space, py_obj) finally: name = rffi.charp2str(pto.c_tp_name) -print '_type_realize done', name pto.c_tp_flags &= ~Py_TPFLAGS_READYING pto.c_tp_flags |= Py_TPFLAGS_READY return w_obj ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ppc-vsx-support: add a many details to implement the reduction pattern (ppc, partly working already)
Author: Richard PlanggerBranch: ppc-vsx-support Changeset: r85487:1360aa62b1ed Date: 2016-07-01 14:00 +0200 http://bitbucket.org/pypy/pypy/changeset/1360aa62b1ed/ Log:add a many details to implement the reduction pattern (ppc, partly working already) diff --git a/rpython/jit/backend/ppc/codebuilder.py b/rpython/jit/backend/ppc/codebuilder.py --- a/rpython/jit/backend/ppc/codebuilder.py +++ b/rpython/jit/backend/ppc/codebuilder.py @@ -605,12 +605,14 @@ # add xvadddp = XX3(60, XO9=96) xvaddsp = XX3(60, XO9=64) +xsadddp = XX3(60, XO9=32) # sub xvsubdp = XX3(60, XO9=104) xvsubsp = XX3(60, XO9=72) # mul xvmuldp = XX3(60, XO9=112) xvmulsp = XX3(60, XO9=80) +xsmuldp = XX3(60, XO9=46) # div xvdivdp = XX3(60, XO9=102) xvdivsp = XX3(60, XO9=88) @@ -662,6 +664,12 @@ # generic splat xxspltd = XX3_splat(60, XO13=10, OE=0) +xxlxor = XX3(60, XO9=154) +xxlor = XX3(60, XO9=146) + +# vector move register is alias to vector or +xvmr = xxlor + # INTEGER # --- diff --git a/rpython/jit/backend/ppc/ppc_assembler.py b/rpython/jit/backend/ppc/ppc_assembler.py --- a/rpython/jit/backend/ppc/ppc_assembler.py +++ b/rpython/jit/backend/ppc/ppc_assembler.py @@ -771,7 +771,7 @@ self.update_frame_depth(frame_depth_no_fixed_size + JITFRAME_FIXED_SIZE) # size_excluding_failure_stuff = self.mc.get_relative_pos() -self.write_pending_failure_recoveries() +self.write_pending_failure_recoveries(regalloc) full_size = self.mc.get_relative_pos() # self.patch_stack_checks(frame_depth_no_fixed_size + JITFRAME_FIXED_SIZE) @@ -852,10 +852,12 @@ self.reserve_gcref_table(allgcrefs) startpos = self.mc.get_relative_pos() +self._update_at_exit(arglocs, inputargs, faildescr, regalloc) + self._check_frame_depth(self.mc, regalloc.get_gcmap()) frame_depth_no_fixed_size = self._assemble(regalloc, inputargs, operations) codeendpos = self.mc.get_relative_pos() -self.write_pending_failure_recoveries() +self.write_pending_failure_recoveries(regalloc) fullsize = self.mc.get_relative_pos() # self.patch_stack_checks(frame_depth_no_fixed_size + JITFRAME_FIXED_SIZE) @@ -928,7 +930,7 @@ ofs = self.cpu.get_ofs_of_frame_field('jf_gcmap') mc.store(r.SCRATCH.value, r.SPP.value, ofs) -def break_long_loop(self): +def break_long_loop(self, regalloc): # If the loop is too long, the guards in it will jump forward # more than 32 KB. We use an approximate hack to know if we # should break the loop here with an unconditional "b" that @@ -936,15 +938,19 @@ jmp_pos = self.mc.currpos() self.mc.trap() -self.write_pending_failure_recoveries() +self.write_pending_failure_recoveries(regalloc) currpos = self.mc.currpos() pmc = OverwritingBuilder(self.mc, jmp_pos, 1) pmc.b(currpos - jmp_pos) pmc.overwrite() -def generate_quick_failure(self, guardtok): +def generate_quick_failure(self, guardtok, regalloc): startpos = self.mc.currpos() +# +self._update_at_exit(guardtok.fail_locs, guardtok.failargs, + guardtok.faildescr, regalloc) +# faildescrindex, target = self.store_info_on_descr(startpos, guardtok) assert target != 0 self.mc.load_imm(r.r2, target) @@ -957,13 +963,13 @@ self.mc.trap() return startpos -def write_pending_failure_recoveries(self): +def write_pending_failure_recoveries(self, regalloc): # for each pending guard, generate the code of the recovery stub # at the end of self.mc. for i in range(self.pending_guard_tokens_recovered, len(self.pending_guard_tokens)): tok = self.pending_guard_tokens[i] -tok.pos_recovery_stub = self.generate_quick_failure(tok) +tok.pos_recovery_stub = self.generate_quick_failure(tok, regalloc) self.pending_guard_tokens_recovered = len(self.pending_guard_tokens) def patch_pending_failure_recoveries(self, rawstart): @@ -1358,6 +1364,60 @@ self.mc.load_imm(r.SCRATCH, fail_index) self.mc.store(r.SCRATCH.value, r.SPP.value, FORCE_INDEX_OFS) +def stitch_bridge(self, faildescr, target): +""" Stitching means that one can enter a bridge with a complete different register +allocation. This needs remapping which is done here for both normal registers +and accumulation registers. +""" +import pdb; pdb.set_trace() +asminfo, bridge_faildescr, version, looptoken = target +assert isinstance(bridge_faildescr, ResumeGuardDescr) +assert isinstance(faildescr, ResumeGuardDescr) +assert
[pypy-commit] extradoc extradoc: rewording
Author: Matti PicusBranch: extradoc Changeset: r5644:90f043cebe19 Date: 2016-07-01 14:53 +0300 http://bitbucket.org/pypy/extradoc/changeset/90f043cebe19/ Log:rewording diff --git a/talk/compiler-workshop-2016/pypy.rst b/talk/compiler-workshop-2016/pypy.rst --- a/talk/compiler-workshop-2016/pypy.rst +++ b/talk/compiler-workshop-2016/pypy.rst @@ -7,7 +7,7 @@ - PyPy is a mature production-ready framework automatically speeding up pure -python code by factors of 2-5 in commercial settings. +python code by factors of 2-5, already used in commercial settings. The PyPy community offers several tools to inspect and optimize Python programs. Examples: vmprof, cffi @@ -29,8 +29,8 @@ Flow graphs -> Annotation -> RTyping -> Code generation Advantages: -* Whole program optimizations (take that C) -* Deliver features fast, without sacrificing speed +* Whole program optimizations (take that, C) +* Deliver features quickly, without sacrificing speed * Loosely coupled (JIT, Interp., RPython) Downsides: @@ -44,23 +44,24 @@ under-funded. For instance, we could be doing alot more for data science but are moving slowly forward on a volunteer basis with C-API compatibility. -Our interests lie in still providing the confort of the Python eco system, -but not sacrificing execution time. Some details (e.g. garbage collection scheme) +Our interests lie in still providing the comfort of the Python ecosystem, +without sacrificing execution time. Some details (e.g. garbage collection scheme) have some impact on user programs. We could use a lot more help in identifying and resolving -some of these issues. If programs do not run out of the box, most users will stick to CPython -because their performance problems are not that of an issue (at that point in time). +these issues. If programs do not run out of the box, most users will just stick to CPython +because their performance problems are not that big of an issue (at that point in time). If we could resolve those issues (funded, or externally contributed) we would create a much better user experience. We are also working on Micro NumPy, which provides the kernels for numerical operations. -It is very much complete, but still some features are missing. We would love to have a +It is very usable, but still some features are missing. We would love to have a partner/company that would help us to complete NumPy for PyPy. We are open to changes to our JIT scheme. We are working on both high level optimizations and backend oriented changes. Ideas would be to mitigate some issues with our tracing JIT compiler -(or even build a region based compiler) and many more. Most of these aspects are covered quite well by -our core development team, but we will eventually take another big step in near future towards the 7th version -of our JIT. +(or even build a region based compiler) and many more. Most of these aspects are covered +quite well by +our core development team, but we will eventually take another big step in near +future towards the 7th version of our JIT. Other Interesting Aspects - ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reverse-debugger: Use marshal version 0 to avoid new_interned_str().
Author: Armin RigoBranch: reverse-debugger Changeset: r85486:0f2ae8aeae0c Date: 2016-07-01 12:57 +0200 http://bitbucket.org/pypy/pypy/changeset/0f2ae8aeae0c/ Log:Use marshal version 0 to avoid new_interned_str(). diff --git a/pypy/interpreter/reverse_debugging.py b/pypy/interpreter/reverse_debugging.py --- a/pypy/interpreter/reverse_debugging.py +++ b/pypy/interpreter/reverse_debugging.py @@ -499,9 +499,11 @@ space = dbstate.space try: code = compile(expression, 'eval') +# Note: using version 0 to marshal watchpoints, in order to +# avoid space.new_interned_str() on unmarshal. This is +# forbidden because it comes with lasting side-effects. marshalled_code = space.str_w(interp_marshal.dumps( -space, space.wrap(code), -space.wrap(interp_marshal.Py_MARSHAL_VERSION))) +space, space.wrap(code), space.wrap(0))) except OperationError as e: revdb.send_watch(e.errorstr(space), ok_flag=0) else: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reverse-debugger: A fix that is also an optimization: when single-stepping on a loop
Author: Armin RigoBranch: reverse-debugger Changeset: r85485:259a2938c2c1 Date: 2016-07-01 11:59 +0200 http://bitbucket.org/pypy/pypy/changeset/259a2938c2c1/ Log:A fix that is also an optimization: when single-stepping on a loop while foo: body then it never jumps back to the first bytecode of the "while" line (it jumps back to the 2nd bytecode of that line). But we still want to see it when stepping in the loop. diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -53,10 +53,14 @@ ### opcode dispatch ### def dispatch(self, pycode, next_instr, ec): +if self.space.config.translation.reverse_debugger: +from pypy.interpreter.reverse_debugging import prepare_code +prepare_code(pycode) +# # For the sequel, force 'next_instr' to be unsigned for performance next_instr = r_uint(next_instr) co_code = pycode.co_code - +# try: while True: next_instr = self.handle_bytecode(co_code, next_instr, ec) @@ -1055,6 +1059,11 @@ def jump_absolute(self, jumpto, ec): # this function is overridden by pypy.module.pypyjit.interp_jit check_nonneg(jumpto) +# +if self.space.config.translation.reverse_debugger: +from pypy.interpreter.reverse_debugging import jump_backward +jump_backward(self, jumpto) +# return jumpto def JUMP_FORWARD(self, jumpby, next_instr): @@ -1308,9 +1317,12 @@ self.space.setitem(w_dict, w_key, w_value) def LOAD_REVDB_VAR(self, oparg, next_instr): -from pypy.interpreter.reverse_debugging import load_metavar -w_var = load_metavar(oparg) -self.pushvalue(w_var) +if self.space.config.translation.reverse_debugger: +from pypy.interpreter.reverse_debugging import load_metavar +w_var = load_metavar(oparg) +self.pushvalue(w_var) +else: +self.MISSING_OPCODE(oparg, next_instr) ### ### diff --git a/pypy/interpreter/reverse_debugging.py b/pypy/interpreter/reverse_debugging.py --- a/pypy/interpreter/reverse_debugging.py +++ b/pypy/interpreter/reverse_debugging.py @@ -5,7 +5,7 @@ from rpython.rtyper.annlowlevel import cast_gcref_to_instance from pypy.interpreter.error import OperationError, oefmt from pypy.interpreter.baseobjspace import W_Root -from pypy.interpreter import gateway, typedef, pycode, pytraceback +from pypy.interpreter import gateway, typedef, pycode, pytraceback, pyframe from pypy.module.marshal import interp_marshal @@ -47,7 +47,11 @@ revdb.register_debug_command(revdb.CMD_WATCHVALUES, lambda_watchvalues) -pycode.PyCode.co_revdb_linestarts = None # or a string: an array of bits +pycode.PyCode.co_revdb_linestarts = None # or a string: see below + +# invariant: "f_revdb_nextline_instr" is the bytecode offset of +# the start of the line that follows "last_instr". +pyframe.PyFrame.f_revdb_nextline_instr = 0 def enter_call(caller_frame, callee_frame): @@ -64,6 +68,17 @@ if dbstate.breakpoint_stack_id == revdb.get_unique_id(caller_frame): revdb.breakpoint(-1) + +def jump_backward(frame, jumpto): +# When we see a jump backward, we set 'f_revdb_nextline_instr' in +# such a way that the next instruction, at 'jumpto', will trigger +# stop_point_at_start_of_line(). We have to trigger it even if +# 'jumpto' is not actually a start of line. For example, in a +# 'while foo: body', the body ends with a JUMP_ABSOLUTE which +# jumps back to the *second* opcode of the while. +frame.f_revdb_nextline_instr = jumpto + + def potential_stop_point(frame): if not we_are_translated(): return @@ -72,22 +87,49 @@ # Uses roughly the same algo as ExecutionContext.run_trace_func() # to know where the line starts are, but tweaked for speed, # avoiding the quadratic complexity when run N times with a large -# code object. A potential difference is that we only record -# where the line starts are; the "We jumped backwards in the same -# line" case of run_trace_func() is not fully reproduced. +# code object. # -code = frame.pycode -lstart = code.co_revdb_linestarts -if lstart is None: -lstart = build_co_revdb_linestarts(code) -index = frame.last_instr -c = lstart[index >> 3] -if ord(c) & (1 << (index & 7)): +cur = frame.last_instr +if cur < frame.f_revdb_nextline_instr: +return# fast path: we're still inside the same line as before +# +call_stop_point_at_line = True +co_revdb_linestarts = frame.pycode.co_revdb_linestarts +if cur > frame.f_revdb_nextline_instr: +# +# We jumped forward over the start of the
[pypy-commit] pypy call-via-pyobj: proof of concept using offset-to-function instead of function
Author: Matti PicusBranch: call-via-pyobj Changeset: r85484:5b38ce2c4c11 Date: 2016-07-01 12:53 +0300 http://bitbucket.org/pypy/pypy/changeset/5b38ce2c4c11/ Log:proof of concept using offset-to-function instead of function diff --git a/pypy/module/cpyext/methodobject.py b/pypy/module/cpyext/methodobject.py --- a/pypy/module/cpyext/methodobject.py +++ b/pypy/module/cpyext/methodobject.py @@ -10,9 +10,10 @@ from pypy.module.cpyext.api import ( CONST_STRING, METH_CLASS, METH_COEXIST, METH_KEYWORDS, METH_NOARGS, METH_O, METH_STATIC, METH_VARARGS, PyObject, PyObjectFields, bootstrap_function, -build_type_checkers, cpython_api, cpython_struct, generic_cpy_call) +build_type_checkers, cpython_api, cpython_struct, generic_cpy_call, +PyTypeObjectPtr) from pypy.module.cpyext.pyobject import ( -Py_DecRef, from_ref, make_ref, make_typedescr) +Py_DecRef, from_ref, make_ref, as_pyobj, make_typedescr) PyCFunction_typedef = rffi.COpaquePtr(typedef='PyCFunction') PyCFunction = lltype.Ptr(lltype.FuncType([PyObject, PyObject], PyObject)) @@ -151,13 +152,14 @@ class W_PyCWrapperObject(W_Root): def __init__(self, space, pto, method_name, wrapper_func, - wrapper_func_kwds, doc, func): + wrapper_func_kwds, doc, func, offset=-1): self.space = space self.method_name = method_name self.wrapper_func = wrapper_func self.wrapper_func_kwds = wrapper_func_kwds self.doc = doc self.func = func +self.offset = offset pyo = rffi.cast(PyObject, pto) w_type = from_ref(space, pyo) assert isinstance(w_type, W_TypeObject) @@ -172,7 +174,17 @@ raise oefmt(space.w_TypeError, "wrapper %s doesn't take any keyword arguments", self.method_name) -return self.wrapper_func(space, w_self, w_args, self.func) +if self.offset >= 0: +pto = rffi.cast(PyTypeObjectPtr, as_pyobj(space, self.w_objclass)) +pto_func_as_int = lltype.cast_ptr_to_int(pto) + self.offset +# XXX make pto_func the equivalent of this line +#lltype.cast_int_to_ptr(pto_func_as_int) +func_to_call = rffi.cast(rffi.VOIDP, pto.c_tp_as_number.c_nb_multiply) +# print '\ncalling', func_to_call, 'not', self.func +else: +# print 'calling', self.method_name,'with no offset' +func_to_call = self.func +return self.wrapper_func(space, w_self, w_args, func_to_call) def descr_method_repr(self): return self.space.wrap("" % @@ -301,12 +313,6 @@ def PyDescr_NewClassMethod(space, w_type, method): return space.wrap(W_PyCClassMethodObject(space, method, w_type)) -def PyDescr_NewWrapper(space, pto, method_name, wrapper_func, - wrapper_func_kwds, doc, func): -# not exactly the API sig -return space.wrap(W_PyCWrapperObject(space, pto, method_name, -wrapper_func, wrapper_func_kwds, doc, func)) - @cpython_api([lltype.Ptr(PyMethodDef), PyObject, CONST_STRING], PyObject) def Py_FindMethod(space, table, w_obj, name_ptr): """Return a bound method object for an extension type implemented in diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py --- a/pypy/module/cpyext/typeobject.py +++ b/pypy/module/cpyext/typeobject.py @@ -17,9 +17,9 @@ generic_cpy_call, Py_TPFLAGS_READY, Py_TPFLAGS_READYING, Py_TPFLAGS_HEAPTYPE, METH_VARARGS, METH_KEYWORDS, CANNOT_FAIL, Py_TPFLAGS_HAVE_GETCHARBUFFER, build_type_checkers, StaticObjectBuilder, -PyObjectFields, Py_TPFLAGS_BASETYPE) +PyObjectFields, Py_TPFLAGS_BASETYPE, PyTypeObject, PyTypeObjectPtr) from pypy.module.cpyext.methodobject import (W_PyCClassMethodObject, -PyDescr_NewWrapper, PyCFunction_NewEx, PyCFunction_typedef, PyMethodDef, +W_PyCWrapperObject, PyCFunction_NewEx, PyCFunction_typedef, PyMethodDef, W_PyCMethodObject, W_PyCFunctionObject) from pypy.module.cpyext.modsupport import convert_method_defs from pypy.module.cpyext.pyobject import ( @@ -30,7 +30,7 @@ from pypy.module.cpyext.state import State from pypy.module.cpyext.structmember import PyMember_GetOne, PyMember_SetOne from pypy.module.cpyext.typeobjectdefs import ( -PyTypeObjectPtr, PyTypeObject, PyGetSetDef, PyMemberDef, newfunc, +PyGetSetDef, PyMemberDef, newfunc, PyNumberMethods, PyMappingMethods, PySequenceMethods, PyBufferProcs) from pypy.objspace.std.typeobject import W_TypeObject, find_best_base @@ -296,6 +296,7 @@ for method_name, slot_names, wrapper_func, wrapper_func_kwds, doc in slotdefs_for_wrappers: if method_name in dict_w: continue +offset = rffi.offsetof(pto._T, slot_names[0]) if len(slot_names) == 1: func = getattr(pto, slot_names[0]) else: @@ -303,14 +304,24 @@ struct = getattr(pto,
[pypy-commit] pypy call-via-pyobj: add a failing test
Author: Matti PicusBranch: call-via-pyobj Changeset: r85483:143f7a33f037 Date: 2016-07-01 12:45 +0300 http://bitbucket.org/pypy/pypy/changeset/143f7a33f037/ Log:add a failing test diff --git a/pypy/module/cpyext/test/array.c b/pypy/module/cpyext/test/array.c --- a/pypy/module/cpyext/test/array.c +++ b/pypy/module/cpyext/test/array.c @@ -2144,6 +2144,15 @@ return array_new(type, args, NULL); } +static PyObject * +switch_multiply(void) +{ +fprintf(stdout, "switching nb_multiply from %p to %p\n", +Arraytype.tp_as_number->nb_multiply, array_base_multiply); +Arraytype.tp_as_number->nb_multiply = array_base_multiply; +Py_RETURN_NONE; +}; + PyDoc_STRVAR(module_doc, "This module defines an object type which can efficiently represent\n\ an array of basic values: characters, integers, floating point\n\ @@ -2394,6 +2403,7 @@ /* No functions in array module. */ static PyMethodDef a_methods[] = { {"_reconstruct", (PyCFunction)_reconstruct, METH_VARARGS, NULL}, +{"switch_multiply", (PyCFunction)switch_multiply, METH_NOARGS, NULL}, {NULL, NULL, 0, NULL}/* Sentinel */ }; diff --git a/pypy/module/cpyext/test/test_arraymodule.py b/pypy/module/cpyext/test/test_arraymodule.py --- a/pypy/module/cpyext/test/test_arraymodule.py +++ b/pypy/module/cpyext/test/test_arraymodule.py @@ -84,3 +84,7 @@ arr = module.array('i', [2]) res = [1, 2, 3] * arr assert res == [1, 2, 3, 1, 2, 3] +module.switch_multiply() +res = [1, 2, 3] * arr +assert res == [2, 4, 6] + ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ppc-vsx-support: merge default
Author: Richard PlanggerBranch: ppc-vsx-support Changeset: r85482:71642c531e12 Date: 2016-07-01 10:41 +0200 http://bitbucket.org/pypy/pypy/changeset/71642c531e12/ Log:merge default diff too long, truncating to 2000 out of 6953 lines diff --git a/pypy/doc/config/commandline.txt b/pypy/doc/config/commandline.txt --- a/pypy/doc/config/commandline.txt +++ b/pypy/doc/config/commandline.txt @@ -9,7 +9,7 @@ PyPy Python interpreter options --- -The following options can be used after ``translate.py +The following options can be used after ``rpython targetpypystandalone`` or as options to ``py.py``. .. GENERATE: objspace @@ -22,7 +22,7 @@ General translation options --- -The following are options of ``translate.py``. They must be +The following are options of ``bin/rpython``. They must be given before the ``targetxxx`` on the command line. * `--opt -O:`__ set the optimization level `[0, 1, size, mem, 2, 3]` diff --git a/pypy/doc/config/index.rst b/pypy/doc/config/index.rst --- a/pypy/doc/config/index.rst +++ b/pypy/doc/config/index.rst @@ -15,12 +15,12 @@ ./py.py <`objspace options`_> -and the ``translate.py`` translation entry +and the ``rpython/bin/rpython`` translation entry point which takes arguments of this form: .. parsed-literal:: -./translate.py <`translation options`_> +./rpython/bin/rpython <`translation options`_> For the common case of being ``targetpypystandalone.py``, you can then pass the `object space options`_ after @@ -28,7 +28,7 @@ .. parsed-literal:: -./translate.py <`translation options`_> targetpypystandalone.py <`objspace options`_> +./rpython/bin/rpython <`translation options`_> targetpypystandalone.py <`objspace options`_> There is an `overview`_ of all command line arguments that can be passed in either position. diff --git a/pypy/doc/config/opt.rst b/pypy/doc/config/opt.rst --- a/pypy/doc/config/opt.rst +++ b/pypy/doc/config/opt.rst @@ -4,8 +4,8 @@ This meta-option selects a default set of optimization settings to use during a translation. Usage:: -translate.py --opt=# -translate.py -O# +bin/rpython --opt=# +bin/rpython -O# where ``#`` is the desired optimization level. The valid choices are: diff --git a/pypy/doc/config/translation.dont_write_c_files.txt b/pypy/doc/config/translation.dont_write_c_files.txt --- a/pypy/doc/config/translation.dont_write_c_files.txt +++ b/pypy/doc/config/translation.dont_write_c_files.txt @@ -1,4 +1,4 @@ write the generated C files to ``/dev/null`` instead of to the disk. Useful if -you want to use translate.py as a benchmark and don't want to access the disk. +you want to use translation as a benchmark and don't want to access the disk. .. _`translation documentation`: ../translation.html diff --git a/pypy/doc/config/translation.fork_before.txt b/pypy/doc/config/translation.fork_before.txt --- a/pypy/doc/config/translation.fork_before.txt +++ b/pypy/doc/config/translation.fork_before.txt @@ -1,4 +1,4 @@ This is an option mostly useful when working on the PyPy toolchain. If you use -it, translate.py will fork before the specified phase. If the translation +it, translation will fork before the specified phase. If the translation crashes after that fork, you can fix the bug in the toolchain, and continue translation at the fork-point. diff --git a/pypy/doc/cppyy.rst b/pypy/doc/cppyy.rst --- a/pypy/doc/cppyy.rst +++ b/pypy/doc/cppyy.rst @@ -122,7 +122,7 @@ $ hg up reflex-support # optional # This example shows python, but using pypy-c is faster and uses less memory -$ python rpython/translator/goal/translate.py --opt=jit pypy/goal/targetpypystandalone --withmod-cppyy +$ python rpython/bin/rpython --opt=jit pypy/goal/targetpypystandalone --withmod-cppyy This will build a ``pypy-c`` that includes the cppyy module, and through that, Reflex support. 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 @@ -1,6 +1,6 @@ -= +== What's new in PyPy2.7 5.3+ -= +== .. this is a revision shortly after release-pypy2.7-v5.3 .. startrev: 873218a739f1 @@ -37,3 +37,19 @@ .. branch: pyfile-tell Sync w_file with the c-level FILE* before returning FILE* in PyFile_AsFile + +.. branch: rw-PyString_AS_STRING +Allow rw access to the char* returned from PyString_AS_STRING, also refactor +PyStringObject to look like cpython's and allow subclassing PyString_Type and +PyUnicode_Type + +.. branch: save_socket_errno + +Bug fix: if ``socket.socket()`` failed, the ``socket.error`` did not show +the errno of the failing system call, but instead some random previous +errno. + +.. branch: PyTuple_Type-subclass + +Refactor PyTupleObject to look like cpython's and allow subclassing
[pypy-commit] pypy default: removed tests that call int_floordiv, this operation does not exist anymore (arm)
Author: Richard PlanggerBranch: Changeset: r85481:518a6a527292 Date: 2016-07-01 10:36 +0200 http://bitbucket.org/pypy/pypy/changeset/518a6a527292/ Log:removed tests that call int_floordiv, this operation does not exist anymore (arm) diff --git a/rpython/jit/backend/arm/test/test_assembler.py b/rpython/jit/backend/arm/test/test_assembler.py --- a/rpython/jit/backend/arm/test/test_assembler.py +++ b/rpython/jit/backend/arm/test/test_assembler.py @@ -1,6 +1,5 @@ from rpython.jit.backend.arm import conditions as c from rpython.jit.backend.arm import registers as r -from rpython.jit.backend.arm.support import arm_int_div from rpython.jit.backend.arm.assembler import AssemblerARM from rpython.jit.backend.arm.locations import imm from rpython.jit.backend.arm.test.support import run_asm @@ -180,19 +179,6 @@ self.a.gen_func_epilog() assert run_asm(self.a) == 133 -def test_division(self): -self.a.gen_func_prolog() -self.a.mc.MOV_ri(r.r0.value, 123) -self.a.mc.MOV_ri(r.r1.value, 2) - -# call to div -self.a.mc.PUSH(range(2, 12)) -div_addr = rffi.cast(lltype.Signed, arm_int_div) -self.a.mc.BL(div_addr) -self.a.mc.POP(range(2, 12)) -self.a.gen_func_epilog() -assert run_asm(self.a) == 61 - def test_bl_with_conditional_exec(self): functype = lltype.Ptr(lltype.FuncType([lltype.Signed], lltype.Signed)) call_addr = rffi.cast(lltype.Signed, llhelper(functype, callme)) diff --git a/rpython/jit/backend/arm/test/test_regalloc.py b/rpython/jit/backend/arm/test/test_regalloc.py --- a/rpython/jit/backend/arm/test/test_regalloc.py +++ b/rpython/jit/backend/arm/test/test_regalloc.py @@ -545,23 +545,6 @@ self.interpret(ops, [s, 1234567890]) assert s[1] == 1234567890 -def test_division_optimized(self): -ops = ''' -[i7, i6] -label(i7, i6, descr=targettoken) -i18 = int_floordiv(i7, i6) -i19 = int_xor(i7, i6) -i21 = int_lt(i19, 0) -i22 = int_mod(i7, i6) -i23 = int_is_true(i22) -i24 = int_eq(i6, 4) -guard_false(i24) [i18] -jump(i18, i6, descr=targettoken) -''' -self.interpret(ops, [10, 4]) -assert self.getint(0) == 2 -# FIXME: Verify that i19 - i23 are removed - class TestRegallocFloats(CustomBaseTestRegalloc): def test_float_add(self): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: remove a little endian check. ctypes does not assign arrays in big endian order for int128_t (s390x)
Author: Richard PlanggerBranch: Changeset: r85480:e3bd32fc0036 Date: 2016-07-01 10:16 +0200 http://bitbucket.org/pypy/pypy/changeset/e3bd32fc0036/ Log:remove a little endian check. ctypes does not assign arrays in big endian order for int128_t (s390x) 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 @@ -171,10 +171,7 @@ _length_ = 2 @property def value(self): -if sys.byteorder == 'little': -res = self[0] | (self[1] << 64) -else: -res = self[1] | (self[0] << 64) +res = self[0] | (self[1] << 64) if res >= (1 << 127): res -= 1 << 128 return res ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit