Author: Carl Friedrich Bolz <[email protected]>
Branch: 
Changeset: r81637:bf4390452db6
Date: 2016-01-08 21:20 +0100
http://bitbucket.org/pypy/pypy/changeset/bf4390452db6/

Log:    have consistent argument order between setfield and setitem

diff --git a/rpython/jit/metainterp/optimizeopt/heap.py 
b/rpython/jit/metainterp/optimizeopt/heap.py
--- a/rpython/jit/metainterp/optimizeopt/heap.py
+++ b/rpython/jit/metainterp/optimizeopt/heap.py
@@ -143,30 +143,32 @@
     # abstract methods
 
     def _get_rhs_from_set_op(self, op):
+        """ given a set(field or arrayitem) op, return the rhs argument """
         raise NotImplementedError("abstract method")
 
     def put_field_back_to_info(self, op, opinfo, optheap):
+        """ this method is called just after a lazy setfield was ommitted. it
+        puts the information of the lazy setfield back into the proper cache in
+        the info. """
         raise NotImplementedError("abstract method")
 
     def _getfield(self, opinfo, descr, optheap, true_force=True):
         raise NotImplementedError("abstract method")
 
     def invalidate(self, descr):
+        """ clear all the cached knowledge in the infos in self.cached_infos.
+        """
         raise NotImplementedError("abstract method")
 
 
 class CachedField(AbstractCachedEntry):
     def _get_rhs_from_set_op(self, op):
-        """ given a set(field or arrayitem) op, return the rhs argument """
         return op.getarg(1)
 
     def put_field_back_to_info(self, op, opinfo, optheap):
-        """ this method is called just after a lazy setfield was ommitted. it
-        puts the information of the lazy setfield back into the proper cache in
-        the info. """
         arg = optheap.get_box_replacement(op.getarg(1))
         struct = optheap.get_box_replacement(op.getarg(0))
-        opinfo.setfield(op.getdescr(), struct, arg, optheap, self)
+        opinfo.setfield(op.getdescr(), struct, arg, optheap=optheap, cf=self)
 
     def _getfield(self, opinfo, descr, optheap, true_force=True):
         res = opinfo.getfield(descr, optheap)
@@ -177,7 +179,7 @@
             if not true_force:
                 return res.op
             res = optheap.optimizer.force_op_from_preamble(res)
-            opinfo.setfield(descr, None, res, optheap)
+            opinfo.setfield(descr, None, res, optheap=optheap)
         return res
 
     def invalidate(self, descr):
@@ -213,7 +215,7 @@
     def put_field_back_to_info(self, op, opinfo, optheap):
         arg = optheap.get_box_replacement(op.getarg(2))
         struct = optheap.get_box_replacement(op.getarg(0))
-        opinfo.setitem(op.getdescr(), self.index, struct, arg, self, optheap)
+        opinfo.setitem(op.getdescr(), self.index, struct, arg, 
optheap=optheap, cf=self)
 
     def invalidate(self, descr):
         for opinfo in self.cached_infos:
@@ -261,7 +263,7 @@
         descrkeys = self.cached_fields.keys()
         if not we_are_translated():
             # XXX Pure operation of boxes that are cached in several places 
will
-            #     only be removed from the peeled loop when red from the first
+            #     only be removed from the peeled loop when read from the first
             #     place discovered here. This is far from ideal, as it makes
             #     the effectiveness of our optimization a bit random. It should
             #     howevere always generate correct results. For tests we dont
@@ -509,7 +511,7 @@
                 if self.optimizer.is_virtual(op.getarg(2)):
                     pendingfields.append(op)
                 else:
-                    cf.force_lazy_setfield(self, descr)                    
+                    cf.force_lazy_setfield(self, descr)
         return pendingfields
 
     def optimize_GETFIELD_GC_I(self, op):
@@ -523,7 +525,7 @@
         self.make_nonnull(op.getarg(0))
         self.emit_operation(op)
         # then remember the result of reading the field
-        structinfo.setfield(op.getdescr(), op.getarg(0), op, self, cf)
+        structinfo.setfield(op.getdescr(), op.getarg(0), op, optheap=self, 
cf=cf)
     optimize_GETFIELD_GC_R = optimize_GETFIELD_GC_I
     optimize_GETFIELD_GC_F = optimize_GETFIELD_GC_I
 
@@ -574,12 +576,12 @@
         # default case: produce the operation
         self.make_nonnull(op.getarg(0))
         self.emit_operation(op)
-        # the remember the result of reading the array item
+        # then remember the result of reading the array item
         if cf is not None:
             arrayinfo.setitem(op.getdescr(), indexb.getint(),
                               self.get_box_replacement(op.getarg(0)),
-                              self.get_box_replacement(op), cf,
-                              self)
+                              self.get_box_replacement(op), optheap=self,
+                              cf=cf)
     optimize_GETARRAYITEM_GC_R = optimize_GETARRAYITEM_GC_I
     optimize_GETARRAYITEM_GC_F = optimize_GETARRAYITEM_GC_I
 
diff --git a/rpython/jit/metainterp/optimizeopt/info.py 
b/rpython/jit/metainterp/optimizeopt/info.py
--- a/rpython/jit/metainterp/optimizeopt/info.py
+++ b/rpython/jit/metainterp/optimizeopt/info.py
@@ -524,7 +524,7 @@
             optforce.emit_operation(setop)
         optforce.pure_from_args(rop.ARRAYLEN_GC, [op], 
ConstInt(len(self._items)))
 
-    def setitem(self, descr, index, struct, op, cf=None, optheap=None):
+    def setitem(self, descr, index, struct, op, optheap=None, cf=None):
         if self._items is None:
             self._items = [None] * (index + 1)
         if index >= len(self._items):
@@ -700,13 +700,13 @@
         info = self._get_array_info(descr, optheap)
         return info.getitem(descr, index)
 
-    def setitem(self, descr, index, struct, op, cf=None, optheap=None):
+    def setitem(self, descr, index, struct, op, optheap=None, cf=None):
         info = self._get_array_info(descr, optheap)
-        info.setitem(descr, index, struct, op, cf)
+        info.setitem(descr, index, struct, op, optheap=optheap, cf=cf)
 
     def setfield(self, fielddescr, struct, op, optheap=None, cf=None):
         info = self._get_info(fielddescr.get_parent_descr(), optheap)
-        info.setfield(fielddescr, struct, op, optheap, cf)
+        info.setfield(fielddescr, struct, op, optheap=optheap, cf=cf)
 
     def is_null(self):
         return not bool(self._const.getref_base())
diff --git a/rpython/jit/metainterp/optimizeopt/shortpreamble.py 
b/rpython/jit/metainterp/optimizeopt/shortpreamble.py
--- a/rpython/jit/metainterp/optimizeopt/shortpreamble.py
+++ b/rpython/jit/metainterp/optimizeopt/shortpreamble.py
@@ -81,7 +81,7 @@
             assert index >= 0
             cf = optheap.arrayitem_cache(descr, index)
             opinfo.setitem(self.getfield_op.getdescr(), index, self.res,
-                           pop, cf, optheap=optheap)
+                           pop, optheap, cf)
 
     def repr(self, memo):
         return "HeapOp(%s, %s)" % (self.res.repr(memo),
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to