Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r48679:665b14e5263a Date: 2011-11-03 10:24 +0100 http://bitbucket.org/pypy/pypy/changeset/665b14e5263a/
Log: merge heads diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -4225,6 +4225,27 @@ """ self.optimize_strunicode_loop(ops, expected) + def test_str_slice_plain_virtual(self): + ops = """ + [] + p0 = newstr(11) + copystrcontent(s"hello world", p0, 0, 0, 11) + p1 = call(0, p0, 0, 5, descr=strslicedescr) + finish(p1) + """ + expected = """ + [] + p0 = newstr(11) + copystrcontent(s"hello world", p0, 0, 0, 11) + # Eventually this should just return s"hello", but ATM this test is + # just verifying that it doesn't return "\0\0\0\0\0", so being + # slightly underoptimized is ok. + p1 = newstr(5) + copystrcontent(p0, p1, 0, 0, 5) + finish(p1) + """ + self.optimize_strunicode_loop(ops, expected) + # ---------- def optimize_strunicode_loop_extradescrs(self, ops, optops): class FakeCallInfoCollection: 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 @@ -7355,6 +7355,26 @@ """ self.optimize_loop(ops, expected) + def test_repeated_setfield_mixed_with_guard(self): + ops = """ + [p22, p18] + setfield_gc(p22, 2, descr=valuedescr) + guard_nonnull_class(p18, ConstClass(node_vtable)) [] + setfield_gc(p22, 2, descr=valuedescr) + jump(p22, p18) + """ + preamble = """ + [p22, p18] + setfield_gc(p22, 2, descr=valuedescr) + guard_nonnull_class(p18, ConstClass(node_vtable)) [] + jump(p22, p18) + """ + expected = """ + [p22, p18] + jump(p22, p18) + """ + self.optimize_loop(ops, expected, preamble) + class TestLLtype(OptimizeOptTest, LLtypeMixin): pass diff --git a/pypy/jit/metainterp/optimizeopt/vstring.py b/pypy/jit/metainterp/optimizeopt/vstring.py --- a/pypy/jit/metainterp/optimizeopt/vstring.py +++ b/pypy/jit/metainterp/optimizeopt/vstring.py @@ -505,11 +505,17 @@ # if (isinstance(vstr, VStringPlainValue) and vstart.is_constant() and vstop.is_constant()): - # slicing with constant bounds of a VStringPlainValue - value = self.make_vstring_plain(op.result, op, mode) - value.setup_slice(vstr._chars, vstart.box.getint(), - vstop.box.getint()) - return True + # slicing with constant bounds of a VStringPlainValue, if any of + # the characters is unitialized we don't do this special slice, we + # do the regular copy contents. + for i in range(vstart.box.getint(), vstop.box.getint()): + if vstr.getitem(i) is optimizer.CVAL_UNINITIALIZED_ZERO: + break + else: + value = self.make_vstring_plain(op.result, op, mode) + value.setup_slice(vstr._chars, vstart.box.getint(), + vstop.box.getint()) + return True # vstr.ensure_nonnull() lengthbox = _int_sub(self, vstop.force_box(self), _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit