[pypy-commit] pypy test-cpyext: Fix test_recursive_package_import to actually check what it claims to
Author: Ronan LamyBranch: test-cpyext Changeset: r86967:3b5fd17a3cac Date: 2016-09-08 19:28 +0100 http://bitbucket.org/pypy/pypy/changeset/3b5fd17a3cac/ Log:Fix test_recursive_package_import to actually check what it claims to diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -641,7 +641,6 @@ apple.__path__ = [os.path.dirname(banana)] import cherry.date -import apple.banana assert sys.modules['apple.banana'].__name__ == 'apple.banana' assert sys.modules['cherry.date'].__name__ == 'cherry.date' ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy test-cpyext: kill w_record_imported_module and unskip test_recursive_package_import() on -A
Author: Ronan LamyBranch: test-cpyext Changeset: r86968:9374f605480e Date: 2016-09-08 23:13 +0100 http://bitbucket.org/pypy/pypy/changeset/9374f605480e/ Log:kill w_record_imported_module and unskip test_recursive_package_import() on -A diff --git a/pypy/module/cpyext/bufferobject.py b/pypy/module/cpyext/bufferobject.py --- a/pypy/module/cpyext/bufferobject.py +++ b/pypy/module/cpyext/bufferobject.py @@ -61,6 +61,7 @@ py_buf.c_b_ptr = rffi.cast(rffi.VOIDP, buf.array._charbuf_start()) py_buf.c_b_size = buf.getlength() else: +raise RuntimeError raise oefmt(space.w_NotImplementedError, "buffer flavor not supported") diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -317,6 +317,15 @@ if not cls.runappdirect: cls.w_runappdirect = space.wrap(cls.runappdirect) +def record_imported_module(self, name): +""" +Record a module imported in a test so that it can be cleaned up in +teardown before the check for leaks is done. + +name gives the name of the module in the space's sys.modules. +""" +self.imported_module_names.append(name) + def setup_method(self, func): @gateway.unwrap_spec(name=str) def compile_module(space, name, @@ -337,6 +346,11 @@ name, source_files=source_files, source_strings=source_strings) + +# hackish, but tests calling compile_module() always end up +# importing the result +self.record_imported_module(name) + return space.wrap(pydname) @gateway.unwrap_spec(name=str, init='str_or_None', body=str, @@ -399,7 +413,7 @@ return imp.load_dynamic(name, mod) else: api.load_extension_module(space, mod, name) -self.imported_module_names.append(name) +self.record_imported_module(name) return space.getitem( space.sys.get('modules'), space.wrap(name)) @@ -429,16 +443,6 @@ w_include_dirs=w_include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) -@gateway.unwrap_spec(name=str) -def record_imported_module(name): -""" -Record a module imported in a test so that it can be cleaned up in -teardown before the check for leaks is done. - -name gives the name of the module in the space's sys.modules. -""" -self.imported_module_names.append(name) - def debug_collect(space): rawrefcount._collect() @@ -468,7 +472,6 @@ self.w_import_module = wrap(interp2app(import_module)) self.w_reimport_module = wrap(interp2app(reimport_module)) self.w_import_extension = wrap(interp2app(import_extension)) -self.w_record_imported_module = wrap(interp2app(record_imported_module)) self.w_here = wrap(str(py.path.local(pypydir)) + '/module/cpyext/test/') self.w_debug_collect = wrap(interp2app(debug_collect)) @@ -621,15 +624,11 @@ If `cherry.date` is an extension module which imports `apple.banana`, the latter is added to `sys.modules` for the `"apple.banana"` key. """ -if self.runappdirect: -skip('record_imported_module not supported in runappdirect mode') # Build the extensions. banana = self.compile_module( "apple.banana", source_files=[self.here + 'banana.c']) -self.record_imported_module("apple.banana") date = self.compile_module( "cherry.date", source_files=[self.here + 'date.c']) -self.record_imported_module("cherry.date") # Set up some package state so that the extensions can actually be # imported. ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reverse-debugger: Remove the runtime part, move it to http://bitbucket.org/pypy/revdb/
Author: Armin RigoBranch: reverse-debugger Changeset: r86966:9f8dd66da2a9 Date: 2016-09-08 18:01 +0200 http://bitbucket.org/pypy/pypy/changeset/9f8dd66da2a9/ Log:Remove the runtime part, move it to http://bitbucket.org/pypy/revdb/ diff --git a/rpython/translator/revdb/ancillary.py b/rpython/translator/revdb/ancillary.py deleted file mode 100644 --- a/rpython/translator/revdb/ancillary.py +++ /dev/null @@ -1,57 +0,0 @@ -import py -import os, sys - - -def build(tmpdir): -import cffi -ffibuilder = cffi.FFI() - -ffibuilder.cdef(""" -int ancil_send_fds(int, const int *, unsigned); -int ancil_recv_fds(int, int *, unsigned); -""") - -local_dir = os.path.dirname(os.path.abspath(__file__)) -src_dir = os.path.join(local_dir, 'src-revdb') - -ffibuilder.set_source("_ancillary_cffi", """ -#include -""", include_dirs=[src_dir], - sources=[os.path.join(src_dir, 'fd_send.c'), - os.path.join(src_dir, 'fd_recv.c')]) - -ffibuilder.compile(tmpdir=tmpdir, verbose=True) - -def import_(verbose=False): -import rpython -basedir = py.path.local(rpython.__file__).dirpath() -tmpdir = str(basedir.ensure('_cache', 'ancillary', dir=1)) -if verbose: -print tmpdir -old_sys_path = sys.path[:] -sys.path.insert(0, tmpdir) -try: -import _ancillary_cffi -except ImportError: -build(tmpdir) -import _ancillary_cffi -sys.path[:] = old_sys_path -return _ancillary_cffi.ffi, _ancillary_cffi.lib - - -def send_fds(pipe_num, fd_list): -ffi, lib = import_() -if lib.ancil_send_fds(pipe_num, fd_list, len(fd_list)) < 0: -raise OSError(ffi.errno, "ancil_send_fds() failed") - -def recv_fds(pipe_num, fd_count): -ffi, lib = import_() -p = ffi.new("int[]", fd_count) -result = lib.ancil_recv_fds(pipe_num, p, fd_count) -if result < 0: -raise OSError(ffi.errno, "ancil_recv_fds() failed") -return [p[i] for i in xrange(result)] - - -if __name__ == '__main__': -import_(verbose=True) diff --git a/rpython/translator/revdb/interact.py b/rpython/translator/revdb/interact.py deleted file mode 100644 --- a/rpython/translator/revdb/interact.py +++ /dev/null @@ -1,492 +0,0 @@ -import sys, os, re -import subprocess, socket -import traceback, linecache -from contextlib import contextmanager -try: -import readline -except ImportError: -pass - -from rpython.translator.revdb.process import ReplayProcessGroup -from rpython.translator.revdb.process import Breakpoint - -r_cmdline = re.compile(r"([a-zA-Z0-9_]\S*|.)\s*(.*)") -r_dollar_num = re.compile(r"\$(\d+)\b") - - -class RevDebugControl(object): - -def __init__(self, revdb_log_filename, executable=None, - pygments_background=None): -with open(revdb_log_filename, 'rb') as f: -header = f.readline() -assert header.endswith('\n') -fields = header[:-1].split('\t') -if len(fields) < 2 or fields[0] != 'RevDB:': -raise ValueError("file %r is not a RevDB log" % ( -revdb_log_filename,)) -if executable is None: -executable = fields[1] -if not os.path.isfile(executable): -raise ValueError("executable %r not found" % (executable,)) -linecacheoutput = self.getlinecacheoutput(pygments_background) -self.pgroup = ReplayProcessGroup(executable, revdb_log_filename, - linecacheoutput) -self.print_extra_pending_info = None - -def interact(self): -self.last_command = 'help' -self.previous_time = None -self.previous_thread = 0 -while True: -prompt = self.print_lines_before_prompt() -try: -while True: -cmdline = self.display_prompt(prompt) -self.run_command(cmdline) -prompt = self.print_lines_before_prompt() -except KeyboardInterrupt: -rtime = self.previous_time or 1 -print -print 'KeyboardInterrupt: restoring state at time %d...' % ( -rtime,) -self.pgroup.recreate_subprocess(rtime) -print "(type 'q' or Ctrl-D to quit)" -self.last_command = '' -self.previous_thread = '?' -self.previous_time = '?' - -def print_lines_before_prompt(self): -last_time = self.pgroup.get_current_time() -if last_time != self.previous_time: -print -if self.pgroup.get_current_thread() != self.previous_thread: -self.previous_thread = self.pgroup.get_current_thread() -if self.previous_thread == 0: -print (' in main thread #0 ' - '') -else: -print ('
[pypy-commit] pypy test-cpyext: Simplify load_it=False logic in import_module()
Author: Ronan LamyBranch: test-cpyext Changeset: r86965:2224e01830ae Date: 2016-09-08 18:15 +0100 http://bitbucket.org/pypy/pypy/changeset/2224e01830ae/ Log:Simplify load_it=False logic in import_module() diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -178,6 +178,7 @@ return arg listview = passthrough str_w = passthrough +wrap = passthrough def unwrap(self, args): try: @@ -391,22 +392,18 @@ mod = self.sys_info.compile_extension_module( name, include_dirs=include_dirs, **kwds) -if load_it: -if self.runappdirect: -import imp -return imp.load_dynamic(name, mod) -else: -api.load_extension_module(space, mod, name) -self.imported_module_names.append(name) -return space.getitem( -space.sys.get('modules'), -space.wrap(name)) +if not load_it: +return space.wrap(mod) +if self.runappdirect: +import imp +return imp.load_dynamic(name, mod) else: -path = os.path.dirname(mod) -if self.runappdirect: -return path -else: -return space.wrap(path) +api.load_extension_module(space, mod, name) +self.imported_module_names.append(name) +return space.getitem( +space.sys.get('modules'), +space.wrap(name)) + @gateway.unwrap_spec(mod=str, name=str) def reimport_module(space, mod, name): diff --git a/pypy/module/cpyext/test/test_import.py b/pypy/module/cpyext/test/test_import.py --- a/pypy/module/cpyext/test/test_import.py +++ b/pypy/module/cpyext/test/test_import.py @@ -1,6 +1,6 @@ from pypy.module.cpyext.test.test_api import BaseApiTest from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase -from rpython.rtyper.lltypesystem import rffi, lltype +from rpython.rtyper.lltypesystem import rffi class TestImport(BaseApiTest): def test_import(self, space, api): @@ -39,9 +39,8 @@ class AppTestImportLogic(AppTestCpythonExtensionBase): def test_import_logic(self): +import sys, os path = self.import_module(name='test_import_module', load_it=False) -import sys -sys.path.append(path) +sys.path.append(os.path.dirname(path)) import test_import_module assert test_import_module.TEST is None - ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy test-cpyext: Simplify import_extension() by extracting make_methods()
Author: Ronan LamyBranch: test-cpyext Changeset: r86964:8ed4d2de2eed Date: 2016-09-08 17:57 +0100 http://bitbucket.org/pypy/pypy/changeset/8ed4d2de2eed/ Log:Simplify import_extension() by extracting make_methods() diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -136,6 +136,28 @@ link_extra=link_extra, ext=get_so_suffix()) +def make_methods(functions, modname): +methods_table = [] +codes = [] +for funcname, flags, code in functions: +cfuncname = "%s_%s" % (modname, funcname) +methods_table.append( +"{\"%s\", %s, %s}," % (funcname, cfuncname, flags)) +func_code = """ +static PyObject* %s(PyObject* self, PyObject* args) +{ +%s +} +""" % (cfuncname, code) +codes.append(func_code) + +body = "\n".join(codes) + """ +static PyMethodDef methods[] = { +%s +{ NULL } +}; +""" % ('\n'.join(methods_table),) +return body def freeze_refcnts(self): rawrefcount._dont_free_any_more() @@ -402,26 +424,7 @@ def import_extension(space, modname, w_functions, prologue="", w_include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): functions = space.unwrap(w_functions) -methods_table = [] -codes = [] -for funcname, flags, code in functions: -cfuncname = "%s_%s" % (modname, funcname) -methods_table.append("{\"%s\", %s, %s}," % - (funcname, cfuncname, flags)) -func_code = """ -static PyObject* %s(PyObject* self, PyObject* args) -{ -%s -} -""" % (cfuncname, code) -codes.append(func_code) - -body = prologue + "\n".join(codes) + """ -static PyMethodDef methods[] = { -%s -{ NULL } -}; -""" % ('\n'.join(methods_table),) +body = prologue + make_methods(functions, modname) init = """Py_InitModule("%s", methods);""" % (modname,) if more_init: init += more_init ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Update whatsnew-head for the force-virtual-state
Author: Spenser Andrew BaumanBranch: Changeset: r86963:b21c171b5632 Date: 2016-09-08 12:55 -0400 http://bitbucket.org/pypy/pypy/changeset/b21c171b5632/ Log:Update whatsnew-head for the force-virtual-state 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 @@ -12,4 +12,7 @@ Implement PyObject_GetBuffer, PyMemoryView_GET_BUFFER, and handles memoryviews in numpypy - +.. branch: force-virtual-state +Improve merging of virtual states in the JIT in order to avoid jumping to the +preamble. Accomplished by allocating virtual objects where non-virtuals are +expected. ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy test-cpyext: Inline create_so()
Author: Ronan LamyBranch: test-cpyext Changeset: r86962:0ab65e47f082 Date: 2016-09-08 16:47 +0100 http://bitbucket.org/pypy/pypy/changeset/0ab65e47f082/ Log:Inline create_so() diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -40,19 +40,6 @@ files.append(filename) return files -def create_so(modname, include_dirs, source_strings=None, source_files=None, -compile_extra=None, link_extra=None, libraries=None): -dirname = (udir/uniquemodulename('module')).ensure(dir=1) -if source_strings: -assert not source_files -files = convert_sources_to_files(source_strings, dirname) -source_files = files -soname = c_compile(source_files, outputfilename=str(dirname/modname), -compile_extra=compile_extra, link_extra=link_extra, -include_dirs=include_dirs, -libraries=libraries) -return soname - class SystemCompilationInfo(object): """Bundles all the generic information required to compile extensions. @@ -69,22 +56,25 @@ def compile_extension_module(self, modname, include_dirs=[], source_files=None, source_strings=None): """ -Build an extension module and return the filename of the resulting native -code file. +Build an extension module and return the filename of the resulting +native code file. -modname is the name of the module, possibly including dots if it is a module -inside a package. +modname is the name of the module, possibly including dots if it is a +module inside a package. Any extra keyword arguments are passed on to ExternalCompilationInfo to build the module (so specify your source with one of those). """ modname = modname.split('.')[-1] -soname = create_so(modname, -include_dirs=self.include_extra + include_dirs, -source_files=source_files, -source_strings=source_strings, +dirname = (udir/uniquemodulename('module')).ensure(dir=1) +if source_strings: +assert not source_files +files = convert_sources_to_files(source_strings, dirname) +source_files = files +soname = c_compile(source_files, outputfilename=str(dirname/modname), compile_extra=self.compile_extra, link_extra=self.link_extra, +include_dirs=self.include_extra + include_dirs, libraries=self.extra_libs) pydname = soname.new(purebasename=modname, ext=self.ext) soname.rename(pydname) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy test-cpyext: Make compile_extension_module() a method of sys_info
Author: Ronan LamyBranch: test-cpyext Changeset: r86961:395605edacba Date: 2016-09-08 16:29 +0100 http://bitbucket.org/pypy/pypy/changeset/395605edacba/ Log:Make compile_extension_module() a method of sys_info diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -66,6 +66,30 @@ self.extra_libs = extra_libs self.ext = ext +def compile_extension_module(self, modname, include_dirs=[], +source_files=None, source_strings=None): +""" +Build an extension module and return the filename of the resulting native +code file. + +modname is the name of the module, possibly including dots if it is a module +inside a package. + +Any extra keyword arguments are passed on to ExternalCompilationInfo to +build the module (so specify your source with one of those). +""" +modname = modname.split('.')[-1] +soname = create_so(modname, +include_dirs=self.include_extra + include_dirs, +source_files=source_files, +source_strings=source_strings, +compile_extra=self.compile_extra, +link_extra=self.link_extra, +libraries=self.extra_libs) +pydname = soname.new(purebasename=modname, ext=self.ext) +soname.rename(pydname) +return str(pydname) + def get_cpyext_info(space): from pypy.module.imp.importing import get_so_extension state = space.fromcache(State) @@ -94,30 +118,6 @@ ext=get_so_extension(space)) -def compile_extension_module(sys_info, modname, include_dirs=[], -source_files=None, source_strings=None): -""" -Build an extension module and return the filename of the resulting native -code file. - -modname is the name of the module, possibly including dots if it is a module -inside a package. - -Any extra keyword arguments are passed on to ExternalCompilationInfo to -build the module (so specify your source with one of those). -""" -modname = modname.split('.')[-1] -soname = create_so(modname, -include_dirs=sys_info.include_extra + include_dirs, -source_files=source_files, -source_strings=source_strings, -compile_extra=sys_info.compile_extra, -link_extra=sys_info.link_extra, -libraries=sys_info.extra_libs) -pydname = soname.new(purebasename=modname, ext=sys_info.ext) -soname.rename(pydname) -return str(pydname) - def get_so_suffix(): from imp import get_suffixes, C_EXTENSION for suffix, mode, typ in get_suffixes(): @@ -320,8 +320,8 @@ source_strings = space.listview_bytes(w_source_strings) else: source_strings = None -pydname = compile_extension_module( -self.sys_info, name, +pydname = self.sys_info.compile_extension_module( +name, source_files=source_files, source_strings=source_strings) return space.wrap(pydname) @@ -376,8 +376,8 @@ filename = py.path.local(pypydir) / 'module' \ / 'cpyext'/ 'test' / (filename + ".c") kwds = dict(source_files=[filename]) -mod = compile_extension_module(self.sys_info, name, -include_dirs=include_dirs, **kwds) +mod = self.sys_info.compile_extension_module( +name, include_dirs=include_dirs, **kwds) if load_it: if self.runappdirect: @@ -469,11 +469,12 @@ def wrap(func): return func self.sys_info = get_sys_info_app() +self.compile_module = self.sys_info.compile_extension_module else: interp2app = gateway.interp2app wrap = self.space.wrap self.sys_info = get_cpyext_info(self.space) -self.w_compile_module = wrap(interp2app(compile_module)) +self.w_compile_module = wrap(interp2app(compile_module)) self.w_import_module = wrap(interp2app(import_module)) self.w_reimport_module = wrap(interp2app(reimport_module)) self.w_import_extension = wrap(interp2app(import_extension)) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Merge in force-virtual-state
Author: Spenser Andrew BaumanBranch: Changeset: r86960:990479cf9d20 Date: 2016-09-08 11:33 -0400 http://bitbucket.org/pypy/pypy/changeset/990479cf9d20/ Log:Merge in force-virtual-state diff --git a/rpython/jit/metainterp/optimizeopt/info.py b/rpython/jit/metainterp/optimizeopt/info.py --- a/rpython/jit/metainterp/optimizeopt/info.py +++ b/rpython/jit/metainterp/optimizeopt/info.py @@ -365,6 +365,13 @@ def visitor_dispatch_virtual_type(self, visitor): raise NotImplementedError("abstract") +def make_guards(self, op, short, optimizer): +from rpython.jit.metainterp.optimizeopt.optimizer import CONST_0 +op = ResOperation(rop.INT_EQ, [op, CONST_0]) +short.append(op) +op = ResOperation(rop.GUARD_FALSE, [op]) +short.append(op) + class RawBufferPtrInfo(AbstractRawPtrInfo): buffer = None diff --git a/rpython/jit/metainterp/optimizeopt/unroll.py b/rpython/jit/metainterp/optimizeopt/unroll.py --- a/rpython/jit/metainterp/optimizeopt/unroll.py +++ b/rpython/jit/metainterp/optimizeopt/unroll.py @@ -16,7 +16,7 @@ from rpython.rlib.debug import debug_print, debug_start, debug_stop,\ have_debug_prints -class UnrollableOptimizer(Optimizer): +class UnrollableOptimizer(Optimizer): def force_op_from_preamble(self, preamble_op): if isinstance(preamble_op, PreambleOp): if self.optunroll.short_preamble_producer is None: @@ -120,7 +120,8 @@ assert op.get_forwarded() is None if check_newops: assert not self.optimizer._newoperations - + + def optimize_preamble(self, trace, runtime_boxes, call_pure_results, memo): info, newops = self.optimizer.propagate_all_forward( trace.get_iter(), call_pure_results, flush=False) @@ -156,7 +157,7 @@ current_vs = self.get_virtual_state(end_jump.getarglist()) # pick the vs we want to jump to assert isinstance(celltoken, JitCellToken) - + target_virtual_state = self.pick_virtual_state(current_vs, state.virtual_state, celltoken.target_tokens) @@ -180,17 +181,27 @@ self.jump_to_preamble(celltoken, end_jump, info) return (UnrollInfo(target_token, label_op, extra_same_as, self.optimizer.quasi_immutable_deps), -self.optimizer._newoperations) +self.optimizer._newoperations) try: -new_virtual_state = self.jump_to_existing_trace(end_jump, label_op, - state.runtime_boxes) +new_virtual_state = self.jump_to_existing_trace( +end_jump, label_op, state.runtime_boxes, force_boxes=False) except InvalidLoop: # inlining short preamble failed, jump to preamble self.jump_to_preamble(celltoken, end_jump, info) return (UnrollInfo(target_token, label_op, extra_same_as, self.optimizer.quasi_immutable_deps), self.optimizer._newoperations) + +if new_virtual_state is not None: +# Attempt to force virtual boxes in order to avoid jumping +# to the preamble. +try: +new_virtual_state = self.jump_to_existing_trace( +end_jump, label_op, state.runtime_boxes, force_boxes=True) +except InvalidLoop: +pass + if new_virtual_state is not None: self.jump_to_preamble(celltoken, end_jump, info) return (UnrollInfo(target_token, label_op, extra_same_as, @@ -199,7 +210,7 @@ self.disable_retracing_if_max_retrace_guards( self.optimizer._newoperations, target_token) - + return (UnrollInfo(target_token, label_op, extra_same_as, self.optimizer.quasi_immutable_deps), self.optimizer._newoperations) @@ -241,7 +252,8 @@ for a in jump_op.getarglist(): self.optimizer.force_box_for_end_of_preamble(a) try: -vs = self.jump_to_existing_trace(jump_op, None, runtime_boxes) +vs = self.jump_to_existing_trace(jump_op, None, runtime_boxes, + force_boxes=False) except InvalidLoop: return self.jump_to_preamble(cell_token, jump_op, info) if vs is None: @@ -252,6 +264,14 @@ cell_token.retraced_count += 1 debug_print('Retracing (%d/%d)' % (cell_token.retraced_count, limit)) else: +# Try forcing boxes to avoid jumping to the preamble +try: +vs = self.jump_to_existing_trace(jump_op, None, runtime_boxes, + force_boxes=True) +
[pypy-commit] pypy default: Align wrapped method compile_module() API with compile_module() function
Author: Ronan LamyBranch: Changeset: r86959:af84bf7ba373 Date: 2016-09-08 15:37 +0100 http://bitbucket.org/pypy/pypy/changeset/af84bf7ba373/ Log:Align wrapped method compile_module() API with compile_module() function diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -307,27 +307,23 @@ def setup_method(self, func): @gateway.unwrap_spec(name=str) def compile_module(space, name, - w_separate_module_files=None, - w_separate_module_sources=None): + w_source_files=None, + w_source_strings=None): """ Build an extension module linked against the cpyext api library. """ -if not space.is_none(w_separate_module_files): -separate_module_files = space.listview_bytes( -w_separate_module_files) -assert separate_module_files is not None +if not space.is_none(w_source_files): +source_files = space.listview_bytes(w_source_files) else: -separate_module_files = [] -if not space.is_none(w_separate_module_sources): -separate_module_sources = space.listview_bytes( -w_separate_module_sources) -assert separate_module_sources is not None +source_files = None +if not space.is_none(w_source_strings): +source_strings = space.listview_bytes(w_source_strings) else: -separate_module_sources = [] +source_strings = None pydname = compile_extension_module( self.sys_info, name, -source_files=separate_module_files, -source_strings=separate_module_sources) +source_files=source_files, +source_strings=source_strings) return space.wrap(pydname) @gateway.unwrap_spec(name=str, init='str_or_None', body=str, @@ -638,10 +634,10 @@ skip('record_imported_module not supported in runappdirect mode') # Build the extensions. banana = self.compile_module( -"apple.banana", separate_module_files=[self.here + 'banana.c']) +"apple.banana", source_files=[self.here + 'banana.c']) self.record_imported_module("apple.banana") date = self.compile_module( -"cherry.date", separate_module_files=[self.here + 'date.c']) +"cherry.date", source_files=[self.here + 'date.c']) self.record_imported_module("cherry.date") # Set up some package state so that the extensions can actually be ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy force-virtual-state: Merge
Author: Spenser Andrew BaumanBranch: force-virtual-state Changeset: r86958:3a3067bcf4c9 Date: 2016-09-08 09:39 -0400 http://bitbucket.org/pypy/pypy/changeset/3a3067bcf4c9/ Log:Merge diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -30,3 +30,4 @@ 68bb3510d8212ae9efb687e12e58c09d29e74f87 release-pypy2.7-v5.4.0 68bb3510d8212ae9efb687e12e58c09d29e74f87 release-pypy2.7-v5.4.0 77392ad263504df011ccfcabf6a62e21d04086d0 release-pypy2.7-v5.4.0 +050d84dd78997f021acf0e133934275d63547cc0 release-pypy2.7-v5.4.1 diff --git a/pypy/doc/index-of-release-notes.rst b/pypy/doc/index-of-release-notes.rst --- a/pypy/doc/index-of-release-notes.rst +++ b/pypy/doc/index-of-release-notes.rst @@ -6,6 +6,7 @@ .. toctree:: + release-pypy2.7-v5.4.1.rst release-pypy2.7-v5.4.0.rst release-pypy2.7-v5.3.1.rst release-pypy2.7-v5.3.0.rst diff --git a/pypy/doc/release-pypy2.7-v5.4.1.rst b/pypy/doc/release-pypy2.7-v5.4.1.rst new file mode 100644 --- /dev/null +++ b/pypy/doc/release-pypy2.7-v5.4.1.rst @@ -0,0 +1,61 @@ +== +PyPy 5.4.1 +== + +We have released a bugfix for PyPy2.7-v5.4.0, released last week, +due to the following issues: + + * Update list of contributors in documentation and LICENSE file, +this was unfortunately left out of 5.4.0. My apoligies to the new +contributors + + * Allow tests run with `-A` to find `libm.so` even if it is a script not a +dynamically loadable file + + * Bump `sys.setrecursionlimit()` when translating PyPy, for translating with CPython + + * Tweak a float comparison with 0 in `backendopt.inline` to avoid rounding errors + + * Fix for an issue where os.access() accepted a float for mode + + * Fix for and issue where `unicode.decode('utf8', 'custom_replace')` messed up +the last byte of a unicode string sometimes + + * Update built-in cffi_ to the soon-to-be-released 1.8.1 version + + * Explicitly detect that we found as-yet-unsupported OpenSSL 1.1, and crash +translation with a message asking for help porting it + +Thanks to those who reported the issues. + +What is PyPy? += + +PyPy is a very compliant Python interpreter, almost a drop-in replacement for +CPython 2.7. It's fast (`PyPy and CPython 2.7.x`_ performance comparison) +due to its integrated tracing JIT compiler. + +We also welcome developers of other +`dynamic languages`_ to see what RPython can do for them. + +This release supports: + + * **x86** machines on most common operating systems +(Linux 32/64, Mac OS X 64, Windows 32, OpenBSD, FreeBSD), + + * newer **ARM** hardware (ARMv6 or ARMv7, with VFPv3) running Linux, + + * big- and little-endian variants of **PPC64** running Linux, + + * **s390x** running Linux + +.. _cffi: https://cffi.readthedocs.io +.. _`PyPy and CPython 2.7.x`: http://speed.pypy.org +.. _`dynamic languages`: http://pypyjs.org + +Please update, and continue to help us make PyPy better. + +Cheers + +The PyPy Team + diff --git a/pypy/tool/release/repackage.sh b/pypy/tool/release/repackage.sh --- a/pypy/tool/release/repackage.sh +++ b/pypy/tool/release/repackage.sh @@ -1,7 +1,7 @@ # Edit these appropriately before running this script maj=5 min=4 -rev=0 +rev=1 branchname=release-$maj.x # ==OR== release-$maj.$min.x tagname=release-pypy2.7-v$maj.$min.$rev # ==OR== release-$maj.$min ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy force-virtual-state: Remove more junk
Author: Spenser Andrew BaumanBranch: force-virtual-state Changeset: r86957:2960c83b0fbf Date: 2016-09-08 09:31 -0400 http://bitbucket.org/pypy/pypy/changeset/2960c83b0fbf/ Log:Remove more junk diff --git a/rpython/jit/metainterp/test/test_ajit.py b/rpython/jit/metainterp/test/test_ajit.py --- a/rpython/jit/metainterp/test/test_ajit.py +++ b/rpython/jit/metainterp/test/test_ajit.py @@ -4531,7 +4531,7 @@ _ptr = lltype.nullptr(rffi.CCHARP.TO) def new_int_buffer(value): -data = lltype.malloc(rffi.CCHARP.TO, noConst(rffi.sizeof(rffi.INT)), flavor='raw', zero=True) +data = lltype.malloc(rffi.CCHARP.TO, rffi.sizeof(rffi.INT), flavor='raw') rffi.cast(rffi.INTP, data)[0] = rffi.cast(rffi.INT, value) return data ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ppc-vsx-support: operations now can be delayed (if they are pure), operation arguments can pull them just before the op itself is emitted
Author: Richard PlanggerBranch: ppc-vsx-support Changeset: r86956:545565fe89bc Date: 2016-09-08 14:36 +0200 http://bitbucket.org/pypy/pypy/changeset/545565fe89bc/ Log:operations now can be delayed (if they are pure), operation arguments can pull them just before the op itself is emitted diff --git a/rpython/jit/metainterp/optimizeopt/dependency.py b/rpython/jit/metainterp/optimizeopt/dependency.py --- a/rpython/jit/metainterp/optimizeopt/dependency.py +++ b/rpython/jit/metainterp/optimizeopt/dependency.py @@ -1042,29 +1042,35 @@ assert isinstance(other, IndexVar) return self.constant - other.constant +def get_operations(self): +var = self.var +tolist = [] +if self.coefficient_mul != 1: +args = [var, ConstInt(self.coefficient_mul)] +var = ResOperation(rop.INT_MUL, args) +tolist.append(var) +if self.coefficient_div != 1: +assert 0 # should never be the case with handling + # of INT_PY_DIV commented out in this file... +if self.constant > 0: +args = [var, ConstInt(self.constant)] +var = ResOperation(rop.INT_ADD, args) +tolist.append(var) +if self.constant < 0: +args = [var, ConstInt(self.constant)] +var = ResOperation(rop.INT_SUB, args) +tolist.append(var) +return tolist + def emit_operations(self, opt, result_box=None): var = self.var if self.is_identity(): return var -if self.coefficient_mul != 1: -args = [var, ConstInt(self.coefficient_mul)] -var = ResOperation(rop.INT_MUL, args) -opt.emit_operation(var) -if self.coefficient_div != 1: -assert 0 # XXX for now; should never be the case with handling - # of INT_PY_DIV commented out in this file... -#args = [var, ConstInt(self.coefficient_div)] -#var = ResOperation(rop.INT_FLOORDIV, args) -#opt.emit_operation(var) -if self.constant > 0: -args = [var, ConstInt(self.constant)] -var = ResOperation(rop.INT_ADD, args) -opt.emit_operation(var) -if self.constant < 0: -args = [var, ConstInt(self.constant)] -var = ResOperation(rop.INT_SUB, args) -opt.emit_operation(var) -return var +last = None +for op in self.get_operations(): +opt.emit_operation(op) +last = op +return last def compare(self, other): """ Returns if the two are compareable as a first result diff --git a/rpython/jit/metainterp/optimizeopt/schedule.py b/rpython/jit/metainterp/optimizeopt/schedule.py --- a/rpython/jit/metainterp/optimizeopt/schedule.py +++ b/rpython/jit/metainterp/optimizeopt/schedule.py @@ -36,9 +36,48 @@ self.invariant_oplist = [] self.invariant_vector_vars = [] self.seen = {} +self.delayed = [] + +def resolve_delayed(self, needs_resolving, delayed, op): +# recursive solving of all delayed objects +if not delayed: +return +args = op.getarglist() +for arg in args: +if arg.is_constant() or arg.is_inputarg(): +continue +if arg not in self.seen: +needs_resolving[arg] = None +indexvars = self.graph.index_vars +i = len(delayed)-1 +while i >= 0: +node = delayed[i] +op = node.getoperation() +if op in needs_resolving: +# either it is a normal operation, or we know that there is a linear combination +if op in indexvars: +indexvar = indexvars[op] +for operation in indexvar.get_operations(): +self.oplist.append(operation) +last = operation +self.renamer.start_renaming(op, last) +del needs_resolving[op] +else: +del needs_resolving[op] +self.resolve_delayed(needs_resolving, delayed, op) +self.oplist.append(op) +i -= 1 + def post_schedule(self): loop = self.graph.loop +# +if self.delayed: +# some operations can be delayed until the jump instruction, +# handle them here +self.resolve_delayed({}, self.delayed, loop.jump) + +# self.renamer.rename(loop.jump) self.ensure_args_unpacked(loop.jump) loop.operations = self.oplist @@ -65,7 +104,7 @@ if node.depends_count() == 0: self.worklist.insert(0, node) -def try_emit_or_delay(self, node, scheduler): +def try_emit_or_delay(self, node): # implement me in subclass. e.g. as in VecScheduleState
[pypy-commit] pypy ppc-vsx-support: drafting new implementation
Author: Richard PlanggerBranch: ppc-vsx-support Changeset: r86955:ed75d303a710 Date: 2016-09-07 17:14 +0200 http://bitbucket.org/pypy/pypy/changeset/ed75d303a710/ Log:drafting new implementation diff --git a/rpython/jit/metainterp/optimizeopt/dependency.py b/rpython/jit/metainterp/optimizeopt/dependency.py --- a/rpython/jit/metainterp/optimizeopt/dependency.py +++ b/rpython/jit/metainterp/optimizeopt/dependency.py @@ -136,6 +136,7 @@ self.schedule_position = -1 self.priority = 0 self._stack = False +self.delayed = None def is_imaginary(self): return False @@ -148,6 +149,7 @@ def getopnum(self): return self.op.getopnum() + def getopname(self): return self.op.getopname() @@ -157,6 +159,9 @@ def can_be_relaxed(self): return self.op.getopnum() in (rop.GUARD_TRUE, rop.GUARD_FALSE) +def is_pure(self): +return rop.is_always_pure(self.op.getopnum()) + def edge_to(self, to, arg=None, failarg=False, label=None): if self is to: return diff --git a/rpython/jit/metainterp/optimizeopt/schedule.py b/rpython/jit/metainterp/optimizeopt/schedule.py --- a/rpython/jit/metainterp/optimizeopt/schedule.py +++ b/rpython/jit/metainterp/optimizeopt/schedule.py @@ -65,9 +65,9 @@ if node.depends_count() == 0: self.worklist.insert(0, node) -def emit(self, node, scheduler): +def try_emit_or_delay(self, node, scheduler): # implement me in subclass. e.g. as in VecScheduleState -return False +raise NotImplementedError def delay(self, node): return False @@ -180,14 +180,7 @@ while state.has_more(): node = self.next(state) if node: -if not state.emit(node, self): -if not node.emitted: -state.pre_emit(node) -self.mark_emitted(node, state) -if not node.is_imaginary(): -op = node.getoperation() -state.seen[op] = None -state.oplist.append(op) +state.try_emit_or_delay(node, scheduler) continue # it happens that packs can emit many nodes that have been @@ -551,6 +544,10 @@ failargs[i] = self.renamer.rename_map.get(seed, seed) op.setfailargs(failargs) +delayed = node.delayed +if delayed: +import pdb; pdb.set_trace() + def profitable(self): return self.costmodel.profitable() @@ -560,18 +557,45 @@ for arg in self.graph.loop.label.getarglist(): self.seen[arg] = None -def emit(self, node, scheduler): -""" If you implement a scheduler this operations is called -to emit the actual operation into the oplist of the scheduler. -""" -if node.pack: +def try_emit_or_delay(self, scheduler, state): +# emission might be blocked by other nodes if this node has a pack! +if self.pack: assert node.pack.numops() > 1 for node in node.pack.operations: self.pre_emit(node) scheduler.mark_emitted(node, self, unpack=False) turn_into_vector(self, node.pack) -return True -return False +return +elif not node.emitted: +if not node.is_imaginary() and node.is_pure(): +# this operation might never be emitted. only if it is really needed +self.delay_emit(scheduler, node) +return +# emit a now! +state.pre_emit(node) +self.mark_emitted(node, state) +if not node.is_imaginary(): +op = node.getoperation() +state.seen[op] = None +state.oplist.append(op) + +def delay_emit(self, scheduler, node): +""" it has been decided that the operation might be scheduled later """ +delayed = node.delayed or [] +delayed.append(self) +node.delayed = None +for to in self.provides(): +self.delegate_delay(to, delayed) +self.mark_emitted(node, state) + +def delegate_delay(self, node, delayed): +""" Chain up delays, this can reduce many more of the operations """ +if node.delayed is None: +node.delayed = delayed +else: +delayedlist = node.delayed +for d in delayed: +delayedlist.append(d) def delay(self, node): if node.pack: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: build the hashmap only once, not *every time* we call _has_reflected_op
Author: Carl Friedrich BolzBranch: Changeset: r86954:4753c209847a Date: 2016-09-08 13:54 +0200 http://bitbucket.org/pypy/pypy/changeset/4753c209847a/ Log:build the hashmap only once, not *every time* we call _has_reflected_op (found while reading control flow graphs) diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py --- a/pypy/module/micronumpy/ufuncs.py +++ b/pypy/module/micronumpy/ufuncs.py @@ -392,31 +392,39 @@ extobj_w = space.newlist([space.wrap(8192), space.wrap(0), space.w_None]) return extobj_w + +_reflected_ops = { +'add': 'radd', +'subtract': 'rsub', +'multiply': 'rmul', +'divide': 'rdiv', +'true_divide': 'rtruediv', +'floor_divide': 'rfloordiv', +'remainder': 'rmod', +'power': 'rpow', +'left_shift': 'rlshift', +'right_shift': 'rrshift', +'bitwise_and': 'rand', +'bitwise_xor': 'rxor', +'bitwise_or': 'ror', +#/* Comparisons */ +'equal': 'eq', +'not_equal': 'ne', +'greater': 'lt', +'less': 'gt', +'greater_equal': 'le', +'less_equal': 'ge', +} + +for key, value in _reflected_ops.items(): +_reflected_ops[key] = "__" + value + "__" +del key +del value + def _has_reflected_op(space, w_obj, op): -refops ={ 'add': 'radd', -'subtract': 'rsub', -'multiply': 'rmul', -'divide': 'rdiv', -'true_divide': 'rtruediv', -'floor_divide': 'rfloordiv', -'remainder': 'rmod', -'power': 'rpow', -'left_shift': 'rlshift', -'right_shift': 'rrshift', -'bitwise_and': 'rand', -'bitwise_xor': 'rxor', -'bitwise_or': 'ror', -#/* Comparisons */ -'equal': 'eq', -'not_equal': 'ne', -'greater': 'lt', -'less': 'gt', -'greater_equal': 'le', -'less_equal': 'ge', -} -if op not in refops: +if op not in _reflected_ops: return False -return space.getattr(w_obj, space.wrap('__' + refops[op] + '__')) is not None +return space.getattr(w_obj, space.wrap(_reflected_ops[op])) is not None def safe_casting_mode(casting): assert casting is not None ___ 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: r789:3af077f71333 Date: 2016-09-08 08:16 +0200 http://bitbucket.org/pypy/pypy.org/changeset/3af077f71333/ Log:update the values diff --git a/don1.html b/don1.html --- a/don1.html +++ b/don1.html @@ -15,7 +15,7 @@ - $65097 of $105000 (62.0%) + $65099 of $105000 (62.0%) @@ -23,7 +23,7 @@ This donation goes towards supporting Python 3 in PyPy. Current status: -we have $5552 left +we have $5553 left in the account. Read proposal ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit