[pypy-svn] r66456 - in pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp: . test

arigo at codespeak.net arigo at codespeak.net
Mon Jul 20 20:13:55 CEST 2009


Author: arigo
Date: Mon Jul 20 20:13:54 2009
New Revision: 66456

Modified:
   pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/optimizeopt.py
   pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizeopt.py
Log:
A first simple test about NEW_WITH_VTABLE.
Skipped the more complicated test.


Modified: pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/optimizeopt.py
==============================================================================
--- pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/optimizeopt.py	(original)
+++ pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/optimizeopt.py	Mon Jul 20 20:13:54 2009
@@ -241,6 +241,7 @@
     def optimize_GETFIELD_GC(self, op):
         instbox = op.args[0]
         if isinstance(instbox, VirtualBox):
+            # optimizefindnode should ensure that 'op.descr in instbox.fields'
             self._make_equal(op.result, instbox.fields[op.descr])
         else:
             self.make_nonnull(instbox)
@@ -256,5 +257,8 @@
             self.make_nonnull(instbox)
             self.optimize_default(op)
 
+    def optimize_NEW_WITH_VTABLE(self, op):
+        self.make_virtual(op.result, op.args[0])
+
 
 optimize_ops = _findall(Optimizer, 'optimize_')

Modified: pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizeopt.py
==============================================================================
--- pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizeopt.py	(original)
+++ pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizeopt.py	Mon Jul 20 20:13:54 2009
@@ -303,6 +303,23 @@
         self.optimize_loop(ops, 'Not, Virtual(node_vtable, valuedescr=Not)',
                            expected)
 
+    def test_virtual_2(self):
+        ops = """
+        [i, p0]
+        i0 = getfield_gc(p0, descr=valuedescr)
+        i1 = int_add(i0, i)
+        p1 = new_with_vtable(ConstClass(node_vtable), descr=nodesize)
+        setfield_gc(p1, i1, descr=valuedescr)
+        jump(i, p1)
+        """
+        expected = """
+        [i, i2]
+        i1 = int_add(i2, i)
+        jump(i, i1)
+        """
+        self.optimize_loop(ops, 'Not, Virtual(node_vtable, valuedescr=Not)',
+                           expected)
+
     def test_virtual_oois(self):
         ops = """
         [p0, p1, p2]
@@ -362,6 +379,28 @@
         expected2 = ops
         self.optimize_loop(ops, 'Not, Not, Not', expected2)
 
+    def test_virtual_default_field(self):
+        py.test.skip("in-progress")
+        ops = """
+        [p0]
+        i0 = getfield_gc(p0, descr=valuedescr)
+        guard_value(i0, 0)
+          fail()
+        p1 = new_with_vtable(ConstClass(node_vtable), descr=nodesize)
+        # the field 'value' has its default value of 0
+        jump(p1)
+        """
+        expected = """
+        [i]
+        guard_value(i, 0)
+          fail()
+        jump(0)
+        """
+        # the 'expected' is sub-optimal, but it should be done by another later
+        # optimization step.  See test_find_nodes_default_field() for why.
+        self.optimize_loop(ops, 'Virtual(node_vtable, valuedescr=Not)',
+                           expected)
+
 
 class TestLLtype(BaseTestOptimizeOpt, LLtypeMixin):
     pass



More information about the Pypy-commit mailing list