[pypy-svn] pypy jit-short-preamble: assume functions marked @jit.loop_invariant dont have any sideeffects

hakanardo commits-noreply at bitbucket.org
Sun Jan 9 17:18:31 CET 2011


Author: Hakan Ardo <hakan at debian.org>
Branch: jit-short-preamble
Changeset: r40530:faff168b0646
Date: 2011-01-09 17:18 +0100
http://bitbucket.org/pypy/pypy/changeset/faff168b0646/

Log:	assume functions marked @jit.loop_invariant dont have any
	sideeffects

diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py b/pypy/jit/metainterp/optimizeopt/unroll.py
--- a/pypy/jit/metainterp/optimizeopt/unroll.py
+++ b/pypy/jit/metainterp/optimizeopt/unroll.py
@@ -7,6 +7,7 @@
 from pypy.jit.metainterp.optimizeutil import InvalidLoop, RetraceLoop
 from pypy.jit.metainterp.jitexc import JitException
 from pypy.jit.metainterp.history import make_hashable_int
+from pypy.jit.codewriter.effectinfo import EffectInfo
 
 # FIXME: Introduce some VirtualOptimizer super class instead
 
@@ -349,6 +350,7 @@
     # to preamble
     def safe_to_move(self, op):
         opnum = op.getopnum()
+        descr = op.getdescr()
         if op.is_always_pure() or op.is_foldable_guard():
             return True
         elif opnum == rop.JUMP:
@@ -357,7 +359,6 @@
               opnum == rop.GETFIELD_RAW):
             if self.heap_dirty:
                 return False
-            descr = op.getdescr()
             if descr in self.unsafe_getitem:
                 return False
             return True
@@ -365,7 +366,6 @@
               opnum == rop.GETARRAYITEM_RAW):
             if self.heap_dirty:
                 return False
-            descr = op.getdescr()
             if descr in self.unsafe_getarrayitem:
                 return False
             index = op.getarg(1)
@@ -379,13 +379,17 @@
                     return False
             return True
         elif opnum == rop.CALL:
-            arg = op.getarg(0)
-            if isinstance(arg, Const):
-                key = make_hashable_int(arg.getint())
-                resvalue = self.optimizer.loop_invariant_results.get(key, None)
-                if resvalue:
-                    return True # This once was CALL_LOOPINVARIANT
-                                # FIXME: Can we realy be sure of that?
+            effectinfo = descr.get_extra_info()
+            if effectinfo is not None:
+                if effectinfo.extraeffect == EffectInfo.EF_LOOPINVARIANT:
+                    return True
+            #arg = op.getarg(0)
+            #if isinstance(arg, Const):
+            #    key = make_hashable_int(arg.getint())
+            #    resvalue = self.optimizer.loop_invariant_results.get(key,None)
+            #    if resvalue:
+            #        return True # This once was CALL_LOOPINVARIANT
+            #                    # FIXME: Can we realy be sure of that?
         elif opnum == rop.GUARD_NO_EXCEPTION:
             return True # FIXME: Is this safe?
         return False

diff --git a/pypy/jit/codewriter/effectinfo.py b/pypy/jit/codewriter/effectinfo.py
--- a/pypy/jit/codewriter/effectinfo.py
+++ b/pypy/jit/codewriter/effectinfo.py
@@ -60,8 +60,12 @@
             return cls._cache[key]
         result = object.__new__(cls)
         result.readonly_descrs_fields = readonly_descrs_fields
-        result.write_descrs_fields = write_descrs_fields
-        result.write_descrs_arrays = write_descrs_arrays
+        if extraeffect == EffectInfo.EF_LOOPINVARIANT:            
+            result.write_descrs_fields = []
+            result.write_descrs_arrays = []
+        else:
+            result.write_descrs_fields = write_descrs_fields
+            result.write_descrs_arrays = write_descrs_arrays
         result.extraeffect = extraeffect
         result.oopspecindex = oopspecindex
         cls._cache[key] = result


More information about the Pypy-commit mailing list