[pypy-svn] pypy jit-short_from_state: moved loop_invariant_results to rewrite

hakanardo commits-noreply at bitbucket.org
Wed Mar 30 08:19:27 CEST 2011


Author: Hakan Ardo <hakan at debian.org>
Branch: jit-short_from_state
Changeset: r43007:13da0acdf169
Date: 2011-03-29 18:43 +0200
http://bitbucket.org/pypy/pypy/changeset/13da0acdf169/

Log:	moved loop_invariant_results to rewrite

diff --git a/pypy/jit/metainterp/optimizeopt/rewrite.py b/pypy/jit/metainterp/optimizeopt/rewrite.py
--- a/pypy/jit/metainterp/optimizeopt/rewrite.py
+++ b/pypy/jit/metainterp/optimizeopt/rewrite.py
@@ -12,10 +12,16 @@
     """Rewrite operations into equivalent, cheaper operations.
        This includes already executed operations and constants.
     """
+    def __init__(self):
+        self.loop_invariant_results = {}
 
     def reconstruct_for_next_iteration(self, surviving_boxes,
                                        optimizer, valuemap):
-        return OptRewrite()
+        new = OptRewrite()
+        for key, value in self.loop_invariant_results.items():
+            new.loop_invariant_results[key] = \
+                                 value.get_cloned(new, valuemap)
+        return new
     
     def propagate_forward(self, op):
         args = self.optimizer.make_args_key(op)
@@ -292,7 +298,7 @@
         # expects a compile-time constant
         assert isinstance(arg, Const)
         key = make_hashable_int(arg.getint())
-        resvalue = self.optimizer.loop_invariant_results.get(key, None)
+        resvalue = self.loop_invariant_results.get(key, None)
         if resvalue is not None:
             self.make_equal_to(op.result, resvalue)
             return
@@ -301,7 +307,7 @@
         op = op.copy_and_change(rop.CALL)
         self.emit_operation(op)
         resvalue = self.getvalue(op.result)
-        self.optimizer.loop_invariant_results[key] = resvalue
+        self.loop_invariant_results[key] = resvalue
     
     def _optimize_nullness(self, op, box, expect_nonnull):
         value = self.getvalue(box)

diff --git a/pypy/jit/metainterp/optimizeopt/optimizer.py b/pypy/jit/metainterp/optimizeopt/optimizer.py
--- a/pypy/jit/metainterp/optimizeopt/optimizer.py
+++ b/pypy/jit/metainterp/optimizeopt/optimizer.py
@@ -265,7 +265,6 @@
         self.interned_refs = self.cpu.ts.new_ref_dict()
         self.resumedata_memo = resume.ResumeDataLoopMemo(metainterp_sd)
         self.bool_boxes = {}
-        self.loop_invariant_results = {}
         self.pure_operations = args_dict()
         self.producer = {}
         self.pendingfields = []
@@ -310,17 +309,11 @@
                          for o in self.optimizations]
         new.set_optimizations(optimizations)
 
-        new.interned_refs = self.interned_refs
-        new.bool_boxes = {}
+        new.interned_refs = self.interned_refs # Constants
+        new.bool_boxes = {} # Flags values as bools
         for value in new.bool_boxes.keys():
             new.bool_boxes[value.get_cloned(new, valuemap)] = None
 
-        # FIXME: Move to rewrite.py
-        new.loop_invariant_results = {}
-        for key, value in self.loop_invariant_results.items():
-            new.loop_invariant_results[key] = \
-                                 value.get_cloned(new, valuemap)
-
         new.pure_operations = self.pure_operations
         new.producer = self.producer
         assert self.posponedop is None


More information about the Pypy-commit mailing list