[pypy-commit] pypy jit-short_from_state: cleaner

hakanardo noreply at buildbot.pypy.org
Thu Jul 21 12:14:23 CEST 2011


Author: Hakan Ardo <hakan at debian.org>
Branch: jit-short_from_state
Changeset: r45801:d5c554280935
Date: 2011-07-20 16:48 +0200
http://bitbucket.org/pypy/pypy/changeset/d5c554280935/

Log:	cleaner

diff --git a/pypy/jit/metainterp/optimizeopt/intbounds.py b/pypy/jit/metainterp/optimizeopt/intbounds.py
--- a/pypy/jit/metainterp/optimizeopt/intbounds.py
+++ b/pypy/jit/metainterp/optimizeopt/intbounds.py
@@ -289,21 +289,21 @@
         array  = self.getvalue(op.getarg(0))
         result = self.getvalue(op.result)
         array.make_len_gt(MODE_ARRAY, op.getdescr(), -1)
-        result.intbound = array.lenbound[2]
+        result.intbound = array.lenbound.bound
 
     def optimize_STRLEN(self, op):
         self.emit_operation(op)
         array  = self.getvalue(op.getarg(0))
         result = self.getvalue(op.result)
         array.make_len_gt(MODE_STR, op.getdescr(), -1)
-        result.intbound = array.lenbound[2]
+        result.intbound = array.lenbound.bound
 
     def optimize_UNICODELEN(self, op):
         self.emit_operation(op)
         array  = self.getvalue(op.getarg(0))
         result = self.getvalue(op.result)
         array.make_len_gt(MODE_UNICODE, op.getdescr(), -1)
-        result.intbound = array.lenbound[2]
+        result.intbound = array.lenbound.bound
 
     def optimize_STRGETITEM(self, op):
         self.emit_operation(op)
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
@@ -25,6 +25,11 @@
 MODE_ARRAY   = '\x00'
 MODE_STR     = '\x01'
 MODE_UNICODE = '\x02'
+class LenBound(object):
+    def __init__(self, mode, descr, bound):
+        self.mode = mode
+        self.descr = descr
+        self.bound = bound
 
 class OptValue(object):
     __metaclass__ = extendabletype
@@ -55,11 +60,11 @@
 
     def make_len_gt(self, mode, descr, val):
         if self.lenbound:
-            assert self.lenbound[0] == mode
-            assert self.lenbound[1] == descr
-            self.lenbound[2].make_gt(IntBound(val, val))
+            assert self.lenbound.mode == mode
+            assert self.lenbound.descr == descr
+            self.lenbound.bound.make_gt(IntBound(val, val))
         else:
-            self.lenbound = (mode, descr, IntLowerBound(val + 1))
+            self.lenbound = LenBound(mode, descr, IntLowerBound(val + 1))
 
     def make_guards(self, box):
         guards = []
@@ -78,17 +83,17 @@
             self.intbound.make_guards(box, guards)
             if self.lenbound:
                 lenbox = BoxInt()
-                if self.lenbound[0] == MODE_ARRAY:
-                    op = ResOperation(rop.ARRAYLEN_GC, [box], lenbox, self.lenbound[1])
-                elif self.lenbound[0] == MODE_STR:
-                    op = ResOperation(rop.STRLEN, [box], lenbox, self.lenbound[1])
-                elif self.lenbound[0] == MODE_UNICODE:
-                    op = ResOperation(rop.UNICODELEN, [box], lenbox, self.lenbound[1])
+                if self.lenbound.mode == MODE_ARRAY:
+                    op = ResOperation(rop.ARRAYLEN_GC, [box], lenbox, self.lenbound.descr)
+                elif self.lenbound.mode == MODE_STR:
+                    op = ResOperation(rop.STRLEN, [box], lenbox, self.lenbound.descr)
+                elif self.lenbound.mode == MODE_UNICODE:
+                    op = ResOperation(rop.UNICODELEN, [box], lenbox, self.lenbound.descr)
                 else:
                     debug_print("Unknown lenbound mode")
                     assert False
                 guards.append(op)
-                self.lenbound[2].make_guards(lenbox, guards)
+                self.lenbound.bound.make_guards(lenbox, guards)
 
         return guards
 
diff --git a/pypy/jit/metainterp/optimizeopt/virtualstate.py b/pypy/jit/metainterp/optimizeopt/virtualstate.py
--- a/pypy/jit/metainterp/optimizeopt/virtualstate.py
+++ b/pypy/jit/metainterp/optimizeopt/virtualstate.py
@@ -237,9 +237,9 @@
             bad[other] = True
             return False
         if self.lenbound and other.lenbound:
-            if self.lenbound[0] != other.lenbound[0] or \
-               self.lenbound[1] != other.lenbound[1] or \
-               not self.lenbound[2].contains_bound(other.lenbound[2]):
+            if self.lenbound.mode != other.lenbound.mode or \
+               self.lenbound.descr != other.lenbound.descr or \
+               not self.lenbound.bound.contains_bound(other.lenbound.bound):
                 bad[self] = True
                 bad[other] = True
                 return False
@@ -341,7 +341,7 @@
 
         lb = ''
         if self.lenbound:
-            lb = ', ' + self.lenbound[2].__repr__()
+            lb = ', ' + self.lenbound.bound.__repr__()
         
         debug_print(indent + mark + 'NotVirtualInfo(%d' % self.position +
                     ', ' + l + ', ' + self.intbound.__repr__() + lb + ')')


More information about the pypy-commit mailing list