[pypy-commit] pypy jit-duplicated_short_boxes: propagate duplications of short boxes
Author: Hakan Ardo Branch: jit-duplicated_short_boxes Changeset: r46678:db795a41638f Date: 2011-08-21 09:48 +0200 http://bitbucket.org/pypy/pypy/changeset/db795a41638f/ Log:propagate duplications of short boxes diff --git a/pypy/jit/metainterp/optimizeopt/virtualstate.py b/pypy/jit/metainterp/optimizeopt/virtualstate.py --- a/pypy/jit/metainterp/optimizeopt/virtualstate.py +++ b/pypy/jit/metainterp/optimizeopt/virtualstate.py @@ -476,6 +476,8 @@ except BoxNotProducable: pass +self.duplicate_short_boxes_if_needed() + def produce_short_preamble_box(self, box): if box in self.short_boxes: return @@ -494,9 +496,12 @@ if op.result not in self.potential_ops: self.potential_ops[op.result] = op return op +return self.duplicate(self.potential_ops, op) + +def duplicate(self, destination, op): newop = op.clone() newop.result = op.result.clonebox() -self.potential_ops[newop.result] = newop +destination[newop.result] = newop if op.result in self.duplicates: self.duplicates[op.result].append(newop.result) else: @@ -504,6 +509,32 @@ self.optimizer.make_equal_to(newop.result, self.optimizer.getvalue(op.result)) return newop +def duplicate_short_boxes_if_needed(self): +may_need_duplication = {} +for op in self.short_boxes.values(): +if op: +may_need_duplication[op] = True +while may_need_duplication: +op, _ = may_need_duplication.popitem() +self.maybe_duplicate_op(op, may_need_duplication) + +def maybe_duplicate_op(self, op, may_need_duplication): +for arg in op.getarglist(): +if arg in self.short_boxes: +producer = self.producer(arg) +if producer in may_need_duplication: +del may_need_duplication[producer] +self.maybe_duplicate_op(producer, may_need_duplication) +for i in range(len(op.getarglist())): +arg = op.getarg(i) +if arg in self.duplicates: +for box in self.duplicates[arg]: +if box in self.short_boxes: +newop = self.duplicate(self.short_boxes, op) +newop.setarg(i, box) +# XXX If more than one arg is duplicated this does not give +# all combinations as each argument is treated separately + def debug_print(self, logops): debug_start('jit-short-boxes') for box, op in self.short_boxes.items(): diff --git a/pypy/jit/metainterp/test/test_virtualstate.py b/pypy/jit/metainterp/test/test_virtualstate.py --- a/pypy/jit/metainterp/test/test_virtualstate.py +++ b/pypy/jit/metainterp/test/test_virtualstate.py @@ -1,7 +1,7 @@ import py from pypy.jit.metainterp.optimize import InvalidLoop from pypy.jit.metainterp.optimizeopt.virtualstate import VirtualStateInfo, VStructStateInfo, \ - VArrayStateInfo, NotVirtualStateInfo, VirtualState + VArrayStateInfo, NotVirtualStateInfo, VirtualState, ShortBoxes from pypy.jit.metainterp.optimizeopt.optimizer import OptValue from pypy.jit.metainterp.history import BoxInt, BoxFloat, BoxPtr, ConstInt, ConstPtr from pypy.rpython.lltypesystem import lltype @@ -10,6 +10,7 @@ from pypy.jit.metainterp.history import TreeLoop, LoopToken from pypy.jit.metainterp.optimizeopt.test.test_optimizeopt import FakeDescr, FakeMetaInterpStaticData from pypy.jit.metainterp.optimize import RetraceLoop +from pypy.jit.metainterp.resoperation import ResOperation, rop class TestBasic: someptr1 = LLtypeMixin.myptr @@ -128,6 +129,7 @@ info.fieldstate = [info] assert info.generalization_of(info, {}, {}) + class BaseTestGenerateGuards(BaseTest): def guards(self, info1, info2, box, expected): info1.position = info2.position = 0 @@ -909,3 +911,88 @@ class TestLLtypeBridges(BaseTestBridges, LLtypeMixin): pass +class FakeOptimizer: +def make_equal_to(*args): +pass +def getvalue(*args): +pass + +class TestShortBoxes: +p1 = BoxPtr() +p2 = BoxPtr() +i1 = BoxInt() +i2 = BoxInt() +i3 = BoxInt() + +def test_short_box_duplication_direct(self): +class Optimizer(FakeOptimizer): +def produce_potential_short_preamble_ops(_self, sb): +sb.add_potential(ResOperation(rop.GETFIELD_GC, [self.p1], self.i1)) +sb.add_potential(ResOperation(rop.GETFIELD_GC, [self.p2], self.i1)) +sb = ShortBoxes(Optimizer(), [self.p1, self.p2]) +assert len(sb.short_boxes) == 4 +assert self.i1 in sb.short_boxes +assert sum([op.result is self.i1 for op in sb.short_boxes.values() if op]) == 1 + +def test_short_box_duplication_indirect1(self): +class Optimizer(FakeOptimizer): +def produce_p
[pypy-commit] pypy jit-duplicated_short_boxes: passing test
Author: Hakan Ardo Branch: jit-duplicated_short_boxes Changeset: r46679:912123d46daa Date: 2011-08-21 10:10 +0200 http://bitbucket.org/pypy/pypy/changeset/912123d46daa/ Log:passing test diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py --- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py +++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py @@ -6997,6 +6997,25 @@ """ self.optimize_loop(ops, expected) +def test_cached_pure_func_of_equal_fields(self): +ops = """ +[p5, p6] +i10 = getfield_gc(p5, descr=valuedescr) +i11 = getfield_gc(p6, descr=nextdescr) +i12 = int_add(i10, 7) +i13 = int_add(i11, 7) +call(i12, i13, descr=nonwritedescr) +setfield_gc(p6, i10, descr=nextdescr) +jump(p5, p6) +""" +expected = """ +[p5, p6, i12, i13, i10] +call(i12, i13, descr=nonwritedescr) +setfield_gc(p6, i10, descr=nextdescr) +jump(p5, p6, i12, i12, i10) +""" +self.optimize_loop(ops, expected) + def test_forced_counter(self): # XXX: VIRTUALHEAP (see above) py.test.skip("would be fixed by make heap optimizer aware of virtual setfields") ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy custom-trace: Closing this branch. It's better to work in a single branch, 'stacklet'.
Author: Armin Rigo Branch: custom-trace Changeset: r46680:c54a9a93a0cf Date: 2011-08-20 12:42 +0200 http://bitbucket.org/pypy/pypy/changeset/c54a9a93a0cf/ Log:Closing this branch. It's better to work in a single branch, 'stacklet'. ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Backout 1f8c162174c6. It fails some tests, in test_stringobject
Author: Armin Rigo Branch: Changeset: r46681:45f85f655b26 Date: 2011-08-21 11:09 +0200 http://bitbucket.org/pypy/pypy/changeset/45f85f655b26/ Log:Backout 1f8c162174c6. It fails some tests, in test_stringobject (obvious place). 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 @@ -924,36 +924,35 @@ for i in range(len(s)): c = s[i] -if not '\x20' <= c < '\x7f': -use_bs_char = False # character quoted by backspace +use_bs_char = False # character quoted by backspace -if c == '\\' or c == quote: -bs_char = c -use_bs_char = True -elif c == '\t': -bs_char = 't' -use_bs_char = True -elif c == '\r': -bs_char = 'r' -use_bs_char = True -elif c == '\n': -bs_char = 'n' -use_bs_char = True -else: -n = ord(c) -if i != startslice: -buf.append_slice(s, startslice, i) -startslice = i + 1 -buf.append('\\x') -buf.append("0123456789abcdef"[n>>4]) -buf.append("0123456789abcdef"[n&0xF]) +if c == '\\' or c == quote: +bs_char = c +use_bs_char = True +elif c == '\t': +bs_char = 't' +use_bs_char = True +elif c == '\r': +bs_char = 'r' +use_bs_char = True +elif c == '\n': +bs_char = 'n' +use_bs_char = True +elif not '\x20' <= c < '\x7f': +n = ord(c) +if i != startslice: +buf.append_slice(s, startslice, i) +startslice = i + 1 +buf.append('\\x') +buf.append("0123456789abcdef"[n>>4]) +buf.append("0123456789abcdef"[n&0xF]) -if use_bs_char: -if i != startslice: -buf.append_slice(s, startslice, i) -startslice = i + 1 -buf.append('\\') -buf.append(bs_char) +if use_bs_char: +if i != startslice: +buf.append_slice(s, startslice, i) +startslice = i + 1 +buf.append('\\') +buf.append(bs_char) if len(s) != startslice: buf.append_slice(s, startslice, len(s)) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Fix the test by properly detecting the case during codewriting,
Author: Armin Rigo Branch: Changeset: r46682:e5fb197506d6 Date: 2011-08-21 11:31 +0200 http://bitbucket.org/pypy/pypy/changeset/e5fb197506d6/ Log:Fix the test by properly detecting the case during codewriting, and raising NotImplementedError. 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 @@ -571,6 +571,7 @@ pure = '_pure' else: pure = '' +self.check_field_access(v_inst.concretetype.TO) argname = getattr(v_inst.concretetype.TO, '_gckind', 'gc') descr = self.cpu.fielddescrof(v_inst.concretetype.TO, c_fieldname.value) @@ -604,6 +605,7 @@ return [SpaceOperation('-live-', [], None), SpaceOperation('setfield_vable_%s' % kind, [v_inst, descr, v_value], None)] +self.check_field_access(v_inst.concretetype.TO) argname = getattr(v_inst.concretetype.TO, '_gckind', 'gc') descr = self.cpu.fielddescrof(v_inst.concretetype.TO, c_fieldname.value) @@ -616,6 +618,22 @@ return (op.args[1].value == 'typeptr' and op.args[0].concretetype.TO._hints.get('typeptr')) +def check_field_access(self, STRUCT): +# check against a GcStruct with a nested GcStruct as a first argument +# but which is not an object at all; see metainterp/test/test_loop, +# test_regular_pointers_in_short_preamble. +if not isinstance(STRUCT, lltype.GcStruct): +return +if STRUCT._first_struct() == (None, None): +return +PARENT = STRUCT +while not PARENT._hints.get('typeptr'): +_, PARENT = PARENT._first_struct() +if PARENT is None: +raise NotImplementedError("%r is a GcStruct using nesting but " + "not inheriting from object" % + (STRUCT,)) + def get_vinfo(self, v_virtualizable): if self.callcontrol is None: # for tests return None diff --git a/pypy/jit/codewriter/test/test_jtransform.py b/pypy/jit/codewriter/test/test_jtransform.py --- a/pypy/jit/codewriter/test/test_jtransform.py +++ b/pypy/jit/codewriter/test/test_jtransform.py @@ -1014,3 +1014,13 @@ assert op1.opname == 'jit_force_quasi_immutable' assert op1.args[0] == v_x assert op1.args[1] == ('fielddescr', STRUCT, 'mutate_x') + +def test_no_gcstruct_nesting_outside_of_OBJECT(): +PARENT = lltype.GcStruct('parent') +STRUCT = lltype.GcStruct('struct', ('parent', PARENT), + ('x', lltype.Signed)) +v_x = varoftype(lltype.Ptr(STRUCT)) +op = SpaceOperation('getfield', [v_x, Constant('x', lltype.Void)], +varoftype(lltype.Signed)) +tr = Transformer(None, None) +raises(NotImplementedError, tr.rewrite_operation, op) diff --git a/pypy/jit/metainterp/test/test_loop.py b/pypy/jit/metainterp/test/test_loop.py --- a/pypy/jit/metainterp/test/test_loop.py +++ b/pypy/jit/metainterp/test/test_loop.py @@ -801,8 +801,6 @@ res = self.meta_interp(f, [200]) def test_regular_pointers_in_short_preamble(self): -# XXX do we really care about this case? If not, we should -# at least detect it and complain during codewriter/jtransform from pypy.rpython.lltypesystem import lltype BASE = lltype.GcStruct('BASE') A = lltype.GcStruct('A', ('parent', BASE), ('val', lltype.Signed)) @@ -829,9 +827,8 @@ assert n>0 and m>0 i += j return sa -expected = f(20, 10, 1) -res = self.meta_interp(f, [20, 10, 1]) -assert res == expected +# This is detected as invalid by the codewriter, for now +py.test.raises(NotImplementedError, self.meta_interp, f, [20, 10, 1]) def test_unerased_pointers_in_short_preamble(self): from pypy.rlib.rerased import new_erasing_pair ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy stacklet: Rewrite the logic to handle threads in the shadowstack root finder.
Author: Armin Rigo Branch: stacklet Changeset: r46683:8452ff8bb035 Date: 2011-08-21 13:53 +0200 http://bitbucket.org/pypy/pypy/changeset/8452ff8bb035/ Log:Rewrite the logic to handle threads in the shadowstack root finder. Based now on custom_trace. This should be better because it allows thread that block for a long time to not have their shadowstack scanned again and again at every minor collection. It should also allow us to reduce virtual memory usage by putting a limit on the number of full-blown shadowstacks around (useful on 32 bits if you have many threads). This last benefit is the key to this rewrite, which will make it reasonable to use the same code for stacklets too (future work). diff --git a/pypy/module/thread/os_thread.py b/pypy/module/thread/os_thread.py --- a/pypy/module/thread/os_thread.py +++ b/pypy/module/thread/os_thread.py @@ -15,11 +15,6 @@ # * The start-up data (the app-level callable and arguments) is # stored in the global bootstrapper object. # -# * The GC is notified that a new thread is about to start; in the -# framework GC with shadow stacks, this allocates a fresh new shadow -# stack (but doesn't use it yet). See gc_thread_prepare(). This -# has no effect in asmgcc. -# # * The new thread is launched at RPython level using an rffi call # to the C function RPyThreadStart() defined in # translator/c/src/thread*.h. This RPython thread will invoke the @@ -33,8 +28,8 @@ # operation is called (this is all done by gil.after_external_call(), # called from the rffi-generated wrapper). The gc_thread_run() # operation will automatically notice that the current thread id was -# not seen before, and start using the freshly prepared shadow stack. -# Again, this has no effect in asmgcc. +# not seen before, and (in shadowstack) it will allocate and use a +# fresh new stack. Again, this has no effect in asmgcc. # # * Only then does bootstrap() really run. The first thing it does # is grab the start-up information (app-level callable and args) @@ -180,7 +175,7 @@ bootstrapper.acquire(space, w_callable, args) try: try: -thread.gc_thread_prepare() +thread.gc_thread_prepare() # (this has no effect any more) ident = thread.start_new_thread(bootstrapper.bootstrap, ()) except Exception, e: bootstrapper.release() # normally called by the new thread diff --git a/pypy/rpython/lltypesystem/lloperation.py b/pypy/rpython/lltypesystem/lloperation.py --- a/pypy/rpython/lltypesystem/lloperation.py +++ b/pypy/rpython/lltypesystem/lloperation.py @@ -479,8 +479,9 @@ # ^^^ returns an address of nursery free pointer, for later modifications 'gc_adr_of_nursery_top' : LLOp(), # ^^^ returns an address of pointer, since it can change at runtime +'gc_adr_of_root_stack_base': LLOp(), 'gc_adr_of_root_stack_top': LLOp(), -# ^^^ returns the address of gcdata.root_stack_top (for shadowstack only) +# returns the address of gcdata.root_stack_base/top (for shadowstack only) # for asmgcroot support to get the address of various static structures # see translator/c/src/mem.h for the valid indices diff --git a/pypy/rpython/memory/gctransform/framework.py b/pypy/rpython/memory/gctransform/framework.py --- a/pypy/rpython/memory/gctransform/framework.py +++ b/pypy/rpython/memory/gctransform/framework.py @@ -132,7 +132,6 @@ return result class FrameworkGCTransformer(GCTransformer): -root_stack_depth = 163840 def __init__(self, translator): from pypy.rpython.memory.gc.base import choose_gc_from_config @@ -742,8 +741,13 @@ resultvar=op.result) def gct_gc_assume_young_pointers(self, hop): +if not hasattr(self, 'assume_young_pointers_ptr'): +return op = hop.spaceop v_addr = op.args[0] +if v_addr.concretetype != llmemory.Address: +v_addr = hop.genop('cast_ptr_to_adr', + [v_addr], resulttype=llmemory.Address) hop.genop("direct_call", [self.assume_young_pointers_ptr, self.c_const_gc, v_addr]) @@ -762,37 +766,37 @@ hop.genop("direct_call", [self.get_member_index_ptr, self.c_const_gc, v_typeid], resultvar=op.result) -def gct_gc_adr_of_nursery_free(self, hop): -if getattr(self.gcdata.gc, 'nursery_free', None) is None: -raise NotImplementedError("gc_adr_of_nursery_free only for generational gcs") +def _gc_adr_of_gc_attr(self, hop, attrname): +if getattr(self.gcdata.gc, attrname, None) is None: +raise NotImplementedError("gc_adr_of_%s only for generational gcs" + % (attrname,)) op = hop.spaceop ofs = llmemory.offsetof(self.c_const_gc.concretetype.TO, -
[pypy-commit] pypy jit-duplicated_short_boxes: only accept loop invariant ops into the short preamble
Author: Hakan Ardo Branch: jit-duplicated_short_boxes Changeset: r46684:5a623ddb5a5c Date: 2011-08-21 15:52 +0200 http://bitbucket.org/pypy/pypy/changeset/5a623ddb5a5c/ Log:only accept loop invariant ops into the short preamble diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py b/pypy/jit/metainterp/optimizeopt/unroll.py --- a/pypy/jit/metainterp/optimizeopt/unroll.py +++ b/pypy/jit/metainterp/optimizeopt/unroll.py @@ -129,13 +129,26 @@ inputargs = virtual_state.make_inputargs(values) short_inputargs = virtual_state.make_inputargs(values, keyboxes=True) +loop_invariants = [] +assert len(jump_args) == len(loop.inputargs) +for i in range(len(jump_args)): +v1 = self.getvalue(jump_args[i]) +v2 = self.getvalue(loop.inputargs[i]) +if v1 is v2: +loop_invariants.append(jump_args[i]) + self.constant_inputargs = {} for box in jump_args: const = self.get_constant_box(box) if const: self.constant_inputargs[box] = const -sb = ShortBoxes(self.optimizer, inputargs + self.constant_inputargs.keys()) +if os.getenv('FULLSHORT'): +sb = ShortBoxes(self.optimizer, +inputargs + self.constant_inputargs.keys()) +else: +sb = ShortBoxes(self.optimizer, +loop_invariants + self.constant_inputargs.keys()) self.short_boxes = sb preamble_optimizer = self.optimizer loop.preamble.quasi_immutable_deps = ( diff --git a/pypy/jit/metainterp/optimizeopt/virtualstate.py b/pypy/jit/metainterp/optimizeopt/virtualstate.py --- a/pypy/jit/metainterp/optimizeopt/virtualstate.py +++ b/pypy/jit/metainterp/optimizeopt/virtualstate.py @@ -12,6 +12,7 @@ from pypy.rlib.objectmodel import we_are_translated from pypy.rlib.debug import debug_start, debug_stop, debug_print from pypy.rlib.objectmodel import we_are_translated +import os class AbstractVirtualStateInfo(resume.AbstractVirtualInfo): position = -1 @@ -475,8 +476,8 @@ self.produce_short_preamble_box(box) except BoxNotProducable: pass - -self.duplicate_short_boxes_if_needed() +if not os.getenv('DONT_DUPLICATE'): +self.duplicate_short_boxes_if_needed() def produce_short_preamble_box(self, box): if box in self.short_boxes: diff --git a/pypy/jit/metainterp/test/test_virtualstate.py b/pypy/jit/metainterp/test/test_virtualstate.py --- a/pypy/jit/metainterp/test/test_virtualstate.py +++ b/pypy/jit/metainterp/test/test_virtualstate.py @@ -996,3 +996,10 @@ self.i3)) sb = ShortBoxes(Optimizer(), [self.p1, self.p2]) assert len(sb.short_boxes) == 5 + +def duplicate_duplicaded_box(self): +pass + +def duplucate_on_both_arguments(self): +pass + ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy stacklet: JIT support.
Author: Armin Rigo Branch: stacklet Changeset: r46685:a36e8d5c70a1 Date: 2011-08-21 14:08 +0200 http://bitbucket.org/pypy/pypy/changeset/a36e8d5c70a1/ Log:JIT support. 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 @@ -83,6 +83,7 @@ # gc_thread_run and gc_thread_die. See docstrings below. shadow_stack_pool = self.shadow_stack_pool +SHADOWSTACKREF = make_shadowstackref(gctransformer) # this is a dict {tid: SHADOWSTACKREF}, where the tid for the # current thread may be missing so far @@ -137,12 +138,12 @@ raise KeyError new_ref = thread_stacks[new_tid] except KeyError: -new_ref = NULL_SHADOWSTACKREF +new_ref = lltype.nullptr(SHADOWSTACKREF) try: old_ref = thread_stacks[gcdata.active_tid] except KeyError: # first time we ask for a SHADOWSTACKREF for this active_tid -old_ref = shadow_stack_pool.allocate() +old_ref = shadow_stack_pool.allocate(SHADOWSTACKREF) thread_stacks[gcdata.active_tid] = old_ref # # no GC operation from here -- switching shadowstack! @@ -208,7 +209,7 @@ self._prepare_unused_stack() self.start_fresh_new_state() -def allocate(self): +def allocate(self, SHADOWSTACKREF): """Allocate an empty SHADOWSTACKREF object.""" return lltype.malloc(SHADOWSTACKREF, zero=True) @@ -250,25 +251,38 @@ raise MemoryError -SHADOWSTACKREFPTR = lltype.Ptr(lltype.GcForwardReference()) -SHADOWSTACKREF = lltype.GcStruct('ShadowStackRef', - ('base', llmemory.Address), - ('top', llmemory.Address), - #('fullstack', lltype.Bool), - rtti=True) -SHADOWSTACKREFPTR.TO.become(SHADOWSTACKREF) -NULL_SHADOWSTACKREF = lltype.nullptr(SHADOWSTACKREF) +def make_shadowstackref(gctransformer): +SHADOWSTACKREFPTR = lltype.Ptr(lltype.GcForwardReference()) +SHADOWSTACKREF = lltype.GcStruct('ShadowStackRef', + ('base', llmemory.Address), + ('top', llmemory.Address), + #('fullstack', lltype.Bool), + rtti=True) +SHADOWSTACKREFPTR.TO.become(SHADOWSTACKREF) -def customtrace(obj, prev): -# a simple but not JIT-ready version -if not prev: -prev = llmemory.cast_adr_to_ptr(obj, SHADOWSTACKREFPTR).top -if prev != llmemory.cast_adr_to_ptr(obj, SHADOWSTACKREFPTR).base: -return prev - sizeofaddr +translator = gctransformer.translator +if hasattr(translator, '_jit2gc'): +iterator_setup = translator._jit2gc['root_iterator_setup'] +iterator_next = translator._jit2gc['root_iterator_next'] +def customtrace(obj, prev): +if not prev: +iterator_setup() +prev = llmemory.cast_adr_to_ptr(obj, SHADOWSTACKREFPTR).top +base = llmemory.cast_adr_to_ptr(obj, SHADOWSTACKREFPTR).base +return iterator_next(prev, base) else: -return llmemory.NULL +def customtrace(obj, prev): +# a simple but not JIT-ready version +if not prev: +prev = llmemory.cast_adr_to_ptr(obj, SHADOWSTACKREFPTR).top +if prev != llmemory.cast_adr_to_ptr(obj, SHADOWSTACKREFPTR).base: +return prev - sizeofaddr +else: +return llmemory.NULL -CUSTOMTRACEFUNC = lltype.FuncType([llmemory.Address, llmemory.Address], - llmemory.Address) -customtraceptr = llhelper(lltype.Ptr(CUSTOMTRACEFUNC), customtrace) -lltype.attachRuntimeTypeInfo(SHADOWSTACKREF, customtraceptr=customtraceptr) +CUSTOMTRACEFUNC = lltype.FuncType([llmemory.Address, llmemory.Address], + llmemory.Address) +customtraceptr = llhelper(lltype.Ptr(CUSTOMTRACEFUNC), customtrace) +lltype.attachRuntimeTypeInfo(SHADOWSTACKREF, customtraceptr=customtraceptr) + +return SHADOWSTACKREF ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy stacklet: Fixes, and also copies most of the last checkin done in the
Author: Armin Rigo Branch: stacklet Changeset: r46686:b02950d06234 Date: 2011-08-21 14:09 + http://bitbucket.org/pypy/pypy/changeset/b02950d06234/ Log:Fixes, and also copies most of the last checkin done in the custom- trace branch. 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 @@ -373,85 +373,85 @@ # rlib/_stacklet_shadowstack. That's why it is written as # an iterator that can also be used with a custom_trace. # -def iterator_setup(): -self._iter_frame_addr = llmemory.NULL -self._iter_callshape = llmemory.NULL -self._iter_saved_prev = llmemory.NULL -# -def iterator_next(gc, prev, range_lowest): -# Return the "next" valid GC object' address. "prev" is the -# previous result (or the highest end of the shadowstack to start -# with), and "range_lowest" is the lowest end of the shadowstack. -# We enumerating backwards, starting from the higher addresses. -# -while True: +class RootIterator: +_alloc_flavor_ = "raw" +frame_addr = 0 + +def next(iself, gc, prev, range_lowest): +# Return the "next" valid GC object' address. We enumerating +# backwards, starting from the high addresses, until we reach +# the 'range_lowest'. The 'prev' argument is the previous +# result (or the high end of the shadowstack to start with). # -# If we are not iterating right now in a JIT frame -if self._iter_frame_addr == llmemory.NULL: +while True: # -# Look for the previous shadowstack address that contains -# a valid pointer -while prev != range_lowest: -prev -= llmemory.sizeof(llmemory.Address) -if gc.points_to_valid_gc_object(prev): -break +# If we are not iterating right now in a JIT frame +if iself.frame_addr == 0: +# +# Look for the previous shadowstack address that +# contains a valid pointer +while prev != range_lowest: +prev -= llmemory.sizeof(llmemory.Address) +if gc.points_to_valid_gc_object(prev): +break +else: +return llmemory.NULL +# +# Now a "valid" pointer can be either really valid, or +# it can be a pointer to a JIT frame in the stack. The +# important part here is that points_to_valid_gc_object +# above returns True even for a pointer to a MARKER +# (which is word-aligned). +if prev.address[0].signed[0] != self.MARKER: +return prev +# +# It's a JIT frame. Save away 'prev' for later, and +# go into JIT-frame-exploring mode. +iself.saved_prev = prev +frame_addr = prev.signed[0] - self.marker_ofs +iself.frame_addr = frame_addr +addr = llmemory.cast_int_to_adr(frame_addr + +self.force_index_ofs) +force_index = addr.signed[0] +if force_index < 0: +force_index = ~force_index +# NB: the next line reads a still-alive _callshapes, +# because we ensure that just before we called this +# piece of assembler, we put on the (same) stack a +# pointer to a loop_token that keeps the force_index +# alive. +callshape = self._callshapes[force_index] else: -return llmemory.NULL +# Continuing to explore this JIT frame +callshape = iself.callshape # -# Now a "valid" pointer can be either really valid, or it -# can be a pointer to a JIT frame in the stack. The -# important part here is that 'points_to_valid_gc_object' -# above returns True even for a pointer to a MARKER -# (which is word-aligned). -if prev.address[0].signed[0] != self.MARKER: -return prev +
[pypy-commit] pypy jit-duplicated_short_boxes: kill env vars
Author: Hakan Ardo Branch: jit-duplicated_short_boxes Changeset: r46687:2362395bd8b6 Date: 2011-08-21 17:05 +0200 http://bitbucket.org/pypy/pypy/changeset/2362395bd8b6/ Log:kill env vars diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py b/pypy/jit/metainterp/optimizeopt/unroll.py --- a/pypy/jit/metainterp/optimizeopt/unroll.py +++ b/pypy/jit/metainterp/optimizeopt/unroll.py @@ -143,12 +143,8 @@ if const: self.constant_inputargs[box] = const -if os.getenv('FULLSHORT'): -sb = ShortBoxes(self.optimizer, -inputargs + self.constant_inputargs.keys()) -else: -sb = ShortBoxes(self.optimizer, -loop_invariants + self.constant_inputargs.keys()) +sb = ShortBoxes(self.optimizer, +loop_invariants + self.constant_inputargs.keys()) self.short_boxes = sb preamble_optimizer = self.optimizer loop.preamble.quasi_immutable_deps = ( diff --git a/pypy/jit/metainterp/optimizeopt/virtualstate.py b/pypy/jit/metainterp/optimizeopt/virtualstate.py --- a/pypy/jit/metainterp/optimizeopt/virtualstate.py +++ b/pypy/jit/metainterp/optimizeopt/virtualstate.py @@ -476,8 +476,7 @@ self.produce_short_preamble_box(box) except BoxNotProducable: pass -if not os.getenv('DONT_DUPLICATE'): -self.duplicate_short_boxes_if_needed() +self.duplicate_short_boxes_if_needed() def produce_short_preamble_box(self, box): if box in self.short_boxes: ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy stacklet: Update the doc of the module.
Author: Armin Rigo Branch: stacklet Changeset: r46688:a042078c604e Date: 2011-08-21 17:37 +0200 http://bitbucket.org/pypy/pypy/changeset/a042078c604e/ Log:Update the doc of the module. diff --git a/pypy/module/_continuation/__init__.py b/pypy/module/_continuation/__init__.py --- a/pypy/module/_continuation/__init__.py +++ b/pypy/module/_continuation/__init__.py @@ -4,26 +4,29 @@ class Module(MixedModule): """This module exposes 'one-shot continuation containers'. -A 'continuation' object from this module is a container that stores a +A 'continulet' object from this module is a container that stores a one-shot continuation. It is similar in purpose to the 'f_back' attribute of frames, which points to where execution should continue after this frame finishes. The difference is that it will be changed (often repeatedly) before the frame actually returns. -To make a 'continuation' object, call 'continuation' with a callable and -optional extra arguments. When later you switch() to the continuation, -the callable is invoked wih the continuation as extra first argument. +To make a continulet object, call 'continulet' with a callable and +optional extra arguments. Later, the first time you switch() to the +continulet, the callable is invoked wih the same continulet object as +the extra first argument. -At this point, the one-shot continuation stored in the continuation -container points to the caller of switch(). When switch() is called -again, this one-shot continuation is exchanged with the current one; it -means that the caller of switch() is suspended, its continuation stored -in the container, and the old continuation from the container is -resumed. +At this point, the one-shot continuation stored in the continulet points +to the caller of switch(). When switch() is called again, this one-shot +continuation is exchanged with the current one; it means that the caller +of switch() is suspended, its continuation stored in the container, and +the old continuation from the continulet object is resumed. -Flexible frames are internally implemented using stacklets. Stacklets +Continulets are internally implemented using stacklets. Stacklets are a bit more primitive (they are really one-shot continuations), but that idea only works in C, not in Python, notably because of exceptions. + +The most primitive API is actually 'permute()', which just permutes the +one-shot continuation stored in two (or more) continulets. """ appleveldefs = { ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-dtype-alt: more whacking, no progress
Author: Alex Gaynor Branch: numpy-dtype-alt Changeset: r46691:f892f37fec58 Date: 2011-08-21 13:20 -0500 http://bitbucket.org/pypy/pypy/changeset/f892f37fec58/ Log:more whacking, no progress 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 @@ -2,7 +2,7 @@ from pypy.jit.metainterp.test.support import LLJitMixin from pypy.module.micronumpy.compile import numpy_compile from pypy.module.micronumpy.interp_dtype import W_Float64Dtype -from pypy.module.micronumpy.interp_numarray import SingleDimArray, Scalar +from pypy.module.micronumpy.interp_numarray import SingleDimArray, scalar_w from pypy.module.micronumpy.interp_ufuncs import negative, add from pypy.rlib.nonconst import NonConstant from pypy.rlib.objectmodel import specialize @@ -22,6 +22,9 @@ def wrap(self, w_obj): return w_obj +def float(self, w_obj): +return float(w_obj) + def float_w(self, w_obj): return float(w_obj) @@ -46,7 +49,7 @@ def test_floatadd(self): def f(i): ar = SingleDimArray(i, dtype=self.float64_dtype) -v = add(self.space, ar, Scalar(self.float64_dtype, self.float64_dtype.box(4.5))) +v = add(self.space, ar, scalar_w(self.space, W_Float64Dtype, 4.5)) return v.dtype.getitem(v.get_concrete().storage, 3) result = self.meta_interp(f, [5], listops=True, backendopt=True) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-dtype-alt: update the TODO
Author: Alex Gaynor Branch: numpy-dtype-alt Changeset: r46690:e1516c06fe86 Date: 2011-08-21 13:14 -0500 http://bitbucket.org/pypy/pypy/changeset/e1516c06fe86/ Log:update the TODO diff --git a/TODO.txt b/TODO.txt --- a/TODO.txt +++ b/TODO.txt @@ -1,7 +1,7 @@ TODO for mering numpy-dtype-alt === -* Fix for raw memory with the JIT under llgraph. +* Fix test_zjit * More operations on more dtypes * dtype guessing * Any more attributes that need to be exposed at app-level ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-dtype-alt: Introduce a new hint on lltype arrays, uncast_on_llgraph, which tells the llgraph backend to cast them to the correct types.
Author: Alex Gaynor Branch: numpy-dtype-alt Changeset: r46689:21deb620ea89 Date: 2011-08-21 13:09 -0500 http://bitbucket.org/pypy/pypy/changeset/21deb620ea89/ Log:Introduce a new hint on lltype arrays, uncast_on_llgraph, which tells the llgraph backend to cast them to the correct types. This is needed since casts are removed by the codewriter. Started fixing micronumpy zjit tests, still some work (annoying since it really translates). diff --git a/pypy/jit/backend/llgraph/llimpl.py b/pypy/jit/backend/llgraph/llimpl.py --- a/pypy/jit/backend/llgraph/llimpl.py +++ b/pypy/jit/backend/llgraph/llimpl.py @@ -57,6 +57,12 @@ else: return LLSupport.from_rstr(s) +FLOAT_ARRAY_TP = lltype.Ptr(lltype.Array(lltype.Float, hints={"nolength": True})) +def maybe_uncast(TP, array): +if array._TYPE.TO._hints.get("uncast_on_llgraph"): +array = rffi.cast(TP, array) +return array + # a list of argtypes of all operations - couldn't find any and it's # very useful. Note however that the table is half-broken here and # there, in ways that are sometimes a bit hard to fix; that's why @@ -1079,7 +1085,7 @@ if isinstance(TYPE, lltype.Ptr): if isinstance(x, (int, long, llmemory.AddressAsInt)): x = llmemory.cast_int_to_adr(x) -if TYPE is rffi.VOIDP: +if TYPE is rffi.VOIDP or TYPE.TO._hints.get("uncast_on_llgraph"): # assume that we want a "C-style" cast, without typechecking the value return rffi.cast(TYPE, x) return llmemory.cast_adr_to_ptr(x, TYPE) @@ -1329,8 +1335,8 @@ return cast_to_floatstorage(array.getitem(index)) def do_getarrayitem_raw_float(array, index): -array = array.adr.ptr._obj -return cast_to_floatstorage(array.getitem(index)) +array = maybe_uncast(FLOAT_ARRAY_TP, array.adr.ptr) +return cast_to_floatstorage(array._obj.getitem(index)) def do_getarrayitem_gc_ptr(array, index): array = array._obj.container @@ -1392,8 +1398,9 @@ newvalue = cast_from_floatstorage(ITEMTYPE, newvalue) array.setitem(index, newvalue) + def do_setarrayitem_raw_float(array, index, newvalue): -array = array.adr.ptr +array = maybe_uncast(FLOAT_ARRAY_TP, array.adr.ptr) ITEMTYPE = lltype.typeOf(array).TO.OF newvalue = cast_from_floatstorage(ITEMTYPE, newvalue) array._obj.setitem(index, newvalue) diff --git a/pypy/jit/metainterp/test/test_rawmem.py b/pypy/jit/metainterp/test/test_rawmem.py --- a/pypy/jit/metainterp/test/test_rawmem.py +++ b/pypy/jit/metainterp/test/test_rawmem.py @@ -5,7 +5,7 @@ class TestJITRawMem(LLJitMixin): def test_cast_void_ptr(self): TP = lltype.Array(lltype.Float, hints={"nolength": True}) -VOID_TP = lltype.Array(lltype.Void, hints={"nolength": True}) +VOID_TP = lltype.Array(lltype.Void, hints={"nolength": True, "uncast_on_llgraph": True}) class A(object): def __init__(self, x): self.storage = rffi.cast(lltype.Ptr(VOID_TP), x)\ 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 @@ -3,24 +3,29 @@ It should not be imported by the module itself """ +from pypy.interpreter.baseobjspace import InternalSpaceCache +from pypy.module.micronumpy.interp_dtype import W_Float64Dtype from pypy.module.micronumpy.interp_numarray import Scalar, SingleDimArray, BaseArray class BogusBytecode(Exception): pass -def create_array(size): -a = SingleDimArray(size) +def create_array(dtype, size): +a = SingleDimArray(size, dtype=dtype) for i in range(size): -a.storage[i] = float(i % 10) +dtype.setitem(a.storage, i, dtype.box(float(i % 10))) return a class TrivialSpace(object): +def __init__(self): +self.fromcache = InternalSpaceCache(self).getorbuild + def wrap(self, x): return x def issequence_w(self, w_obj): -# Completley wrong in the general case, but good enough for this. +# Completely wrong in the general case, but good enough for this. return isinstance(w_obj, BaseArray) def float_w(self, w_obj): @@ -31,12 +36,13 @@ space = TrivialSpace() stack = [] i = 0 +dtype = space.fromcache(W_Float64Dtype) for b in bytecode: if b == 'a': -stack.append(create_array(array_size)) +stack.append(create_array(dtype, array_size)) i += 1 elif b == 'f': -stack.append(Scalar(1.2)) +stack.append(Scalar(dtype, dtype.box(1.2))) elif b == '+': right = stack.pop() stack.append(stack.pop().descr_add(space, right)) 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 @@ -45,7 +45,7 @@ class Bas
[pypy-commit] pypy numpy-dtype-alt: random progress, most of them don't work for obscure reasons still
Author: Alex Gaynor Branch: numpy-dtype-alt Changeset: r46692:7501f32f96eb Date: 2011-08-21 13:35 -0500 http://bitbucket.org/pypy/pypy/changeset/7501f32f96eb/ Log:random progress, most of them don't work for obscure reasons still 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 @@ -1,9 +1,9 @@ from pypy.interpreter.baseobjspace import InternalSpaceCache from pypy.jit.metainterp.test.support import LLJitMixin +from pypy.module.micronumpy import interp_ufuncs, signature from pypy.module.micronumpy.compile import numpy_compile from pypy.module.micronumpy.interp_dtype import W_Float64Dtype -from pypy.module.micronumpy.interp_numarray import SingleDimArray, scalar_w -from pypy.module.micronumpy.interp_ufuncs import negative, add +from pypy.module.micronumpy.interp_numarray import SingleDimArray, SingleDimSlice, scalar_w from pypy.rlib.nonconst import NonConstant from pypy.rlib.objectmodel import specialize from pypy.rpython.test.test_llinterp import interpret @@ -36,7 +36,7 @@ def test_add(self): def f(i): ar = SingleDimArray(i, dtype=self.float64_dtype) -v = add(self.space, ar, ar) +v = interp_ufuncs.add(self.space, ar, ar) concrete = v.get_concrete() return concrete.dtype.getitem(concrete.storage, 3).val @@ -49,7 +49,7 @@ def test_floatadd(self): def f(i): ar = SingleDimArray(i, dtype=self.float64_dtype) -v = add(self.space, ar, scalar_w(self.space, W_Float64Dtype, 4.5)) +v = interp_ufuncs.add(self.space, ar, scalar_w(self.space, W_Float64Dtype, 4.5)) return v.dtype.getitem(v.get_concrete().storage, 3) result = self.meta_interp(f, [5], listops=True, backendopt=True) @@ -62,7 +62,7 @@ space = self.space def f(i): -ar = SingleDimArray(i) +ar = SingleDimArray(i, dtype=self.float64_dtype) return ar.descr_add(space, ar).descr_sum(space) result = self.meta_interp(f, [5], listops=True, backendopt=True) @@ -75,7 +75,7 @@ space = self.space def f(i): -ar = SingleDimArray(i) +ar = SingleDimArray(i, dtype=self.float64_dtype) return ar.descr_add(space, ar).descr_prod(space) result = self.meta_interp(f, [5], listops=True, backendopt=True) @@ -88,7 +88,7 @@ space = self.space def f(i): -ar = SingleDimArray(i) +ar = SingleDimArray(i, dtype=self.float64_dtype) j = 0 while j < i: ar.get_concrete().storage[j] = float(j) @@ -106,7 +106,7 @@ space = self.space def f(i): -ar = SingleDimArray(i) +ar = SingleDimArray(i, dtype=self.float64_dtype) j = 0 while j < i: ar.get_concrete().storage[j] = float(j) @@ -124,7 +124,7 @@ space = self.space def f(i): -ar = SingleDimArray(i) +ar = SingleDimArray(i, dtype=self.float64_dtype) j = 0 while j < i: ar.get_concrete().storage[j] = float(j) @@ -142,7 +142,7 @@ space = self.space def f(i): -ar = SingleDimArray(i) +ar = SingleDimArray(i, dtype=self.float64_dtype) j = 0 while j < i: ar.get_concrete().storage[j] = 1.0 @@ -158,7 +158,7 @@ space = self.space def f(i): -ar = SingleDimArray(i) +ar = SingleDimArray(i, dtype=self.float64_dtype) return ar.descr_add(space, ar).descr_any(space) result = self.meta_interp(f, [5], listops=True, backendopt=True) @@ -167,11 +167,11 @@ "int_lt": 1, "guard_true": 1, "jump": 1}) assert result == f(5) -def test_already_forecd(self): +def test_already_forced(self): def f(i): -ar = SingleDimArray(i) -v1 = Call2(add, ar, Scalar(4.5), Signature()) -v2 = Call2(mul, v1, Scalar(4.5), Signature()) +ar = SingleDimArray(i, dtype=self.float64_dtype) +v1 = interp_ufuncs.add(self.space, ar, scalar_w(self.space, W_Float64Dtype, 4.5)) +v2 = interp_ufuncs.mul(self.space, v1, scalar_w(self.space, W_Float64Dtype, 4.5)) v1.force_if_needed() return v2.get_concrete().storage[3] @@ -187,9 +187,9 @@ def test_ufunc(self): space = self.space def f(i): -ar = SingleDimArray(i) -v1 = Call2(add, ar, ar, Signature()) -v2 = negative(space, v1) +ar = SingleDimArray(i, dtype=self.float64_dtype) +v1 = interp_ufuncs.add(space, ar, ar) +v2 = interp_ufuncs.negative(space, v1) return v2.get_
[pypy-commit] Notification: pypyfreebsdfix
You have received a notification from Gabriel Lavoie. Hi, I forked pypy. My fork is at https://bitbucket.org/glavoie/pypyfreebsdfix. -- Disable notifications at https://bitbucket.org/account/notifications/ ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] [OPEN] Pull request #6 for pypy/pypy: Some fixes for FreeBSD translation
A new pull request has been opened by Gabriel Lavoie. glavoie/pypyfreebsdfix has changes to be pulled into pypy/pypy. https://bitbucket.org/pypy/pypy/pull-request/6/some-fixes-for-freebsd-translation Title: Some fixes for FreeBSD translation - Use FreeBSD's platform configuration to find expat.h and libexpat.so. - Retrieve available system memory for translation process. -- This is an issue notification from bitbucket.org. You are receiving this either because you are the participating in a pull request, or you are following it. ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] Notification: pypy
You have received a notification from Mitchell Hashimoto. Hi, I forked pypy. My fork is at https://bitbucket.org/mitchellh/pypy. -- Disable notifications at https://bitbucket.org/account/notifications/ ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-dtype-alt: bunch of small fixes in the tests.
Author: Alex Gaynor Branch: numpy-dtype-alt Changeset: r46693:58163d20 Date: 2011-08-21 20:15 -0500 http://bitbucket.org/pypy/pypy/changeset/58163d20/ Log:bunch of small fixes in the tests. 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 @@ -37,8 +37,7 @@ def f(i): ar = SingleDimArray(i, dtype=self.float64_dtype) v = interp_ufuncs.add(self.space, ar, ar) -concrete = v.get_concrete() -return concrete.dtype.getitem(concrete.storage, 3).val +return v.get_concrete().eval(3).val result = self.meta_interp(f, [5], listops=True, backendopt=True) self.check_loops({'getarrayitem_raw': 2, 'float_add': 1, @@ -50,7 +49,7 @@ def f(i): ar = SingleDimArray(i, dtype=self.float64_dtype) v = interp_ufuncs.add(self.space, ar, scalar_w(self.space, W_Float64Dtype, 4.5)) -return v.dtype.getitem(v.get_concrete().storage, 3) +return v.get_concrete().eval(3).val result = self.meta_interp(f, [5], listops=True, backendopt=True) self.check_loops({"getarrayitem_raw": 1, "float_add": 1, @@ -91,7 +90,7 @@ ar = SingleDimArray(i, dtype=self.float64_dtype) j = 0 while j < i: -ar.get_concrete().storage[j] = float(j) +ar.get_concrete().setitem(space, j, float(j)) j += 1 return ar.descr_add(space, ar).descr_max(space) @@ -109,7 +108,7 @@ ar = SingleDimArray(i, dtype=self.float64_dtype) j = 0 while j < i: -ar.get_concrete().storage[j] = float(j) +ar.get_concrete().setitem(space, j, float(j)) j += 1 return ar.descr_add(space, ar).descr_min(space) @@ -127,7 +126,7 @@ ar = SingleDimArray(i, dtype=self.float64_dtype) j = 0 while j < i: -ar.get_concrete().storage[j] = float(j) +ar.get_concrete().setitem(space, j, float(j)) j += 1 return ar.descr_add(space, ar).descr_argmin(space) @@ -145,9 +144,10 @@ ar = SingleDimArray(i, dtype=self.float64_dtype) j = 0 while j < i: -ar.get_concrete().storage[j] = 1.0 +ar.get_concrete().setitem(space, j, float(j)) j += 1 return ar.descr_add(space, ar).descr_all(space) + result = self.meta_interp(f, [5], listops=True, backendopt=True) self.check_loops({"getarrayitem_raw": 2, "float_add": 1, "int_add": 1, "float_ne": 1, @@ -171,9 +171,9 @@ def f(i): ar = SingleDimArray(i, dtype=self.float64_dtype) v1 = interp_ufuncs.add(self.space, ar, scalar_w(self.space, W_Float64Dtype, 4.5)) -v2 = interp_ufuncs.mul(self.space, v1, scalar_w(self.space, W_Float64Dtype, 4.5)) +v2 = interp_ufuncs.multiply(self.space, v1, scalar_w(self.space, W_Float64Dtype, 4.5)) v1.force_if_needed() -return v2.get_concrete().storage[3] +return v2.get_concrete().eval(3).val result = self.meta_interp(f, [5], listops=True, backendopt=True) # This is the sum of the ops for both loops, however if you remove the @@ -190,7 +190,7 @@ ar = SingleDimArray(i, dtype=self.float64_dtype) v1 = interp_ufuncs.add(space, ar, ar) v2 = interp_ufuncs.negative(space, v1) -return v2.get_concrete().storage[3] +return v2.get_concrete().eval(3).val result = self.meta_interp(f, [5], listops=True, backendopt=True) self.check_loops({"getarrayitem_raw": 2, "float_add": 1, "float_neg": 1, @@ -209,8 +209,8 @@ v2.get_concrete() for i in xrange(5): -v1 = interp_ufuncs.mul(space, ar, ar) -v2 = negative(space, v1) +v1 = interp_ufuncs.multiply(space, ar, ar) +v2 = interp_ufuncs.negative(space, v1) v2.get_concrete() self.meta_interp(f, [5], listops=True, backendopt=True) @@ -226,7 +226,7 @@ ]) s = SingleDimSlice(0, step*i, step, i, ar, new_sig) v = interp_ufuncs.add(self.space, s, s) -return v.get_concrete().storage[3] +return v.get_concrete().eval(3).val result = self.meta_interp(f, [5], listops=True, backendopt=True) self.check_loops({'int_mul': 1, 'getarrayitem_raw': 2, 'float_add': 1, @@ -238,11 +238,17 @@ def f(i): step1 = 2 step2 = 3 -ar = SingleDimArray(step2*i) -s1 = SingleDimSlice(0, step1*i, step1, i, ar, ar.signature.transition(SingleDimSlice.static_
[pypy-commit] pypy numpy-dtype-alt: another test_zjit test passing.
Author: Alex Gaynor Branch: numpy-dtype-alt Changeset: r46694:d8e0d3c9b375 Date: 2011-08-21 23:18 -0500 http://bitbucket.org/pypy/pypy/changeset/d8e0d3c9b375/ Log:another test_zjit test passing. 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 @@ -403,10 +403,12 @@ return self.res_dtype def _eval(self, i): +val = self.values.eval(i).convert_to(self.res_dtype) + sig = jit.promote(self.signature) +assert isinstance(sig, signature.Signature) call_sig = sig.components[0] assert isinstance(call_sig, signature.Call1) -val = self.values.eval(i).convert_to(self.res_dtype) return call_sig.func(self.res_dtype, val) class Call2(VirtualArray): @@ -432,7 +434,9 @@ def _eval(self, i): lhs = self.left.eval(i).convert_to(self.res_dtype) rhs = self.right.eval(i).convert_to(self.res_dtype) + sig = jit.promote(self.signature) +assert isinstance(sig, signature.Signature) call_sig = sig.components[0] assert isinstance(call_sig, signature.Call2) return call_sig.func(self.res_dtype, lhs, rhs) diff --git a/pypy/module/micronumpy/signature.py b/pypy/module/micronumpy/signature.py --- a/pypy/module/micronumpy/signature.py +++ b/pypy/module/micronumpy/signature.py @@ -18,6 +18,8 @@ return res class BaseSignature(object): +_attrs_ = [] + def eq(self, other): return self is other @@ -27,6 +29,7 @@ class Signature(BaseSignature): _known_sigs = r_dict(components_eq, components_hash) +_attrs_ = ["components"] _immutable_fields_ = ["components[*]"] def __init__(self, components): 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 @@ -1,9 +1,10 @@ -from pypy.interpreter.baseobjspace import InternalSpaceCache +from pypy.interpreter.baseobjspace import InternalSpaceCache, W_Root from pypy.jit.metainterp.test.support import LLJitMixin from pypy.module.micronumpy import interp_ufuncs, signature from pypy.module.micronumpy.compile import numpy_compile from pypy.module.micronumpy.interp_dtype import W_Float64Dtype -from pypy.module.micronumpy.interp_numarray import SingleDimArray, SingleDimSlice, scalar_w +from pypy.module.micronumpy.interp_numarray import (BaseArray, SingleDimArray, +SingleDimSlice, scalar_w) from pypy.rlib.nonconst import NonConstant from pypy.rlib.objectmodel import specialize from pypy.rpython.test.test_llinterp import interpret @@ -19,14 +20,21 @@ return True @specialize.argtype(1) -def wrap(self, w_obj): +def wrap(self, obj): +if isinstance(obj, float): +return FloatObject(obj) +raise Exception + +def float(self, w_obj): +assert isinstance(w_obj, FloatObject) return w_obj -def float(self, w_obj): -return float(w_obj) +def float_w(self, w_obj): +return w_obj.floatval -def float_w(self, w_obj): -return float(w_obj) +class FloatObject(W_Root): +def __init__(self, floatval): +self.floatval = floatval class TestNumpyJIt(LLJitMixin): def setup_class(cls): @@ -48,7 +56,11 @@ def test_floatadd(self): def f(i): ar = SingleDimArray(i, dtype=self.float64_dtype) -v = interp_ufuncs.add(self.space, ar, scalar_w(self.space, W_Float64Dtype, 4.5)) +v = interp_ufuncs.add(self.space, +ar, +scalar_w(self.space, W_Float64Dtype, self.space.wrap(4.5)) +) +assert isinstance(v, BaseArray) return v.get_concrete().eval(3).val result = self.meta_interp(f, [5], listops=True, backendopt=True) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-dtype-alt: Fix all but one of the test_zjit tests. Last one fails for reasons I don't understand. Updated the TODO.
Author: Alex Gaynor Branch: numpy-dtype-alt Changeset: r46695:316788ca486d Date: 2011-08-22 00:03 -0500 http://bitbucket.org/pypy/pypy/changeset/316788ca486d/ Log:Fix all but one of the test_zjit tests. Last one fails for reasons I don't understand. Updated the TODO. diff --git a/TODO.txt b/TODO.txt --- a/TODO.txt +++ b/TODO.txt @@ -1,9 +1,10 @@ TODO for mering numpy-dtype-alt === -* Fix test_zjit +* Fix the last test_zjit * More operations on more dtypes * dtype guessing +* fix sum() and prod() types * Any more attributes that need to be exposed at app-level For later 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 @@ -20,6 +20,8 @@ slice_driver2 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 'stop', 'source', 'dest']) class BaseArray(Wrappable): +_attrs_ = ["invalidates", "signature"] + def __init__(self): self.invalidates = [] @@ -323,6 +325,8 @@ """ signature = signature.BaseSignature() +_attrs_ = ["dtype", "value"] + def __init__(self, dtype, value): BaseArray.__init__(self) self.dtype = dtype 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 @@ -23,6 +23,10 @@ def wrap(self, obj): if isinstance(obj, float): return FloatObject(obj) +elif isinstance(obj, bool): +return BoolObject(obj) +elif isinstance(obj, int): +return IntObject(obj) raise Exception def float(self, w_obj): @@ -32,10 +36,19 @@ def float_w(self, w_obj): return w_obj.floatval + class FloatObject(W_Root): def __init__(self, floatval): self.floatval = floatval +class BoolObject(W_Root): +def __init__(self, boolval): +self.boolval = boolval + +class IntObject(W_Root): +def __init__(self, intval): +self.intval = intval + class TestNumpyJIt(LLJitMixin): def setup_class(cls): cls.space = FakeSpace() @@ -71,10 +84,13 @@ def test_sum(self): space = self.space +float64_dtype = self.float64_dtype def f(i): -ar = SingleDimArray(i, dtype=self.float64_dtype) -return ar.descr_add(space, ar).descr_sum(space) +ar = SingleDimArray(i, dtype=NonConstant(float64_dtype)) +v = ar.descr_add(space, ar).descr_sum(space) +assert isinstance(v, FloatObject) +return v.floatval result = self.meta_interp(f, [5], listops=True, backendopt=True) self.check_loops({"getarrayitem_raw": 2, "float_add": 2, @@ -84,10 +100,13 @@ def test_prod(self): space = self.space +float64_dtype = self.float64_dtype def f(i): -ar = SingleDimArray(i, dtype=self.float64_dtype) -return ar.descr_add(space, ar).descr_prod(space) +ar = SingleDimArray(i, dtype=NonConstant(float64_dtype)) +v = ar.descr_add(space, ar).descr_prod(space) +assert isinstance(v, FloatObject) +return v.floatval result = self.meta_interp(f, [5], listops=True, backendopt=True) self.check_loops({"getarrayitem_raw": 2, "float_add": 1, @@ -97,14 +116,15 @@ def test_max(self): space = self.space +float64_dtype = self.float64_dtype def f(i): -ar = SingleDimArray(i, dtype=self.float64_dtype) +ar = SingleDimArray(i, dtype=NonConstant(float64_dtype)) j = 0 while j < i: -ar.get_concrete().setitem(space, j, float(j)) +ar.get_concrete().setitem(space, j, space.wrap(float(j))) j += 1 -return ar.descr_add(space, ar).descr_max(space) +return ar.descr_add(space, ar).descr_max(space).floatval result = self.meta_interp(f, [5], listops=True, backendopt=True) self.check_loops({"getarrayitem_raw": 2, "float_add": 1, @@ -115,14 +135,15 @@ def test_min(self): space = self.space +float64_dtype = self.float64_dtype def f(i): -ar = SingleDimArray(i, dtype=self.float64_dtype) +ar = SingleDimArray(i, dtype=NonConstant(float64_dtype)) j = 0 while j < i: -ar.get_concrete().setitem(space, j, float(j)) +ar.get_concrete().setitem(space, j, space.wrap(float(j))) j += 1 -return ar.descr_add(space, ar).descr_min(space) +return ar.descr_add(space, ar).descr_min(space).floatval result = self.meta_interp(f, [5], listops=True, backendopt=True) self.check_loops({"getarrayitem_raw": 2, "float_add": 1
[pypy-commit] pypy numpy-dtype-alt: further attempts at RPythonification
Author: Alex Gaynor Branch: numpy-dtype-alt Changeset: r46696:190cccef14dc Date: 2011-08-22 00:14 -0500 http://bitbucket.org/pypy/pypy/changeset/190cccef14dc/ Log:further attempts at RPythonification 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 @@ -19,8 +19,12 @@ class TrivialSpace(object): def __init__(self): +"NOT_RPYTHON" self.fromcache = InternalSpaceCache(self).getorbuild +def _freeze_(self): +return True + def wrap(self, x): return x 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 @@ -7,6 +7,7 @@ SingleDimSlice, scalar_w) from pypy.rlib.nonconst import NonConstant from pypy.rlib.objectmodel import specialize +from pypy.rpython.annlowlevel import llstr from pypy.rpython.test.test_llinterp import interpret @@ -327,6 +328,5 @@ def test_translation(self): # we import main to check if the target compiles from pypy.translator.goal.targetnumpystandalone import main -from pypy.rpython.annlowlevel import llstr interpret(main, [llstr('af+'), 100]) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-dtype-alt: Yay. Incredible improvement: actually *display* the graph
Author: Armin Rigo Branch: numpy-dtype-alt Changeset: r46697:82779143884f Date: 2011-08-22 07:23 +0200 http://bitbucket.org/pypy/pypy/changeset/82779143884f/ Log:Yay. Incredible improvement: actually *display* the graph passed in the error message, instead of just displaying something very helpful like "" and nothing else. diff --git a/pypy/tool/error.py b/pypy/tool/error.py --- a/pypy/tool/error.py +++ b/pypy/tool/error.py @@ -17,7 +17,7 @@ from pypy.interpreter.pytraceback import offset2lineno import traceback -def source_lines(graph, block, operindex=None, offset=None, long=False, \ +def source_lines1(graph, block, operindex=None, offset=None, long=False, \ show_lines_of_code=SHOW_DEFAULT_LINES_OF_CODE): if block is not None: if block is graph.returnblock: @@ -61,6 +61,10 @@ lines.append("") return lines +def source_lines(graph, *args, **kwds): +lines = source_lines1(graph, *args, **kwds) +return ['In %r:' % (graph,)] + lines + class FlowingError(Exception): pass ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-dtype-alt: fix test translation.
Author: Alex Gaynor Branch: numpy-dtype-alt Changeset: r46698:53b1543a926c Date: 2011-08-22 01:04 -0500 http://bitbucket.org/pypy/pypy/changeset/53b1543a926c/ Log:fix test translation. 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 @@ -3,9 +3,10 @@ It should not be imported by the module itself """ -from pypy.interpreter.baseobjspace import InternalSpaceCache +from pypy.interpreter.baseobjspace import InternalSpaceCache, W_Root from pypy.module.micronumpy.interp_dtype import W_Float64Dtype from pypy.module.micronumpy.interp_numarray import Scalar, SingleDimArray, BaseArray +from pypy.rlib.objectmodel import specialize class BogusBytecode(Exception): @@ -17,27 +18,50 @@ dtype.setitem(a.storage, i, dtype.box(float(i % 10))) return a -class TrivialSpace(object): +class FakeSpace(object): +w_ValueError = None + def __init__(self): -"NOT_RPYTHON" +"""NOT_RPYTHON""" self.fromcache = InternalSpaceCache(self).getorbuild -def _freeze_(self): +def issequence_w(self, w_obj): return True -def wrap(self, x): -return x +@specialize.argtype(1) +def wrap(self, obj): +if isinstance(obj, float): +return FloatObject(obj) +elif isinstance(obj, bool): +return BoolObject(obj) +elif isinstance(obj, int): +return IntObject(obj) +raise Exception -def issequence_w(self, w_obj): -# Completely wrong in the general case, but good enough for this. -return isinstance(w_obj, BaseArray) +def float(self, w_obj): +assert isinstance(w_obj, FloatObject) +return w_obj def float_w(self, w_obj): -assert isinstance(w_obj, float) -return w_obj +return w_obj.floatval + + +class FloatObject(W_Root): +def __init__(self, floatval): +self.floatval = floatval + +class BoolObject(W_Root): +def __init__(self, boolval): +self.boolval = boolval + +class IntObject(W_Root): +def __init__(self, intval): +self.intval = intval + + +space = FakeSpace() def numpy_compile(bytecode, array_size): -space = TrivialSpace() stack = [] i = 0 dtype = space.fromcache(W_Float64Dtype) @@ -49,21 +73,33 @@ stack.append(Scalar(dtype, dtype.box(1.2))) elif b == '+': right = stack.pop() -stack.append(stack.pop().descr_add(space, right)) +res = stack.pop().descr_add(space, right) +assert isinstance(res, BaseArray) +stack.append(res) elif b == '-': right = stack.pop() -stack.append(stack.pop().descr_sub(space, right)) +res = stack.pop().descr_sub(space, right) +assert isinstance(res, BaseArray) +stack.append(res) elif b == '*': right = stack.pop() -stack.append(stack.pop().descr_mul(space, right)) +res = stack.pop().descr_mul(space, right) +assert isinstance(res, BaseArray) +stack.append(res) elif b == '/': right = stack.pop() -stack.append(stack.pop().descr_div(space, right)) +res = stack.pop().descr_div(space, right) +assert isinstance(res, BaseArray) +stack.append(res) elif b == '%': right = stack.pop() -stack.append(stack.pop().descr_mod(space, right)) +res = stack.pop().descr_mod(space, right) +assert isinstance(res, BaseArray) +stack.append(res) elif b == '|': -stack.append(stack.pop().descr_abs(space)) +res = stack.pop().descr_abs(space) +assert isinstance(res, BaseArray) +stack.append(res) else: print "Unknown opcode: %s" % b raise BogusBytecode() 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 @@ -1,55 +1,16 @@ from pypy.interpreter.baseobjspace import InternalSpaceCache, W_Root from pypy.jit.metainterp.test.support import LLJitMixin from pypy.module.micronumpy import interp_ufuncs, signature -from pypy.module.micronumpy.compile import numpy_compile +from pypy.module.micronumpy.compile import (numpy_compile, FakeSpace, +FloatObject, IntObject, BoolObject) from pypy.module.micronumpy.interp_dtype import W_Float64Dtype from pypy.module.micronumpy.interp_numarray import (BaseArray, SingleDimArray, SingleDimSlice, scalar_w) from pypy.rlib.nonconst import NonConstant -from pypy.rlib.objectmodel import specialize from pypy.rpython.annlowlevel import llstr from pypy.rpython.test.test_llinterp import interpret -class FakeSpace(object): -w_ValueError =
[pypy-commit] pypy numpy-dtype-alt: all tests pass
Author: Alex Gaynor Branch: numpy-dtype-alt Changeset: r46699:8d6c1468e035 Date: 2011-08-22 01:07 -0500 http://bitbucket.org/pypy/pypy/changeset/8d6c1468e035/ Log:all tests pass diff --git a/TODO.txt b/TODO.txt --- a/TODO.txt +++ b/TODO.txt @@ -1,7 +1,6 @@ TODO for mering numpy-dtype-alt === -* Fix the last test_zjit * More operations on more dtypes * dtype guessing * fix sum() and prod() types ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-dtype-alt: fix translation (which actually revealed a bug)
Author: Alex Gaynor Branch: numpy-dtype-alt Changeset: r46700:929a973da782 Date: 2011-08-22 01:32 -0500 http://bitbucket.org/pypy/pypy/changeset/929a973da782/ Log:fix translation (which actually revealed a bug) 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 @@ -16,8 +16,7 @@ reds = ['result_size', 'i', 'self', 'result']) all_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self', 'dtype']) any_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self', 'dtype']) -slice_driver1 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 'stop', 'source', 'dest']) -slice_driver2 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 'stop', 'source', 'dest']) +slice_driver = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 'stop', 'source', 'dest']) class BaseArray(Wrappable): _attrs_ = ["invalidates", "signature"] @@ -258,7 +257,7 @@ self.find_size()) if step == 0: # Single index -self.get_concrete().setitem(space, start, w_value) +self.get_concrete().setitem_w(space, start, w_value) else: concrete = self.get_concrete() if isinstance(w_value, BaseArray): @@ -276,25 +275,14 @@ def descr_mean(self, space): return space.wrap(space.float_w(self.descr_sum(space))/self.find_size()) -def _sliceloop1(self, start, stop, step, source, dest): +def _sliceloop(self, start, stop, step, source, dest): i = start j = 0 -while i < stop: -slice_driver1.jit_merge_point(signature=source.signature, -step=step, stop=stop, i=i, j=j, source=source, -dest=dest) -dest.dtype.setitem(dest.storage, i, source.eval(j)) -j += 1 -i += step - -def _sliceloop2(self, start, stop, step, source, dest): -i = start -j = 0 -while i > stop: -slice_driver2.jit_merge_point(signature=source.signature, -step=step, stop=stop, i=i, j=j, source=source, -dest=dest) -dest.dtype.setitem(dest.storage, i, source.eval(j)) +while (step > 0 and i < stop) or (step < 0 and i > stop): +slice_driver.jit_merge_point(signature=source.signature, step=step, + stop=stop, i=i, j=j, source=source, + dest=dest) +dest.setitem(i, source.eval(j)) j += 1 i += step @@ -382,6 +370,9 @@ return self.forced_result.eval(i) return self._eval(i) +def setitem(self, item, value): +return self.get_concrete().setitem(item, value) + def find_size(self): if self.forced_result is not None: # The result has been computed and sources may be unavailable @@ -467,8 +458,11 @@ return self.parent.eval(self.calc_index(i)) @unwrap_spec(item=int) -def setitem(self, space, item, w_value): -return self.parent.setitem(space, self.calc_index(item), w_value) +def setitem_w(self, space, item, w_value): +return self.parent.setitem_w(space, self.calc_index(item), w_value) + +def setitem(self, item, value): +return self.parent.setitem(self.calc_index(item), value) def descr_len(self, space): return space.wrap(self.find_size()) @@ -494,7 +488,7 @@ self.size = slice_length def get_root_storage(self): -return self.parent.storage +return self.parent.get_concrete().get_root_storage() def find_size(self): return self.size @@ -507,10 +501,7 @@ if stop != -1: stop = self.calc_index(stop) step = self.step * step -if step > 0: -self._sliceloop1(start, stop, step, arr, self.parent) -else: -self._sliceloop2(start, stop, step, arr, self.parent) +self._sliceloop(start, stop, step, arr, self.parent) def calc_index(self, item): return (self.start + item * self.step) @@ -542,15 +533,16 @@ def descr_len(self, space): return space.wrap(self.size) -def setitem(self, space, item, w_value): +def setitem_w(self, space, item, w_value): self.invalidated() self.dtype.setitem_w(space, self.storage, item, w_value) +def setitem(self, item, value): +self.invalidated() +self.dtype.setitem(self.storage, item, value) + def setslice(self, space, start, stop, step, slice_length, arr): -if step > 0: -self._sliceloop1(start, stop, step, arr, self) -else: -self._sliceloop2(start, stop, step, arr, self) +self._sliceloo