[pypy-commit] pypy default: Fixed #1301 -- copystrcontents from Constant -> virtual is fully unrolled now
alex_gaynor
noreply at buildbot.pypy.org
Thu Oct 25 03:46:33 CEST 2012
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r58412:15b5a4bb248a
Date: 2012-10-24 18:46 -0700
http://bitbucket.org/pypy/pypy/changeset/15b5a4bb248a/
Log: Fixed #1301 -- copystrcontents from Constant -> virtual is fully
unrolled now
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
@@ -4306,14 +4306,7 @@
"""
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)
+ finish(s"hello")
"""
self.optimize_strunicode_loop(ops, expected)
@@ -4963,12 +4956,7 @@
"""
expected = """
[i1]
- p0 = newstr(6)
- copystrcontent(s"hello!", p0, 0, 0, 6)
- p1 = newstr(12)
- copystrcontent(p0, p1, 0, 0, 6)
- copystrcontent(s"abc123", p1, 0, 6, 6)
- i0 = strgetitem(p1, i1)
+ i0 = strgetitem(s"hello!abc123", i1)
finish(i0)
"""
self.optimize_strunicode_loop(ops, expected)
@@ -4984,10 +4972,7 @@
"""
expected = """
[]
- p0 = newstr(6)
- copystrcontent(s"hello!", p0, 0, 0, 6)
- i0 = strgetitem(p0, 0)
- finish(i0)
+ finish(104)
"""
self.optimize_strunicode_loop(ops, expected)
@@ -5067,6 +5052,21 @@
"""
self.optimize_strunicode_loop(ops, expected)
+ def test_str_copy_constant_virtual(self):
+ ops = """
+ []
+ p0 = newstr(10)
+ copystrcontent(s"abcd", p0, 0, 0, 4)
+ strsetitem(p0, 4, 101)
+ copystrcontent(s"fghij", p0, 0, 5, 5)
+ finish(p0)
+ """
+ expected = """
+ []
+ finish(s"abcdefghij")
+ """
+ self.optimize_strunicode_loop(ops, expected)
+
def test_call_pure_vstring_const(self):
py.test.skip("implement me")
ops = """
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
@@ -489,6 +489,7 @@
def optimize_COPYSTRCONTENT(self, op):
self._optimize_COPYSTRCONTENT(op, mode_string)
+
def optimize_COPYUNICODECONTENT(self, op):
self._optimize_COPYSTRCONTENT(op, mode_unicode)
@@ -507,8 +508,8 @@
if length.is_constant() and length.box.getint() == 0:
return
- elif (src.is_virtual() and dst.is_virtual() and srcstart.is_constant() and
- dststart.is_constant() and length.is_constant()):
+ elif ((src.is_virtual() or src.is_constant()) and dst.is_virtual() and
+ srcstart.is_constant() and dststart.is_constant() and length.is_constant()):
src_start = srcstart.force_box(self).getint()
dst_start = dststart.force_box(self).getint()
More information about the pypy-commit
mailing list