Author: Alex Gaynor <alex.gay...@gmail.com> Branch: Changeset: r49672:d550918b20a6 Date: 2011-11-22 14:57 -0600 http://bitbucket.org/pypy/pypy/changeset/d550918b20a6/
Log: merged upstream diff --git a/pypy/doc/project-ideas.rst b/pypy/doc/project-ideas.rst --- a/pypy/doc/project-ideas.rst +++ b/pypy/doc/project-ideas.rst @@ -23,6 +23,12 @@ PyPy's implementation of the Python ``long`` type is slower than CPython's. Find out why and optimize them. +Make bytearray type fast +------------------------ + +PyPy's bytearray type is very inefficient. It would be an interesting +task to look into possible optimizations on this. + Numpy improvements ------------------ diff --git a/pypy/jit/metainterp/optimizeopt/optimizer.py b/pypy/jit/metainterp/optimizeopt/optimizer.py --- a/pypy/jit/metainterp/optimizeopt/optimizer.py +++ b/pypy/jit/metainterp/optimizeopt/optimizer.py @@ -348,6 +348,7 @@ self.opaque_pointers = {} self.replaces_guard = {} self._newoperations = [] + self.seen_results = {} self.optimizer = self self.optpure = None self.optearlyforce = None @@ -542,6 +543,10 @@ op = self.store_final_boxes_in_guard(op) elif op.can_raise(): self.exception_might_have_happened = True + if op.result: + if op.result in self.seen_results: + raise ValueError, "invalid optimization" + self.seen_results[op.result] = None self._newoperations.append(op) def replace_op(self, old_op, new_op): 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 @@ -5568,6 +5568,35 @@ jump() """ self.optimize_loop(ops, expected) + # + ops = """ + [] + p0 = new_with_vtable(ConstClass(ptrobj_immut_vtable)) + p1 = new_with_vtable(ConstClass(ptrobj_immut_vtable)) + setfield_gc(p0, p1, descr=immut_ptrval) + setfield_gc(p1, p0, descr=immut_ptrval) + escape(p0) + jump() + """ + class PtrObjSelf2(object): + _TYPE = llmemory.GCREF.TO + def __eq__(slf, other): + if slf is other: + return 1 + p1 = other.container.ptrval + p1cast = lltype.cast_pointer(lltype.Ptr(self.PTROBJ_IMMUT), p1) + p2 = p1cast.ptrval + assert p2 != p1 + p2cast = lltype.cast_pointer(lltype.Ptr(self.PTROBJ_IMMUT), p2) + return p2cast.ptrval == p1 + self.namespace['ptrobjself2'] = lltype._ptr(llmemory.GCREF, + PtrObjSelf2()) + expected = """ + [] + escape(ConstPtr(ptrobjself2)) + jump() + """ + self.optimize_loop(ops, expected) # ---------- def optimize_strunicode_loop(self, ops, optops, preamble): diff --git a/pypy/jit/metainterp/optimizeopt/virtualize.py b/pypy/jit/metainterp/optimizeopt/virtualize.py --- a/pypy/jit/metainterp/optimizeopt/virtualize.py +++ b/pypy/jit/metainterp/optimizeopt/virtualize.py @@ -111,7 +111,7 @@ if value.is_constant(): pass # it is a constant value: ok elif (isinstance(value, AbstractVirtualStructValue) - and value.box is None): + and value.is_virtual()): # recursive check if not value._is_immutable_and_filled_with_constants(memo): return False _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit