[pypy-commit] pypy default: fix a corner case in a test
Author: fijal Branch: Changeset: r79933:b1465cb3c7e1 Date: 2015-10-02 15:32 +0200 http://bitbucket.org/pypy/pypy/changeset/b1465cb3c7e1/ Log:fix a corner case in a test diff --git a/rpython/rtyper/module/test/test_ll_time.py b/rpython/rtyper/module/test/test_ll_time.py --- a/rpython/rtyper/module/test/test_ll_time.py +++ b/rpython/rtyper/module/test/test_ll_time.py @@ -40,11 +40,11 @@ # we can only subtract two numbers returned by the same function. # Moreover they might have different precisions, but it should # be at least 0.01 seconds, hence the "sleeps". -assert 0.0199 <= t2-t0 <= 9.0 -assert 0.0199 <= t3-t1 <= t4-t0 <= 9.0 -assert 0.0199 <= t4-t2 <= t5-t1 <= t6-t0 <= 9.0 -assert 0.0199 <= t5-t3 <= t6-t2 <= 9.0 -assert 0.0199 <= t6-t4 <= 9.0 +assert 0.0099 <= t2-t0 <= 9.0 +assert 0.0099 <= t3-t1 <= t4-t0 <= 9.0 +assert 0.0099 <= t4-t2 <= t5-t1 <= t6-t0 <= 9.0 +assert 0.0099 <= t5-t3 <= t6-t2 <= 9.0 +assert 0.0099 <= t6-t4 <= 9.0 def test_time_sleep(self): def does_nothing(): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: kill useless test
Author: fijal Branch: Changeset: r79934:bde66c2cf46f Date: 2015-10-02 15:39 +0200 http://bitbucket.org/pypy/pypy/changeset/bde66c2cf46f/ Log:kill useless test diff --git a/pypy/module/pypyjit/test/test_jit_hook.py b/pypy/module/pypyjit/test/test_jit_hook.py --- a/pypy/module/pypyjit/test/test_jit_hook.py +++ b/pypy/module/pypyjit/test/test_jit_hook.py @@ -213,22 +213,6 @@ self.on_abort() assert l == [('pypyjit', 'ABORT_TOO_LONG', [])] -def test_on_optimize(self): -import pypyjit -l = [] - -def hook(info): -l.append(info.jitdriver_name) - -def optimize_hook(info): -return [] - -pypyjit.set_compile_hook(hook) -pypyjit.set_optimize_hook(optimize_hook) -self.on_optimize() -self.on_compile() -assert l == ['pypyjit'] - def test_creation(self): from pypyjit import ResOperation ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vecopt-merge: store operations did not correctly split packs (wrong size used) and thus did not sign extend correctly some times
Author: Richard PlanggerBranch: vecopt-merge Changeset: r79930:569c929fd2a1 Date: 2015-10-02 14:53 +0200 http://bitbucket.org/pypy/pypy/changeset/569c929fd2a1/ Log:store operations did not correctly split packs (wrong size used) and thus did not sign extend correctly some times diff --git a/pypy/module/micronumpy/test/test_zjit.py b/pypy/module/micronumpy/test/test_zjit.py --- a/pypy/module/micronumpy/test/test_zjit.py +++ b/pypy/module/micronumpy/test/test_zjit.py @@ -844,7 +844,7 @@ def test_where(self): result = self.run("where") assert result == -40 -self.check_vectorized(1, 0) # TODO might be possible to vectorize +self.check_vectorized(1, 1) def define_searchsorted(): 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 @@ -235,6 +235,34 @@ def check_operation(self, state, pack, op): pass +def crop_vector(self, op, newsize, size): +return newsize, size + +def must_crop_vector(self, op, index): +restrict = self.argument_restrictions[index] +size = op.getarg(index).bytesize +newsize = self.crop_to_size(op, index) +return not restrict.any_size() and newsize != size + +@always_inline +def crop_to_size(self, op, index): +restrict = self.argument_restrictions[index] +return restrict.bytesize + +class StoreRestrict(OpRestrict): +def __init__(self, argument_restris): +self.argument_restrictions = argument_restris + +def must_crop_vector(self, op, index): +size = op.getarg(index).bytesize +return self.crop_to_size(op, index) != size + +@always_inline +def crop_to_size(self, op, index): +# there is only one parameter that needs to be transformed! +descr = op.getdescr() +return descr.get_item_size_in_bytes() + class OpMatchSizeTypeFirst(OpRestrict): def check_operation(self, state, pack, op): i = 0 @@ -283,9 +311,9 @@ rop.VEC_FLOAT_ABS: OpRestrict([TR_ANY_FLOAT]), rop.VEC_FLOAT_NEG: OpRestrict([TR_ANY_FLOAT]), -rop.VEC_RAW_STORE: OpRestrict([None, None, TR_ANY]), -rop.VEC_SETARRAYITEM_RAW: OpRestrict([None, None, TR_ANY]), -rop.VEC_SETARRAYITEM_GC:OpRestrict([None, None, TR_ANY]), +rop.VEC_RAW_STORE: StoreRestrict([None, None, TR_ANY]), +rop.VEC_SETARRAYITEM_RAW: StoreRestrict([None, None, TR_ANY]), +rop.VEC_SETARRAYITEM_GC:StoreRestrict([None, None, TR_ANY]), rop.GUARD_TRUE: OpRestrict([TR_ANY_INTEGER]), rop.GUARD_FALSE:OpRestrict([TR_ANY_INTEGER]), @@ -361,16 +389,18 @@ # 1) args[i] = vecop # a) assemble_scattered_values(state, pack, args, i) # c) -crop_vector(state, restrict, pack, args, i) # b) +crop_vector(state, oprestrict, restrict, pack, args, i) # b) position_values(state, restrict, pack, args, i, pos) # d) restrict.check(args[i]) @always_inline -def crop_vector(state, restrict, pack, args, i): +def crop_vector(state, oprestrict, restrict, pack, args, i): # convert size i64 -> i32, i32 -> i64, ... arg = args[i] -newsize, size = restrict.bytesize, arg.bytesize -if not restrict.any_size() and newsize != size: +size = arg.bytesize +left = pack.leftmost() +if oprestrict.must_crop_vector(left, i): +newsize = oprestrict.crop_to_size(left, i) assert arg.type == 'i' state._prevent_signext(newsize, size) count = arg.count @@ -713,8 +743,8 @@ op = pack.leftmost() if op.returns_void(): assert op.is_primitive_store() -arg = op.getarg(2) -return vec_reg_size // arg.bytesize +descr = op.getdescr() +return vec_reg_size // descr.get_item_size_in_bytes() if op.is_typecast(): if op.casts_down(): @@ -788,8 +818,9 @@ if left.is_primitive_store(): # make this case more general if it turns out this is # not the only case where packs need to be trashed -indexarg = left.getarg(2) -return indexarg.bytesize * self.numops() - vec_reg_size +descr = left.getdescr() +bytesize = descr.get_item_size_in_bytes() +return bytesize * self.numops() - vec_reg_size return 0 if self.numops() == 0: return -1 diff --git a/rpython/jit/metainterp/optimizeopt/test/test_schedule.py b/rpython/jit/metainterp/optimizeopt/test/test_schedule.py --- a/rpython/jit/metainterp/optimizeopt/test/test_schedule.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_schedule.py @@ -11,16 +11,11 @@ from
[pypy-commit] pypy default: make this test not dependant on importing stuff
Author: fijal Branch: Changeset: r79935:40a16dffa99f Date: 2015-10-02 15:51 +0200 http://bitbucket.org/pypy/pypy/changeset/40a16dffa99f/ Log:make this test not dependant on importing stuff diff --git a/pypy/module/pypyjit/test_pypy_c/test_buffers.py b/pypy/module/pypyjit/test_pypy_c/test_buffers.py --- a/pypy/module/pypyjit/test_pypy_c/test_buffers.py +++ b/pypy/module/pypyjit/test_pypy_c/test_buffers.py @@ -28,7 +28,7 @@ def test_struct_unpack(self): def main(n): -import struct +import _struct as struct import array a = array.array('c', struct.pack('i', 42)) i = 0 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix the test
Author: fijal Branch: Changeset: r79936:d01d9a0ef18b Date: 2015-10-02 15:58 +0200 http://bitbucket.org/pypy/pypy/changeset/d01d9a0ef18b/ Log:fix the test diff --git a/pypy/module/pypyjit/test_pypy_c/test_jitlogparser.py b/pypy/module/pypyjit/test_pypy_c/test_jitlogparser.py --- a/pypy/module/pypyjit/test_pypy_c/test_jitlogparser.py +++ b/pypy/module/pypyjit/test_pypy_c/test_jitlogparser.py @@ -76,6 +76,6 @@ assert len(mod_bridges) in (1, 2, 3) # check that counts are reasonable (precise # may change in the future) -assert N - 2000 < sum(l.count for l in fn_with_bridges_loops) < N + 1000 +assert N - 2000 < sum(l.count for l in fn_with_bridges_loops) < N + 1500 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vecopt-merge: removed commented (old code)
Author: Richard PlanggerBranch: vecopt-merge Changeset: r79931:4b9eb5c3d265 Date: 2015-10-02 15:03 +0200 http://bitbucket.org/pypy/pypy/changeset/4b9eb5c3d265/ Log:removed commented (old code) diff --git a/rpython/jit/metainterp/optimizeopt/guard.py b/rpython/jit/metainterp/optimizeopt/guard.py --- a/rpython/jit/metainterp/optimizeopt/guard.py +++ b/rpython/jit/metainterp/optimizeopt/guard.py @@ -269,31 +269,8 @@ def emit_operation(self, op): self.renamer.rename(op) -#if op.is_always_pure(): -#self.delay(op) -#return -#self.emit_delayed_for(op) -#if not op.is_always_pure(): self._newoperations.append(op) -# delay the pure ops -#def delay(self, op): -#self.delayed[op] = None -#print "delayed", op - -#def emit_delayed_for(self, op): -#if op.is_inputarg(): -#return -#additional = [] -#if op.is_guard(): -#additional = op.getfailargs() -#for arg in op.getarglist() + additional: -#if arg in self.delayed: -#del self.delayed[arg] -#self.emit_delayed_for(arg) -#self._newoperations.append(op) - - def operation_position(self): return len(self._newoperations) 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 @@ -621,10 +621,6 @@ op = node.getoperation() if op.is_guard(): # add accumulation info to the descriptor -# TODO for version in self.loop.versions: -## this needs to be done for renamed (accum arguments) -#version.renamed_inputargs = [ renamer.rename_map.get(arg,arg) for arg in version.inputargs ] -#self.appendedvar_pos_arg_count = len(sched_data.invariant_vector_vars) failargs = op.getfailargs() descr = op.getdescr() # note: stitching a guard must resemble the order of the label ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vecopt-merge: translation issue (missing import)
Author: Richard PlanggerBranch: vecopt-merge Changeset: r79932:31753dc0d45d Date: 2015-10-02 15:27 +0200 http://bitbucket.org/pypy/pypy/changeset/31753dc0d45d/ Log:translation issue (missing import) 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 @@ -11,6 +11,7 @@ from rpython.rlib.objectmodel import specialize, always_inline from rpython.jit.metainterp.jitexc import NotAVectorizeableLoop, NotAProfitableLoop from rpython.rtyper.lltypesystem.lloperation import llop +from rpython.rtyper.lltypesystem import lltype class SchedulerState(object): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vecopt-merge: same operation for iter states failed if index and _indices where not the same (fixed)
Author: Richard PlanggerBranch: vecopt-merge Changeset: r79929:232d93b7d261 Date: 2015-10-02 13:10 +0200 http://bitbucket.org/pypy/pypy/changeset/232d93b7d261/ Log:same operation for iter states failed if index and _indices where not the same (fixed) concrete type of a loaded singlefloat was f, but singlefloat_to_float demands i as parameter diff --git a/pypy/module/micronumpy/iterators.py b/pypy/module/micronumpy/iterators.py --- a/pypy/module/micronumpy/iterators.py +++ b/pypy/module/micronumpy/iterators.py @@ -84,7 +84,9 @@ self.offset = offset def same(self, other): -if self.offset == other.offset: +if self.offset == other.offset and \ + self.index == other.index and \ + self._indices == other._indices: return self.iterator.same_shape(other.iterator) return False @@ -119,9 +121,9 @@ self.factors = factors def same_shape(self, other): -""" if two iterators share the same shape, -next() only needs to be called on one! -""" +""" Iterating over the same element """ +if not self.contiguous or not other.contiguous: +return False return (self.contiguous == other.contiguous and self.array.dtype is self.array.dtype and self.shape_m1 == other.shape_m1 and diff --git a/pypy/module/micronumpy/test/test_zjit.py b/pypy/module/micronumpy/test/test_zjit.py --- a/pypy/module/micronumpy/test/test_zjit.py +++ b/pypy/module/micronumpy/test/test_zjit.py @@ -895,7 +895,8 @@ a = [[1, 2, 3, 4], [3, 4, 5, 6], [5, 6, 7, 8], [7, 8, 9, 10], [9, 10, 11, 12], [11, 12, 13, 14], [13, 14, 15, 16], [16, 17, 18, 19]] b = a -> ::2 c = b + b -c -> 1 -> 1 +d = c -> 1 +d -> 1 """ def test_multidim_slice(self): @@ -904,7 +905,7 @@ self.check_trace_count(3) # ::2 creates a view object -> needs an inner loop # that iterates continous chunks of the matrix -self.check_vectorized(1,1) +self.check_vectorized(1,0) def define_dot_matrix(): return """ @@ -930,7 +931,6 @@ """ def test_pow(self): -py.test.skip("Not implemented CDefinedIntSymbolic('RPY_TLOFS_rpy_errno')") result = self.run("pow") assert result == 29 ** 2 self.check_trace_count(1) @@ -944,20 +944,6 @@ """ def test_pow_int(self): -py.test.skip("Not implemented CDefinedIntSymbolic('RPY_TLOFS_rpy_errno')") result = self.run("pow_int") assert result == 15 ** 2 self.check_trace_count(4) # extra one for the astype - - -def define_take(): -return """ -a = |10| -b = take(a, [1, 1, 3, 2]) -b -> 2 -""" - -def test_take(self): -py.test.skip("key error get item?") -result = self.run("take") -assert result == 3 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 @@ -10,6 +10,7 @@ from rpython.jit.metainterp.jitexc import NotAProfitableLoop from rpython.rlib.objectmodel import specialize, always_inline from rpython.jit.metainterp.jitexc import NotAVectorizeableLoop, NotAProfitableLoop +from rpython.rtyper.lltypesystem.lloperation import llop class SchedulerState(object): @@ -162,6 +163,14 @@ for node in state.graph.nodes: assert node.emitted +def failnbail_transformation(msg): +msg = '%s\n' % msg +if we_are_translated(): +llop.debug_print(lltype.Void, msg) +else: +import pdb; pdb.set_trace() +raise NotImplementedError(msg) + class TypeRestrict(object): ANY_TYPE = '\x00' ANY_SIZE = -1 @@ -191,15 +200,27 @@ def check(self, value): assert value.datatype != '\x00' if self.type != TypeRestrict.ANY_TYPE: -assert self.type == value.datatype +if self.type != value.datatype: +msg = "type mismatch %s != %s" % \ +(self.type, value.datatype) +failnbail_transformation(msg) assert value.bytesize > 0 if not self.any_size(): -assert self.bytesize == value.bytesize +if self.bytesize != value.bytesize: +msg = "bytesize mismatch %s != %s" % \ +(self.bytesize, value.bytesize) +failnbail_transformation(msg) assert value.count > 0 if self.count != TypeRestrict.ANY_COUNT: -assert value.count >= self.count +if value.count < self.count: +msg = "count mismatch %s < %s" % \ +(self.count, value.count) +failnbail_transformation(msg) if self.sign !=
[pypy-commit] pypy ppc-updated-backend: hg merge default
Author: Armin RigoBranch: ppc-updated-backend Changeset: r79927:add2cdb7a761 Date: 2015-09-21 14:14 +0200 http://bitbucket.org/pypy/pypy/changeset/add2cdb7a761/ Log:hg merge default diff too long, truncating to 2000 out of 50549 lines diff --git a/lib-python/conftest.py b/lib-python/conftest.py --- a/lib-python/conftest.py +++ b/lib-python/conftest.py @@ -303,7 +303,7 @@ RegrTest('test_memoryio.py'), RegrTest('test_memoryview.py'), RegrTest('test_md5.py'), -RegrTest('test_mhlib.py'), +RegrTest('test_mhlib.py', usemodules='binascii struct'), RegrTest('test_mimetools.py'), RegrTest('test_mimetypes.py'), RegrTest('test_MimeWriter.py', core=False, usemodules='binascii'), diff --git a/lib_pypy/_curses.py b/lib_pypy/_curses.py --- a/lib_pypy/_curses.py +++ b/lib_pypy/_curses.py @@ -1026,16 +1026,22 @@ def tigetflag(capname): _ensure_initialised_setupterm() +if isinstance(capname, unicode): +capname = capname.encode('ascii') return lib.tigetflag(capname) def tigetnum(capname): _ensure_initialised_setupterm() +if isinstance(capname, unicode): +capname = capname.encode('ascii') return lib.tigetnum(capname) def tigetstr(capname): _ensure_initialised_setupterm() +if isinstance(capname, unicode): +capname = capname.encode('ascii') val = lib.tigetstr(capname) if int(ffi.cast("intptr_t", val)) in (0, -1): return None diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py --- a/pypy/config/pypyoption.py +++ b/pypy/config/pypyoption.py @@ -92,6 +92,8 @@ if sys.platform == "win32": module_suggests["cpyext"].append(("translation.shared", True)) + +# NOTE: this dictionary is not used any more module_import_dependencies = { # no _rawffi if importing rpython.rlib.clibffi raises ImportError # or CompilationError or py.test.skip.Exception @@ -108,6 +110,7 @@ } def get_module_validator(modname): +# NOTE: this function is not used any more if modname in module_import_dependencies: modlist = module_import_dependencies[modname] def validator(config): diff --git a/pypy/doc/embedding.rst b/pypy/doc/embedding.rst --- a/pypy/doc/embedding.rst +++ b/pypy/doc/embedding.rst @@ -20,10 +20,6 @@ It initializes the RPython/PyPy GC and does a bunch of necessary startup code. This function cannot fail. -.. function:: void pypy_init_threads(void); - - Initialize threads. Only need to be called if there are any threads involved - .. function:: int pypy_setup_home(char* home, int verbose); This function searches the PyPy standard library starting from the given @@ -38,6 +34,11 @@ Function returns 0 on success or -1 on failure, can be called multiple times until the library is found. +.. function:: void pypy_init_threads(void); + + Initialize threads. Only need to be called if there are any threads involved. + *Must be called after pypy_setup_home()* + .. function:: int pypy_execute_source(char* source); Execute the Python source code given in the ``source`` argument. In case of diff --git a/pypy/doc/jit-hooks.rst b/pypy/doc/jit-hooks.rst --- a/pypy/doc/jit-hooks.rst +++ b/pypy/doc/jit-hooks.rst @@ -5,19 +5,8 @@ understanding what's pypy's JIT doing while running your program. There are three functions related to that coming from the ``pypyjit`` module: -.. function:: set_optimize_hook(callable) -Set a compiling hook that will be called each time a loop is optimized, -but before assembler compilation. This allows adding additional -optimizations on Python level. - -The callable will be called with the ``pypyjit.JitLoopInfo`` object. -Refer to it's documentation for details. - -Result value will be the resulting list of operations, or None - - -.. function:: set_compile_hook(callable) +.. function:: set_compile_hook(callable, operations=True) Set a compiling hook that will be called each time a loop is compiled. @@ -28,6 +17,9 @@ inside the jit hook is itself jitted, it will get compiled, but the jit hook won't be called for that. +if operations=False, no list of operations will be available. Useful +if the hook is supposed to be very lighweight. + .. function:: set_abort_hook(hook) Set a hook (callable) that will be called each time there is tracing @@ -66,3 +58,25 @@ * ``loop_run_times`` - counters for number of times loops are run, only works when ``enable_debug`` is called. + +.. class:: JitLoopInfo + + A class containing information about the compiled loop. Usable attributes: + + * ``operations`` - list of operations, if requested + + * ``jitdriver_name`` - the name of jitdriver associated with this loop + + * ``greenkey`` - a key at which the loop got compiled (e.g. code position, + is_being_profiled, pycode tuple for python jitdriver) + + * ``loop_no`` - loop cardinal number + + *
[pypy-commit] pypy ppc-updated-backend: PPC Backend #6: most tests pass
Author: Armin RigoBranch: ppc-updated-backend Changeset: r79928:0766a869fc86 Date: 2015-10-02 10:49 +0200 http://bitbucket.org/pypy/pypy/changeset/0766a869fc86/ Log:PPC Backend #6: most tests pass Various remaining fixes, until most tests pass. Took the relevant tests, copied and adapted from the x86 backend. This also includes test_zll_stress_*.py from rpython/jit/backend/test. Update to default for the "optresult" changes. diff --git a/rpython/jit/backend/arm/regalloc.py b/rpython/jit/backend/arm/regalloc.py --- a/rpython/jit/backend/arm/regalloc.py +++ b/rpython/jit/backend/arm/regalloc.py @@ -41,11 +41,7 @@ from rpython.jit.backend.llsupport.descr import CallDescr -# xxx hack: set a default value for TargetToken._ll_loop_code. If 0, we know -# that it is a LABEL that was not compiled yet. -TargetToken._ll_loop_code = 0 - -class TempInt(TempVar): +class TempInt(TempBox): type = INT def __repr__(self): diff --git a/rpython/jit/backend/llsupport/test/test_gc_integration.py b/rpython/jit/backend/llsupport/test/test_gc_integration.py --- a/rpython/jit/backend/llsupport/test/test_gc_integration.py +++ b/rpython/jit/backend/llsupport/test/test_gc_integration.py @@ -3,7 +3,7 @@ """ import py -import re +import re, sys, struct from rpython.jit.metainterp.history import TargetToken, BasicFinalDescr,\ JitCellToken, BasicFailDescr, AbstractDescr from rpython.jit.backend.llsupport.gc import GcLLDescription, GcLLDescr_boehm,\ @@ -613,7 +613,10 @@ cpu = CPU(None, None) cpu.gc_ll_descr = GCDescrShadowstackDirect() wbd = cpu.gc_ll_descr.write_barrier_descr -wbd.jit_wb_if_flag_byteofs = 0 # directly into 'hdr' field +if sys.byteorder == 'little': +wbd.jit_wb_if_flag_byteofs = 0 # directly into 'hdr' field +else: +wbd.jit_wb_if_flag_byteofs = struct.calcsize("l") - 1 S = lltype.GcForwardReference() S.become(lltype.GcStruct('S', ('hdr', lltype.Signed), diff --git a/rpython/jit/backend/ppc/helper/regalloc.py b/rpython/jit/backend/ppc/helper/regalloc.py --- a/rpython/jit/backend/ppc/helper/regalloc.py +++ b/rpython/jit/backend/ppc/helper/regalloc.py @@ -1,4 +1,4 @@ -from rpython.jit.metainterp.history import ConstInt, Box, FLOAT +from rpython.jit.metainterp.history import ConstInt, FLOAT from rpython.jit.backend.ppc.locations import imm def check_imm_box(arg, lower_bound=-2**15, upper_bound=2**15-1): @@ -21,7 +21,7 @@ else: l1 = self.ensure_reg(a1) self.free_op_vars() -res = self.force_allocate_reg_or_cc(op.result) +res = self.force_allocate_reg_or_cc(op) return [l0, l1, res] return f prepare_cmp_op = _prepare_cmp_op(signed=True) @@ -31,27 +31,27 @@ l0 = self.ensure_reg(op.getarg(0)) l1 = imm(0) self.free_op_vars() -res = self.force_allocate_reg_or_cc(op.result) +res = self.force_allocate_reg_or_cc(op) return [l0, l1, res] def prepare_float_cmp(self, op): l0 = self.ensure_reg(op.getarg(0)) l1 = self.ensure_reg(op.getarg(1)) self.free_op_vars() -res = self.force_allocate_reg_or_cc(op.result) +res = self.force_allocate_reg_or_cc(op) return [l0, l1, res] def prepare_unary_op(self, op): l0 = self.ensure_reg(op.getarg(0)) self.free_op_vars() -res = self.force_allocate_reg(op.result) +res = self.force_allocate_reg(op) return [l0, res] def prepare_binary_op(self, op): reg1 = self.ensure_reg(op.getarg(0)) reg2 = self.ensure_reg(op.getarg(1)) self.free_op_vars() -res = self.force_allocate_reg(op.result) +res = self.force_allocate_reg(op) return [reg1, reg2, res] def prepare_int_add_or_mul(self, op): @@ -65,7 +65,7 @@ else: l1 = self.ensure_reg(a1) self.free_op_vars() -res = self.force_allocate_reg(op.result) +res = self.force_allocate_reg(op) return [l0, l1, res] def prepare_int_sub(self, op): @@ -76,5 +76,5 @@ else: l1 = self.ensure_reg(a1) self.free_op_vars() -res = self.force_allocate_reg(op.result) +res = self.force_allocate_reg(op) return [l0, l1, res] diff --git a/rpython/jit/backend/ppc/opassembler.py b/rpython/jit/backend/ppc/opassembler.py --- a/rpython/jit/backend/ppc/opassembler.py +++ b/rpython/jit/backend/ppc/opassembler.py @@ -10,9 +10,9 @@ THREADLOCAL_ADDR_OFFSET, IS_BIG_ENDIAN) -from rpython.jit.metainterp.history import (JitCellToken, TargetToken, Box, +from rpython.jit.metainterp.history import (JitCellToken, TargetToken, AbstractFailDescr, FLOAT, INT, REF, -ConstInt) +ConstInt, VOID) from rpython.rlib.objectmodel import
[pypy-commit] pypy ppc-updated-backend: PPC Backend #6 step 1
Author: Armin RigoBranch: ppc-updated-backend Changeset: r79926:7d9d9d7d1398 Date: 2015-10-02 10:35 +0200 http://bitbucket.org/pypy/pypy/changeset/7d9d9d7d1398/ Log:PPC Backend #6 step 1 diff too long, truncating to 2000 out of 4756 lines diff --git a/rpython/jit/backend/arm/assembler.py b/rpython/jit/backend/arm/assembler.py --- a/rpython/jit/backend/arm/assembler.py +++ b/rpython/jit/backend/arm/assembler.py @@ -225,6 +225,10 @@ if not for_frame: self._push_all_regs_to_jitframe(mc, [], withfloats, callee_only=True) else: +# NOTE: don't save registers on the jitframe here! It might +# override already-saved values that will be restored +# later... +# # we're possibly called from the slowpath of malloc # save the caller saved registers # assuming we do not collect here diff --git a/rpython/jit/backend/arm/regalloc.py b/rpython/jit/backend/arm/regalloc.py --- a/rpython/jit/backend/arm/regalloc.py +++ b/rpython/jit/backend/arm/regalloc.py @@ -1259,18 +1259,6 @@ self.possibly_free_vars(guard_op.getfailargs()) return locs + [resloc, tmploc] -def _prepare_args_for_new_op(self, new_args): -gc_ll_descr = self.cpu.gc_ll_descr -args = gc_ll_descr.args_for_new(new_args) -arglocs = [] -for i in range(len(args)): -arg = args[i] -t = TempInt() -l = self.force_allocate_reg(t, selected_reg=r.all_regs[i]) -self.assembler.load(l, imm(arg)) -arglocs.append(t) -return arglocs - prepare_op_float_add = prepare_float_op(name='prepare_op_float_add') prepare_op_float_sub = prepare_float_op(name='prepare_op_float_sub') prepare_op_float_mul = prepare_float_op(name='prepare_op_float_mul') diff --git a/rpython/jit/backend/llsupport/test/ztranslation_test.py b/rpython/jit/backend/llsupport/test/ztranslation_test.py --- a/rpython/jit/backend/llsupport/test/ztranslation_test.py +++ b/rpython/jit/backend/llsupport/test/ztranslation_test.py @@ -303,7 +303,7 @@ for line in open(str(logfile)): if 'guard_class' in line: guard_class += 1 -# if we get many more guard_classes, it means that we generate +# if we get many more guard_classes (~93), it means that we generate # guards that always fail (the following assert's original purpose # is to catch the following case: each GUARD_CLASS is misgenerated # and always fails with "gcremovetypeptr") diff --git a/rpython/jit/backend/ppc/callbuilder.py b/rpython/jit/backend/ppc/callbuilder.py --- a/rpython/jit/backend/ppc/callbuilder.py +++ b/rpython/jit/backend/ppc/callbuilder.py @@ -126,8 +126,8 @@ if gcrootmap.is_shadow_stack and self.is_call_release_gil: # in this mode, 'ebx' happens to contain the shadowstack # top at this point, so reuse it instead of loading it again -ssreg = ebx -self.asm._reload_frame_if_necessary(self.mc) +ssreg = self.RSHADOWPTR +self.asm._reload_frame_if_necessary(self.mc, shadowstack_reg=ssreg) def emit_raw_call(self): self.mc.raw_call() @@ -151,9 +151,10 @@ # Save this thread's shadowstack pointer into r29, for later comparison gcrootmap = self.asm.cpu.gc_ll_descr.gcrootmap if gcrootmap: -rst = gcrootmap.get_root_stack_top_addr() -self.mc.load_imm(RSHADOWPTR, rst) -self.mc.load(RSHADOWOLD.value, RSHADOWPTR.value, 0) +if gcrootmap.is_shadow_stack: +rst = gcrootmap.get_root_stack_top_addr() +self.mc.load_imm(RSHADOWPTR, rst) +self.mc.load(RSHADOWOLD.value, RSHADOWPTR.value, 0) # # change 'rpy_fastgil' to 0 (it should be non-zero right now) self.mc.load_imm(RFASTGILPTR, fastgil) @@ -184,7 +185,8 @@ self.mc.cmpdi(0, r.r10.value, 0) b1_location = self.mc.currpos() -self.mc.trap() # patched with a BEQ: jump if r10 is zero +self.mc.trap() # boehm: patched with a BEQ: jump if r10 is zero + # shadowstack: patched with BNE instead if self.asm.cpu.gc_ll_descr.gcrootmap: # When doing a call_release_gil with shadowstack, there @@ -192,20 +194,23 @@ # current shadowstack can be the one of a different # thread. So here we check if the shadowstack pointer # is still the same as before we released the GIL (saved -# in 'r7'), and if not, we fall back to 'reacqgil_addr'. -XXX -self.mc.LDR_ri(r.ip.value, r.r5.value, cond=c.EQ) -self.mc.CMP_rr(r.ip.value, r.r7.value, cond=c.EQ) +# in RSHADOWOLD), and if not, we fall back to 'reacqgil_addr'. +
[pypy-commit] pypy default: fix the segfault when no stats are present
Author: fijal Branch: Changeset: r79937:cfc4705ad692 Date: 2015-10-02 17:40 +0200 http://bitbucket.org/pypy/pypy/changeset/cfc4705ad692/ Log:fix the segfault when no stats are present diff --git a/pypy/module/pypyjit/interp_resop.py b/pypy/module/pypyjit/interp_resop.py --- a/pypy/module/pypyjit/interp_resop.py +++ b/pypy/module/pypyjit/interp_resop.py @@ -315,11 +315,12 @@ """ ll_times = jit_hooks.stats_get_loop_run_times(None) w_times = space.newdict() -for i in range(len(ll_times)): -w_key = space.newtuple([space.wrap(ll_times[i].type), -space.wrap(ll_times[i].number)]) -space.setitem(w_times, w_key, - space.wrap(ll_times[i].counter)) +if ll_times: +for i in range(len(ll_times)): +w_key = space.newtuple([space.wrap(ll_times[i].type), +space.wrap(ll_times[i].number)]) +space.setitem(w_times, w_key, + space.wrap(ll_times[i].counter)) w_counters = space.newdict() for i, counter_name in enumerate(Counters.counter_names): v = jit_hooks.stats_get_counter_value(None, i) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Issue #2137: try harder to avoid infinite recursion in some cases of
Author: Armin RigoBranch: Changeset: r79925:fed018f3c786 Date: 2015-10-02 09:59 +0200 http://bitbucket.org/pypy/pypy/changeset/fed018f3c786/ Log:Issue #2137: try harder to avoid infinite recursion in some cases of __coerce__() with old-style instances diff --git a/pypy/module/__builtin__/interp_classobj.py b/pypy/module/__builtin__/interp_classobj.py --- a/pypy/module/__builtin__/interp_classobj.py +++ b/pypy/module/__builtin__/interp_classobj.py @@ -253,27 +253,30 @@ def binaryop(self, space, w_other): w_a, w_b = _coerce_helper(space, self, w_other) -if w_a is None: -w_a = self -w_b = w_other -if w_a is self: -w_meth = self.getattr(space, specialname, False) +if isinstance(w_a, W_InstanceObject): +w_meth = w_a.getattr(space, specialname, False) if w_meth is None: return space.w_NotImplemented return space.call_function(w_meth, w_b) else: +# fall back to space.xxx() if coerce returns a non-W_Instance +# object as first argument return getattr(space, objspacename)(w_a, w_b) binaryop.func_name = name def rbinaryop(self, space, w_other): w_a, w_b = _coerce_helper(space, self, w_other) -if w_a is None or w_a is self: -w_meth = self.getattr(space, rspecialname, False) +if isinstance(w_a, W_InstanceObject): +w_meth = w_a.getattr(space, rspecialname, False) if w_meth is None: return space.w_NotImplemented -return space.call_function(w_meth, w_other) +return space.call_function(w_meth, w_b) else: -return getattr(space, objspacename)(w_b, w_a) +# here, if coerce returns a non-W_Instance object as first +# argument, then give up. The idea is that this strange +# case should already have been handled by the binaryop() +# called from descroperation first. +return space.w_NotImplemented rbinaryop.func_name = "r" + name return binaryop, rbinaryop @@ -283,7 +286,7 @@ except OperationError, e: if not e.match(space, space.w_TypeError): raise -return [None, None] +return [w_self, w_other] return space.fixedview(w_tup, 2) def descr_instance_new(space, w_type, w_class, w_dict=None): @@ -523,13 +526,9 @@ def descr_cmp(self, space, w_other): # do all the work here like CPython w_a, w_b = _coerce_helper(space, self, w_other) -if w_a is None: -w_a = self -w_b = w_other -else: -if (not isinstance(w_a, W_InstanceObject) and -not isinstance(w_b, W_InstanceObject)): -return space.cmp(w_a, w_b) +if (not isinstance(w_a, W_InstanceObject) and +not isinstance(w_b, W_InstanceObject)): +return space.cmp(w_a, w_b) if isinstance(w_a, W_InstanceObject): w_func = w_a.getattr(space, '__cmp__', False) if w_func is not None: @@ -636,42 +635,36 @@ def descr_pow(self, space, w_other, w_modulo=None): if space.is_none(w_modulo): w_a, w_b = _coerce_helper(space, self, w_other) -if w_a is None: -w_a = self -w_b = w_other -if w_a is self: -w_func = self.getattr(space, '__pow__', False) -if w_func is not None: -return space.call_function(w_func, w_other) -return space.w_NotImplemented +if isinstance(w_a, W_InstanceObject): +w_func = w_a.getattr(space, '__pow__', False) +if w_func is None: +return space.w_NotImplemented +return space.call_function(w_func, w_other) else: return space.pow(w_a, w_b, space.w_None) else: # CPython also doesn't try coercion in this case w_func = self.getattr(space, '__pow__', False) -if w_func is not None: -return space.call_function(w_func, w_other, w_modulo) -return space.w_NotImplemented +if w_func is None: +return space.w_NotImplemented +return space.call_function(w_func, w_other, w_modulo) def descr_rpow(self, space, w_other, w_modulo=None): if space.is_none(w_modulo): w_a, w_b = _coerce_helper(space, self, w_other) -if w_a is None: -w_a = self -w_b = w_other -if w_a is self: -w_func = self.getattr(space, '__rpow__', False) -if w_func is not None: -return space.call_function(w_func, w_other) +if isinstance(w_a, W_InstanceObject): +w_func = w_a.getattr(space,