Author: Armin Rigo <ar...@tunes.org> Branch: gc_no_cleanup_nursery Changeset: r73711:deb4d03d1f18 Date: 2014-09-25 20:19 +0200 http://bitbucket.org/pypy/pypy/changeset/deb4d03d1f18/
Log: Fix: vstring no longer removes strsetitem(.., 0). This was a rather pointless anyway. diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -4791,15 +4791,18 @@ ops = """ [p0] p1 = newstr(4) + strsetitem(p1, 2, 0) setfield_gc(p0, p1, descr=valuedescr) jump(p0) """ - # It used to be the case that this would have a series of - # strsetitem(p1, idx, 0), which was silly because memory is 0 filled - # when allocated. + # This test is slightly bogus: the string is not fully initialized. + # I *think* it is still right to not have a series of extra + # strsetitem(p1, idx, 0). We do preserve the single one from the + # source, though. expected = """ [p0] p1 = newstr(4) + strsetitem(p1, 2, 0) setfield_gc(p0, p1, descr=valuedescr) jump(p0) """ @@ -5115,6 +5118,9 @@ strsetitem(p1, 6, i0) strsetitem(p1, 7, i0) strsetitem(p1, 8, 3) + strsetitem(p1, 9, 0) + strsetitem(p1, 10, 0) + strsetitem(p1, 11, 0) finish(p1) """ self.optimize_strunicode_loop(ops, expected) diff --git a/rpython/jit/metainterp/optimizeopt/vstring.py b/rpython/jit/metainterp/optimizeopt/vstring.py --- a/rpython/jit/metainterp/optimizeopt/vstring.py +++ b/rpython/jit/metainterp/optimizeopt/vstring.py @@ -189,13 +189,11 @@ charvalue = self.getitem(i) if charvalue is not None: charbox = charvalue.force_box(string_optimizer) - if not (isinstance(charbox, Const) and - charbox.same_constant(CONST_0)): - op = ResOperation(mode.STRSETITEM, [targetbox, - offsetbox, - charbox], - None) - string_optimizer.emit_operation(op) + op = ResOperation(mode.STRSETITEM, [targetbox, + offsetbox, + charbox], + None) + string_optimizer.emit_operation(op) offsetbox = _int_add(string_optimizer, offsetbox, CONST_1) return offsetbox _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit