[pypy-svn] r72221 - in pypy/trunk/pypy/jit/metainterp: . test

fijal at codespeak.net fijal at codespeak.net
Sun Mar 14 05:20:59 CET 2010


Author: fijal
Date: Sun Mar 14 05:20:58 2010
New Revision: 72221

Modified:
   pypy/trunk/pypy/jit/metainterp/optimizeopt.py
   pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py
Log:
A test and a trivial optimization


Modified: pypy/trunk/pypy/jit/metainterp/optimizeopt.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/optimizeopt.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/optimizeopt.py	Sun Mar 14 05:20:58 2010
@@ -927,6 +927,8 @@
                 val = source_value.getitem(index + source_start)
                 dest_value.setitem(index + dest_start, val)
             return
+        if length and length.getint() == 0:
+            return # 0-length arraycopy
         descr = op.args[0]
         assert isinstance(descr, AbstractDescr)
         self.emit_operation(ResOperation(rop.CALL, op.args[1:], op.result,

Modified: pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py	Sun Mar 14 05:20:58 2010
@@ -2775,6 +2775,21 @@
         '''
         self.optimize_loop(ops, 'Not', expected)
 
+    def test_arraycopy_no_elem(self):
+        """ this was actually observed in the wild
+        """
+        ops = '''
+        [p1]
+        p0 = new_array(0, descr=arraydescr)
+        arraycopy(0, 0, p0, p1, 0, 0, 0, descr=arraydescr)
+        jump(p1)
+        '''
+        expected = '''
+        [p1]
+        jump(p1)
+        '''
+        self.optimize_loop(ops, 'Not', expected)
+
 class TestOOtype(BaseTestOptimizeOpt, OOtypeMixin):
 
     def test_instanceof(self):



More information about the Pypy-commit mailing list