[pypy-svn] r65488 - in pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp: . test

fijal at codespeak.net fijal at codespeak.net
Fri May 29 03:31:15 CEST 2009


Author: fijal
Date: Fri May 29 03:31:12 2009
New Revision: 65488

Modified:
   pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py
   pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py
Log:
A trivial test and a fix for node without vtable


Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py	Fri May 29 03:31:12 2009
@@ -135,8 +135,11 @@
 
     def rebuild_virtual(self, ops, node):
         assert node.virtual
-        ops.append(ResOperation(rop.NEW_WITH_VTABLE, [node.cls],
-                                node.source, node.size))
+        if node.cls is not None:
+            ops.append(ResOperation(rop.NEW_WITH_VTABLE, [node.cls],
+                                    node.source, node.size))
+        else:
+            ops.append(ResOperation(rop.NEW, [], node.source, node.size))
         for field, valuenode in node.cleanfields.iteritems():
             if valuenode.virtual:
                 self.rebuild_virtual(ops, valuenode)
@@ -381,6 +384,15 @@
         return True
 
     @staticmethod
+    def optimize_new(op, spec):
+        node = spec.getnode(op.result)
+        if node.escaped:
+            return False
+        node.virtual = True
+        node.size = op.descr
+        return True
+
+    @staticmethod
     def optimize_setfield_gc(op, spec):
         instnode = spec.getnode(op.args[0])
         if not instnode.virtual:

Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py	Fri May 29 03:31:12 2009
@@ -472,6 +472,22 @@
         self.assert_equal(self.optimize(pre_op, [SimpleVirtualizableOpt(),
                                                  SimpleVirtualOpt()]),
                           expected)
+
+    def test_virtual_without_vtable(self):
+        pre_op = """
+        [i1]
+        p0 = new()
+        guard_true(i1)
+            fail(p0)
+        """
+        expected = """
+        [i1]
+        guard_true(i1)
+            p0 = new()
+            fail(p0)
+        """
+        self.assert_equal(self.optimize(pre_op, [SimpleVirtualOpt()]),
+                          expected)
         
 
 class TestLLtype(LLtypeMixin, BaseTestOptimize2):



More information about the Pypy-commit mailing list