[pypy-commit] pypy default: Use OneDimIterator if we have one already. Fix it since tests started failing,
Author: Maciej Fijalkowski Branch: Changeset: r49941:8e56ec1b31a3 Date: 2011-11-29 10:10 +0200 http://bitbucket.org/pypy/pypy/changeset/8e56ec1b31a3/ Log:Use OneDimIterator if we have one already. Fix it since tests started failing, make test_zjit look better again. diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -180,10 +180,10 @@ return self.offset class OneDimIterator(BaseIterator): -def __init__(self, start, step, size): +def __init__(self, start, step, stop): self.offset = start self.step = step -self.size = size +self.size = stop * step + start def next(self, shapelen): arr = instantiate(OneDimIterator) @@ -193,7 +193,7 @@ return arr def done(self): -return self.offset >= self.size +return self.offset == self.size def get_offset(self): return self.offset @@ -1109,8 +1109,8 @@ def start_iter(self, res_shape=None): if res_shape is not None and res_shape != self.shape: return BroadcastIterator(self, res_shape) -# XXX there is a possible optimization here with SingleDimViewIterator -# ignore for now +if len(self.shape) == 1: +return OneDimIterator(self.start, self.strides[0], self.shape[0]) return ViewIterator(self) def setitem(self, item, value): 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 @@ -246,12 +246,12 @@ def test_slice(self): result = self.run("slice") assert result == 18 -# arraylen_gc are removed by the backend, would be good if they weren't -# here though -self.check_simple_loop({'int_mul': 2, 'getarrayitem_raw': 2, 'float_add': 1, - 'setarrayitem_raw': 1, 'int_add': 3, - 'int_lt': 1, 'guard_true': 1, 'jump': 1, - 'arraylen_gc': 4}) +self.check_simple_loop({'getarrayitem_raw': 2, +'float_add': 1, +'setarrayitem_raw': 1, +'int_add': 3, +'int_ge': 1, 'guard_false': 1, +'jump': 1}) def define_slice2(): return """ @@ -265,12 +265,9 @@ def test_slice2(self): result = self.run("slice2") assert result == 15 -# arraylen_gc are removed by the backend, would be good if they weren't -# here though -self.check_simple_loop({'int_mul': 2, 'getarrayitem_raw': 2, 'float_add': 1, -'setarrayitem_raw': 1, 'int_add': 1, -'int_lt': 1, 'guard_true': 1, 'jump': 1, -'arraylen_gc': 4}) +self.check_simple_loop({'getarrayitem_raw': 2, 'float_add': 1, +'setarrayitem_raw': 1, 'int_add': 3, +'int_ge': 1, 'guard_false': 1, 'jump': 1}) def define_multidim(): return """ ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: kill a duplicate test
Author: Maciej Fijalkowski Branch: Changeset: r49942:12123f742146 Date: 2011-11-29 10:14 +0200 http://bitbucket.org/pypy/pypy/changeset/12123f742146/ Log:kill a duplicate test 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 @@ -333,19 +333,6 @@ 'setarrayitem_raw': 1, 'int_add': 2, 'int_lt': 1, 'guard_true': 1, 'jump': 1}) -def define_set_slice(): -return """ -a = |30| -b = |30| -b[:] = a + a -b -> 3 -""" - -def test_set_slice(self): -result = self.run("set_slice") -assert result == 6 -self.check_loop_count(1) - class TestNumpyOld(LLJitMixin): def setup_class(cls): py.test.skip("old") ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fixes
Author: Maciej Fijalkowski Branch: Changeset: r49943:831d8e975963 Date: 2011-11-29 10:33 +0200 http://bitbucket.org/pypy/pypy/changeset/831d8e975963/ Log:fixes diff --git a/pypy/module/micronumpy/compile.py b/pypy/module/micronumpy/compile.py --- a/pypy/module/micronumpy/compile.py +++ b/pypy/module/micronumpy/compile.py @@ -69,8 +69,12 @@ if start < 0: start += size if stop < 0: -stop += size -return (start, stop, step, (stop - start)//step + 1) +stop += size + 1 +if step < 0: +lgt = (stop - start + 1) / step + 1 +else: +lgt = (stop - start - 1) / step + 1 +return (start, stop, step, lgt) @specialize.argtype(1) def wrap(self, obj): diff --git a/pypy/module/micronumpy/test/test_compile.py b/pypy/module/micronumpy/test/test_compile.py --- a/pypy/module/micronumpy/test/test_compile.py +++ b/pypy/module/micronumpy/test/test_compile.py @@ -221,3 +221,14 @@ b -> 3 """) assert interp.results[0].value.val == 6 + +def test_set_slice2(self): +interp = self.run(""" +a = |30| +b = |10| +b[1] = 5.5 +c = b + b +a[0:30:3] = c +a -> 3 +""") +assert interp.results[0].value.val == 11 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Test and check that we don't do stupid copies - it's not only inefficient, it's
Author: Maciej Fijalkowski Branch: Changeset: r49944:6fabd9a00be8 Date: 2011-11-29 10:39 +0200 http://bitbucket.org/pypy/pypy/changeset/6fabd9a00be8/ Log:Test and check that we don't do stupid copies - it's not only inefficient, it's also wrong diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -726,13 +726,7 @@ item = concrete._index_of_single_item(space, w_idx) concrete.setitem_w(space, item, w_value) return -if isinstance(w_value, BaseArray): -# for now we just copy if setting part of an array from part of -# itself. can be improved. -if (concrete.get_root_storage() == -w_value.get_concrete().get_root_storage()): -w_value = w_value.descr_copy(space) -else: +if not isinstance(w_value, BaseArray): w_value = convert_to_array(space, w_value) chunks = self._prepare_slice_args(space, w_idx) view = self.create_slice(space, chunks) diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py --- a/pypy/module/micronumpy/test/test_numarray.py +++ b/pypy/module/micronumpy/test/test_numarray.py @@ -750,6 +750,12 @@ assert bool(array([1])) assert not bool(array([0])) +def test_slice_assignment(self): +from numpypy import arange +a = arange(5) +a[::-1] = a +assert (a == [0, 1, 2, 1, 0]).all() + class AppTestMultiDim(BaseNumpyAppTest): def test_init(self): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix the test
Author: Maciej Fijalkowski Branch: Changeset: r49945:0f011382b9bc Date: 2011-11-29 10:43 +0200 http://bitbucket.org/pypy/pypy/changeset/0f011382b9bc/ Log:fix the test diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -718,8 +718,8 @@ def descr_setitem(self, space, w_idx, w_value): self.invalidated() -concrete = self.get_concrete() if self._single_item_result(space, w_idx): +concrete = self.get_concrete() if len(concrete.shape) < 1: raise OperationError(space.w_IndexError, space.wrap( "0-d arrays can't be indexed")) 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 @@ -328,10 +328,10 @@ def test_setslice(self): result = self.run("setslice") assert result == 11.0 -py.test.skip("generates 2 loops ATM, investigate") +self.check_loop_count(1) self.check_simple_loop({'getarrayitem_raw': 2, 'float_add' : 1, -'setarrayitem_raw': 1, 'int_add': 2, -'int_lt': 1, 'guard_true': 1, 'jump': 1}) +'setarrayitem_raw': 1, 'int_add': 3, +'int_eq': 1, 'guard_false': 1, 'jump': 1}) class TestNumpyOld(LLJitMixin): def setup_class(cls): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ppc-jit-backend: Added a few methods which will be needed later on
Author: hager Branch: ppc-jit-backend Changeset: r49946:30281c041368 Date: 2011-11-24 15:38 +0100 http://bitbucket.org/pypy/pypy/changeset/30281c041368/ Log:Added a few methods which will be needed later on diff --git a/pypy/jit/backend/ppc/ppcgen/regalloc.py b/pypy/jit/backend/ppc/ppcgen/regalloc.py --- a/pypy/jit/backend/ppc/ppcgen/regalloc.py +++ b/pypy/jit/backend/ppc/ppcgen/regalloc.py @@ -201,6 +201,12 @@ def next_instruction(self): self.rm.next_instruction() +def force_spill_var(self, var): +if var.type == FLOAT: +assert 0, "not implemented yet" +else: +self.rm.force_spill_var(var) + def before_call(self, force_store=[], save_all_regs=False): self.rm.before_call(force_store, save_all_regs) @@ -721,6 +727,24 @@ prepare_debug_merge_point = void prepare_jit_debug = void +def prepare_force_token(self, op): +res_loc = self.force_allocate_reg(op.result) +self.possibly_free_var(op.result) +return [res_loc] + +def prepare_guard_call_may_force(self, op, guard_op): +faildescr = guard_op.getdescr() +fail_index = self.cpu.get_fail_descr_number(faildescr) +self.assembler._write_fail_index(fail_index) +args = [imm(rffi.cast(lltype.Signed, op.getarg(0).getint()))] +for v in guard_op.getfailargs(): +if v in self.rm.reg_bindings: +self.force_spill_var(v) +self.assembler.emit_call(op, args, self, fail_index) +locs = self._prepare_guard(guard_op) +self.possibly_free_vars(guard_op.getfailargs()) +return locs + def prepare_guard_call_assembler(self, op, guard_op): descr = op.getdescr() assert isinstance(descr, LoopToken) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ppc-jit-backend: merge
Author: hager Branch: ppc-jit-backend Changeset: r49947:1676cac93ae4 Date: 2011-11-29 10:35 +0100 http://bitbucket.org/pypy/pypy/changeset/1676cac93ae4/ Log:merge diff --git a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py --- a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py +++ b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py @@ -34,6 +34,7 @@ from pypy.jit.backend.x86.support import values_array from pypy.rlib import rgc from pypy.rpython.annlowlevel import llhelper +from pypy.rlib.objectmodel import we_are_translated memcpy_fn = rffi.llexternal('memcpy', [llmemory.Address, llmemory.Address, rffi.SIZE_T], lltype.Void, @@ -187,6 +188,7 @@ self.mc.stdu(r.SP.value, r.SP.value, -frame_depth) self.mc.mflr(r.r0.value) self.mc.std(r.r0.value, r.SP.value, frame_depth + 2 * WORD) +self.mc.std(r.SPP.value, r.SP.value, WORD) # compute spilling pointer (SPP) self.mc.addi(r.SPP.value, r.SP.value, frame_depth @@ -266,13 +268,12 @@ stack_location = decode32(enc, i+1) i += 4 if group == self.FLOAT_TYPE: -value = decode64(stack, frame_depth - stack_location*WORD) -self.fail_boxes_float.setitem(fail_index, value) -continue +assert 0, "not implemented yet" else: -#value = decode32(spilling_area, spilling_area - stack_location * WORD) -#import pdb; pdb.set_trace() -value = decode32(spilling_area, spilling_depth - stack_location * WORD) + if IS_PPC_32: +value = decode32(spilling_area, spilling_depth - stack_location * WORD) + else: +value = decode64(spilling_area, spilling_depth - stack_location * WORD) else: # REG_LOC reg = ord(enc[i]) if group == self.FLOAT_TYPE: @@ -597,7 +598,7 @@ self._make_prologue(regalloc_head, frame_depth) direct_bootstrap_code = self.mc.currpos() -self.gen_direct_bootstrap_code(loophead, looptoken, inputargs, frame_depth) +#self.gen_direct_bootstrap_code(loophead, looptoken, inputargs, frame_depth) self.write_pending_failure_recoveries() loop_start = self.materialize_loop(looptoken, False) @@ -615,6 +616,11 @@ else: looptoken.ppc_code = self.gen_64_bit_func_descr(real_start) self.process_pending_guards(loop_start) +if not we_are_translated(): +print 'Loop', inputargs, operations +self.mc._dump_trace(loop_start, 'loop_%s.asm' % self.cpu.total_compiled_loops) +print 'Done assembling loop with token %r' % looptoken + self._teardown() def assemble_bridge(self, faildescr, inputargs, operations, looptoken, log): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ppc-jit-backend: merge
Author: hager Branch: ppc-jit-backend Changeset: r49948:5e00ef86a581 Date: 2011-11-29 10:45 +0100 http://bitbucket.org/pypy/pypy/changeset/5e00ef86a581/ Log:merge diff --git a/pypy/jit/backend/ppc/ppcgen/opassembler.py b/pypy/jit/backend/ppc/ppcgen/opassembler.py --- a/pypy/jit/backend/ppc/ppcgen/opassembler.py +++ b/pypy/jit/backend/ppc/ppcgen/opassembler.py @@ -295,8 +295,7 @@ descr = op.getdescr() assert isinstance(descr, LoopToken) if descr._ppc_bootstrap_code == 0: -curpos = self.mc.get_rel_pos() -self.mc.b(descr._ppc_loop_code - curpos) +self.mc.b_offset(descr._ppc_loop_code) else: target = descr._ppc_bootstrap_code + descr._ppc_loop_code self.mc.b_abs(target) diff --git a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py --- a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py +++ b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py @@ -270,10 +270,7 @@ if group == self.FLOAT_TYPE: assert 0, "not implemented yet" else: - if IS_PPC_32: -value = decode32(spilling_area, spilling_depth - stack_location * WORD) - else: -value = decode64(spilling_area, spilling_depth - stack_location * WORD) +value = decode32(spilling_area, spilling_depth - stack_location * WORD) else: # REG_LOC reg = ord(enc[i]) if group == self.FLOAT_TYPE: @@ -281,10 +278,12 @@ self.fail_boxes_float.setitem(fail_index, value) continue else: +# XXX dirty, fix +sub = r.managed_regs_sub(reg) if IS_PPC_32: -value = decode32(regs, (reg - 3) * WORD) +value = decode32(regs, (reg - sub) * WORD) else: -value = decode64(regs, (reg - 3) * WORD) +value = decode64(regs, (reg - sub) * WORD) if group == self.INT_TYPE: self.fail_boxes_int.setitem(fail_index, value) @@ -325,8 +324,10 @@ loc = regalloc.frame_manager.frame_pos(stack_loc, INT) j += 4 else: # REG_LOC -#loc = r.all_regs[ord(res)] -loc = r.MANAGED_REGS[ord(res) - 3] +reg = ord(res) +# XXX dirty, fix +sub = r.managed_regs_sub(reg) +loc = r.MANAGED_REGS[reg - sub] j += 1 locs.append(loc) return locs diff --git a/pypy/jit/backend/ppc/ppcgen/register.py b/pypy/jit/backend/ppc/ppcgen/register.py --- a/pypy/jit/backend/ppc/ppcgen/register.py +++ b/pypy/jit/backend/ppc/ppcgen/register.py @@ -16,8 +16,14 @@ RES = r3 MANAGED_REGS = [r3, r4, r5, r6, r7, r8, r9, r10, -r11, r12, r13, r14, r15, r16, r17, r18, +r11, r12, r14, r15, r16, r17, r18, r19, r20, r21, r22, r23, r24, r25, r26, r27, r28, r29, r30] PARAM_REGS = [r3, r4, r5, r6, r7, r8, r9, r10] + +# XXX fix this at some point +def managed_regs_sub(reg): +if reg > r13.value: +return 4 +return 3 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy disable_merge_different_int_types: add missing import
Author: David Schneider Branch: disable_merge_different_int_types Changeset: r49949:f012fa9edd70 Date: 2011-11-29 10:08 +0100 http://bitbucket.org/pypy/pypy/changeset/f012fa9edd70/ Log:add missing import diff --git a/pypy/jit/metainterp/optimizeopt/fficall.py b/pypy/jit/metainterp/optimizeopt/fficall.py --- a/pypy/jit/metainterp/optimizeopt/fficall.py +++ b/pypy/jit/metainterp/optimizeopt/fficall.py @@ -7,7 +7,7 @@ from pypy.rlib.libffi import Func from pypy.rlib.objectmodel import we_are_translated from pypy.rpython.annlowlevel import cast_base_ptr_to_instance -from pypy.rpython.lltypesystem import llmemory +from pypy.rpython.lltypesystem import llmemory, rffi class FuncInfo(object): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy disable_merge_different_int_types: (arigo, bivab): add some u's and shuffle operations around
Author: David Schneider Branch: disable_merge_different_int_types Changeset: r49950:f3f7ebd8ca8a Date: 2011-11-29 12:35 +0100 http://bitbucket.org/pypy/pypy/changeset/f3f7ebd8ca8a/ Log:(arigo, bivab): add some u's and shuffle operations around diff --git a/pypy/jit/codewriter/jtransform.py b/pypy/jit/codewriter/jtransform.py --- a/pypy/jit/codewriter/jtransform.py +++ b/pypy/jit/codewriter/jtransform.py @@ -1053,35 +1053,20 @@ # jit.codewriter.support. for _op, _oopspec in [('llong_invert', 'INVERT'), - ('ullong_invert', 'INVERT'), ('llong_lt', 'LT'), ('llong_le', 'LE'), ('llong_eq', 'EQ'), ('llong_ne', 'NE'), ('llong_gt', 'GT'), ('llong_ge', 'GE'), - ('ullong_lt', 'ULT'), - ('ullong_le', 'ULE'), - ('ullong_eq', 'EQ'), - ('ullong_ne', 'NE'), - ('ullong_gt', 'UGT'), - ('ullong_ge', 'UGE'), ('llong_add', 'ADD'), ('llong_sub', 'SUB'), ('llong_mul', 'MUL'), ('llong_and', 'AND'), ('llong_or', 'OR'), ('llong_xor', 'XOR'), - ('ullong_add','ADD'), - ('ullong_sub','SUB'), - ('ullong_mul','MUL'), - ('ullong_and','AND'), - ('ullong_or', 'OR'), - ('ullong_xor','XOR'), ('llong_lshift', 'LSHIFT'), ('llong_rshift', 'RSHIFT'), - ('ullong_lshift', 'LSHIFT'), - ('ullong_rshift', 'URSHIFT'), ('cast_int_to_longlong', 'FROM_INT'), ('truncate_longlong_to_int', 'TO_INT'), ('cast_float_to_longlong', 'FROM_FLOAT'), @@ -1104,6 +1089,21 @@ ('cast_uint_to_ulonglong','FROM_UINT'), ('cast_float_to_ulonglong', 'FROM_FLOAT'), ('cast_ulonglong_to_float', 'U_TO_FLOAT'), + ('ullong_invert', 'INVERT'), + ('ullong_lt', 'ULT'), + ('ullong_le', 'ULE'), + ('ullong_eq', 'EQ'), + ('ullong_ne', 'NE'), + ('ullong_gt', 'UGT'), + ('ullong_ge', 'UGE'), + ('ullong_add','ADD'), + ('ullong_sub','SUB'), + ('ullong_mul','MUL'), + ('ullong_and','AND'), + ('ullong_or', 'OR'), + ('ullong_xor','XOR'), + ('ullong_lshift', 'LSHIFT'), + ('ullong_rshift', 'URSHIFT'), ]: exec py.code.Source(''' def rewrite_op_%s(self, op): diff --git a/pypy/jit/codewriter/support.py b/pypy/jit/codewriter/support.py --- a/pypy/jit/codewriter/support.py +++ b/pypy/jit/codewriter/support.py @@ -258,6 +258,9 @@ y = ~r_ulonglong(xll) return u_to_longlong(y) +def _ll_1_ullong_invert(xull): +return ~xull + def _ll_2_llong_lt(xll, yll): return xll < yll @@ -276,16 +279,22 @@ def _ll_2_llong_ge(xll, yll): return xll >= yll -def _ll_2_llong_ult(xull, yull): +def _ll_2_ullong_eq(xull, yull): +return xull == yull + +def _ll_2_ullong_ne(xull, yull): +return xull != yull + +def _ll_2_ullong_ult(xull, yull): return xull < yull -def _ll_2_llong_ule(xull, yull): +def _ll_2_ullong_ule(xull, yull): return xull <= yull -def _ll_2_llong_ugt(xull, yull): +def _ll_2_ullong_ugt(xull, yull): return xull > yull -def _ll_2_llong_uge(xull, yull): +def _ll_2_ullong_uge(xull, yull): return xull >= yull def _ll_2_llong_add(xll, yll): @@ -312,14 +321,41 @@ z = r_ulonglong(xll) ^ r_ulonglong(yll) return u_to_longlong(z) +def _ll_2_ullong_add(xull, yull): +z = (xull) + (yull) +return (z) + +def _ll_2_ullong_sub(xull, yull): +z = (xull) - (yull) +return (z) + +def _ll_2_ullong_mul(xull, yull): +z = (xull) * (yull) +return (z) + +def _ll_2_ullong_and(xull, yull): +z = (xull) & (yull) +return (z) + +def _ll_2_ullong_or(xull, yull): +z = (xull) | (yull) +return (z) + +def _ll_2_ullong_xor(xull, yull): +z = (xull) ^ (yull) +return (z) + def _ll_2_llong_lshift(xll, y): z = r_ulonglong(xll) <<
[pypy-commit] pypy default: kill unused nonsensical function
Author: Maciej Fijalkowski Branch: Changeset: r49951:f54bf973f305 Date: 2011-11-29 13:54 +0200 http://bitbucket.org/pypy/pypy/changeset/f54bf973f305/ Log:kill unused nonsensical function diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -1072,9 +1072,6 @@ for sh in shape: self.size *= sh -def get_root_storage(self): -return self.parent.get_concrete().get_root_storage() - def find_size(self): return self.size @@ -1127,9 +1124,6 @@ def get_concrete(self): return self -def get_root_storage(self): -return self.storage - def find_size(self): return self.size ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: (arigo, bivab): do not require gcc 4.0 as a default on the mac anymore
Author: David Schneider Branch: Changeset: r49952:e68a7b79ae93 Date: 2011-11-29 12:57 +0100 http://bitbucket.org/pypy/pypy/changeset/e68a7b79ae93/ Log:(arigo, bivab): do not require gcc 4.0 as a default on the mac anymore diff --git a/pypy/translator/platform/darwin.py b/pypy/translator/platform/darwin.py --- a/pypy/translator/platform/darwin.py +++ b/pypy/translator/platform/darwin.py @@ -12,17 +12,10 @@ so_ext = 'dylib' -# NOTE: GCC 4.2 will fail at runtime due to subtle issues, possibly -# related to GC roots. Using LLVM-GCC or Clang will break the build. -default_cc = 'gcc-4.0' - -def __init__(self, cc=None): -if cc is None: -try: -cc = os.environ['CC'] -except KeyError: -cc = self.default_cc -self.cc = cc +# NOTE: With asmgcc GCC 4.2 will fail at runtime due to subtle issues, +# possibly related to GC roots. Using LLVM-GCC or Clang will break the +# build. On Darwin asmgcc is not the default anymore, so it is fine to use +# whatever gcc we find on the system def _args_for_shared(self, args): return (list(self.shared_only) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy disable_merge_different_int_types: (arigo, bivab): fix an overfix in setobject
Author: David Schneider Branch: disable_merge_different_int_types Changeset: r49953:8eaa554846b5 Date: 2011-11-29 12:49 +0100 http://bitbucket.org/pypy/pypy/changeset/8eaa554846b5/ Log:(arigo, bivab): fix an overfix in setobject diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py --- a/pypy/objspace/std/setobject.py +++ b/pypy/objspace/std/setobject.py @@ -462,7 +462,8 @@ hash = hash * 69069 + 907133923 if hash == 0: hash = 590923713 -w_set.hash = intmask(hash) +hash = intmask(hash) +w_set.hash = hash return space.wrap(hash) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy disable_merge_different_int_types: merge default
Author: David Schneider Branch: disable_merge_different_int_types Changeset: r49954:89efc1956c94 Date: 2011-11-29 12:50 +0100 http://bitbucket.org/pypy/pypy/changeset/89efc1956c94/ Log:merge default diff --git a/pypy/jit/backend/llsupport/gc.py b/pypy/jit/backend/llsupport/gc.py --- a/pypy/jit/backend/llsupport/gc.py +++ b/pypy/jit/backend/llsupport/gc.py @@ -648,14 +648,10 @@ # make a malloc function, with two arguments def malloc_basic(size, tid): type_id = llop.extract_ushort(llgroup.HALFWORD, tid) -has_finalizer = bool(tid & (1< 0: +if v2 & 1: +res *= v1 +v2 >>= 1 +if v2 == 0: +break +v1 *= v1 +return res + class SignedIntegerArithmeticDtype(IntegerArithmeticDtype): _mixin_ = True diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -102,11 +102,12 @@ w_order=NoneNotWrapped): # find scalar if not space.issequence_w(w_item_or_iterable): -w_dtype = interp_ufuncs.find_dtype_for_scalar(space, - w_item_or_iterable, - w_dtype) +if space.is_w(w_dtype, space.w_None): +w_dtype = interp_ufuncs.find_dtype_for_scalar(space, + w_item_or_iterable) dtype = space.interp_w(interp_dtype.W_Dtype, - space.call_function(space.gettypefor(interp_dtype.W_Dtype), w_dtype)) +space.call_function(space.gettypefor(interp_dtype.W_Dtype), w_dtype) +) return scalar_w(space, dtype, w_item_or_iterable) if w_order is None: order = 'C' @@ -179,10 +180,10 @@ return self.offset class OneDimIterator(BaseIterator): -def __init__(self, start, step, size): +def __init__(self, start, step, stop): self.offset = start self.step = step -self.size = size +self.size = stop * step + start def next(self, shapelen): arr = instantiate(OneDimIterator) @@ -192,7 +193,7 @@ return arr def done(self): -return self.offset >= self.size +return self.offset == self.size def get_offset(self): return self.offset @@ -717,21 +718,15 @@ def descr_setitem(self, space, w_idx, w_value): self.invalidated() -concrete = self.get_concrete() if self._single_item_result(space, w_idx): +concrete = self.get_concrete() if len(concrete.shape) < 1: raise OperationError(space.w_IndexError, space.wrap( "0-d arrays can't be indexed")) item = concrete._index_of_single_item(space, w_idx) concrete.setitem_w(space, item, w_value) return -if isinstance(w_value, BaseArray): -# for now we just copy if setting part of an array from part of -# itself. can be improved. -if (concrete.get_root_storage() == -w_value.get_concrete().get_root_storage()): -w_value = w_value.descr_copy(space) -else: +if not isinstance(w_value, BaseArray): w_value = convert_to_array(space, w_value) chunks = self._prepare_slice_args(space, w_idx) view = self.create_slice(space, chunks) @@ -968,9 +963,9 @@ call_sig = sig.components[0] assert isinstance(call_sig, signature.Call1) if self.forced_result is not None: -return 'Call1(%s, forced=%s)' % (call_sig.func.func_name, +return 'Call1(%s, forced=%s)' % (call_sig.name, self.forced_result.debug_repr()) -return 'Call1(%s, %s)' % (call_sig.func.func_name, +return 'Call1(%s, %s)' % (call_sig.name, self.values.debug_repr()) class Call2(VirtualArray): @@ -1018,9 +1013,9 @@ call_sig = sig.components[0] assert isinstance(call_sig, signature.Call2) if self.forced_result is not None: -return 'Call2(%s, forced=%s)' % (call_sig.func.func_name, +return 'Call2(%s, forced=%s)' % (call_sig.name, self.forced_result.debug_repr()) -return 'Call2(%s, %s, %s)' % (call_sig.func.func_name, +return 'Call2(%s, %s, %s)' % (call_sig.name, self.left.debug_repr(), self.right.debug_repr()) @@ -1108,8 +1103,8 @@ def start_iter(self, res_shape=None): if res_shape is not None and res_shape != self.shape: return BroadcastIterator(self, res_shape) -# XXX there is a possible optimization here with SingleDimViewIterator -# ignore for now +if len(self.shape
[pypy-commit] pypy disable_merge_different_int_types: merge default
Author: David Schneider Branch: disable_merge_different_int_types Changeset: r49955:5cb23d0a9a6f Date: 2011-11-29 12:59 +0100 http://bitbucket.org/pypy/pypy/changeset/5cb23d0a9a6f/ Log:merge default diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -1072,9 +1072,6 @@ for sh in shape: self.size *= sh -def get_root_storage(self): -return self.parent.get_concrete().get_root_storage() - def find_size(self): return self.size @@ -1127,9 +1124,6 @@ def get_concrete(self): return self -def get_root_storage(self): -return self.storage - def find_size(self): return self.size diff --git a/pypy/translator/platform/darwin.py b/pypy/translator/platform/darwin.py --- a/pypy/translator/platform/darwin.py +++ b/pypy/translator/platform/darwin.py @@ -12,17 +12,10 @@ so_ext = 'dylib' -# NOTE: GCC 4.2 will fail at runtime due to subtle issues, possibly -# related to GC roots. Using LLVM-GCC or Clang will break the build. -default_cc = 'gcc-4.0' - -def __init__(self, cc=None): -if cc is None: -try: -cc = os.environ['CC'] -except KeyError: -cc = self.default_cc -self.cc = cc +# NOTE: With asmgcc GCC 4.2 will fail at runtime due to subtle issues, +# possibly related to GC roots. Using LLVM-GCC or Clang will break the +# build. On Darwin asmgcc is not the default anymore, so it is fine to use +# whatever gcc we find on the system def _args_for_shared(self, args): return (list(self.shared_only) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merge
Author: Maciej Fijalkowski Branch: Changeset: r49957:ec72fff50853 Date: 2011-11-29 14:41 +0200 http://bitbucket.org/pypy/pypy/changeset/ec72fff50853/ Log:merge diff --git a/pypy/translator/platform/darwin.py b/pypy/translator/platform/darwin.py --- a/pypy/translator/platform/darwin.py +++ b/pypy/translator/platform/darwin.py @@ -12,17 +12,10 @@ so_ext = 'dylib' -# NOTE: GCC 4.2 will fail at runtime due to subtle issues, possibly -# related to GC roots. Using LLVM-GCC or Clang will break the build. -default_cc = 'gcc-4.0' - -def __init__(self, cc=None): -if cc is None: -try: -cc = os.environ['CC'] -except KeyError: -cc = self.default_cc -self.cc = cc +# NOTE: With asmgcc GCC 4.2 will fail at runtime due to subtle issues, +# possibly related to GC roots. Using LLVM-GCC or Clang will break the +# build. On Darwin asmgcc is not the default anymore, so it is fine to use +# whatever gcc we find on the system def _args_for_shared(self, args): return (list(self.shared_only) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Make tests reflect the reality. It actually works, but a bit by chance
Author: Maciej Fijalkowski Branch: Changeset: r49956:2158b5ddab51 Date: 2011-11-29 14:34 +0200 http://bitbucket.org/pypy/pypy/changeset/2158b5ddab51/ Log:Make tests reflect the reality. It actually works, but a bit by chance diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py --- a/pypy/module/micronumpy/test/test_numarray.py +++ b/pypy/module/micronumpy/test/test_numarray.py @@ -263,7 +263,7 @@ assert a[1] == 0. assert a[3] == 1. b[::-1] = b -assert b[0] == 1. +assert b[0] == 0. assert b[1] == 0. def test_setslice_of_slice_array(self): @@ -751,11 +751,14 @@ assert not bool(array([0])) def test_slice_assignment(self): -from numpypy import arange -a = arange(5) +from numpypy import array +a = array(range(5)) a[::-1] = a assert (a == [0, 1, 2, 1, 0]).all() - +# but we force intermediates +a = array(range(5)) +a[::-1] = a + a +assert (a == [8, 6, 4, 2, 0]).all() class AppTestMultiDim(BaseNumpyAppTest): def test_init(self): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy op_malloc_gc: Refactoring, in-progress.
Author: Armin Rigo Branch: op_malloc_gc Changeset: r49958:2d92b6d542ce Date: 2011-11-29 09:31 +0100 http://bitbucket.org/pypy/pypy/changeset/2d92b6d542ce/ Log:Refactoring, in-progress. diff --git a/pypy/jit/backend/llsupport/gc.py b/pypy/jit/backend/llsupport/gc.py --- a/pypy/jit/backend/llsupport/gc.py +++ b/pypy/jit/backend/llsupport/gc.py @@ -25,10 +25,6 @@ # class GcLLDescription(GcCache): -minimal_size_in_nursery = 0 -get_malloc_slowpath_addr = None - -TIDFLAG_HAS_FINALIZER = 0 def __init__(self, gcdescr, translator=None, rtyper=None): GcCache.__init__(self, translator is not None, rtyper) @@ -45,9 +41,6 @@ self.field_strlen_descr = get_field_arraylen_descr(self, rstr.STR) self.field_unicodelen_descr = get_field_arraylen_descr(self, rstr.UNICODE) -self.fielddescr_tid = None # unless overridden -self.str_type_id = llop.combine_ushort(lltype.Signed, 0, 0) -self.unicode_type_id = llop.combine_ushort(lltype.Signed, 0, 0) def _freeze_(self): return True @@ -62,12 +55,53 @@ def freeing_block(self, start, stop): pass -def get_funcptr_for_newarray(self): -return llhelper(self.GC_MALLOC_ARRAY, self.malloc_array) -def get_funcptr_for_newstr(self): -return llhelper(self.GC_MALLOC_STR_UNICODE, self.malloc_str) -def get_funcptr_for_newunicode(self): -return llhelper(self.GC_MALLOC_STR_UNICODE, self.malloc_unicode) +def get_funcptr_for_malloc_gc_fixed(self): +"""Returns a function pointer to a function that implements +the simple case of MALLOC_GC: the case where the variable size +is zero. The function pointer has signature (size) -> GCREF.""" +raise NotImplementedError + +def get_funcptr_for_malloc_gc_variable(self): +"""Returns a function pointer to a function that implements +the complex case of MALLOC_GC: the case where the variable size +is not known to be zero. The signature is: +(base_size, num_elem, item_size) -> GCREF""" +raise NotImplementedError + +def gc_malloc(self, sizedescr): +"""Blackhole: do a 'bh_new'. Also used for 'bh_new_with_vtable', +with the vtable pointer set manually afterwards.""" +assert isinstance(sizedescr, BaseSizeDescr) +res = self.get_funcptr_for_malloc_gc_fixed()(sizedescr.size) +if res: +pass # XXX tid +return res + +def gc_malloc_array(self, arraydescr, num_elem): +assert isinstance(arraydescr, BaseArrayDescr) +ofs_length = arraydescr.get_ofs_length(self.translate_support_code) +basesize = arraydescr.get_base_size(self.translate_support_code) +itemsize = arraydescr.get_item_size(self.translate_support_code) +return self._gc_malloc_array(basesize, num_elem, itemsize, ofs_length) + +def _gc_malloc_array(self, basesize, num_elem, itemsize, ofs_length): +mallocptr = self.get_funcptr_for_malloc_gc_variable() +res = mallocptr(basesize, num_elem, itemsize) +if res: +# XXX tid +arrayptr = rffi.cast(rffi.CArrayPtr(lltype.Signed), res) +arrayptr[ofs_length/WORD] = num_elem +return res + +def gc_malloc_str(self, num_elem): +return self._gc_malloc_array(self.str_basesize, num_elem, + self.str_itemsize, + self.str_ofs_length) + +def gc_malloc_unicode(self, num_elem): +return self._gc_malloc_array(self.unicode_basesize, num_elem, + self.unicode_itemsize, + self.unicode_ofs_length) def _record_constptrs(self, op, gcrefs_output_list): for i in range(op.numargs()): @@ -89,9 +123,13 @@ # class GcLLDescr_boehm(GcLLDescription): -moving_gc = False -gcrootmap = None -write_barrier_descr = None +moving_gc = False +gcrootmap = None +write_barrier_descr = None +fielddescr_tid= None +TIDFLAG_HAS_FINALIZER = 0 +str_type_id = 0 +unicode_type_id = 0 @classmethod def configure_boehm_once(cls): @@ -102,6 +140,16 @@ from pypy.rpython.tool import rffi_platform compilation_info = rffi_platform.configure_boehm() +# on some platform GC_init is required before any other +# GC_* functions, call it here for the benefit of tests +# XXX move this to tests +init_fn_ptr = rffi.llexternal("GC_init", + [], lltype.Void, + compilation_info=compilation_info, + sandboxsafe=True, +
[pypy-commit] pypy disable_merge_different_int_types: (bivab, arigo) Bah, undo this, which was too much.
Author: Armin Rigo Branch: disable_merge_different_int_types Changeset: r49960:82c99d032cfc Date: 2011-11-29 14:23 +0100 http://bitbucket.org/pypy/pypy/changeset/82c99d032cfc/ Log:(bivab, arigo) Bah, undo this, which was too much. diff --git a/pypy/jit/codewriter/support.py b/pypy/jit/codewriter/support.py --- a/pypy/jit/codewriter/support.py +++ b/pypy/jit/codewriter/support.py @@ -347,7 +347,7 @@ def _ll_2_llong_lshift(xll, y): z = r_ulonglong(xll) << y -return (z) +return u_to_longlong(z) def _ll_2_ullong_lshift(xull, y): return xull << y ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy disable_merge_different_int_types: (bivab, arigo) Fix.
Author: Armin Rigo Branch: disable_merge_different_int_types Changeset: r49961:2d877298ba62 Date: 2011-11-29 14:33 +0100 http://bitbucket.org/pypy/pypy/changeset/2d877298ba62/ Log:(bivab, arigo) Fix. diff --git a/pypy/jit/codewriter/jtransform.py b/pypy/jit/codewriter/jtransform.py --- a/pypy/jit/codewriter/jtransform.py +++ b/pypy/jit/codewriter/jtransform.py @@ -1134,7 +1134,7 @@ def rewrite_op_llong_is_true(self, op): v = varoftype(op.args[0].concretetype) -op0 = SpaceOperation('cast_int_to_longlong', +op0 = SpaceOperation('cast_primitive', [Constant(0, lltype.Signed)], v) args = [op.args[0], v] ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy op_malloc_gc: Refactor more. Test_rewrite passes.
Author: Armin Rigo Branch: op_malloc_gc Changeset: r49959:911d0419ed7f Date: 2011-11-29 09:50 +0100 http://bitbucket.org/pypy/pypy/changeset/911d0419ed7f/ Log:Refactor more. Test_rewrite passes. diff --git a/pypy/jit/backend/llsupport/gc.py b/pypy/jit/backend/llsupport/gc.py --- a/pypy/jit/backend/llsupport/gc.py +++ b/pypy/jit/backend/llsupport/gc.py @@ -127,7 +127,6 @@ gcrootmap = None write_barrier_descr = None fielddescr_tid= None -TIDFLAG_HAS_FINALIZER = 0 str_type_id = 0 unicode_type_id = 0 @@ -606,24 +605,40 @@ class GcLLDescr_framework(GcLLDescription): DEBUG = False# forced to True by x86/test/test_zrpy_gc.py -TIDFLAG_HAS_FINALIZER = 1 << llgroup.HALFSHIFT -TIDFLAG_HAS_LIGHT_FINALIZER = 1 << (llgroup.HALFSHIFT+1) - -def __init__(self, gcdescr, translator, rtyper, llop1=llop): +def __init__(self, gcdescr, translator, rtyper, llop1=llop, + really_not_translated=False): from pypy.rpython.memory.gctypelayout import check_typeid from pypy.rpython.memory.gcheader import GCHeaderBuilder from pypy.rpython.memory.gctransform import framework GcLLDescription.__init__(self, gcdescr, translator, rtyper) -assert self.translate_support_code, "required with the framework GC" self.translator = translator self.llop1 = llop1 +if really_not_translated: +assert not self.translate_support_code # but half does not work +self._initialize_for_tests() +else: +assert self.translate_support_code,"required with the framework GC" +self._check_valid_gc() +self._make_gcrootmap() +self._make_layoutbuilder() +self._setup_gcclass() +def _initialize_for_tests(self): +self.layoutbuilder = None +self.str_type_id = 10083# random, for tests only +self.unicode_type_id = 10085 +self.fielddescr_tid = AbstractDescr() +self.max_size_of_young_obj = 1000 +self.write_barrier_descr = None + +def _check_valid_gc(self): # we need the hybrid or minimark GC for rgc._make_sure_does_not_move() # to work -if gcdescr.config.translation.gc not in ('hybrid', 'minimark'): +if self.gcdescr.config.translation.gc not in ('hybrid', 'minimark'): raise NotImplementedError("--gc=%s not implemented with the JIT" % (gcdescr.config.translation.gc,)) +def _make_gcrootmap(self): # to find roots in the assembler, make a GcRootMap name = gcdescr.config.translation.gcrootfinder try: @@ -634,6 +649,7 @@ gcrootmap = cls(gcdescr) self.gcrootmap = gcrootmap +def _make_layoutbuilder(self): # make a TransformerLayoutBuilder and save it on the translator # where it can be fished and reused by the FrameworkGCTransformer self.layoutbuilder = framework.TransformerLayoutBuilder(translator) @@ -641,6 +657,7 @@ self.translator._jit2gc = {'layoutbuilder': self.layoutbuilder} gcrootmap.add_jit2gc_hooks(self.translator._jit2gc) +def _setup_gcclass(self): self.GCClass = self.layoutbuilder.GCClass self.moving_gc = self.GCClass.moving_gc self.HDRPTR = lltype.Ptr(self.GCClass.HDR) @@ -657,14 +674,10 @@ # make a malloc function, with two arguments def malloc_basic(size, tid): type_id = llop.extract_ushort(llgroup.HALFWORD, tid) -has_finalizer = bool(tid & self.TIDFLAG_HAS_FINALIZER) -has_light_finalizer = bool(tid & self.TIDFLAG_HAS_LIGHT_FINALIZER) check_typeid(type_id) res = llop1.do_malloc_fixedsize_clear(llmemory.GCREF, type_id, size, - has_finalizer, - has_light_finalizer, - False) + False, False, False) # In case the operation above failed, we are returning NULL # from this function to assembler. There is also an RPython # exception set, typically MemoryError; but it's easier and @@ -757,18 +770,15 @@ self.gcrootmap.initialize() def init_size_descr(self, S, descr): -type_id = self.layoutbuilder.get_type_id(S) -assert not self.layoutbuilder.is_weakref_type(S) -flags = 0 -if self.layoutbuilder.has_finalizer(S): -flags |= self.TIDFLAG_HAS_FINALIZER -if self.layoutbuilder.has_light_finalizer(S): -flags |= self.TIDFLAG_HAS_LIGHT_FINALIZER -descr.tid = llop.combine_ushort(lltype.Signed, type_id, flags) +if self.layoutbuilder is not None: +type_id = self.layou
[pypy-commit] pypy disable_merge_different_int_types: merge default
Author: David Schneider Branch: disable_merge_different_int_types Changeset: r49962:78c6f8cf48ab Date: 2011-11-29 15:08 +0100 http://bitbucket.org/pypy/pypy/changeset/78c6f8cf48ab/ Log:merge default diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py --- a/pypy/module/micronumpy/test/test_numarray.py +++ b/pypy/module/micronumpy/test/test_numarray.py @@ -263,7 +263,7 @@ assert a[1] == 0. assert a[3] == 1. b[::-1] = b -assert b[0] == 1. +assert b[0] == 0. assert b[1] == 0. def test_setslice_of_slice_array(self): @@ -751,11 +751,14 @@ assert not bool(array([0])) def test_slice_assignment(self): -from numpypy import arange -a = arange(5) +from numpypy import array +a = array(range(5)) a[::-1] = a assert (a == [0, 1, 2, 1, 0]).all() - +# but we force intermediates +a = array(range(5)) +a[::-1] = a + a +assert (a == [8, 6, 4, 2, 0]).all() class AppTestMultiDim(BaseNumpyAppTest): def test_init(self): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy disable_merge_different_int_types: (arigo, bivab) close branch
Author: David Schneider Branch: disable_merge_different_int_types Changeset: r49963:8cf681375aab Date: 2011-11-29 15:09 +0100 http://bitbucket.org/pypy/pypy/changeset/8cf681375aab/ Log:(arigo, bivab) close branch ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: (arigo, bivab) merge disable_merge_different_int_types
Author: David Schneider Branch: Changeset: r49964:e7aab5877bf5 Date: 2011-11-29 15:09 +0100 http://bitbucket.org/pypy/pypy/changeset/e7aab5877bf5/ Log:(arigo, bivab) merge disable_merge_different_int_types diff --git a/pypy/annotation/binaryop.py b/pypy/annotation/binaryop.py --- a/pypy/annotation/binaryop.py +++ b/pypy/annotation/binaryop.py @@ -252,7 +252,26 @@ # unsignedness is considered a rare and contagious disease def union((int1, int2)): -knowntype = rarithmetic.compute_restype(int1.knowntype, int2.knowntype) +if int1.unsigned == int2.unsigned: +knowntype = rarithmetic.compute_restype(int1.knowntype, int2.knowntype) +else: +t1 = int1.knowntype +if t1 is bool: +t1 = int +t2 = int2.knowntype +if t2 is bool: +t2 = int + +if t2 is int: +if int2.nonneg == False: +raise UnionError, "Merging %s and a possibly negative int is not allowed" % t1 +knowntype = t1 +elif t1 is int: +if int1.nonneg == False: +raise UnionError, "Merging %s and a possibly negative int is not allowed" % t2 +knowntype = t2 +else: +raise UnionError, "Merging these types (%s, %s) is not supported" % (t1, t2) return SomeInteger(nonneg=int1.nonneg and int2.nonneg, knowntype=knowntype) diff --git a/pypy/annotation/model.py b/pypy/annotation/model.py --- a/pypy/annotation/model.py +++ b/pypy/annotation/model.py @@ -591,13 +591,11 @@ immutable = True def __init__(self, method): self.method = method - -NUMBER = object() + annotation_to_ll_map = [ (SomeSingleFloat(), lltype.SingleFloat), (s_None, lltype.Void), # also matches SomeImpossibleValue() (s_Bool, lltype.Bool), -(SomeInteger(knowntype=r_ulonglong), NUMBER), (SomeFloat(), lltype.Float), (SomeLongFloat(), lltype.LongFloat), (SomeChar(), lltype.Char), @@ -623,10 +621,11 @@ return lltype.Ptr(p.PARENTTYPE) if isinstance(s_val, SomePtr): return s_val.ll_ptrtype +if type(s_val) is SomeInteger: +return lltype.build_number(None, s_val.knowntype) + for witness, T in annotation_to_ll_map: if witness.contains(s_val): -if T is NUMBER: -return lltype.build_number(None, s_val.knowntype) return T if info is None: info = '' @@ -635,7 +634,7 @@ raise ValueError("%sshould return a low-level type,\ngot instead %r" % ( info, s_val)) -ll_to_annotation_map = dict([(ll, ann) for ann, ll in annotation_to_ll_map if ll is not NUMBER]) +ll_to_annotation_map = dict([(ll, ann) for ann, ll in annotation_to_ll_map]) def lltype_to_annotation(T): try: diff --git a/pypy/annotation/test/test_annrpython.py b/pypy/annotation/test/test_annrpython.py --- a/pypy/annotation/test/test_annrpython.py +++ b/pypy/annotation/test/test_annrpython.py @@ -856,6 +856,46 @@ py.test.raises(Exception, a.build_types, f, []) # if you want to get a r_uint, you have to be explicit about it +def test_add_different_ints(self): +def f(a, b): +return a + b +a = self.RPythonAnnotator() +py.test.raises(Exception, a.build_types, f, [r_uint, int]) + +def test_merge_different_ints(self): +def f(a, b): +if a: +c = a +else: +c = b +return c +a = self.RPythonAnnotator() +py.test.raises(Exception, a.build_types, f, [r_uint, int]) + +def test_merge_ruint_zero(self): +def f(a): +if a: +c = a +else: +c = 0 +return c +a = self.RPythonAnnotator() +s = a.build_types(f, [r_uint]) +assert s == annmodel.SomeInteger(nonneg = True, unsigned = True) + +def test_merge_ruint_nonneg_signed(self): +def f(a, b): +if a: +c = a +else: +assert b >= 0 +c = b +return c +a = self.RPythonAnnotator() +s = a.build_types(f, [r_uint, int]) +assert s == annmodel.SomeInteger(nonneg = True, unsigned = True) + + def test_prebuilt_long_that_is_not_too_long(self): small_constant = 12L def f(): @@ -3029,7 +3069,7 @@ if g(x, y): g(x, r_uint(y)) a = self.RPythonAnnotator() -a.build_types(f, [int, int]) +py.test.raises(Exception, a.build_types, f, [int, int]) def test_compare_with_zero(self): def g(): diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py --- a/pypy/interpreter/pyframe.py +++ b/pypy/interpreter/pyframe.py @@ -10,7 +10,7 @@ from pypy.rlib.objectmodel import we_are_tran
[pypy-commit] pypy numpy-dtype-refactor: Merged default in.
Author: Alex Gaynor Branch: numpy-dtype-refactor Changeset: r49965:fef6d4e76590 Date: 2011-11-29 09:29 -0500 http://bitbucket.org/pypy/pypy/changeset/fef6d4e76590/ Log:Merged default in. diff --git a/pypy/annotation/binaryop.py b/pypy/annotation/binaryop.py --- a/pypy/annotation/binaryop.py +++ b/pypy/annotation/binaryop.py @@ -252,7 +252,26 @@ # unsignedness is considered a rare and contagious disease def union((int1, int2)): -knowntype = rarithmetic.compute_restype(int1.knowntype, int2.knowntype) +if int1.unsigned == int2.unsigned: +knowntype = rarithmetic.compute_restype(int1.knowntype, int2.knowntype) +else: +t1 = int1.knowntype +if t1 is bool: +t1 = int +t2 = int2.knowntype +if t2 is bool: +t2 = int + +if t2 is int: +if int2.nonneg == False: +raise UnionError, "Merging %s and a possibly negative int is not allowed" % t1 +knowntype = t1 +elif t1 is int: +if int1.nonneg == False: +raise UnionError, "Merging %s and a possibly negative int is not allowed" % t2 +knowntype = t2 +else: +raise UnionError, "Merging these types (%s, %s) is not supported" % (t1, t2) return SomeInteger(nonneg=int1.nonneg and int2.nonneg, knowntype=knowntype) diff --git a/pypy/annotation/model.py b/pypy/annotation/model.py --- a/pypy/annotation/model.py +++ b/pypy/annotation/model.py @@ -591,13 +591,11 @@ immutable = True def __init__(self, method): self.method = method - -NUMBER = object() + annotation_to_ll_map = [ (SomeSingleFloat(), lltype.SingleFloat), (s_None, lltype.Void), # also matches SomeImpossibleValue() (s_Bool, lltype.Bool), -(SomeInteger(knowntype=r_ulonglong), NUMBER), (SomeFloat(), lltype.Float), (SomeLongFloat(), lltype.LongFloat), (SomeChar(), lltype.Char), @@ -623,10 +621,11 @@ return lltype.Ptr(p.PARENTTYPE) if isinstance(s_val, SomePtr): return s_val.ll_ptrtype +if type(s_val) is SomeInteger: +return lltype.build_number(None, s_val.knowntype) + for witness, T in annotation_to_ll_map: if witness.contains(s_val): -if T is NUMBER: -return lltype.build_number(None, s_val.knowntype) return T if info is None: info = '' @@ -635,7 +634,7 @@ raise ValueError("%sshould return a low-level type,\ngot instead %r" % ( info, s_val)) -ll_to_annotation_map = dict([(ll, ann) for ann, ll in annotation_to_ll_map if ll is not NUMBER]) +ll_to_annotation_map = dict([(ll, ann) for ann, ll in annotation_to_ll_map]) def lltype_to_annotation(T): try: diff --git a/pypy/annotation/test/test_annrpython.py b/pypy/annotation/test/test_annrpython.py --- a/pypy/annotation/test/test_annrpython.py +++ b/pypy/annotation/test/test_annrpython.py @@ -856,6 +856,46 @@ py.test.raises(Exception, a.build_types, f, []) # if you want to get a r_uint, you have to be explicit about it +def test_add_different_ints(self): +def f(a, b): +return a + b +a = self.RPythonAnnotator() +py.test.raises(Exception, a.build_types, f, [r_uint, int]) + +def test_merge_different_ints(self): +def f(a, b): +if a: +c = a +else: +c = b +return c +a = self.RPythonAnnotator() +py.test.raises(Exception, a.build_types, f, [r_uint, int]) + +def test_merge_ruint_zero(self): +def f(a): +if a: +c = a +else: +c = 0 +return c +a = self.RPythonAnnotator() +s = a.build_types(f, [r_uint]) +assert s == annmodel.SomeInteger(nonneg = True, unsigned = True) + +def test_merge_ruint_nonneg_signed(self): +def f(a, b): +if a: +c = a +else: +assert b >= 0 +c = b +return c +a = self.RPythonAnnotator() +s = a.build_types(f, [r_uint, int]) +assert s == annmodel.SomeInteger(nonneg = True, unsigned = True) + + def test_prebuilt_long_that_is_not_too_long(self): small_constant = 12L def f(): @@ -3029,7 +3069,7 @@ if g(x, y): g(x, r_uint(y)) a = self.RPythonAnnotator() -a.build_types(f, [int, int]) +py.test.raises(Exception, a.build_types, f, [int, int]) def test_compare_with_zero(self): def g(): diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py --- a/pypy/interpreter/pyframe.py +++ b/pypy/interpreter/pyframe.py @@ -10,7 +10,7 @@ from pypy.rlib.objectmodel import we_are_translated, instantiate
[pypy-commit] pypy default: issue944 wontfix
Author: Armin Rigo Branch: Changeset: r49966:9f57fcbd3b17 Date: 2011-11-29 15:36 +0100 http://bitbucket.org/pypy/pypy/changeset/9f57fcbd3b17/ Log:issue944 wontfix Document this as an implementation detail. 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 @@ -304,5 +304,14 @@ never a dictionary as it sometimes is in CPython. Assigning to ``__builtins__`` has no effect. +* directly calling the internal magic methods of a few built-in types + with invalid arguments may have a slightly different result. For + example, ``[].__add__(None)`` and ``(2).__add__(None)`` both return + ``NotImplemented`` on PyPy; on CPython, only the later does, and the + former raises ``TypeError``. (Of course, ``[]+None`` and ``2+None`` + both raise ``TypeError`` everywhere.) This difference is an + implementation detail that shows up because of internal C-level slots + that PyPy does not have. + .. include:: _ref.txt ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy generator-in-rpython: A first version of the test.
Author: Armin Rigo Branch: generator-in-rpython Changeset: r49967:026ff0f93709 Date: 2011-11-29 15:58 +0100 http://bitbucket.org/pypy/pypy/changeset/026ff0f93709/ Log:A first version of the test. diff --git a/pypy/translator/test/test_generator.py b/pypy/translator/test/test_generator.py new file mode 100644 --- /dev/null +++ b/pypy/translator/test/test_generator.py @@ -0,0 +1,126 @@ +from pypy.objspace.flow.objspace import FlowObjSpace +from pypy.translator.translator import TranslationContext +from pypy.translator.generator import replace_graph_with_bootstrap + + +# + +def f_gen(n): +i = 0 +while i < n: +yield i +i += 1 + +class GeneratorIterator(object): +def __init__(self, entry): +self.current = entry +def next(self): +e = self.current +self.current = None +if isinstance(e, Yield1): +n = e.n_0 +i = e.i_0 +i += 1 +else: +n = e.n_0 +i = 0 +if i < n: +e = Yield1() +e.n_0 = n +e.i_0 = i +self.current = e +return i +raise StopIteration + +def __iter__(self): +return self + +class AbstractPosition(object): +_immutable_ = True +class Entry1(AbstractPosition): +_immutable_ = True +class Yield1(AbstractPosition): +_immutable_ = True + +def f_explicit(n): +e = Entry1() +e.n_0 = n +return GeneratorIterator(e) + +def test_explicit(): +assert list(f_gen(10)) == list(f_explicit(10)) + +# + + +class TestGenerator: + +def test_replace_graph_with_bootstrap(self): +def func(n, x, y, z): +yield n +yield n +# +space = FlowObjSpace() +graph = space.build_flow(func) +assert graph.startblock.operations[0].opname == 'generator_entry' +replace_graph_with_bootstrap(graph, 'newgraph') +block = graph.startblock +ops = block.operations +assert ops[0].opname == 'call' # e = Entry1() +assert ops[1].opname == 'setattr' # e.n_0 = n +assert ops[1].args[1].value.startswith('n_') +assert ops[2].opname == 'setattr' # e.x_0 = x +assert ops[2].args[1].value.startswith('x_') +assert ops[3].opname == 'setattr' # e.y_0 = y +assert ops[3].args[1].value.startswith('y_') +assert ops[4].opname == 'setattr' # e.z_0 = z +assert ops[4].args[1].value.startswith('z_') +assert ops[5].opname == 'call' # g = Generator(e) +assert ops[5].args[1] == ops[0].result +assert len(ops) == 6 +assert len(block.exits) == 1 +assert block.exits[0].target is graph.returnblock + +def test_make_generator_body_graph(self): +def f(n, x, y, z): +z *= 10 +yield n +z -= 10 +# +def f__next(generator): +n = generator.n_0 +x = generator.x_0 +y = generator.y_0 +z = generator.z_0 +e = generator.current +generator.current = None +if isinstance(e, "some class"): +xxx +# +space = FlowObjSpace() +graph = space.build_flow(func) +newgraph = make_generator_body_graph(graph) +assert len(newgraph.startblock.inputargs) == 1 +[v_generator] = newgraph.startblock.inputargs +ops = newgraph.startblock.operations +assert ops[0].opname == 'getattr' # n = g.n_0 +assert ops[0].args[0] == v_generator +assert ops[0].args[1].value.startswith('n_') +assert ops[1].opname == 'getattr' # x = g.x_0 +assert ops[1].args[0] == v_generator +assert ops[1].args[1].value.startswith('x_') +assert ops[2].opname == 'getattr' # y = g.y_0 +assert ops[2].args[0] == v_generator +assert ops[2].args[1].value.startswith('y_') +assert ops[3].opname == 'getattr' # z = g.z_0 +assert ops[3].args[0] == v_generator +assert ops[3].args[1].value.startswith('z_') +assert ops[4].opname == 'getattr' # e = g.current +assert ops[4].args[0] == v_generator +assert ops[4].args[1].value == 'current' +assert ops[5].opname == 'setattr' # g.current = None +assert ops[5].args[0] == v_generator +assert ops[5].args[1].value == 'current' +assert ops[6].opname == 'call' # isinstance(e, Yield1) +assert ops[6].args[0].value == isinstance +assert len(ops) == 7 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-dtype-refactor: fix translation
Author: Alex Gaynor Branch: numpy-dtype-refactor Changeset: r49968:192b326cb379 Date: 2011-11-29 09:45 -0500 http://bitbucket.org/pypy/pypy/changeset/192b326cb379/ Log:fix translation diff --git a/pypy/module/micronumpy/interp_boxes.py b/pypy/module/micronumpy/interp_boxes.py --- a/pypy/module/micronumpy/interp_boxes.py +++ b/pypy/module/micronumpy/interp_boxes.py @@ -18,7 +18,7 @@ def new(space, w_subtype, w_value): dtype = get_dtype(space) return dtype.itemtype.coerce_subtype(space, w_subtype, w_value) -return new, staticmethod(get_dtype) +return func_with_new_name(new, name + "_box_new"), staticmethod(get_dtype) class PrimitiveBox(object): _mixin_ = True ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-dtype-refactor: translation fix
Author: Alex Gaynor Branch: numpy-dtype-refactor Changeset: r49969:fc7d508c2176 Date: 2011-11-29 10:15 -0500 http://bitbucket.org/pypy/pypy/changeset/fc7d508c2176/ Log:translation fix diff --git a/pypy/module/micronumpy/interp_dtype.py b/pypy/module/micronumpy/interp_dtype.py --- a/pypy/module/micronumpy/interp_dtype.py +++ b/pypy/module/micronumpy/interp_dtype.py @@ -14,6 +14,9 @@ BOOLLTR = "b" FLOATINGLTR = "f" + +VOID_STORAGE = lltype.Array(lltype.Char, hints={'nolength': True, 'render_as_void': True}) + class W_Dtype(Wrappable): def __init__(self, itemtype, num, kind, name, char, w_box_type, alternate_constructors=[]): self.signature = signature.BaseSignature() @@ -27,7 +30,7 @@ def malloc(self, length): # XXX find out why test_zjit explodes with tracking of allocations -return lltype.malloc(rffi.CArray(lltype.Char), self.itemtype.get_element_size() * length, +return lltype.malloc(VOID_STORAGE, self.itemtype.get_element_size() * length, zero=True, flavor="raw", track_allocation=False, add_memory_pressure=True ) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy.org extradoc: Link win32.
Author: Armin Rigo Branch: extradoc Changeset: r295:62f26ca8eb05 Date: 2011-11-29 16:20 +0100 http://bitbucket.org/pypy/pypy.org/changeset/62f26ca8eb05/ Log:Link win32. diff --git a/download.html b/download.html --- a/download.html +++ b/download.html @@ -72,7 +72,7 @@ https://bitbucket.org/pypy/pypy/downloads/pypy-1.7-linux.tar.bz2";>Linux binary (32bit) https://bitbucket.org/pypy/pypy/downloads/pypy-1.7-linux64.tar.bz2";>Linux binary (64bit) https://bitbucket.org/pypy/pypy/downloads/pypy-1.7-osx64.tar.bz2";>Mac OS/X binary (64bit) -Windows binary (32bit) release c - not ready yet +https://bitbucket.org/pypy/pypy/downloads/pypy-1.7-win32.zip";>Windows binary (32bit) If your CPU is really old, it may not have SSE2. In this case, you need to translate yourself with the option --jit-backend=x86-without-sse2. diff --git a/source/download.txt b/source/download.txt --- a/source/download.txt +++ b/source/download.txt @@ -41,11 +41,12 @@ * `Linux binary (32bit)`__ * `Linux binary (64bit)`__ * `Mac OS/X binary (64bit)`__ -* Windows binary (32bit) release c - not ready yet +* `Windows binary (32bit)`__ .. __: https://bitbucket.org/pypy/pypy/downloads/pypy-1.7-linux.tar.bz2 .. __: https://bitbucket.org/pypy/pypy/downloads/pypy-1.7-linux64.tar.bz2 .. __: https://bitbucket.org/pypy/pypy/downloads/pypy-1.7-osx64.tar.bz2 +.. __: https://bitbucket.org/pypy/pypy/downloads/pypy-1.7-win32.zip .. VS 2010 runtime libraries: http://www.microsoft.com/downloads/en/details.aspx?familyid=A7B7A05E-6DE6-4D3A-A423-37BF0912DB84 If your CPU is really old, it may not have SSE2. In this case, you need ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy arm-backend-2: refactor check_imm_arg
Author: David Schneider Branch: arm-backend-2 Changeset: r49970:d61888e925b8 Date: 2011-11-29 14:01 +0100 http://bitbucket.org/pypy/pypy/changeset/d61888e925b8/ Log:refactor check_imm_arg diff --git a/pypy/jit/backend/arm/assembler.py b/pypy/jit/backend/arm/assembler.py --- a/pypy/jit/backend/arm/assembler.py +++ b/pypy/jit/backend/arm/assembler.py @@ -9,7 +9,7 @@ from pypy.jit.backend.arm.arch import WORD, FUNC_ALIGN, PC_OFFSET, N_REGISTERS_SAVED_BY_MALLOC from pypy.jit.backend.arm.codebuilder import ARMv7Builder, OverwritingBuilder from pypy.jit.backend.arm.regalloc import (Regalloc, ARMFrameManager, ARMv7RegisterMananger, -_check_imm_arg, TempInt, +check_imm_arg, TempInt, TempPtr, operations as regalloc_operations, operations_with_guard as regalloc_operations_with_guard) @@ -245,7 +245,8 @@ i += 4 if group == self.FLOAT_TYPE: value = decode64(stack, frame_depth - stack_loc*WORD) -self.fail_boxes_float.setitem(fail_index, value) +fvalue = longlong2float(value) +self.fail_boxes_float.setitem(fail_index, fvalue) continue else: value = decode32(stack, frame_depth - stack_loc*WORD) @@ -914,14 +915,14 @@ temp = r.lr else: temp = r.ip -offset = ConstInt(loc.position*WORD) -if not _check_imm_arg(offset, size=0xFFF): +offset = loc.position*WORD +if not check_imm_arg(offset, size=0xFFF): self.mc.PUSH([temp.value], cond=cond) -self.mc.gen_load_int(temp.value, -offset.value, cond=cond) +self.mc.gen_load_int(temp.value, -offset, cond=cond) self.mc.STR_rr(prev_loc.value, r.fp.value, temp.value, cond=cond) self.mc.POP([temp.value], cond=cond) else: -self.mc.STR_ri(prev_loc.value, r.fp.value, imm=-1*offset.value, cond=cond) +self.mc.STR_ri(prev_loc.value, r.fp.value, imm=-offset, cond=cond) else: assert 0, 'unsupported case' @@ -931,27 +932,27 @@ assert prev_loc.type != FLOAT, 'trying to load from an incompatible location into a core register' assert loc is not r.lr, 'lr is not supported as a target when moving from the stack' # unspill a core register -offset = ConstInt(prev_loc.position*WORD) -if not _check_imm_arg(offset, size=0xFFF): +offset = prev_loc.position*WORD +if not check_imm_arg(offset, size=0xFFF): self.mc.PUSH([r.lr.value], cond=cond) pushed = True -self.mc.gen_load_int(r.lr.value, -offset.value, cond=cond) +self.mc.gen_load_int(r.lr.value, -offset, cond=cond) self.mc.LDR_rr(loc.value, r.fp.value, r.lr.value, cond=cond) else: -self.mc.LDR_ri(loc.value, r.fp.value, imm=-offset.value, cond=cond) +self.mc.LDR_ri(loc.value, r.fp.value, imm=-offset, cond=cond) if pushed: self.mc.POP([r.lr.value], cond=cond) elif loc.is_vfp_reg(): assert prev_loc.type == FLOAT, 'trying to load from an incompatible location into a float register' # load spilled value into vfp reg -offset = ConstInt(prev_loc.position*WORD) +offset = prev_loc.position*WORD self.mc.PUSH([r.ip.value], cond=cond) pushed = True -if not _check_imm_arg(offset): -self.mc.gen_load_int(r.ip.value, offset.value, cond=cond) +if not check_imm_arg(offset): +self.mc.gen_load_int(r.ip.value, offset, cond=cond) self.mc.SUB_rr(r.ip.value, r.fp.value, r.ip.value, cond=cond) else: -self.mc.SUB_ri(r.ip.value, r.fp.value, offset.value, cond=cond) +self.mc.SUB_ri(r.ip.value, r.fp.value, offset, cond=cond) self.mc.VLDR(loc.value, r.ip.value, cond=cond) if pushed: self.mc.POP([r.ip.value], cond=cond) @@ -973,12 +974,12 @@ assert loc.type == FLOAT, 'trying to store to an incompatible location from a float register' # spill vfp register self.mc.PUSH([r.ip.value], cond=cond) -offset = ConstInt(loc.position*WORD) -if not _check_imm_arg(offset): -self.mc.gen_load_int(r.ip.value, offset.value, cond=cond) +offset = loc.position*WORD +if not check_imm_arg(offset): +self.mc.gen_load_int(r.ip.value, offset, cond=cond) self.mc.SUB_r
[pypy-commit] pypy arm-backend-2: merge disable_merge_different_int_types
Author: David Schneider Branch: arm-backend-2 Changeset: r49972:cbf05f6c40ef Date: 2011-11-29 14:38 +0100 http://bitbucket.org/pypy/pypy/changeset/cbf05f6c40ef/ Log:merge disable_merge_different_int_types diff --git a/pypy/annotation/binaryop.py b/pypy/annotation/binaryop.py --- a/pypy/annotation/binaryop.py +++ b/pypy/annotation/binaryop.py @@ -252,7 +252,26 @@ # unsignedness is considered a rare and contagious disease def union((int1, int2)): -knowntype = rarithmetic.compute_restype(int1.knowntype, int2.knowntype) +if int1.unsigned == int2.unsigned: +knowntype = rarithmetic.compute_restype(int1.knowntype, int2.knowntype) +else: +t1 = int1.knowntype +if t1 is bool: +t1 = int +t2 = int2.knowntype +if t2 is bool: +t2 = int + +if t2 is int: +if int2.nonneg == False: +raise UnionError, "Merging %s and a possibly negative int is not allowed" % t1 +knowntype = t1 +elif t1 is int: +if int1.nonneg == False: +raise UnionError, "Merging %s and a possibly negative int is not allowed" % t2 +knowntype = t2 +else: +raise UnionError, "Merging these types (%s, %s) is not supported" % (t1, t2) return SomeInteger(nonneg=int1.nonneg and int2.nonneg, knowntype=knowntype) diff --git a/pypy/annotation/model.py b/pypy/annotation/model.py --- a/pypy/annotation/model.py +++ b/pypy/annotation/model.py @@ -591,13 +591,11 @@ immutable = True def __init__(self, method): self.method = method - -NUMBER = object() + annotation_to_ll_map = [ (SomeSingleFloat(), lltype.SingleFloat), (s_None, lltype.Void), # also matches SomeImpossibleValue() (s_Bool, lltype.Bool), -(SomeInteger(knowntype=r_ulonglong), NUMBER), (SomeFloat(), lltype.Float), (SomeLongFloat(), lltype.LongFloat), (SomeChar(), lltype.Char), @@ -623,10 +621,11 @@ return lltype.Ptr(p.PARENTTYPE) if isinstance(s_val, SomePtr): return s_val.ll_ptrtype +if type(s_val) is SomeInteger: +return lltype.build_number(None, s_val.knowntype) + for witness, T in annotation_to_ll_map: if witness.contains(s_val): -if T is NUMBER: -return lltype.build_number(None, s_val.knowntype) return T if info is None: info = '' @@ -635,7 +634,7 @@ raise ValueError("%sshould return a low-level type,\ngot instead %r" % ( info, s_val)) -ll_to_annotation_map = dict([(ll, ann) for ann, ll in annotation_to_ll_map if ll is not NUMBER]) +ll_to_annotation_map = dict([(ll, ann) for ann, ll in annotation_to_ll_map]) def lltype_to_annotation(T): try: diff --git a/pypy/annotation/test/test_annrpython.py b/pypy/annotation/test/test_annrpython.py --- a/pypy/annotation/test/test_annrpython.py +++ b/pypy/annotation/test/test_annrpython.py @@ -856,6 +856,46 @@ py.test.raises(Exception, a.build_types, f, []) # if you want to get a r_uint, you have to be explicit about it +def test_add_different_ints(self): +def f(a, b): +return a + b +a = self.RPythonAnnotator() +py.test.raises(Exception, a.build_types, f, [r_uint, int]) + +def test_merge_different_ints(self): +def f(a, b): +if a: +c = a +else: +c = b +return c +a = self.RPythonAnnotator() +py.test.raises(Exception, a.build_types, f, [r_uint, int]) + +def test_merge_ruint_zero(self): +def f(a): +if a: +c = a +else: +c = 0 +return c +a = self.RPythonAnnotator() +s = a.build_types(f, [r_uint]) +assert s == annmodel.SomeInteger(nonneg = True, unsigned = True) + +def test_merge_ruint_nonneg_signed(self): +def f(a, b): +if a: +c = a +else: +assert b >= 0 +c = b +return c +a = self.RPythonAnnotator() +s = a.build_types(f, [r_uint, int]) +assert s == annmodel.SomeInteger(nonneg = True, unsigned = True) + + def test_prebuilt_long_that_is_not_too_long(self): small_constant = 12L def f(): @@ -3029,7 +3069,7 @@ if g(x, y): g(x, r_uint(y)) a = self.RPythonAnnotator() -a.build_types(f, [int, int]) +py.test.raises(Exception, a.build_types, f, [int, int]) def test_compare_with_zero(self): def g(): diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py --- a/pypy/interpreter/pyframe.py +++ b/pypy/interpreter/pyframe.py @@ -10,7 +10,7 @@ from pypy.rlib.objectmodel import we_are_transl
[pypy-commit] pypy arm-backend-2: translation fix
Author: David Schneider Branch: arm-backend-2 Changeset: r49973:cf2af9ba668b Date: 2011-11-29 16:47 +0100 http://bitbucket.org/pypy/pypy/changeset/cf2af9ba668b/ Log:translation fix diff --git a/pypy/jit/backend/arm/assembler.py b/pypy/jit/backend/arm/assembler.py --- a/pypy/jit/backend/arm/assembler.py +++ b/pypy/jit/backend/arm/assembler.py @@ -245,7 +245,7 @@ i += 4 if group == self.FLOAT_TYPE: value = decode64(stack, frame_depth - stack_loc*WORD) -fvalue = longlong2float(value) +fvalue = rffi.cast(longlong.FLOATSTORAGE, value) self.fail_boxes_float.setitem(fail_index, fvalue) continue else: ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-dtype-refactor: fix tests for 32-bit
Author: Alex Gaynor Branch: numpy-dtype-refactor Changeset: r49974:b443d8b4f544 Date: 2011-11-29 11:25 -0500 http://bitbucket.org/pypy/pypy/changeset/b443d8b4f544/ Log:fix tests for 32-bit diff --git a/pypy/module/micronumpy/__init__.py b/pypy/module/micronumpy/__init__.py --- a/pypy/module/micronumpy/__init__.py +++ b/pypy/module/micronumpy/__init__.py @@ -25,6 +25,7 @@ 'signedinteger': 'interp_boxes.W_SignedIntegerBox', 'bool_': 'interp_boxes.W_BoolBox', 'int8': 'interp_boxes.W_Int8Box', +'int64': 'interp_boxes.W_Int64Box', 'int_': 'interp_boxes.W_LongBox', 'inexact': 'interp_boxes.W_InexactBox', 'floating': 'interp_boxes.W_FloatingBox', diff --git a/pypy/module/micronumpy/interp_boxes.py b/pypy/module/micronumpy/interp_boxes.py --- a/pypy/module/micronumpy/interp_boxes.py +++ b/pypy/module/micronumpy/interp_boxes.py @@ -239,6 +239,7 @@ W_Int64Box.typedef = TypeDef("int64", (W_SignedIntegerBox.typedef,) + MIXIN_64, __module__ = "numpy", +__new__ = interp2app(W_Int64Box.descr__new__.im_func), ) W_UInt64Box.typedef = TypeDef("uint64", W_UnsignedIntgerBox.typedef, diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py --- a/pypy/module/micronumpy/test/test_dtypes.py +++ b/pypy/module/micronumpy/test/test_dtypes.py @@ -44,13 +44,13 @@ assert a[i] is True_ def test_copy_array_with_dtype(self): -from numpypy import array, False_, True_ +from numpypy import array, False_, True_, int64 a = array([0, 1, 2, 3], dtype=long) # int on 64-bit, long in 32-bit -assert isinstance(a[0], (int, long)) +assert isinstance(a[0], int64) b = a.copy() -assert isinstance(b[0], (int, long)) +assert isinstance(b[0], int64) a = array([0, 1, 2, 3], dtype=bool) assert a[0] is False_ @@ -72,17 +72,17 @@ assert a[i] is True_ def test_zeros_long(self): -from numpypy import zeros +from numpypy import zeros, int64 a = zeros(10, dtype=long) for i in range(10): -assert isinstance(a[i], (int, long)) +assert isinstance(a[i], int64) assert a[1] == 0 def test_ones_long(self): -from numpypy import ones +from numpypy import ones, int64 a = ones(10, dtype=long) for i in range(10): -assert isinstance(a[i], (int, long)) +assert isinstance(a[i], int64) assert a[1] == 1 def test_overflow(self): @@ -213,6 +213,18 @@ assert numpy.int_ is numpy.dtype(int).type assert numpy.int_.mro() == [numpy.int_, numpy.signedinteger, numpy.integer, numpy.number, numpy.generic, int, object] +def test_int64(self): +import sys +import numpypy as numpy + +if sys.maxint == 2 ** 63 -1: +assert numpy.int64.mro() == [numpy.int64, numpy.signedinteger, numpy.integer, numpy.number, numpy.generic, int, object] +else: +assert numpy.int64.mro() == [numpy.int64, numpy.signedinteger, numpy.integer, numpy.number, numpy.generic, object] + +assert numpy.dtype(numpy.int64).type is numpy.int64 +assert numpy.int64(3) == 3 + def test_float64(self): import numpypy as numpy ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Fix (probably; tests coming).
Author: Armin Rigo Branch: Changeset: r49975:ca55b862ead9 Date: 2011-11-29 19:15 +0100 http://bitbucket.org/pypy/pypy/changeset/ca55b862ead9/ Log:Fix (probably; tests coming). diff --git a/pypy/rpython/memory/gctransform/shadowstack.py b/pypy/rpython/memory/gctransform/shadowstack.py --- a/pypy/rpython/memory/gctransform/shadowstack.py +++ b/pypy/rpython/memory/gctransform/shadowstack.py @@ -307,7 +307,7 @@ "restore_state_from: broken shadowstack") self.gcdata.root_stack_base = shadowstackref.base self.gcdata.root_stack_top = shadowstackref.top -self.destroy(shadowstackref) +self._cleanup(shadowstackref) def start_fresh_new_state(self): self.gcdata.root_stack_base = self.unused_full_stack @@ -315,6 +315,10 @@ self.unused_full_stack = llmemory.NULL def destroy(self, shadowstackref): +llmemory.raw_free(shadowstackref.base) +self._cleanup(shadowstackref) + +def _cleanup(self, shadowstackref): shadowstackref.base = llmemory.NULL shadowstackref.top = llmemory.NULL shadowstackref.context = llmemory.NULL ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: The test for ca55b862ead9. Without the fix, it crashes with MemoryError as originally reported by ltratt with the Converge VM.
Author: Armin Rigo Branch: Changeset: r49976:ccac319dfdd7 Date: 2011-11-29 19:30 +0100 http://bitbucket.org/pypy/pypy/changeset/ccac319dfdd7/ Log:The test for ca55b862ead9. Without the fix, it crashes with MemoryError as originally reported by ltratt with the Converge VM. diff --git a/pypy/rlib/test/test_rstacklet.py b/pypy/rlib/test/test_rstacklet.py --- a/pypy/rlib/test/test_rstacklet.py +++ b/pypy/rlib/test/test_rstacklet.py @@ -65,6 +65,15 @@ self.tasks[0].withdepth(self.random.genrand32() % 50) assert len(self.tasks[0].lst) == 0 +@here_is_a_test +def test_destroy(self): +# this used to give MemoryError in shadowstack tests +for i in range(10): +self.status = 0 +h = self.sthread.new(switchbackonce_callback, + rffi.cast(llmemory.Address, 321)) +self.sthread.destroy(h) + def any_alive(self): for task in self.tasks: if task.h: ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy win64-stage1: reverted a bad import of pypy into app_operator
Author: Christian Tismer Branch: win64-stage1 Changeset: r49977:0145566e0b02 Date: 2011-11-29 20:34 +0100 http://bitbucket.org/pypy/pypy/changeset/0145566e0b02/ Log:reverted a bad import of pypy into app_operator diff --git a/pypy/module/operator/app_operator.py b/pypy/module/operator/app_operator.py --- a/pypy/module/operator/app_operator.py +++ b/pypy/module/operator/app_operator.py @@ -5,8 +5,6 @@ equivalent to x+y. ''' from __pypy__ import builtinify -from pypy.rlib.rarithmetic import is_valid_int - def countOf(a,b): 'countOf(a, b) -- Return the number of times b occurs in a.' @@ -55,7 +53,7 @@ def repeat(obj, num): 'repeat(a, b) -- Return a * b, where a is a sequence, and b is an integer.' -if not is_valid_int(num): +if not isinstance(num, (int, long)): raise TypeError, 'an integer is required' if not isSequenceType(obj): raise TypeError, "non-sequence object can't be repeated" ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: (chronitis) String tests should test (bytes) strings.
Author: Amaury Forgeot d'Arc Branch: py3k Changeset: r49978:d5cb1a5800c3 Date: 2011-11-29 22:04 +0100 http://bitbucket.org/pypy/pypy/changeset/d5cb1a5800c3/ Log:(chronitis) String tests should test (bytes) strings. Also make sure that the fillchar character in bytes.rjust() cannot be a unicode string. diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py --- a/pypy/interpreter/gateway.py +++ b/pypy/interpreter/gateway.py @@ -832,7 +832,7 @@ defs_w.append(None) else: spec = unwrap_spec[i] -if spec in ['bufferstr']: +if isinstance(val, str) and spec not in [str]: defs_w.append(space.wrapbytes(val)) else: defs_w.append(space.wrap(val)) diff --git a/pypy/objspace/std/stringobject.py b/pypy/objspace/std/stringobject.py --- a/pypy/objspace/std/stringobject.py +++ b/pypy/objspace/std/stringobject.py @@ -389,7 +389,7 @@ def str_rjust__String_ANY_ANY(space, w_self, w_arg, w_fillchar): u_arg = space.int_w(w_arg) u_self = w_self._value -fillchar = space.str_w(w_fillchar) +fillchar = space.bytes_w(w_fillchar) if len(fillchar) != 1: raise OperationError(space.w_TypeError, space.wrap("rjust() argument 2 must be a single character")) @@ -405,7 +405,7 @@ def str_ljust__String_ANY_ANY(space, w_self, w_arg, w_fillchar): u_self = w_self._value u_arg = space.int_w(w_arg) -fillchar = space.str_w(w_fillchar) +fillchar = space.bytes_w(w_fillchar) if len(fillchar) != 1: raise OperationError(space.w_TypeError, space.wrap("ljust() argument 2 must be a single character")) @@ -614,7 +614,7 @@ def str_center__String_ANY_ANY(space, w_self, w_arg, w_fillchar): u_self = w_self._value u_arg = space.int_w(w_arg) -fillchar = space.str_w(w_fillchar) +fillchar = space.bytes_w(w_fillchar) if len(fillchar) != 1: raise OperationError(space.w_TypeError, space.wrap("center() argument 2 must be a single character")) @@ -966,7 +966,7 @@ space.wrap("translation table must be 256 characters long")) string = w_string._value -deletechars = space.str_w(w_deletechars) +deletechars = space.bytes_w(w_deletechars) if len(deletechars) == 0: buf = StringBuilder(len(string)) for char in string: diff --git a/pypy/objspace/std/strjoinobject.py b/pypy/objspace/std/strjoinobject.py --- a/pypy/objspace/std/strjoinobject.py +++ b/pypy/objspace/std/strjoinobject.py @@ -29,7 +29,7 @@ def unwrap(w_self, space): return w_self.force() -str_w = unwrap +bytes_w = unwrap registerimplementation(W_StringJoinObject) @@ -51,7 +51,7 @@ def add__StringJoin_String(space, w_self, w_other): if len(w_self.joined_strs) > w_self.until: w_self.force(True) -other = space.str_w(w_other) +other = space.bytes_w(w_other) w_self.joined_strs.append(other) return W_StringJoinObject(w_self.joined_strs) diff --git a/pypy/objspace/std/test/test_strbufobject.py b/pypy/objspace/std/test/test_strbufobject.py --- a/pypy/objspace/std/test/test_strbufobject.py +++ b/pypy/objspace/std/test/test_strbufobject.py @@ -12,36 +12,36 @@ import __pypy__ # cannot do "Hello, " + "World!" because cpy2.5 optimises this # away on AST level -s = "Hello, ".__add__("World!") -assert type(s) is str +s = b"Hello, ".__add__(b"World!") +assert type(s) is bytes assert 'W_StringBufferObject' in __pypy__.internal_repr(s) def test_add_twice(self): -x = "a".__add__("b") -y = x + "c" -c = x + "d" -assert y == "abc" -assert c == "abd" +x = b"a".__add__(b"b") +y = x + b"c" +c = x + b"d" +assert y == b"abc" +assert c == b"abd" def test_add(self): import __pypy__ -all = "" +all = b"" for i in range(20): -all += str(i) +all += str(i).encode() assert 'W_StringBufferObject' in __pypy__.internal_repr(all) -assert all == "012345678910111213141516171819" +assert all == b"012345678910111213141516171819" def test_hash(self): import __pypy__ def join(s): return s[:len(s) // 2] + s[len(s) // 2:] -t = 'a' * 101 +t = b'a' * 101 s = join(t) assert 'W_StringBufferObject' in __pypy__.internal_repr(s) assert hash(s) == hash(t) def test_len(self): -s = "a".__add__("b") -r = "c".__add__("d") +s = b"a".__add__(b"b") +r = b"c".__add__(b"d") t = s + r assert len(s) == 2 assert len(r) == 2 @@ -49,30 +49,30 @@ def test_add_strbuf(self): # make three strbuf objects -s = 'a'.__add__('b') -t = 'x'.__add__('c') -u = 'y'
[pypy-commit] pypy py3k: (chronitis) Add bytes.maketrans, and allow buffer-compatible objects to
Author: Amaury Forgeot d'Arc Branch: py3k Changeset: r49979:5a8c73ef4e8f Date: 2011-11-29 23:25 +0100 http://bitbucket.org/pypy/pypy/changeset/5a8c73ef4e8f/ Log:(chronitis) Add bytes.maketrans, and allow buffer-compatible objects to be used as arguments of most bytes methods diff --git a/pypy/objspace/std/stringobject.py b/pypy/objspace/std/stringobject.py --- a/pypy/objspace/std/stringobject.py +++ b/pypy/objspace/std/stringobject.py @@ -250,10 +250,10 @@ return space.newlist(res_w) -def str_split__String_String_ANY(space, w_self, w_by, w_maxsplit=-1): +def str_split__String_ANY_ANY(space, w_self, w_by, w_maxsplit=-1): maxsplit = space.int_w(w_maxsplit) value = w_self._value -by = w_by._value +by = space.bufferstr_w(w_by) bylen = len(by) if bylen == 0: raise OperationError(space.w_ValueError, space.wrap("empty separator")) @@ -324,12 +324,19 @@ def make_rsplit_with_delim(funcname, sliced): from pypy.tool.sourcetools import func_with_new_name +if 'Unicode' in funcname: +def unwrap_sep(space, w_by): +return w_by.value +else: +def unwrap_sep(space, w_by): +return space.bufferstr_w(w_by) + def fn(space, w_self, w_by, w_maxsplit=-1): maxsplit = space.int_w(w_maxsplit) res_w = [] value = w_self._value end = len(value) -by = w_by._value +by = unwrap_sep(space, w_by) bylen = len(by) if bylen == 0: raise OperationError(space.w_ValueError, space.wrap("empty separator")) @@ -348,8 +355,8 @@ return func_with_new_name(fn, funcname) -str_rsplit__String_String_ANY = make_rsplit_with_delim('str_rsplit__String_String_ANY', - sliced) +str_rsplit__String_ANY_ANY = make_rsplit_with_delim( +'str_rsplit__String_ANY_ANY', sliced) def str_join__String_ANY(space, w_self, w_list): list_w = space.listview(w_list) @@ -372,18 +379,22 @@ reslen = len(self) * (size - 1) for i in range(size): w_s = list_w[i] -if not space.isinstance_w(w_s, space.w_bytes): +try: +item = space.bufferstr_w(w_s) +except OperationError, e: +if not e.match(space, space.w_TypeError): +raise raise operationerrfmt( space.w_TypeError, "sequence item %d: expected bytes, %s " "found", i, space.type(w_s).getname(space)) -reslen += len(space.bytes_w(w_s)) +reslen += len(item) sb = StringBuilder(reslen) for i in range(size): if self and i != 0: sb.append(self) -sb.append(space.bytes_w(list_w[i])) +sb.append(space.bufferstr_w(list_w[i])) return space.wrapbytes(sb.build()) def str_rjust__String_ANY_ANY(space, w_self, w_arg, w_fillchar): @@ -426,6 +437,11 @@ space, lenself, w_start, w_end, upper_bound=upper_bound) return (self, start, end) +def contains__String_ANY(space, w_self, w_sub): +self = w_self._value +sub = space.bufferstr_w(w_sub) +return space.newbool(self.find(sub) >= 0) + def contains__String_String(space, w_self, w_sub): self = w_self._value sub = w_sub._value @@ -436,13 +452,23 @@ char = w_char.intval return space.newbool(self.find(chr(char)) >= 0) +def str_find__String_ANY_ANY_ANY(space, w_self, w_sub, w_start, w_end): +(self, start, end) = _convert_idx_params(space, w_self, w_start, w_end) +res = self.find(space.bufferstr_w(w_sub), start, end) +return space.wrap(res) + def str_find__String_String_ANY_ANY(space, w_self, w_sub, w_start, w_end): -(self, start, end) = _convert_idx_params(space, w_self, w_start, w_end) +(self, start, end) = _convert_idx_params(space, w_self, w_start, w_end) res = self.find(w_sub._value, start, end) return space.wrap(res) +def str_rfind__String_ANY_ANY_ANY(space, w_self, w_sub, w_start, w_end): +(self, start, end) = _convert_idx_params(space, w_self, w_start, w_end) +res = self.rfind(space.bufferstr_w(w_sub), start, end) +return space.wrap(res) + def str_rfind__String_String_ANY_ANY(space, w_self, w_sub, w_start, w_end): -(self, start, end) = _convert_idx_params(space, w_self, w_start, w_end) +(self, start, end) = _convert_idx_params(space, w_self, w_start, w_end) res = self.rfind(w_sub._value, start, end) return space.wrap(res) @@ -554,7 +580,7 @@ def _strip(space, w_self, w_chars, left, right): "internal function called by str_xstrip methods" u_self = w_self._value -u_chars = w_chars._value +u_chars = space.bufferstr_w(w_chars) lpos = 0 rpos = len(u_self) @@ -590,20 +616,20 @@ assert rpos >= lpos# annotator hint, don't remove return sliced(space, u_self, lpos, rpos, w_self) -def str_strip__String_String(space, w_self, w_chars): +def str_strip__String_ANY(space, w_
[pypy-commit] pypy default: corrected nullpath for windows
Author: Christian Tismer Branch: Changeset: r49980:70f319a40fd6 Date: 2011-11-29 21:36 +0100 http://bitbucket.org/pypy/pypy/changeset/70f319a40fd6/ Log:corrected nullpath for windows diff --git a/pypy/tool/nullpath.py b/pypy/tool/nullpath.py --- a/pypy/tool/nullpath.py +++ b/pypy/tool/nullpath.py @@ -1,4 +1,9 @@ -import py +import py, os + +if os.name <> 'nt': +NULLPATHNAME = '/dev/null' +else: +NULLPATHNAME = 'NUL' class NullPyPathLocal(py.path.local): @@ -6,7 +11,7 @@ return self.__class__(py.path.local.join(self, *args)) def open(self, mode): -return open('/dev/null', mode) +return open(NULLPATHNAME, mode) def __repr__(self): return py.path.local.__repr__(self) + ' [fake]' diff --git a/pypy/tool/test/test_nullpath.py b/pypy/tool/test/test_nullpath.py --- a/pypy/tool/test/test_nullpath.py +++ b/pypy/tool/test/test_nullpath.py @@ -1,10 +1,7 @@ import sys import py -from pypy.tool.nullpath import NullPyPathLocal +from pypy.tool.nullpath import NullPyPathLocal, NULLPATHNAME -def setup_module(): -if 'posix' not in sys.builtin_module_names: -py.test.skip('posix only') def test_nullpath(tmpdir): path = NullPyPathLocal(tmpdir) @@ -13,4 +10,4 @@ assert isinstance(foo_txt, NullPyPathLocal) # f = foo_txt.open('w') -assert f.name == '/dev/null' +assert f.name == NULLPATHNAME ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy win64-stage1: Merge with default
Author: Christian Tismer Branch: win64-stage1 Changeset: r49981:f16c55f8b3e5 Date: 2011-11-29 21:39 +0100 http://bitbucket.org/pypy/pypy/changeset/f16c55f8b3e5/ Log:Merge with default diff --git a/pypy/tool/nullpath.py b/pypy/tool/nullpath.py --- a/pypy/tool/nullpath.py +++ b/pypy/tool/nullpath.py @@ -1,4 +1,9 @@ -import py +import py, os + +if os.name <> 'nt': +NULLPATHNAME = '/dev/null' +else: +NULLPATHNAME = 'NUL' class NullPyPathLocal(py.path.local): @@ -6,7 +11,7 @@ return self.__class__(py.path.local.join(self, *args)) def open(self, mode): -return open('/dev/null', mode) +return open(NULLPATHNAME, mode) def __repr__(self): return py.path.local.__repr__(self) + ' [fake]' diff --git a/pypy/tool/test/test_nullpath.py b/pypy/tool/test/test_nullpath.py --- a/pypy/tool/test/test_nullpath.py +++ b/pypy/tool/test/test_nullpath.py @@ -1,10 +1,7 @@ import sys import py -from pypy.tool.nullpath import NullPyPathLocal +from pypy.tool.nullpath import NullPyPathLocal, NULLPATHNAME -def setup_module(): -if 'posix' not in sys.builtin_module_names: -py.test.skip('posix only') def test_nullpath(tmpdir): path = NullPyPathLocal(tmpdir) @@ -13,4 +10,4 @@ assert isinstance(foo_txt, NullPyPathLocal) # f = foo_txt.open('w') -assert f.name == '/dev/null' +assert f.name == NULLPATHNAME ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Merge
Author: Christian Tismer Branch: Changeset: r49984:4698190ee108 Date: 2011-11-29 23:27 +0100 http://bitbucket.org/pypy/pypy/changeset/4698190ee108/ Log:Merge diff --git a/pypy/tool/nullpath.py b/pypy/tool/nullpath.py --- a/pypy/tool/nullpath.py +++ b/pypy/tool/nullpath.py @@ -1,4 +1,9 @@ -import py +import py, os + +if os.name <> 'nt': +NULLPATHNAME = '/dev/null' +else: +NULLPATHNAME = 'NUL' class NullPyPathLocal(py.path.local): @@ -6,7 +11,7 @@ return self.__class__(py.path.local.join(self, *args)) def open(self, mode): -return open('/dev/null', mode) +return open(NULLPATHNAME, mode) def __repr__(self): return py.path.local.__repr__(self) + ' [fake]' diff --git a/pypy/tool/test/test_nullpath.py b/pypy/tool/test/test_nullpath.py --- a/pypy/tool/test/test_nullpath.py +++ b/pypy/tool/test/test_nullpath.py @@ -1,10 +1,7 @@ import sys import py -from pypy.tool.nullpath import NullPyPathLocal +from pypy.tool.nullpath import NullPyPathLocal, NULLPATHNAME -def setup_module(): -if 'posix' not in sys.builtin_module_names: -py.test.skip('posix only') def test_nullpath(tmpdir): path = NullPyPathLocal(tmpdir) @@ -13,4 +10,4 @@ assert isinstance(foo_txt, NullPyPathLocal) # f = foo_txt.open('w') -assert f.name == '/dev/null' +assert f.name == NULLPATHNAME ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy win64-stage1: Merge
Author: Christian Tismer Branch: win64-stage1 Changeset: r49983:f3c6d05cd02c Date: 2011-11-29 23:15 +0100 http://bitbucket.org/pypy/pypy/changeset/f3c6d05cd02c/ Log:Merge diff --git a/pypy/objspace/std/test/test_longobject.py b/pypy/objspace/std/test/test_longobject.py --- a/pypy/objspace/std/test/test_longobject.py +++ b/pypy/objspace/std/test/test_longobject.py @@ -225,6 +225,7 @@ assert x ^ 0x5L == 0x5L def test_hash(self): +import sys # ints have the same hash as equal longs for i in range(-4, 14): assert hash(i) == hash(long(i)) @@ -233,6 +234,8 @@ assert hash(1234567890123456789L) in ( -1895067127,# with 32-bit platforms 1234567890123456789)# with 64-bit platforms +assert hash(long(sys.maxint)) == sys.maxint +assert hash(long(-sys.maxint-1)) == -sys.maxint-1 def test_math_log(self): import math diff --git a/pypy/rpython/llinterp.py b/pypy/rpython/llinterp.py --- a/pypy/rpython/llinterp.py +++ b/pypy/rpython/llinterp.py @@ -1019,6 +1019,7 @@ def op_int_neg_ovf(self, x): assert is_valid_int(x) +assert isinstance(x, (int, long)) try: return ovfcheck(-x) except OverflowError: @@ -1026,6 +1027,7 @@ def op_int_abs_ovf(self, x): assert is_valid_int(x) +assert isinstance(x, (int, long)) try: return ovfcheck(abs(x)) except OverflowError: @@ -1034,6 +1036,7 @@ def op_int_lshift_ovf(self, x, y): assert is_valid_int(x) assert is_valid_int(y) +assert isinstance(y, (int, long)) try: return ovfcheck(x << y) except OverflowError: diff --git a/pypy/rpython/lltypesystem/ll2ctypes.py b/pypy/rpython/lltypesystem/ll2ctypes.py --- a/pypy/rpython/lltypesystem/ll2ctypes.py +++ b/pypy/rpython/lltypesystem/ll2ctypes.py @@ -15,6 +15,7 @@ load_library_kwargs = {} import os, platform as host_platform +from pypy import conftest from pypy.rpython.lltypesystem import lltype, llmemory from pypy.rpython.extfunc import ExtRegistryEntry from pypy.rlib.objectmodel import Symbolic, ComputedIntSymbolic diff --git a/pypy/rpython/lltypesystem/lltype.py b/pypy/rpython/lltypesystem/lltype.py --- a/pypy/rpython/lltypesystem/lltype.py +++ b/pypy/rpython/lltypesystem/lltype.py @@ -1,7 +1,8 @@ import py from pypy.rlib.rarithmetic import (r_int, r_uint, intmask, r_singlefloat, r_ulonglong, r_longlong, r_longfloat, - base_int, normalizedinttype, longlongmask) + base_int, normalizedinttype, longlongmask, + r_uint32) from pypy.rlib.objectmodel import Symbolic from pypy.tool.uid import Hashable from pypy.tool.identity_dict import identity_dict diff --git a/pypy/rpython/module/ll_os.py b/pypy/rpython/module/ll_os.py --- a/pypy/rpython/module/ll_os.py +++ b/pypy/rpython/module/ll_os.py @@ -444,9 +444,14 @@ if config['HAVE_UTIMES']: class CConfig: -_compilation_info_ = ExternalCompilationInfo( +if not _WIN32: +_compilation_info_ = ExternalCompilationInfo( includes = includes -) +) +else: +_compilation_info_ = ExternalCompilationInfo( +includes = ['time.h'] +) TIMEVAL = platform.Struct('struct timeval', [('tv_sec', rffi.LONG), ('tv_usec', rffi.LONG)]) config = platform.configure(CConfig) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: (chronitis) Add a couple more string test cases, and fix contains and expandtabs appropriately.
Author: Amaury Forgeot d'Arc Branch: py3k Changeset: r49985:fee4e22f1a4f Date: 2011-11-29 23:40 +0100 http://bitbucket.org/pypy/pypy/changeset/fee4e22f1a4f/ Log:(chronitis) Add a couple more string test cases, and fix contains and expandtabs appropriately. diff --git a/pypy/objspace/std/stringobject.py b/pypy/objspace/std/stringobject.py --- a/pypy/objspace/std/stringobject.py +++ b/pypy/objspace/std/stringobject.py @@ -450,7 +450,11 @@ def contains__String_Int(space, w_self, w_char): self = w_self._value char = w_char.intval -return space.newbool(self.find(chr(char)) >= 0) +if 0 <= char < 256: +return space.newbool(self.find(chr(char)) >= 0) +else: +raise OperationError(space.w_ValueError, + space.wrap("character must be in range(256)")) def str_find__String_ANY_ANY_ANY(space, w_self, w_sub, w_start, w_end): (self, start, end) = _convert_idx_params(space, w_self, w_start, w_end) @@ -702,6 +706,9 @@ def _tabindent(u_token, u_tabsize): "calculates distance behind the token to the next tabstop" +if u_tabsize <= 0: +return u_tabsize + distance = u_tabsize if u_token: distance = 0 diff --git a/pypy/objspace/std/test/test_stringobject.py b/pypy/objspace/std/test/test_stringobject.py --- a/pypy/objspace/std/test/test_stringobject.py +++ b/pypy/objspace/std/test/test_stringobject.py @@ -112,6 +112,7 @@ assert b"".split(b'x') == [b''] assert b" ".split() == [] assert b"a".split() == [b'a'] +assert b"a".split(b"aa") == [b'a'] assert b"a".split(b"a", 1) == [b'', b''] assert b" ".split(b" ", 1) == [b'', b''] assert b"aa".split(b"a", 2) == [b'', b'', b''] @@ -131,6 +132,8 @@ assert b'a//b//c//d'.split(b'//') == [b'a', b'b', b'c', b'd'] assert b'endcase test'.split(b'test') == [b'endcase ', b''] raises(ValueError, b'abc'.split, b'') +raises(TypeError, b'abc'.split, 123) +raises(TypeError, b'abc'.split, None, 1.0) def test_rsplit(self): assert b"".rsplit() == [] @@ -156,9 +159,6 @@ assert b'endcase test'.rsplit(b'test') == [b'endcase ', b''] raises(ValueError, b'abc'.rsplit, b'') -def test_split_splitchar(self): -assert b"/a/b/c".split(b'/') == [b'',b'a',b'b',b'c'] - def test_title(self): assert b"brown fox".title() == b"Brown Fox" assert b"!brown fox".title() == b"!Brown Fox" @@ -200,8 +200,13 @@ assert b'abc'.rjust(3) == b'abc' assert b'abc'.rjust(2) == b'abc' assert b'abc'.rjust(5, b'*') == b'**abc' # Python 2.4 +assert b'abc'.rjust(0) == b'abc' +assert b'abc'.rjust(-1) == b'abc' +raises(TypeError, b'abc'.rjust, 5.0) raises(TypeError, b'abc'.rjust, 5, '*') raises(TypeError, b'abc'.rjust, 5, b'xx') +raises(TypeError, b'abc'.rjust, 5, bytearray(b' ')) +raises(TypeError, b'abc'.rjust, 5, 32) def test_ljust(self): s = b"abc" @@ -282,7 +287,10 @@ assert b'abc'.center(3) == b'abc' assert b'abc'.center(2) == b'abc' assert b'abc'.center(5, b'*') == b'*abc*' # Python 2.4 +assert b'abc'.center(0) == b'abc' +assert b'abc'.center(-1) == b'abc' raises(TypeError, b'abc'.center, 4, b'cba') +raises(TypeError, b'abc'.center, 5, bytearray(b' ')) assert b' abc'.center(7) == b' abc ' def test_count(self): @@ -307,6 +315,8 @@ assert b''.startswith(b'') is True assert b''.startswith(b'a') is False assert b'x'.startswith(b'xx') is False +assert b'hello'.startswith((bytearray(b'he'), bytearray(b'hel'))) +assert b'hello'.startswith((b'he', None, 123)) assert b'y'.startswith(b'xx') is False def test_startswith_more(self): @@ -380,6 +390,9 @@ assert b'xy'.expandtabs() == b'xy' assert b''.expandtabs() == b'' +assert b'x\t\t'.expandtabs(-1) == b'x' +assert b'x\t\t'.expandtabs(0) == b'x' + raises(OverflowError, b"t\tt\t".expandtabs, sys.maxint) def test_expandtabs_overflows_gracefully(self): @@ -416,6 +429,9 @@ assert b'abcdefghiabc'.find(b'def', 4) == -1 assert b'abcdef'.find(b'', 13) == -1 assert b'abcdefg'.find(b'def', 5, None) == -1 +assert b'abcdef'.find(b'd', 6, 0) == -1 +assert b'abcdef'.find(b'd', 3, 3) == -1 +raises(TypeError, b'abcdef'.find, b'd', 1.0) def test_index(self): from sys import maxint @@ -647,9 +663,13 @@ assert not b'd' in b'abc' assert 97 in b'a' raises(TypeError, b'a'.__contains__, 1.0) +raises(ValueError, b'a'.__contains__, 256) +raises(ValueError, b'a'.__contains__, -1) +raises(TypeError, b'a'.__contains__, None) def test_decode(self): assert b'hello'.decode('ascii') == 'hello' +raises(U
[pypy-commit] pypy default: adjusted nullpath according to amaury's suggestion
Author: Christian Tismer Branch: Changeset: r49986:5c81dab4eeda Date: 2011-11-30 01:11 +0100 http://bitbucket.org/pypy/pypy/changeset/5c81dab4eeda/ Log:adjusted nullpath according to amaury's suggestion diff --git a/pypy/tool/nullpath.py b/pypy/tool/nullpath.py --- a/pypy/tool/nullpath.py +++ b/pypy/tool/nullpath.py @@ -1,17 +1,12 @@ import py, os -if os.name <> 'nt': -NULLPATHNAME = '/dev/null' -else: -NULLPATHNAME = 'NUL' - class NullPyPathLocal(py.path.local): def join(self, *args): return self.__class__(py.path.local.join(self, *args)) def open(self, mode): -return open(NULLPATHNAME, mode) +return open(os.devnull, mode) def __repr__(self): return py.path.local.__repr__(self) + ' [fake]' diff --git a/pypy/tool/test/test_nullpath.py b/pypy/tool/test/test_nullpath.py --- a/pypy/tool/test/test_nullpath.py +++ b/pypy/tool/test/test_nullpath.py @@ -1,7 +1,6 @@ -import sys +import sys, os import py -from pypy.tool.nullpath import NullPyPathLocal, NULLPATHNAME - +from pypy.tool.nullpath import NullPyPathLocal def test_nullpath(tmpdir): path = NullPyPathLocal(tmpdir) @@ -10,4 +9,4 @@ assert isinstance(foo_txt, NullPyPathLocal) # f = foo_txt.open('w') -assert f.name == NULLPATHNAME +assert f.name == os.devnull ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy win64-stage1: Merge with default
Author: Christian Tismer Branch: win64-stage1 Changeset: r49987:83d2aaba0f24 Date: 2011-11-30 01:14 +0100 http://bitbucket.org/pypy/pypy/changeset/83d2aaba0f24/ Log:Merge with default diff --git a/pypy/tool/nullpath.py b/pypy/tool/nullpath.py --- a/pypy/tool/nullpath.py +++ b/pypy/tool/nullpath.py @@ -11,7 +11,7 @@ return self.__class__(py.path.local.join(self, *args)) def open(self, mode): -return open(NULLPATHNAME, mode) +return open(os.devnull, mode) def __repr__(self): return py.path.local.__repr__(self) + ' [fake]' diff --git a/pypy/tool/test/test_nullpath.py b/pypy/tool/test/test_nullpath.py --- a/pypy/tool/test/test_nullpath.py +++ b/pypy/tool/test/test_nullpath.py @@ -1,8 +1,7 @@ -import sys +import sys, os import py from pypy.tool.nullpath import NullPyPathLocal, NULLPATHNAME - def test_nullpath(tmpdir): path = NullPyPathLocal(tmpdir) assert repr(path).endswith('[fake]') @@ -10,4 +9,4 @@ assert isinstance(foo_txt, NullPyPathLocal) # f = foo_txt.open('w') -assert f.name == NULLPATHNAME +assert f.name == os.devnull ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Turn off reporting const-fold errors as WARNINGs. This gives quite a
Author: Armin Rigo Branch: Changeset: r49988:12a0a0c0eb4a Date: 2011-11-29 22:32 +0100 http://bitbucket.org/pypy/pypy/changeset/12a0a0c0eb4a/ Log:Turn off reporting const-fold errors as WARNINGs. This gives quite a bunch of warnings in any C translation, and I've never had any use of them over the years, so well. diff --git a/pypy/translator/backendopt/constfold.py b/pypy/translator/backendopt/constfold.py --- a/pypy/translator/backendopt/constfold.py +++ b/pypy/translator/backendopt/constfold.py @@ -37,8 +37,9 @@ except (KeyboardInterrupt, SystemExit): raise except Exception, e: -log.WARNING('constant-folding %r:' % (spaceop,)) -log.WARNING(' %s: %s' % (e.__class__.__name__, e)) +pass # turn off reporting these as warnings: useless +#log.WARNING('constant-folding %r:' % (spaceop,)) +#log.WARNING(' %s: %s' % (e.__class__.__name__, e)) else: # success in folding this space operation if spaceop.opname in fixup_op_result: ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Allow at least the front-end to be tested with the "none" gc.
Author: Armin Rigo Branch: Changeset: r49989:79bcc27b894a Date: 2011-11-30 02:23 +0100 http://bitbucket.org/pypy/pypy/changeset/79bcc27b894a/ Log:Allow at least the front-end to be tested with the "none" gc. diff --git a/pypy/jit/metainterp/gc.py b/pypy/jit/metainterp/gc.py --- a/pypy/jit/metainterp/gc.py +++ b/pypy/jit/metainterp/gc.py @@ -7,6 +7,9 @@ self.config = config +class GC_none(GcDescription): +malloc_zero_filled = True + class GC_boehm(GcDescription): malloc_zero_filled = True ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merge heads
Author: Armin Rigo Branch: Changeset: r49992:ac6210475691 Date: 2011-11-30 02:41 +0100 http://bitbucket.org/pypy/pypy/changeset/ac6210475691/ Log:merge heads diff --git a/pypy/tool/nullpath.py b/pypy/tool/nullpath.py --- a/pypy/tool/nullpath.py +++ b/pypy/tool/nullpath.py @@ -1,4 +1,4 @@ -import py +import py, os class NullPyPathLocal(py.path.local): @@ -6,7 +6,7 @@ return self.__class__(py.path.local.join(self, *args)) def open(self, mode): -return open('/dev/null', mode) +return open(os.devnull, mode) def __repr__(self): return py.path.local.__repr__(self) + ' [fake]' diff --git a/pypy/tool/test/test_nullpath.py b/pypy/tool/test/test_nullpath.py --- a/pypy/tool/test/test_nullpath.py +++ b/pypy/tool/test/test_nullpath.py @@ -1,11 +1,7 @@ -import sys +import sys, os import py from pypy.tool.nullpath import NullPyPathLocal -def setup_module(): -if 'posix' not in sys.builtin_module_names: -py.test.skip('posix only') - def test_nullpath(tmpdir): path = NullPyPathLocal(tmpdir) assert repr(path).endswith('[fake]') @@ -13,4 +9,4 @@ assert isinstance(foo_txt, NullPyPathLocal) # f = foo_txt.open('w') -assert f.name == '/dev/null' +assert f.name == os.devnull ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Add another test that switch() calls are supposed to have an
Author: Armin Rigo Branch: Changeset: r49990:36e3174f324f Date: 2011-11-30 02:24 +0100 http://bitbucket.org/pypy/pypy/changeset/36e3174f324f/ Log:Add another test that switch() calls are supposed to have an effectinfo of EF_RANDOM_EFFECTS. I thought it was tested already, but it's not, and it fails. diff --git a/pypy/jit/codewriter/test/test_call.py b/pypy/jit/codewriter/test/test_call.py --- a/pypy/jit/codewriter/test/test_call.py +++ b/pypy/jit/codewriter/test/test_call.py @@ -192,3 +192,21 @@ [op] = block.operations call_descr = cc.getcalldescr(op) assert call_descr.extrainfo.has_random_effects() + +def test_random_effects_on_stacklet_switch(): +from pypy.jit.backend.llgraph.runner import LLtypeCPU +from pypy.rlib._rffi_stacklet import switch, thread_handle, handle +@jit.dont_look_inside +def f(): +switch(rffi.cast(thread_handle, 0), rffi.cast(handle, 0)) + +rtyper = support.annotate(f, []) +jitdriver_sd = FakeJitDriverSD(rtyper.annotator.translator.graphs[0]) +cc = CallControl(LLtypeCPU(rtyper), jitdrivers_sd=[jitdriver_sd]) +res = cc.find_all_graphs(FakePolicy()) + +[f_graph] = [x for x in res if x.func is f] +[block, _] = list(f_graph.iterblocks()) +op = block.operations[-1] +call_descr = cc.getcalldescr(op) +assert call_descr.extrainfo.has_random_effects() ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Fix the test.
Author: Armin Rigo Branch: Changeset: r49991:b37ba47c5260 Date: 2011-11-30 02:39 +0100 http://bitbucket.org/pypy/pypy/changeset/b37ba47c5260/ Log:Fix the test. diff --git a/pypy/jit/codewriter/effectinfo.py b/pypy/jit/codewriter/effectinfo.py --- a/pypy/jit/codewriter/effectinfo.py +++ b/pypy/jit/codewriter/effectinfo.py @@ -243,11 +243,20 @@ class RandomEffectsAnalyzer(BoolGraphAnalyzer): def analyze_direct_call(self, graph, seen=None): if hasattr(graph, "func") and hasattr(graph.func, "_ptr"): +# the attribute _ptr is stored on the function 'graph.func' +# by rffi.llexternal(). It's a hack... if graph.func._ptr._obj.random_effects_on_gcobjs: return True return super(RandomEffectsAnalyzer, self).analyze_direct_call(graph, seen) +def analyze_external_call(self, op, seen=None): +funcobj = op.args[0].value._obj +if funcobj.random_effects_on_gcobjs: +return True +return super(RandomEffectsAnalyzer, self).analyze_external_call(op, +seen) + def analyze_simple_operation(self, op, graphinfo): return False diff --git a/pypy/rpython/lltypesystem/rffi.py b/pypy/rpython/lltypesystem/rffi.py --- a/pypy/rpython/lltypesystem/rffi.py +++ b/pypy/rpython/lltypesystem/rffi.py @@ -245,6 +245,7 @@ wrapper._annspecialcase_ = 'specialize:ll' wrapper._always_inline_ = True # for debugging, stick ll func ptr to that +# (nowadays used in a not-for-debugging way by jit/codewriter/effectinfo) wrapper._ptr = funcptr wrapper = func_with_new_name(wrapper, name) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Fix test.
Author: Armin Rigo Branch: Changeset: r49993:35781cc8c09d Date: 2011-11-30 02:43 +0100 http://bitbucket.org/pypy/pypy/changeset/35781cc8c09d/ Log:Fix test. diff --git a/pypy/jit/codewriter/test/test_longlong.py b/pypy/jit/codewriter/test/test_longlong.py --- a/pypy/jit/codewriter/test/test_longlong.py +++ b/pypy/jit/codewriter/test/test_longlong.py @@ -78,7 +78,7 @@ oplist = tr.rewrite_operation(op) assert len(oplist) == 2 assert oplist[0].opname == 'residual_call_irf_f' -assert oplist[0].args[0].value == 'llong_from_int' +assert oplist[0].args[0].value == opname.split('_')[0]+'_from_int' assert oplist[0].args[1] == 'calldescr-84' assert list(oplist[0].args[2]) == [const(0)] assert list(oplist[0].args[3]) == [] ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Oups.
Author: Armin Rigo Branch: Changeset: r49994:e99702a71e7e Date: 2011-11-30 02:45 +0100 http://bitbucket.org/pypy/pypy/changeset/e99702a71e7e/ Log:Oups. diff --git a/pypy/jit/codewriter/effectinfo.py b/pypy/jit/codewriter/effectinfo.py --- a/pypy/jit/codewriter/effectinfo.py +++ b/pypy/jit/codewriter/effectinfo.py @@ -251,9 +251,12 @@ seen) def analyze_external_call(self, op, seen=None): -funcobj = op.args[0].value._obj -if funcobj.random_effects_on_gcobjs: -return True +try: +funcobj = op.args[0].value._obj +if funcobj.random_effects_on_gcobjs: +return True +except lltype.DelayedPointer: +pass return super(RandomEffectsAnalyzer, self).analyze_external_call(op, seen) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Fix.
Author: Armin Rigo Branch: Changeset: r49995:c28d62b01ab1 Date: 2011-11-30 03:02 +0100 http://bitbucket.org/pypy/pypy/changeset/c28d62b01ab1/ Log:Fix. diff --git a/pypy/jit/codewriter/effectinfo.py b/pypy/jit/codewriter/effectinfo.py --- a/pypy/jit/codewriter/effectinfo.py +++ b/pypy/jit/codewriter/effectinfo.py @@ -255,10 +255,10 @@ funcobj = op.args[0].value._obj if funcobj.random_effects_on_gcobjs: return True -except lltype.DelayedPointer: +except (AttributeError, lltype.DelayedPointer): pass -return super(RandomEffectsAnalyzer, self).analyze_external_call(op, -seen) +return super(RandomEffectsAnalyzer, self).analyze_external_call( +op, seen) def analyze_simple_operation(self, op, graphinfo): return False ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Add a warning message when using stacklet_destroy() with
Author: Armin Rigo Branch: Changeset: r49996:5e4711c2e500 Date: 2011-11-30 03:14 +0100 http://bitbucket.org/pypy/pypy/changeset/5e4711c2e500/ Log:Add a warning message when using stacklet_destroy() with reference counting. diff --git a/pypy/rlib/_stacklet_n_a.py b/pypy/rlib/_stacklet_n_a.py --- a/pypy/rlib/_stacklet_n_a.py +++ b/pypy/rlib/_stacklet_n_a.py @@ -1,4 +1,5 @@ from pypy.rlib import _rffi_stacklet as _c +from pypy.rlib import objectmodel, debug from pypy.rpython.annlowlevel import llhelper from pypy.tool.staticmethods import StaticMethods @@ -21,6 +22,9 @@ def destroy(thrd, h): _c.destroy(thrd._thrd, h) +if objectmodel.we_are_translated(): +debug.debug_print("not using a framework GC: " + "stacklet_destroy() may leak") is_empty_handle = _c.is_empty_handle ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Actually, it seems that the new code replaces any need for the old
Author: Armin Rigo Branch: Changeset: r49997:46119931a154 Date: 2011-11-30 03:15 +0100 http://bitbucket.org/pypy/pypy/changeset/46119931a154/ Log:Actually, it seems that the new code replaces any need for the old code. Good, I can remove the comment in rffi.py too... diff --git a/pypy/jit/codewriter/effectinfo.py b/pypy/jit/codewriter/effectinfo.py --- a/pypy/jit/codewriter/effectinfo.py +++ b/pypy/jit/codewriter/effectinfo.py @@ -241,15 +241,6 @@ return op.opname == 'jit_force_quasi_immutable' class RandomEffectsAnalyzer(BoolGraphAnalyzer): -def analyze_direct_call(self, graph, seen=None): -if hasattr(graph, "func") and hasattr(graph.func, "_ptr"): -# the attribute _ptr is stored on the function 'graph.func' -# by rffi.llexternal(). It's a hack... -if graph.func._ptr._obj.random_effects_on_gcobjs: -return True -return super(RandomEffectsAnalyzer, self).analyze_direct_call(graph, - seen) - def analyze_external_call(self, op, seen=None): try: funcobj = op.args[0].value._obj diff --git a/pypy/rpython/lltypesystem/rffi.py b/pypy/rpython/lltypesystem/rffi.py --- a/pypy/rpython/lltypesystem/rffi.py +++ b/pypy/rpython/lltypesystem/rffi.py @@ -245,7 +245,6 @@ wrapper._annspecialcase_ = 'specialize:ll' wrapper._always_inline_ = True # for debugging, stick ll func ptr to that -# (nowadays used in a not-for-debugging way by jit/codewriter/effectinfo) wrapper._ptr = funcptr wrapper = func_with_new_name(wrapper, name) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy win64-stage1: this patch makes at least the setup part of test_newgc work.
Author: Christian Tismer Branch: win64-stage1 Changeset: r49998:6110a798a844 Date: 2011-11-30 03:44 +0100 http://bitbucket.org/pypy/pypy/changeset/6110a798a844/ Log:this patch makes at least the setup part of test_newgc work. But there is much left, which is probably better corrected via simpler tests. Postponed diff --git a/pypy/translator/c/test/test_newgc.py b/pypy/translator/c/test/test_newgc.py --- a/pypy/translator/c/test/test_newgc.py +++ b/pypy/translator/c/test/test_newgc.py @@ -692,7 +692,7 @@ ptr = CallbackFuncPtr([ffi_type_pointer, ffi_type_pointer], ffi_type_sint, callback) -TP = rffi.CArray(rffi.LONG) +TP = rffi.CArray(lltype.Signed) to_sort = lltype.malloc(TP, 4, flavor='raw') to_sort[0] = 4 to_sort[1] = 3 @@ -700,7 +700,7 @@ to_sort[3] = 2 qsort.push_arg(rffi.cast(rffi.VOIDP, to_sort)) qsort.push_arg(rffi.cast(rffi.SIZE_T, 4)) -qsort.push_arg(rffi.cast(rffi.SIZE_T, rffi.sizeof(rffi.LONG))) +qsort.push_arg(rffi.cast(rffi.SIZE_T, rffi.sizeof(lltype.Signed))) qsort.push_arg(rffi.cast(rffi.VOIDP, ptr.ll_closure)) qsort.call(lltype.Void) result = [to_sort[i] for i in range(4)] == [1,2,3,4] ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy win64-stage1: temp hack. something makes this cast necessary. Find the reason!
Author: Christian Tismer Branch: win64-stage1 Changeset: r4:7129b5efa170 Date: 2011-11-30 03:49 +0100 http://bitbucket.org/pypy/pypy/changeset/7129b5efa170/ Log:temp hack. something makes this cast necessary. Find the reason! diff --git a/pypy/rlib/rdynload.py b/pypy/rlib/rdynload.py --- a/pypy/rlib/rdynload.py +++ b/pypy/rlib/rdynload.py @@ -118,6 +118,9 @@ res = rwin32.LoadLibrary(name) if not res: err = rwin32.GetLastError() +err = rffi.cast(rwin32.DWORD, err) # why? +# XXX this must not be needed, something else is wrong. +# remove ASAP after finding the reason for this raise DLOpenError(rwin32.FormatError(err)) return res ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy win64-stage1: Merge
Author: Christian Tismer Branch: win64-stage1 Changeset: r5:64d02c8953ea Date: 2011-11-30 03:52 +0100 http://bitbucket.org/pypy/pypy/changeset/64d02c8953ea/ Log:Merge diff --git a/pypy/tool/nullpath.py b/pypy/tool/nullpath.py --- a/pypy/tool/nullpath.py +++ b/pypy/tool/nullpath.py @@ -11,7 +11,7 @@ return self.__class__(py.path.local.join(self, *args)) def open(self, mode): -return open(NULLPATHNAME, mode) +return open(os.devnull, mode) def __repr__(self): return py.path.local.__repr__(self) + ' [fake]' diff --git a/pypy/tool/test/test_nullpath.py b/pypy/tool/test/test_nullpath.py --- a/pypy/tool/test/test_nullpath.py +++ b/pypy/tool/test/test_nullpath.py @@ -1,8 +1,7 @@ -import sys +import sys, os import py from pypy.tool.nullpath import NullPyPathLocal, NULLPATHNAME - def test_nullpath(tmpdir): path = NullPyPathLocal(tmpdir) assert repr(path).endswith('[fake]') @@ -10,4 +9,4 @@ assert isinstance(foo_txt, NullPyPathLocal) # f = foo_txt.open('w') -assert f.name == NULLPATHNAME +assert f.name == os.devnull ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy win64-stage1: Merge with default
Author: Christian Tismer Branch: win64-stage1 Changeset: r50001:422cff143e9b Date: 2011-11-30 03:54 +0100 http://bitbucket.org/pypy/pypy/changeset/422cff143e9b/ Log:Merge with default diff --git a/pypy/jit/codewriter/effectinfo.py b/pypy/jit/codewriter/effectinfo.py --- a/pypy/jit/codewriter/effectinfo.py +++ b/pypy/jit/codewriter/effectinfo.py @@ -241,12 +241,15 @@ return op.opname == 'jit_force_quasi_immutable' class RandomEffectsAnalyzer(BoolGraphAnalyzer): -def analyze_direct_call(self, graph, seen=None): -if hasattr(graph, "func") and hasattr(graph.func, "_ptr"): -if graph.func._ptr._obj.random_effects_on_gcobjs: +def analyze_external_call(self, op, seen=None): +try: +funcobj = op.args[0].value._obj +if funcobj.random_effects_on_gcobjs: return True -return super(RandomEffectsAnalyzer, self).analyze_direct_call(graph, - seen) +except (AttributeError, lltype.DelayedPointer): +pass +return super(RandomEffectsAnalyzer, self).analyze_external_call( +op, seen) def analyze_simple_operation(self, op, graphinfo): return False diff --git a/pypy/jit/codewriter/test/test_call.py b/pypy/jit/codewriter/test/test_call.py --- a/pypy/jit/codewriter/test/test_call.py +++ b/pypy/jit/codewriter/test/test_call.py @@ -192,3 +192,21 @@ [op] = block.operations call_descr = cc.getcalldescr(op) assert call_descr.extrainfo.has_random_effects() + +def test_random_effects_on_stacklet_switch(): +from pypy.jit.backend.llgraph.runner import LLtypeCPU +from pypy.rlib._rffi_stacklet import switch, thread_handle, handle +@jit.dont_look_inside +def f(): +switch(rffi.cast(thread_handle, 0), rffi.cast(handle, 0)) + +rtyper = support.annotate(f, []) +jitdriver_sd = FakeJitDriverSD(rtyper.annotator.translator.graphs[0]) +cc = CallControl(LLtypeCPU(rtyper), jitdrivers_sd=[jitdriver_sd]) +res = cc.find_all_graphs(FakePolicy()) + +[f_graph] = [x for x in res if x.func is f] +[block, _] = list(f_graph.iterblocks()) +op = block.operations[-1] +call_descr = cc.getcalldescr(op) +assert call_descr.extrainfo.has_random_effects() diff --git a/pypy/jit/codewriter/test/test_longlong.py b/pypy/jit/codewriter/test/test_longlong.py --- a/pypy/jit/codewriter/test/test_longlong.py +++ b/pypy/jit/codewriter/test/test_longlong.py @@ -78,7 +78,7 @@ oplist = tr.rewrite_operation(op) assert len(oplist) == 2 assert oplist[0].opname == 'residual_call_irf_f' -assert oplist[0].args[0].value == 'llong_from_int' +assert oplist[0].args[0].value == opname.split('_')[0]+'_from_int' assert oplist[0].args[1] == 'calldescr-84' assert list(oplist[0].args[2]) == [const(0)] assert list(oplist[0].args[3]) == [] diff --git a/pypy/jit/metainterp/gc.py b/pypy/jit/metainterp/gc.py --- a/pypy/jit/metainterp/gc.py +++ b/pypy/jit/metainterp/gc.py @@ -7,6 +7,9 @@ self.config = config +class GC_none(GcDescription): +malloc_zero_filled = True + class GC_boehm(GcDescription): malloc_zero_filled = True diff --git a/pypy/rlib/_stacklet_n_a.py b/pypy/rlib/_stacklet_n_a.py --- a/pypy/rlib/_stacklet_n_a.py +++ b/pypy/rlib/_stacklet_n_a.py @@ -1,4 +1,5 @@ from pypy.rlib import _rffi_stacklet as _c +from pypy.rlib import objectmodel, debug from pypy.rpython.annlowlevel import llhelper from pypy.tool.staticmethods import StaticMethods @@ -21,6 +22,9 @@ def destroy(thrd, h): _c.destroy(thrd._thrd, h) +if objectmodel.we_are_translated(): +debug.debug_print("not using a framework GC: " + "stacklet_destroy() may leak") is_empty_handle = _c.is_empty_handle diff --git a/pypy/translator/backendopt/constfold.py b/pypy/translator/backendopt/constfold.py --- a/pypy/translator/backendopt/constfold.py +++ b/pypy/translator/backendopt/constfold.py @@ -37,8 +37,9 @@ except (KeyboardInterrupt, SystemExit): raise except Exception, e: -log.WARNING('constant-folding %r:' % (spaceop,)) -log.WARNING(' %s: %s' % (e.__class__.__name__, e)) +pass # turn off reporting these as warnings: useless +#log.WARNING('constant-folding %r:' % (spaceop,)) +#log.WARNING(' %s: %s' % (e.__class__.__name__, e)) else: # success in folding this space operation if spaceop.opname in fixup_op_result: ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy nedbat-sandbox: An implementation of do_ll_os__ll_os_fstat, no tests, not sure if it's right.
Author: Ned Batchelder Branch: nedbat-sandbox Changeset: r50002:ca8246ba93b7 Date: 2011-11-28 21:01 -0500 http://bitbucket.org/pypy/pypy/changeset/ca8246ba93b7/ Log:An implementation of do_ll_os__ll_os_fstat, no tests, not sure if it's right. diff --git a/pypy/translator/sandbox/sandlib.py b/pypy/translator/sandbox/sandlib.py --- a/pypy/translator/sandbox/sandlib.py +++ b/pypy/translator/sandbox/sandlib.py @@ -471,6 +471,15 @@ # don't try to read more than 256KB at once here return f.read(min(size, 256*1024)) +def do_ll_os__ll_os_fstat(self, fd): +try: +f = self.open_fds[fd] +except KeyError: +return super(VirtualizedSandboxedProc, self).do_ll_os__ll_os_fstat(fd) +else: +return os.stat(f.name) # Isn't there a better way to do this? +do_ll_os__ll_os_fstat.resulttype = s_StatResult + def do_ll_os__ll_os_lseek(self, fd, pos, how): f = self.get_file(fd) f.seek(pos, how) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy nedbat-sandbox: Avoid a compile at startup by using our own marshalling of stat results, instead of calling into rmarshal to do it.
Author: Ned Batchelder Branch: nedbat-sandbox Changeset: r50003:0cca0b181f5c Date: 2011-11-29 22:00 -0500 http://bitbucket.org/pypy/pypy/changeset/0cca0b181f5c/ Log:Avoid a compile at startup by using our own marshalling of stat results, instead of calling into rmarshal to do it. diff --git a/pypy/translator/sandbox/sandlib.py b/pypy/translator/sandbox/sandlib.py --- a/pypy/translator/sandbox/sandlib.py +++ b/pypy/translator/sandbox/sandlib.py @@ -50,6 +50,25 @@ marshal.dump(msg, g) else: marshal.dump(msg, g, 0) +elif resulttype is s_StatResult: +# Hand-coded marshal for stat results that mimics what rmarshal expects. +# marshal.dump(tuple(msg)) would have been too easy. rmarshal insists +# on 64-bit ints at places, even when the value fits in 32 bits. +import struct +st = tuple(msg) +fmt = "iIIiiiIfff" +buf = [] +buf.append(struct.pack("http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix translation
Author: Alex Gaynor Branch: Changeset: r50004:9eec6149907c Date: 2011-11-29 23:27 -0500 http://bitbucket.org/pypy/pypy/changeset/9eec6149907c/ Log:fix translation diff --git a/pypy/module/micronumpy/interp_dtype.py b/pypy/module/micronumpy/interp_dtype.py --- a/pypy/module/micronumpy/interp_dtype.py +++ b/pypy/module/micronumpy/interp_dtype.py @@ -131,7 +131,7 @@ def binop(func): -func._annspecialcase_ = "specialize:call_location" +specialize.argtype(1, 2)(func) @functools.wraps(func) def impl(self, v1, v2): return self.adapt_val(func(self, @@ -141,6 +141,7 @@ return impl def raw_binop(func): +specialize.argtype(1, 2)(func) # Returns the result unwrapped. @functools.wraps(func) def impl(self, v1, v2): @@ -151,6 +152,7 @@ return impl def unaryop(func): +specialize.argtype(1)(func) @functools.wraps(func) def impl(self, v): return self.adapt_val(func(self, self.for_computation(self.unbox(v ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit