[pypy-svn] r78680 - in pypy/branch/jit-unroll-loops/pypy/jit: metainterp/optimizeopt metainterp/test tl

hakanardo at codespeak.net hakanardo at codespeak.net
Wed Nov 3 20:22:21 CET 2010


Author: hakanardo
Date: Wed Nov  3 20:22:19 2010
New Revision: 78680

Modified:
   pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/heap.py
   pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_optimizeopt.py
   pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit.py
   pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_child.py
   pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_demo.py
Log:
Problematic getfield case where the heap optimizer fails in the loop but not in the preamble

Modified: pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/heap.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/heap.py	(original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/heap.py	Wed Nov  3 20:22:19 2010
@@ -97,7 +97,7 @@
         self.emitting_operation(op)
         self.next_optimization.propagate_forward(op)
 
-    def emitting_operation(self, op):        
+    def emitting_operation(self, op):
         if op.has_no_side_effect():
             return
         if op.is_ovf():

Modified: pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_optimizeopt.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_optimizeopt.py	(original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_optimizeopt.py	Wed Nov  3 20:22:19 2010
@@ -3518,6 +3518,41 @@
         self.node.value = 5
         self.optimize_loop(ops, expected)
 
+    def test_getfield_guard_const(self):
+        ops = """
+        [p0]
+        p20 = getfield_gc(p0, descr=nextdescr)
+        guard_nonnull(p20) []
+        guard_class(p20, ConstClass(node_vtable)) []
+        guard_class(p20, ConstClass(node_vtable)) []
+        p23 = getfield_gc(p20, descr=valuedescr)
+        guard_isnull(p23) []
+        guard_class(p20, ConstClass(node_vtable)) []
+        guard_value(p20, ConstPtr(myptr)) []
+
+        p37 = getfield_gc(p0, descr=nextdescr)
+        guard_nonnull(p37) []
+        guard_class(p37, ConstClass(node_vtable)) []
+        guard_class(p37, ConstClass(node_vtable)) []
+        p40 = getfield_gc(p37, descr=valuedescr)
+        guard_isnull(p40) []
+        guard_class(p37, ConstClass(node_vtable)) []
+        guard_value(p37, ConstPtr(myptr)) []
+
+        p64 = call_may_force(p23, p40, descr=plaincalldescr)
+        jump(p0)
+        """
+        expected = """
+        [p0]
+        p20 = getfield_gc(p0, descr=nextdescr)
+        guard_value(p20, ConstPtr(myptr)) []
+        p23 = getfield_gc(p20, descr=valuedescr)
+        guard_isnull(p23) []
+        p64 = call_may_force(NULL, NULL, descr=plaincalldescr)
+        jump(p0)
+        """
+        self.optimize_loop(ops, expected, expected)
+
     def test_addsub_ovf(self):
         ops = """
         [i0]
@@ -4506,6 +4541,7 @@
         # can be raised by ll_str2unicode()
 
 
+
 ##class TestOOtype(OptimizeOptTest, OOtypeMixin):
 
 ##    def test_instanceof(self):

Modified: pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit.py	(original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit.py	Wed Nov  3 20:22:19 2010
@@ -38,7 +38,7 @@
 config.objspace.allworkingmodules = False
 config.objspace.usemodules.pypyjit = True
 config.objspace.usemodules.array = True
-config.objspace.usemodules._weakref = False
+config.objspace.usemodules._weakref = True
 config.objspace.usemodules._sre = False
 #
 config.objspace.usemodules._ffi = True

Modified: pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_child.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_child.py	(original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_child.py	Wed Nov  3 20:22:19 2010
@@ -35,5 +35,5 @@
     warmspot.jittify_and_run(interp, graph, [], policy=policy,
                              listops=True, CPUClass=CPUClass,
                              backendopt=True, inline=False,
-                             optimizer=OPTIMIZER_NO_UNROLL)
+                             optimizer=OPTIMIZER_FULL)
 

Modified: pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_demo.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_demo.py	(original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_demo.py	Wed Nov  3 20:22:19 2010
@@ -58,27 +58,38 @@
 ##     #img=array('h',(1,2,3,4))
 ##     print f(3)
 
-    from array import array
-    class Circular(array):
-        def __new__(cls):
-            self = array.__new__(cls, 'i', range(16))
-            return self
-        def __getitem__(self, i):
-            #assert self.__len__() == 16 
-            return array.__getitem__(self, i & 15)
+##     from array import array
+##     class Circular(array):
+##         def __new__(cls):
+##             self = array.__new__(cls, 'i', range(16))
+##             return self
+##         def __getitem__(self, i):
+##             #assert self.__len__() == 16 
+##             return array.__getitem__(self, i & 15)
 
-    def main():
-        buf = Circular()
-        i = 10
-        sa = 0
-        while i < 20:
-            #sa += buf[i-2] + buf[i-1] + buf[i] + buf[i+1] + buf[i+2]
-            sa += buf[i]
-            i += 1
-        return sa
+##     def main():
+##         buf = Circular()
+##         i = 10
+##         sa = 0
+##         while i < 20:
+##             #sa += buf[i-2] + buf[i-1] + buf[i] + buf[i+1] + buf[i+2]
+##             sa += buf[i]
+##             i += 1
+##         return sa
 
     import pypyjit
     pypyjit.set_param(threshold=3, inlining=True)
+##     print main()
+
+    def main():
+        i=2
+        sa=0
+        while i < 10: 
+            #sa+=max(range(i))
+            a = range
+            b = max([i])
+            i+=1
+        return sa
     print main()
     
 except Exception, e:



More information about the Pypy-commit mailing list