[pypy-commit] pypy zarch-simd-support: int_is_true fixed
Author: Richard Plangger Branch: zarch-simd-support Changeset: r87216:28e71ef2f8ec Date: 2016-09-19 09:11 +0200 http://bitbucket.org/pypy/pypy/changeset/28e71ef2f8ec/ Log:int_is_true fixed diff --git a/rpython/jit/backend/zarch/instructions.py b/rpython/jit/backend/zarch/instructions.py --- a/rpython/jit/backend/zarch/instructions.py +++ b/rpython/jit/backend/zarch/instructions.py @@ -329,6 +329,7 @@ 'VREPI': ('vri_a', ['\xE7','\x45']), 'VCEQ': ('vrr_b', ['\xE7','\xF8']), +'VCHL': ('vrr_b', ['\xE7','\xF9']), # pack, merge, shift, ... 'VMRL': ('vrr_c', ['\xE7','\x60'], 'v,v,v,m'), diff --git a/rpython/jit/backend/zarch/vector_ext.py b/rpython/jit/backend/zarch/vector_ext.py --- a/rpython/jit/backend/zarch/vector_ext.py +++ b/rpython/jit/backend/zarch/vector_ext.py @@ -186,9 +186,8 @@ size = sizeloc.value tmploc = regalloc.vrm.get_scratch_reg() self.mc.VX(tmploc, tmploc, tmploc) # all zero -self.mc.VNO(tmploc, tmploc, tmploc) # all one -self.mc.VCEQ(resloc, argloc, tmploc, l.itemsize_to_mask(size), 0b0001) -flush_vec_cc(self, regalloc, c.VNEI, op.bytesize, resloc) +self.mc.VCHL(resloc, argloc, tmploc, l.itemsize_to_mask(size), 0b0001) +flush_vec_cc(self, regalloc, c.VEQI, op.bytesize, resloc) def emit_vec_float_eq(self, op, arglocs, regalloc): assert isinstance(op, VectorOp) @@ -574,8 +573,9 @@ prepare_vec_cast_int_to_float = prepare_vec_cast_float_to_int def prepare_vec_guard_true(self, op): -self.assembler.guard_success_cc = c.VEQI +self.assembler.guard_success_cc = c.EQ return self._prepare_guard(op) def prepare_vec_guard_false(self, op): -self.assembler.guard_success_cc = c.VNEI +self.assembler.guard_success_cc = c.NE +return self._prepare_guard(op) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy zarch-simd-support: close branch
Author: Richard Plangger Branch: zarch-simd-support Changeset: r87218:ba39bd805638 Date: 2016-09-19 09:12 +0200 http://bitbucket.org/pypy/pypy/changeset/ba39bd805638/ Log:close branch ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ppc-vsx-support: document branches
Author: Richard Plangger Branch: ppc-vsx-support Changeset: r87219:b5e36e08c898 Date: 2016-09-19 09:14 +0200 http://bitbucket.org/pypy/pypy/changeset/b5e36e08c898/ Log:document branches 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 @@ -16,3 +16,11 @@ 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. + +.. branch: zarch-simd-support + +s390x implementation for vector operations used in VecOpt + +.. branch: ppc-vsx-support + +PowerPC implementation for vector operations used in VecOpt ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ppc-vsx-support: catchup with default
Author: Richard Plangger Branch: ppc-vsx-support Changeset: r87221:950c5eb14f89 Date: 2016-09-19 09:43 +0200 http://bitbucket.org/pypy/pypy/changeset/950c5eb14f89/ Log:catchup with default diff too long, truncating to 2000 out of 2146 lines diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py b/lib-python/2.7/distutils/sysconfig_pypy.py --- a/lib-python/2.7/distutils/sysconfig_pypy.py +++ b/lib-python/2.7/distutils/sysconfig_pypy.py @@ -13,6 +13,7 @@ import sys import os import shlex +import imp from distutils.errors import DistutilsPlatformError @@ -62,8 +63,8 @@ """Initialize the module as appropriate for POSIX systems.""" g = {} g['EXE'] = "" -g['SO'] = ".so" -g['SOABI'] = g['SO'].rsplit('.')[0] +g['SOABI'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION] +g['SO'] = g['SOABI'][0] g['LIBDIR'] = os.path.join(sys.prefix, 'lib') g['CC'] = "gcc -pthread" # -pthread might not be valid on OS/X, check @@ -75,8 +76,8 @@ """Initialize the module as appropriate for NT""" g = {} g['EXE'] = ".exe" -g['SO'] = ".pyd" -g['SOABI'] = g['SO'].rsplit('.')[0] +g['SOABI'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION] +g['SO'] = g['SOABI'][0] global _config_vars _config_vars = g diff --git a/lib-python/2.7/sysconfig.py b/lib-python/2.7/sysconfig.py --- a/lib-python/2.7/sysconfig.py +++ b/lib-python/2.7/sysconfig.py @@ -526,10 +526,7 @@ # PyPy: import imp -for suffix, mode, type_ in imp.get_suffixes(): -if type_ == imp.C_EXTENSION: -_CONFIG_VARS['SOABI'] = suffix.split('.')[1] -break +_CONFIG_VARS['SOABI'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION] if args: vals = [] diff --git a/lib_pypy/cffi.egg-info/PKG-INFO b/lib_pypy/cffi.egg-info/PKG-INFO --- a/lib_pypy/cffi.egg-info/PKG-INFO +++ b/lib_pypy/cffi.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: cffi -Version: 1.8.2 +Version: 1.8.3 Summary: Foreign Function Interface for Python calling C code. Home-page: http://cffi.readthedocs.org Author: Armin Rigo, Maciej Fijalkowski diff --git a/lib_pypy/cffi/__init__.py b/lib_pypy/cffi/__init__.py --- a/lib_pypy/cffi/__init__.py +++ b/lib_pypy/cffi/__init__.py @@ -4,8 +4,8 @@ from .api import FFI, CDefError, FFIError from .ffiplatform import VerificationError, VerificationMissing -__version__ = "1.8.2" -__version_info__ = (1, 8, 2) +__version__ = "1.8.3" +__version_info__ = (1, 8, 3) # The verifier module file names are based on the CRC32 of a string that # contains the following version number. It may be older than __version__ diff --git a/lib_pypy/cffi/_embedding.h b/lib_pypy/cffi/_embedding.h --- a/lib_pypy/cffi/_embedding.h +++ b/lib_pypy/cffi/_embedding.h @@ -233,7 +233,7 @@ f = PySys_GetObject((char *)"stderr"); if (f != NULL && f != Py_None) { PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME - "\ncompiled with cffi version: 1.8.2" + "\ncompiled with cffi version: 1.8.3" "\n_cffi_backend module: ", f); modules = PyImport_GetModuleDict(); mod = PyDict_GetItemString(modules, "_cffi_backend"); diff --git a/pypy/doc/config/translation.profopt.txt b/pypy/doc/config/translation.profopt.txt --- a/pypy/doc/config/translation.profopt.txt +++ b/pypy/doc/config/translation.profopt.txt @@ -3,3 +3,14 @@ RPython program) to gather profile data. Example for pypy-c: "-c 'from richards import main;main(); from test import pystone; pystone.main()'" + +NOTE: be aware of what this does in JIT-enabled executables. What it +does is instrument and later optimize the C code that happens to run in +the example you specify, ignoring any execution of the JIT-generated +assembler. That means that you have to choose the example wisely. If +it is something that will just generate assembler and stay there, there +is little value. If it is something that exercises heavily library +routines that are anyway written in C, then it will optimize that. Most +interesting would be something that causes a lot of JIT-compilation, +like running a medium-sized test suite several times in a row, in order +to optimize the warm-up in general. diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst --- a/pypy/doc/cpython_differences.rst +++ b/pypy/doc/cpython_differences.rst @@ -449,6 +449,27 @@ support (see ``multiline_input()``). On the other hand, ``parse_and_bind()`` calls are ignored (issue `#2072`_). +* ``sys.getsizeof()`` always raises ``TypeError``. This is because a + memory profiler using this function is most likely to give results + inconsistent with reality on PyPy. It would be possible to have + ``sys.getsizeof()`` return a number (with enough work), but that may + or may not represent how
[pypy-commit] pypy ppc-vsx-support: expand gpr/fpr to a vector reg
Author: Richard Plangger Branch: ppc-vsx-support Changeset: r87220:a7ce3d0c0585 Date: 2016-09-19 09:42 +0200 http://bitbucket.org/pypy/pypy/changeset/a7ce3d0c0585/ Log:expand gpr/fpr to a vector reg diff --git a/rpython/jit/backend/zarch/instruction_builder.py b/rpython/jit/backend/zarch/instruction_builder.py --- a/rpython/jit/backend/zarch/instruction_builder.py +++ b/rpython/jit/backend/zarch/instruction_builder.py @@ -546,6 +546,19 @@ self.writechar(opcode2) return encode_vri_a +def build_vri_c(mnemonic, (opcode1,opcode2), argtypes='v,v,i16,m'): +@builder.arguments(argtypes) +def encode_vri_c(self, v1, v3, i2, mask4): +self.writechar(opcode1) +rbx = (v1 >= 16) << 3 +rbx |= (v3 >= 16) << 2 +byte = (v1 & BIT_MASK_4) << 4 | (v3 & BIT_MASK_4) +self.writechar(chr(byte)) +self.write_i16(i2 & BIT_MASK_16) +self.writechar(chr((mask4 & BIT_MASK_4) << 4 | (rbx & BIT_MASK_4))) +self.writechar(opcode2) +return encode_vri_c + def build_vrs_b(mnemonic, (opcode1,opcode2), argtypes='v,r,db,m'): @builder.arguments(argtypes) def encode_vrs_b(self, v1, r2, db3, m4): diff --git a/rpython/jit/backend/zarch/instructions.py b/rpython/jit/backend/zarch/instructions.py --- a/rpython/jit/backend/zarch/instructions.py +++ b/rpython/jit/backend/zarch/instructions.py @@ -300,6 +300,8 @@ 'VST':('vrx', ['\xE7','\x0E'], 'v,bid'), +'VREP': ('vri_c', ['\xE7','\x4D']), + # integral # -> arith 'VA': ('vrr_c', ['\xE7','\xF3'], 'v,v,v,m'), diff --git a/rpython/jit/backend/zarch/vector_ext.py b/rpython/jit/backend/zarch/vector_ext.py --- a/rpython/jit/backend/zarch/vector_ext.py +++ b/rpython/jit/backend/zarch/vector_ext.py @@ -244,9 +244,20 @@ assert isinstance(op, VectorOp) resloc, loc0 = arglocs size = op.bytesize -self.mc.VLREP(resloc, loc0, l.itemsize_to_mask(size)) +if loc0.is_core_reg(): +self.mc.VLVG(resloc, loc0, l.addr(0), l.itemsize_to_mask(size)) +self.mc.VREP(resloc, loc0, l.imm0, l.itemsize_to_mask(size)) +else: +self.mc.VLREP(resloc, loc0, l.itemsize_to_mask(size)) -emit_vec_expand_f = emit_vec_expand_i +def emit_vec_expand_f(self, op, arglocs, regalloc): +assert isinstance(op, VectorOp) +resloc, loc0 = arglocs +size = op.bytesize +if loc0.is_fp_reg(): +self.mc.VREP(resloc, loc0, l.imm0, l.itemsize_to_mask(size)) +else: +self.mc.VLREP(resloc, loc0, l.itemsize_to_mask(size)) def _accum_reduce(self, op, arg, accumloc, targetloc): # Currently the accumulator can ONLY be 64 bit float/int ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Issue #2325/2361: __class__ assignment between two classes with the same
Author: Armin Rigo Branch: Changeset: r87222:4dd20155b7eb Date: 2016-09-19 11:05 +0200 http://bitbucket.org/pypy/pypy/changeset/4dd20155b7eb/ Log:Issue #2325/2361: __class__ assignment between two classes with the same slots. Adapted from PR #459 from mark wililams. Thanks! diff --git a/pypy/objspace/std/test/test_typeobject.py b/pypy/objspace/std/test/test_typeobject.py --- a/pypy/objspace/std/test/test_typeobject.py +++ b/pypy/objspace/std/test/test_typeobject.py @@ -797,9 +797,7 @@ class AA(object): __slots__ = ('a',) aa = AA() -# the following line works on CPython >= 2.6 but not on PyPy. -# but see below for more -raises(TypeError, "aa.__class__ = A") +aa.__class__ = A raises(TypeError, "aa.__class__ = object") class Z1(A): pass @@ -861,9 +859,13 @@ __slots__ = ['a', 'b'] class Order2(object): __slots__ = ['b', 'a'] -# the following line works on CPython >= 2.6 but not on PyPy. -# but see below for more -raises(TypeError, "Order1().__class__ = Order2") +Order1().__class__ = Order2 + +# like CPython, the order of slot names doesn't matter +x = Order1() +x.a, x.b = 1, 2 +x.__class__ = Order2 +assert (x.a, x.b) == (1, 2) class U1(object): __slots__ = ['a', 'b'] @@ -873,10 +875,11 @@ __slots__ = ['a', 'b'] class V2(V1): __slots__ = ['c', 'd', 'e'] -# the following line does not work on CPython >= 2.6 either. -# that's just obscure. Really really. So we just ignore -# the whole issue until someone comes complaining. Then we'll -# just kill slots altogether apart from maybe doing a few checks. +# the following line does not work on CPython either: we can't +# change a class if the old and new class have different layouts +# that look compatible but aren't, because they don't have the +# same base-layout class (even if these base classes are +# themselves compatible)... obscure. raises(TypeError, "U2().__class__ = V2") def test_name(self): diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py --- a/pypy/objspace/std/typeobject.py +++ b/pypy/objspace/std/typeobject.py @@ -102,9 +102,10 @@ """ _immutable_ = True -def __init__(self, typedef, nslots, base_layout=None): +def __init__(self, typedef, nslots, newslotnames=[], base_layout=None): self.typedef = typedef self.nslots = nslots +self.newslotnames = newslotnames[:]# make a fixed-size list self.base_layout = base_layout def issublayout(self, parent): @@ -114,6 +115,12 @@ return False return True +def expand(self, hasdict, weakrefable): +"""Turn this Layout into a tuple. If two classes get equal +tuples, it means their instances have a fully compatible layout.""" +return (self.typedef, self.newslotnames, self.base_layout, +hasdict, weakrefable) + # possible values of compares_by_identity_status UNKNOWN = 0 @@ -289,8 +296,7 @@ # compute a tuple that fully describes the instance layout def get_full_instance_layout(self): -layout = self.layout -return (layout, self.hasdict, self.weakrefable) +return self.layout.expand(self.hasdict, self.weakrefable) def compute_default_mro(self): return compute_C3_mro(self.space, self) @@ -1001,11 +1007,15 @@ w_self.weakrefable = w_self.weakrefable or w_base.weakrefable return hasoldstylebase + def create_all_slots(w_self, hasoldstylebase, w_bestbase, force_new_layout): +from pypy.objspace.std.listobject import StringSort + base_layout = w_bestbase.layout index_next_extra_slot = base_layout.nslots space = w_self.space dict_w = w_self.dict_w +newslotnames = [] if '__slots__' not in dict_w: wantdict = True wantweakref = True @@ -1031,8 +1041,22 @@ "__weakref__ slot disallowed: we already got one") wantweakref = True else: -index_next_extra_slot = create_slot(w_self, slot_name, -index_next_extra_slot) +newslotnames.append(slot_name) +# Sort the list of names collected so far +sorter = StringSort(newslotnames, len(newslotnames)) +sorter.sort() +# Try to create all slots in order. The creation of some of +# them might silently fail; then we delete the name from the +# list. At the end, 'index_next_extra_slot' has been advanced +# by the final length of 'newslotnames'. +i = 0 +while i < len(newslotnames): +if create_slot(w_self, newslotnames[i], index_next_extr
[pypy-commit] pypy py3.5: Implement default keyword on min & max with tests
Author: Daniel Patrick Branch: py3.5 Changeset: r87224:85eef6bf8b2e Date: 2016-09-19 12:28 +0100 http://bitbucket.org/pypy/pypy/changeset/85eef6bf8b2e/ Log:Implement default keyword on min & max with tests diff --git a/pypy/module/__builtin__/functional.py b/pypy/module/__builtin__/functional.py --- a/pypy/module/__builtin__/functional.py +++ b/pypy/module/__builtin__/functional.py @@ -136,14 +136,24 @@ "%s() expects at least one argument", implementation_of) w_key = None + has_default = False if any_kwds: kwds = args.keywords -if kwds[0] == "key" and len(kwds) == 1: -w_key = args.keywords_w[0] -else: -raise oefmt(space.w_TypeError, -"%s() got unexpected keyword argument", -implementation_of) +for n in range(len(kwds)): +if kwds[n] == "key": +w_key = args.keywords_w[n] +elif kwds[n] == "default": +w_default = args.keywords_w[n] +has_default = True +else: +raise oefmt(space.w_TypeError, +"%s() got unexpected keyword argument", +implementation_of) + +if has_default and len(args_w) > 1: +raise oefmt(space.w_TypeError, +"Cannot specify a default for %s() with multiple positional arguments", +implementation_of) w_iter = space.iter(w_sequence) w_type = space.type(w_iter) @@ -170,7 +180,10 @@ w_max_item = w_item w_max_val = w_compare_with if w_max_item is None: -raise oefmt(space.w_ValueError, "arg is an empty sequence") +if has_default: +w_max_item = w_default +else: +raise oefmt(space.w_ValueError, "arg is an empty sequence") return w_max_item if unroll: min_max_impl = jit.unroll_safe(min_max_impl) diff --git a/pypy/module/__builtin__/test/test_functional.py b/pypy/module/__builtin__/test/test_functional.py --- a/pypy/module/__builtin__/test/test_functional.py +++ b/pypy/module/__builtin__/test/test_functional.py @@ -590,6 +590,12 @@ assert type(min(1, 1.0, 1)) is int assert type(min(1.0, 1, 1)) is float assert type(min(1, 1, 1.0)) is int +assert min([], default=-1) == -1 +assert min([1, 2], default=-1) == 1 +raises(TypeError, min, 0, 1, default=-1) +assert min([], default=None) == None +raises(TypeError, min, 1, default=0) +raises(TypeError, min, default=1) def test_max(self): assert max(1, 2) == 2 @@ -602,3 +608,9 @@ assert type(max(1, 1.0, 1)) is int assert type(max(1.0, 1, 1)) is float assert type(max(1, 1, 1.0)) is int +assert max([], default=-1) == -1 +assert max([1, 2], default=3) == 2 +raises(TypeError, min, 0, 1, default=-1) +assert max([], default=None) == None +raises(TypeError, max, 1, default=0) +raises(TypeError, max, default=1) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ppc-vsx-support: translation issues
Author: Richard Plangger Branch: ppc-vsx-support Changeset: r87225:0cc906e34289 Date: 2016-09-19 14:29 +0200 http://bitbucket.org/pypy/pypy/changeset/0cc906e34289/ Log:translation issues diff --git a/rpython/jit/backend/zarch/assembler.py b/rpython/jit/backend/zarch/assembler.py --- a/rpython/jit/backend/zarch/assembler.py +++ b/rpython/jit/backend/zarch/assembler.py @@ -896,7 +896,7 @@ ofs = self.cpu.get_ofs_of_frame_field('jf_gcmap') mc.LG(r.SCRATCH, l.addr(ofs, r.SPP)) -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 @@ -904,7 +904,7 @@ jmp_pos = self.mc.currpos() self.mc.reserve_cond_jump() -self.write_pending_failure_recoveries() +self.write_pending_failure_recoveries(regalloc) currpos = self.mc.currpos() pmc = OverwritingBuilder(self.mc, jmp_pos, 1) diff --git a/rpython/jit/backend/zarch/instruction_builder.py b/rpython/jit/backend/zarch/instruction_builder.py --- a/rpython/jit/backend/zarch/instruction_builder.py +++ b/rpython/jit/backend/zarch/instruction_builder.py @@ -628,7 +628,7 @@ return 0 elif argtype == 'r' or argtype == 'r/m' or \ argtype == 'f' or argtype == 'eo' or \ - argtype == 'v': + argtype == 'v' or argtype == 'm': return arg.value elif argtype.startswith('i') or argtype.startswith('u') or argtype.startswith('h'): return arg.value diff --git a/rpython/jit/backend/zarch/locations.py b/rpython/jit/backend/zarch/locations.py --- a/rpython/jit/backend/zarch/locations.py +++ b/rpython/jit/backend/zarch/locations.py @@ -247,6 +247,7 @@ from rpython.jit.backend.zarch.registers import JITFRAME_FIXED_SIZE return base_ofs + WORD * (position + JITFRAME_FIXED_SIZE) +imm3 = imm(1) imm1 = imm(1) imm0 = imm(0) @@ -254,16 +255,17 @@ MASK_VEC_HWORD = 1 MASK_VEC_WORD = 2 MASK_VEC_DWORD = 3 +MASK_VEC_QWORD = 4 def itemsize_to_mask(v): if v == 16: -return MASK_VEC_QWORD +return imm(MASK_VEC_QWORD) elif v == 8: -return MASK_VEC_DWORD +return imm(MASK_VEC_DWORD) elif v == 4: -return MASK_VEC_WORD +return imm(MASK_VEC_WORD) elif v == 2: -return MASK_VEC_HWORD +return imm(MASK_VEC_HWORD) elif v == 1: -return MASK_VEC_BYTE +return imm(MASK_VEC_BYTE) assert 0, "not supported itemsize to mask!" diff --git a/rpython/jit/backend/zarch/regalloc.py b/rpython/jit/backend/zarch/regalloc.py --- a/rpython/jit/backend/zarch/regalloc.py +++ b/rpython/jit/backend/zarch/regalloc.py @@ -615,7 +615,7 @@ self.fprm._check_invariants() self.vrm._check_invariants() if self.assembler.mc.get_relative_pos() > self.limit_loop_break: -self.assembler.break_long_loop() +self.assembler.break_long_loop(self) self.limit_loop_break = (self.assembler.mc.get_relative_pos() + LIMIT_LOOP_BREAK) i += 1 diff --git a/rpython/jit/backend/zarch/vector_ext.py b/rpython/jit/backend/zarch/vector_ext.py --- a/rpython/jit/backend/zarch/vector_ext.py +++ b/rpython/jit/backend/zarch/vector_ext.py @@ -21,6 +21,7 @@ from rpython.rtyper.lltypesystem import lltype, rffi from rpython.jit.codewriter import longlong from rpython.rlib.objectmodel import always_inline +from rpython.jit.backend.zarch.arch import WORD def not_implemented(msg): msg = '[zarch/vector_ext] %s\n' % msg @@ -30,7 +31,7 @@ @always_inline def permi(v1,v2): -return (v1 << 2 | v2) & 0xf +return l.imm((v1 << 2 | v2) & 0xf) def flush_vec_cc(asm, regalloc, condition, size, resultloc): # After emitting an instruction that leaves a boolean result in @@ -91,7 +92,7 @@ resloc, loc0, loc1, itemsize_loc = arglocs itemsize = itemsize_loc.value if itemsize == 8: -self.mc.VFA(resloc, loc0, loc1, 3, 0, 0) +self.mc.VFA(resloc, loc0, loc1, l.imm(3), l.imm(0), l.imm(0)) return not_implemented("vec_float_add of size %d" % itemsize) @@ -99,7 +100,7 @@ resloc, loc0, loc1, itemsize_loc = arglocs itemsize = itemsize_loc.value if itemsize == 8: -self.mc.VFS(resloc, loc0, loc1, 3, 0, 0) +self.mc.VFS(resloc, loc0, loc1, l.imm(3), l.imm(0), l.imm(0)) return not_implemented("vec_float_sub of size %d" % itemsize) @@ -107,7 +108,7 @@ resloc, loc0, loc1, itemsize_loc = arglocs itemsize = itemsize_loc.value if itemsize == 8: -self.mc.VFM(resloc, loc0, loc1, 3, 0, 0) +self.mc.VFM(resloc, loc0, loc1, l.imm(3), l
[pypy-commit] pypy ppc-vsx-support: same patch for x86
Author: Richard Plangger Branch: ppc-vsx-support Changeset: r87227:93b3c662735a Date: 2016-09-19 14:43 +0200 http://bitbucket.org/pypy/pypy/changeset/93b3c662735a/ Log:same patch for x86 diff --git a/rpython/jit/backend/x86/assembler.py b/rpython/jit/backend/x86/assembler.py --- a/rpython/jit/backend/x86/assembler.py +++ b/rpython/jit/backend/x86/assembler.py @@ -16,6 +16,7 @@ from rpython.rtyper import rclass from rpython.rlib.jit import AsmInfo from rpython.jit.backend.model import CompiledLoopToken +from rpython.jit.backend.x86.jump import remap_frame_layout_mixed from rpython.jit.backend.x86.regalloc import (RegAlloc, get_ebp_ofs, gpr_reg_mgr_cls, xmm_reg_mgr_cls) from rpython.jit.backend.llsupport.regalloc import (get_scale, valid_addressing_size) @@ -682,17 +683,25 @@ bridge_accum_info = bridge_accum_info.next() guard_accum_info = guard_accum_info.next() -# register mapping is most likely NOT valid, thus remap it in this -# short piece of assembler +# register mapping is most likely NOT valid, thus remap it +src_locations1 = [] +dst_locations1 = [] +src_locations2 = [] +dst_locations2 = [] + +# Build the four lists assert len(guard_locs) == len(bridge_locs) -for i,gloc in enumerate(guard_locs): -bloc = bridge_locs[i] -bstack = bloc.location_code() == 'b' -gstack = gloc.location_code() == 'b' -if bstack and gstack: -pass -elif gloc is not bloc: -self.mov(gloc, bloc) +for i,src_loc in enumerate(guard_locs): +dst_loc = bridge_locs[i] +if not src_loc.is_fp_reg(): +src_locations1.append(src_loc) +dst_locations1.append(dst_loc) +else: +src_locations2.append(src_loc) +dst_locations2.append(dst_loc) +remap_frame_layout_mixed(self, src_locations1, dst_locations1, r.SCRATCH, + src_locations2, dst_locations2, r.FP_SCRATCH) + offset = self.mc.get_relative_pos() self.mc.JMP_l(0) self.mc.writeimm32(0) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ppc-vsx-support: use x86 scratch regs instead
Author: Richard Plangger Branch: ppc-vsx-support Changeset: r87228:d93cde0eb27e Date: 2016-09-19 15:21 +0200 http://bitbucket.org/pypy/pypy/changeset/d93cde0eb27e/ Log:use x86 scratch regs instead diff --git a/rpython/jit/backend/x86/assembler.py b/rpython/jit/backend/x86/assembler.py --- a/rpython/jit/backend/x86/assembler.py +++ b/rpython/jit/backend/x86/assembler.py @@ -699,8 +699,8 @@ else: src_locations2.append(src_loc) dst_locations2.append(dst_loc) -remap_frame_layout_mixed(self, src_locations1, dst_locations1, r.SCRATCH, - src_locations2, dst_locations2, r.FP_SCRATCH) +remap_frame_layout_mixed(self, src_locations1, dst_locations1, X86_64_SCRATCH_REG, + src_locations2, dst_locations2, X86_64_XMM_SCRATCH_REG) offset = self.mc.get_relative_pos() self.mc.JMP_l(0) diff --git a/rpython/translator/platform/arch/s390x.py b/rpython/translator/platform/arch/s390x.py --- a/rpython/translator/platform/arch/s390x.py +++ b/rpython/translator/platform/arch/s390x.py @@ -39,8 +39,14 @@ return ids def s390x_detect_vx(): +contentlist = [] with open("/proc/cpuinfo", "rb") as fd: -content = fd.read() +while True: +snippet = fd.read(4096) +if not snippet: +break +contentlist.append(snippet) +content = ''.join(contentlist) start = content.find("features", 0) if start >= 0: after_colon = content.find(":", start) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ppc-vsx-support: use detect_vsx in ppc, not detect_simd_z
Author: Richard Plangger Branch: ppc-vsx-support Changeset: r87229:a19724e734a3 Date: 2016-09-19 15:30 +0200 http://bitbucket.org/pypy/pypy/changeset/a19724e734a3/ Log:use detect_vsx in ppc, not detect_simd_z 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 @@ -20,7 +20,7 @@ from rpython.jit.backend.llsupport.asmmemmgr import MachineDataBlockWrapper from rpython.rtyper.lltypesystem import lltype, rffi from rpython.jit.codewriter import longlong -from rpython.jit.backend.zarch.detect_feature import detect_simd_z +from rpython.jit.backend.ppc.detect_feature import detect_vsx from rpython.rlib.objectmodel import always_inline def not_implemented(msg): @@ -85,7 +85,7 @@ class AltiVectorExt(VectorExt): def setup_once(self, asm): -if detect_simd_z(): +if detect_vsx(): self.enable(16, accum=True) asm.setup_once_vector() self._setup = True diff --git a/rpython/translator/platform/arch/s390x.py b/rpython/translator/platform/arch/s390x.py --- a/rpython/translator/platform/arch/s390x.py +++ b/rpython/translator/platform/arch/s390x.py @@ -41,12 +41,7 @@ def s390x_detect_vx(): contentlist = [] with open("/proc/cpuinfo", "rb") as fd: -while True: -snippet = fd.read(4096) -if not snippet: -break -contentlist.append(snippet) -content = ''.join(contentlist) +content = fd.read() start = content.find("features", 0) if start >= 0: after_colon = content.find(":", start) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: backout bd9d1dd19c2c, per a8a4ffe56b74
Author: Ronan Lamy Branch: py3k Changeset: r87230:5c701a472a00 Date: 2016-09-19 14:39 +0100 http://bitbucket.org/pypy/pypy/changeset/5c701a472a00/ Log:backout bd9d1dd19c2c, per a8a4ffe56b74 diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py --- a/pypy/objspace/std/unicodeobject.py +++ b/pypy/objspace/std/unicodeobject.py @@ -78,7 +78,6 @@ return self._value @jit.elidable -@jit.call_shortcut def identifier_w(self, space): identifier = self._utf8 if identifier is not None: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: revert 2b244ba62cf4, redo the distutils part to be cpython compliant (no SOABI)
Author: Matti Picus Branch: Changeset: r87233:71a05328d60c Date: 2016-09-19 18:08 +0300 http://bitbucket.org/pypy/pypy/changeset/71a05328d60c/ Log:revert 2b244ba62cf4, redo the distutils part to be cpython compliant (no SOABI) diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py b/lib-python/2.7/distutils/sysconfig_pypy.py --- a/lib-python/2.7/distutils/sysconfig_pypy.py +++ b/lib-python/2.7/distutils/sysconfig_pypy.py @@ -63,8 +63,7 @@ """Initialize the module as appropriate for POSIX systems.""" g = {} g['EXE'] = "" -g['SOABI'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION] -g['SO'] = g['SOABI'][0] +g['SO'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION][0] g['LIBDIR'] = os.path.join(sys.prefix, 'lib') g['CC'] = "gcc -pthread" # -pthread might not be valid on OS/X, check @@ -76,8 +75,7 @@ """Initialize the module as appropriate for NT""" g = {} g['EXE'] = ".exe" -g['SOABI'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION] -g['SO'] = g['SOABI'][0] +g['SO'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION][0] global _config_vars _config_vars = g diff --git a/lib-python/2.7/sysconfig.py b/lib-python/2.7/sysconfig.py --- a/lib-python/2.7/sysconfig.py +++ b/lib-python/2.7/sysconfig.py @@ -526,7 +526,10 @@ # PyPy: import imp -_CONFIG_VARS['SOABI'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION] +for suffix, mode, type_ in imp.get_suffixes(): +if type_ == imp.C_EXTENSION: +_CONFIG_VARS['SOABI'] = suffix.split('.')[1] +break if args: vals = [] ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy better-storesink: merge
Author: Carl Friedrich Bolz Branch: better-storesink Changeset: r87236:ce6f32acf15c Date: 2016-09-19 21:54 +0200 http://bitbucket.org/pypy/pypy/changeset/ce6f32acf15c/ Log:merge diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst --- a/pypy/doc/cpython_differences.rst +++ b/pypy/doc/cpython_differences.rst @@ -449,6 +449,27 @@ support (see ``multiline_input()``). On the other hand, ``parse_and_bind()`` calls are ignored (issue `#2072`_). +* ``sys.getsizeof()`` always raises ``TypeError``. This is because a + memory profiler using this function is most likely to give results + inconsistent with reality on PyPy. It would be possible to have + ``sys.getsizeof()`` return a number (with enough work), but that may + or may not represent how much memory the object uses. It doesn't even + make really sense to ask how much *one* object uses, in isolation with + the rest of the system. For example, instances have maps, which are + often shared across many instances; in this case the maps would + probably be ignored by an implementation of ``sys.getsizeof()``, but + their overhead is important in some cases if they are many instances + with unique maps. Conversely, equal strings may share their internal + string data even if they are different objects---or empty containers + may share parts of their internals as long as they are empty. Even + stranger, some lists create objects as you read them; if you try to + estimate the size in memory of ``range(10**6)`` as the sum of all + items' size, that operation will by itself create one million integer + objects that never existed in the first place. Note that some of + these concerns also exist on CPython, just less so. For this reason + we explicitly don't implement ``sys.getsizeof()``. + + .. _`is ignored in PyPy`: http://bugs.python.org/issue14621 .. _`little point`: http://events.ccc.de/congress/2012/Fahrplan/events/5152.en.html .. _`#2072`: https://bitbucket.org/pypy/pypy/issue/2072/ 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 @@ -16,3 +16,8 @@ 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. + +.. branch: conditional_call_value_3 +JIT residual calls: if the called function starts with a fast-path +like "if x.foo != 0: return x.foo", then inline the check before +doing the CALL. For now, string hashing is about the only case. diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py --- a/pypy/interpreter/generator.py +++ b/pypy/interpreter/generator.py @@ -63,7 +63,7 @@ """x.__iter__() <==> iter(x)""" return self.space.wrap(self) -def descr_send(self, w_arg=None): +def descr_send(self, w_arg): """send(arg) -> send 'arg' into generator, return next yielded value or raise StopIteration.""" return self.send_ex(w_arg) diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py --- a/pypy/interpreter/pyframe.py +++ b/pypy/interpreter/pyframe.py @@ -264,25 +264,22 @@ try: executioncontext.call_trace(self) # -if operr is not None: -ec = self.space.getexecutioncontext() -next_instr = self.handle_operation_error(ec, operr) -self.last_instr = intmask(next_instr - 1) -else: -# Execution starts just after the last_instr. Initially, -# last_instr is -1. After a generator suspends it points to -# the YIELD_VALUE instruction. -next_instr = r_uint(self.last_instr + 1) -if next_instr != 0: -self.pushvalue(w_inputvalue) -# try: +if operr is not None: +ec = self.space.getexecutioncontext() +next_instr = self.handle_operation_error(ec, operr) +self.last_instr = intmask(next_instr - 1) +else: +# Execution starts just after the last_instr. Initially, +# last_instr is -1. After a generator suspends it points to +# the YIELD_VALUE instruction. +next_instr = r_uint(self.last_instr + 1) +if next_instr != 0: +self.pushvalue(w_inputvalue) w_exitvalue = self.dispatch(self.pycode, next_instr, executioncontext) -except Exception: -executioncontext.return_trace(self, self.space.w_None) -raise -executioncontext.return_trace(self, w_exitvalue) +finally: +executioncontext.return_trace(self, w_exitvalue) # it used to say self.last_exception = None
[pypy-commit] pypy better-storesink: a passing test
Author: Carl Friedrich Bolz Branch: better-storesink Changeset: r87234:5c15154ee248 Date: 2016-09-19 20:03 +0200 http://bitbucket.org/pypy/pypy/changeset/5c15154ee248/ Log:a passing test diff --git a/rpython/translator/backendopt/test/test_cse.py b/rpython/translator/backendopt/test/test_cse.py --- a/rpython/translator/backendopt/test/test_cse.py +++ b/rpython/translator/backendopt/test/test_cse.py @@ -335,6 +335,25 @@ return res self.check(f, [int], getfield=0) +def test_loopinvariant_heap_merge_not_possible(self): +class A(object): +pass +def f(i): +res = 0 +x = i +a = A() +if i == 0: +a.x = 1 +else: +a.x = i +while x: +x -= 1 +res += a.x +if x % 1000 == 1: +a.x = 5 +return res +self.check(f, [int], getfield=1) + def test_direct_merge(self): def f(i): a = i + 1 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy better-storesink: loop_blocks was broken in complex cases
Author: Carl Friedrich Bolz Branch: better-storesink Changeset: r87235:c701f3c76e7c Date: 2016-09-19 21:53 +0200 http://bitbucket.org/pypy/pypy/changeset/c701f3c76e7c/ Log:loop_blocks was broken in complex cases diff --git a/rpython/translator/backendopt/cse.py b/rpython/translator/backendopt/cse.py --- a/rpython/translator/backendopt/cse.py +++ b/rpython/translator/backendopt/cse.py @@ -304,7 +304,46 @@ result._clear_heapcache_for_loop_blocks(loop_blocks) return result -def loop_blocks(graph): +def compute_reachability_no_backedges(graph, backedges): +reachable = {} +blocks = list(graph.iterblocks()) +# Reversed order should make the reuse path more likely. +for block in reversed(blocks): +reach = set() +scheduled = [block] +while scheduled: +current = scheduled.pop() +for link in current.exits: +if link in backedges: +continue +if link.target in reachable: +reach.add(link.target) +reach = reach | reachable[link.target] +continue +if link.target not in reach: +reach.add(link.target) +scheduled.append(link.target) +reachable[block] = reach +return reachable + +def loop_blocks(graph, backedges, entrymap): +reachable_no_backedges = compute_reachability_no_backedges(graph, backedges) +reachable = support.compute_reachability(graph) +result = {} +for block in graph.iterblocks(): +entering_backedges = [link for link in entrymap[block] +if link in backedges] +if not entering_backedges: +# no backedge entries +continue +loop_blocks = {block} +for target in reachable_no_backedges[block]: +if any(link.prevblock in reachable[target] + for link in entering_backedges): +loop_blocks.add(target) +result[block] = loop_blocks +return result + loop_blocks = support.find_loop_blocks(graph) result = {} for loop_block, start in loop_blocks.iteritems(): @@ -319,8 +358,8 @@ def transform(self, graph): variable_families = ssa.DataFlowFamilyBuilder(graph).get_variable_families() entrymap = mkentrymap(graph) -loops = loop_blocks(graph) backedges = support.find_backedges(graph) +loops = loop_blocks(graph, backedges, entrymap) todo = collections.deque([graph.startblock]) caches_to_merge = collections.defaultdict(list) done = set() diff --git a/rpython/translator/backendopt/test/test_cse.py b/rpython/translator/backendopt/test/test_cse.py --- a/rpython/translator/backendopt/test/test_cse.py +++ b/rpython/translator/backendopt/test/test_cse.py @@ -1,6 +1,6 @@ import pytest from rpython.translator.translator import TranslationContext, graphof -from rpython.translator.backendopt.cse import CSE, Cache +from rpython.translator.backendopt.cse import CSE, Cache, loop_blocks from rpython.flowspace.model import Variable, Constant from rpython.translator.backendopt import removenoops from rpython.flowspace.model import checkgraph, summary @@ -354,6 +354,28 @@ return res self.check(f, [int], getfield=1) +def test_loopinvariant_heap_merge_nested(self): +class A(object): +pass +def f(i): +res = 0 +y = 0 +while y < i: +y += 1 +x = i +a = A() +if i == 0: +a.x = 1 +else: +a.x = i +while x: +x -= 1 +res += a.x +if x % 1000 == 1: +a.x = 5 +return res +self.check(f, [int], getfield=1) + def test_direct_merge(self): def f(i): a = i + 1 @@ -567,3 +589,45 @@ assert not needs_adding assert res is v2 + +def test_loop_blocks(): +from rpython.flowspace.model import mkentrymap +from rpython.translator.backendopt import support +class A(object): pass +def f(i): +res = 0 +y = 0 +while y < i: # block1 +y += 1 # block2 +x = i +a = A() +if i == 0: +a.x = 1 # block3 +else: +a.x = i # block4 +while x: # block5 +x -= 1 # block6 +res += a.x +if x % 1000 == 1: +a.x = 5 # block7 +return res # block8 + +t = TranslationContext() +t.buildannotator().build_types(f, [int]) +t.buildrtyper().specialize() +graph = graphof(t, f) +startblock = graph.startblock +block1 = startblock.exits[0].target +block2 = block1.exits[1].target +block3 = block2.exits[0].target +
[pypy-commit] pypy py3.5: untabify
Author: Armin Rigo Branch: py3.5 Changeset: r87237:434221ac191c Date: 2016-09-19 22:05 +0200 http://bitbucket.org/pypy/pypy/changeset/434221ac191c/ Log:untabify diff --git a/pypy/module/__builtin__/functional.py b/pypy/module/__builtin__/functional.py --- a/pypy/module/__builtin__/functional.py +++ b/pypy/module/__builtin__/functional.py @@ -136,7 +136,7 @@ "%s() expects at least one argument", implementation_of) w_key = None - has_default = False +has_default = False if any_kwds: kwds = args.keywords for n in range(len(kwds)): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Test that loops automatically unroll if they are written anywhere in the
Author: Armin Rigo Branch: Changeset: r87238:3ebb2e0f8d2b Date: 2016-09-19 22:07 +0200 http://bitbucket.org/pypy/pypy/changeset/3ebb2e0f8d2b/ Log:Test that loops automatically unroll if they are written anywhere in the same function as one that contains a jit_merge_point() 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 @@ -4558,3 +4558,20 @@ self.meta_interp(f, []) self.check_resops(guard_nonnull=0) +def test_loop_before_main_loop(self): +fdriver = JitDriver(greens=[], reds='auto') +gdriver = JitDriver(greens=[], reds='auto') +def f(i, j): +while j > 0: # this loop unrolls because it is in the same +j -= 1 # function as a jit_merge_point() +while i > 0: +fdriver.jit_merge_point() +i -= 1 +def g(i, j, k): +while k > 0: +gdriver.jit_merge_point() +f(i, j) +k -= 1 + +self.meta_interp(g, [5, 5, 5]) +self.check_resops(guard_true=10) # 5 unrolled, plus 5 unrelated ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit