[pypy-svn] r70329 - pypy/branch/virtual-forcing/pypy/jit/metainterp/test

arigo at codespeak.net arigo at codespeak.net
Tue Dec 29 10:39:04 CET 2009


Author: arigo
Date: Tue Dec 29 10:39:03 2009
New Revision: 70329

Modified:
   pypy/branch/virtual-forcing/pypy/jit/metainterp/test/test_optimizefindnode.py
   pypy/branch/virtual-forcing/pypy/jit/metainterp/test/test_optimizeopt.py
Log:
Fix more tests.


Modified: pypy/branch/virtual-forcing/pypy/jit/metainterp/test/test_optimizefindnode.py
==============================================================================
--- pypy/branch/virtual-forcing/pypy/jit/metainterp/test/test_optimizefindnode.py	(original)
+++ pypy/branch/virtual-forcing/pypy/jit/metainterp/test/test_optimizefindnode.py	Tue Dec 29 10:39:03 2009
@@ -106,12 +106,13 @@
     readadescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
                                  EffectInfo([adescr], [], []))
     mayforcevirtdescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
-                 EffectInfo([], [], forces_virtual_or_virtualizable=True))
+                 EffectInfo([], [], [], forces_virtual_or_virtualizable=True))
 
     from pypy.jit.metainterp.virtualref import jit_virtual_ref_vtable
     from pypy.jit.metainterp.virtualref import JIT_VIRTUAL_REF
     virtualtokendescr = cpu.fielddescrof(JIT_VIRTUAL_REF, 'virtual_token')
     virtualrefindexdescr = cpu.fielddescrof(JIT_VIRTUAL_REF,'virtualref_index')
+    virtualforceddescr = cpu.fielddescrof(JIT_VIRTUAL_REF, 'forced')
 
     cpu.class_sizes = {cpu.cast_adr_to_int(node_vtable_adr): cpu.sizeof(NODE),
                       cpu.cast_adr_to_int(node_vtable_adr2): cpu.sizeof(NODE2),

Modified: pypy/branch/virtual-forcing/pypy/jit/metainterp/test/test_optimizeopt.py
==============================================================================
--- pypy/branch/virtual-forcing/pypy/jit/metainterp/test/test_optimizeopt.py	(original)
+++ pypy/branch/virtual-forcing/pypy/jit/metainterp/test/test_optimizeopt.py	Tue Dec 29 10:39:03 2009
@@ -2331,13 +2331,42 @@
         """
         self.optimize_loop(ops, 'Not, Not, Not, Not', ops)
 
-    def test_vref_nonvirtual(self):
+    def test_vref_nonvirtual_nonescape(self):
         ops = """
         [p1]
         p2 = virtual_ref(p1, 5)
+        virtual_ref_finish(p2, p1)
         jump(p1)
         """
-        py.test.raises(compile.GiveUp, self.optimize_loop, ops, 'Not', ops)
+        expected = """
+        [p1]
+        i0 = force_token()
+        jump(p1)
+        """
+        self.optimize_loop(ops, 'Not', expected)
+
+    def test_vref_nonvirtual_escape(self):
+        ops = """
+        [p1]
+        p2 = virtual_ref(p1, 5)
+        escape(p2)
+        virtual_ref_finish(p2, p1)
+        jump(p1)
+        """
+        expected = """
+        [p1]
+        i0 = force_token()
+        p2 = new_with_vtable(ConstClass(jit_virtual_ref_vtable))
+        setfield_gc(p2, i0, descr=virtualtokendescr)
+        setfield_gc(p2, 5, descr=virtualrefindexdescr)
+        escape(p2)
+        setfield_gc(p2, p1, descr=virtualforceddescr)
+        setfield_gc(p2, 0, descr=virtualtokendescr)
+        jump(p1)
+        """
+        # XXX we should optimize a bit more the case of a nonvirtual.
+        # in theory it is enough to just do 'p2 = p1'.
+        self.optimize_loop(ops, 'Not', expected)
 
     def test_vref_virtual_1(self):
         ops = """



More information about the Pypy-commit mailing list