[pypy-svn] r78105 - in pypy/branch/jit-unroll-loops/pypy: jit/metainterp/optimizeopt jit/metainterp/test jit/tl module/array/benchmark

hakanardo at codespeak.net hakanardo at codespeak.net
Wed Oct 20 07:40:35 CEST 2010


Author: hakanardo
Date: Wed Oct 20 07:40:33 2010
New Revision: 78105

Modified:
   pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/heap.py
   pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/unroll.py
   pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_optimizeopt.py
   pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_child.py
   pypy/branch/jit-unroll-loops/pypy/jit/tl/pypyjit_demo.py
   pypy/branch/jit-unroll-loops/pypy/module/array/benchmark/circulartst.py
Log:
Optimize

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 Oct 20 07:40:33 2010
@@ -107,6 +107,7 @@
             return
         opnum = op.getopnum()
         if (opnum == rop.SETFIELD_GC or
+            opnum == rop.SETFIELD_RAW or
             opnum == rop.SETARRAYITEM_GC or
             opnum == rop.DEBUG_MERGE_POINT):
             return
@@ -236,6 +237,10 @@
         # remember the result of future reads of the field
         self.cache_field_value(op.getdescr(), value, fieldvalue, write=True)
 
+    optimize_GETFIELD_RAW = optimize_GETFIELD_GC
+    optimize_SETFIELD_RAW = optimize_SETFIELD_GC
+    # FIXME: Do we need separate caches for raw and gc?
+
     def optimize_GETARRAYITEM_GC(self, op):
         value = self.getvalue(op.getarg(0))
         indexvalue = self.getvalue(op.getarg(1))

Modified: pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/unroll.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/unroll.py	(original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/unroll.py	Wed Oct 20 07:40:33 2010
@@ -73,7 +73,7 @@
                     args.extend(self.getvalue(arg).get_forced_boxes())
                 newop.initarglist(args + inputargs[len(args):])
 
-            #print 'P: ', newop
+            #print 'P: ', str(newop)
             current = len(self.optimizer.newoperations)
             self.emit_operation(newop)
 
@@ -81,7 +81,7 @@
             current = max(current-1, 0)
                 
             for op in self.optimizer.newoperations[current:]:
-                #print 'E: ', op,  self.optimizer.newoperations.index(op)
+                #print 'E: ', str(op)
                 if op.is_guard():
                     descr = op.getdescr()
                     assert isinstance(descr, ResumeGuardDescr)

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 Oct 20 07:40:33 2010
@@ -3571,6 +3571,25 @@
         """
         self.optimize_loop(ops, 'Not, Not', expected)
 
+    def test_setgetfield_raw(self):
+        ops = """
+        [p4, p7, i30]
+        p16 = getfield_gc(p4, descr=valuedescr)
+        guard_value(p16, ConstPtr(myptr), descr=<Guard3>) []
+        i1 = getfield_raw(p7, descr=nextdescr)
+        i2 = int_add(i1, i30)
+        setfield_raw(p7, 7, descr=nextdescr)
+        setfield_raw(p7, i2, descr=nextdescr)
+        jump(p4, p7, i30)
+        """
+        expected = """
+        [p4, p7, i30, i2]
+        i33 = int_add(i2, i30)
+        setfield_raw(p7, i33, descr=nextdescr)        
+        jump(p4, p7, i30, i33)
+        """
+        self.optimize_loop(ops, 'Not, Not, Not', expected)
+
     def test_addsub_ovf(self):
         ops = """
         [i0]

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 Oct 20 07:40:33 2010
@@ -34,6 +34,6 @@
     option.view = True
     warmspot.jittify_and_run(interp, graph, [], policy=policy,
                              listops=True, CPUClass=CPUClass,
-                             backendopt=True, inline=True,
+                             backendopt=True, inline=False,
                              optimizer=OPTIMIZER_NO_PERFECTSPEC)
 

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 Oct 20 07:40:33 2010
@@ -57,24 +57,28 @@
 
 ##     #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 
+            #assert self.__len__() == 16 
             return array.__getitem__(self, i & 15)
 
     def main():
         buf = Circular()
         i = 10
         sa = 0
-        while i < 20000:
-            sa += buf[i-2] + buf[i-1] + buf[i] + buf[i+1] + buf[i+2]
+        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()
     
 except Exception, e:

Modified: pypy/branch/jit-unroll-loops/pypy/module/array/benchmark/circulartst.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/module/array/benchmark/circulartst.py	(original)
+++ pypy/branch/jit-unroll-loops/pypy/module/array/benchmark/circulartst.py	Wed Oct 20 07:40:33 2010
@@ -11,7 +11,7 @@
     buf = Circular()
     i = 10
     sa = 0
-    while i < 200000000:
+    while i < 20000000:
         sa += buf[i-2] + buf[i-1] + buf[i] + buf[i+1] + buf[i+2]
         i += 1
     return sa



More information about the Pypy-commit mailing list