Author: Hakan Ardo <ha...@debian.org>
Branch: jit-short_from_state
Changeset: r44739:4b217e56b6d5
Date: 2011-06-06 14:20 +0200
http://bitbucket.org/pypy/pypy/changeset/4b217e56b6d5/

Log:    test

diff --git a/pypy/jit/metainterp/test/test_optimizeopt.py 
b/pypy/jit/metainterp/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/test/test_optimizeopt.py
@@ -163,7 +163,7 @@
                             expected.operations, False, remap, text_right)
 
     def optimize_loop(self, ops, optops, expected_preamble=None,
-                      call_pure_results=None):
+                      call_pure_results=None, expected_short=None):
         loop = self.parse(ops)
         if optops != "crash!":
             expected = self.parse(optops)
@@ -171,6 +171,8 @@
             expected = "crash!"
         if expected_preamble:
             expected_preamble = self.parse(expected_preamble)
+        if expected_short:
+            expected_short = self.parse(expected_short)
         #
         self.loop = loop
         loop.call_pure_results = args_dict()
@@ -200,21 +202,34 @@
         #
 
         print
+        print "Preamble:"
         print loop.preamble.inputargs
         if loop.preamble.operations:
             print '\n'.join([str(o) for o in loop.preamble.operations])
         else:
             print 'Failed!'
         print
+        print "Loop:"
         print loop.inputargs
         print '\n'.join([str(o) for o in loop.operations])
         print
+        if expected_short:
+            print "Short Preamble:"
+            short = loop.preamble.token.short_preamble[0]
+            print short.inputargs
+            print '\n'.join([str(o) for o in short.operations])        
+            print
+        
 
         assert expected != "crash!", "should have raised an exception"
         self.assert_equal(loop, expected)
         if expected_preamble:
             self.assert_equal(loop.preamble, expected_preamble,
                               text_right='expected preamble')
+        if expected_short:
+            self.assert_equal(short, expected_short,
+                              text_right='expected short preamble')
+            
 
         return loop
 
@@ -6377,4 +6392,30 @@
         jump(p0, p3, i1)
         """
         self.optimize_loop(ops, expected)
+
+    def test_guards_before_getfields_in_short_preamble(self):
+        ops = """
+        [p0]
+        guard_nonnull_class(p0, ConstClass(node_vtable)) []
+        p1 = getfield_gc(p0, descr=nextdescr)
+        guard_nonnull_class(p1, ConstClass(node_vtable)) []
+        p2 = getfield_gc(p1, descr=nextdescr)
+        guard_nonnull_class(p2, ConstClass(node_vtable)) []        
+        jump(p0)
+        """
+        expected = """
+        [p0]
+        jump(p0)
+        """
+        short = """
+        [p0]
+        p1 = getfield_gc(p0, descr=nextdescr)
+        guard_nonnull(p1) []
+        guard_class(p1, ConstClass(node_vtable)) []
+        p2 = getfield_gc(p1, descr=nextdescr)
+        guard_nonnull(p2) []
+        guard_class(p2, ConstClass(node_vtable)) []        
+        jump(p0)
+        """
+        self.optimize_loop(ops, expected, expected_short=short)
         
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to