Commits

Alex Gaynor  committed 2024b06

some random pep8 cleanups

  • Participants
  • Parent commits 8148f32

Comments (0)

Files changed (3)

File rpython/jit/metainterp/optimizeopt/generalize.py

 from rpython.jit.metainterp.optimizeopt.optimizer import MININT, MAXINT
 
+
 class GeneralizationStrategy(object):
     def __init__(self, optimizer):
         self.optimizer = optimizer
     def apply(self):
         raise NotImplementedError
 
+
 class KillHugeIntBounds(GeneralizationStrategy):
     def apply(self):
         for v in self.optimizer.values.values():
             if v.is_constant():
                 continue
-            if v.intbound.lower < MININT/2:
+            if v.intbound.lower < MININT / 2:
                 v.intbound.lower = MININT
-            if v.intbound.upper > MAXINT/2:
+            if v.intbound.upper > MAXINT / 2:
                 v.intbound.upper = MAXINT
-          

File rpython/jit/metainterp/optimizeopt/heap.py

 import os
 
+from rpython.jit.metainterp.history import Const
 from rpython.jit.metainterp.jitexc import JitException
 from rpython.jit.metainterp.optimizeopt.optimizer import Optimization, MODE_ARRAY, LEVEL_KNOWNCLASS
-from rpython.jit.metainterp.history import ConstInt, Const
 from rpython.jit.metainterp.optimizeopt.util import make_dispatcher_method
 from rpython.jit.metainterp.resoperation import rop, ResOperation
 from rpython.rlib.objectmodel import we_are_translated
     def do_setfield(self, optheap, op):
         # Update the state with the SETFIELD_GC/SETARRAYITEM_GC operation 'op'.
         structvalue = optheap.getvalue(op.getarg(0))
-        fieldvalue  = optheap.getvalue(op.getarglist()[-1])
+        fieldvalue = optheap.getvalue(op.getarglist()[-1])
         if self.possible_aliasing(optheap, structvalue):
             self.force_lazy_setfield(optheap)
             assert not self.possible_aliasing(optheap, structvalue)
         cached_fieldvalue = self._cached_fields.get(structvalue, None)
 
         # Hack to ensure constants are imported from the preamble
-        if cached_fieldvalue and fieldvalue.is_constant(): 
+        if cached_fieldvalue and fieldvalue.is_constant():
             optheap.optimizer.ensure_imported(cached_fieldvalue)
             cached_fieldvalue = self._cached_fields.get(structvalue, None)
 
             if not self._lazy_setfield_registered:
                 optheap._lazy_setfields_and_arrayitems.append(self)
                 self._lazy_setfield_registered = True
-            
+
         else:
             # this is the case where the pending setfield ends up
             # storing precisely the value that is already there,
             # back in the cache: the value of this particular structure's
             # field.
             structvalue = optheap.getvalue(op.getarg(0))
-            fieldvalue  = optheap.getvalue(op.getarglist()[-1])
+            fieldvalue = optheap.getvalue(op.getarglist()[-1])
             self.remember_field_value(structvalue, fieldvalue, op)
         elif not can_cache:
             self.clear()
         #
         cf = self.field_cache(op.getdescr())
         cf.do_setfield(self, op)
-        
 
     def optimize_GETARRAYITEM_GC(self, op):
         arrayvalue = self.getvalue(op.getarg(0))

File rpython/jit/metainterp/optimizeopt/intbounds.py

 import sys
-from rpython.jit.metainterp.optimizeopt.optimizer import Optimization, CONST_1, CONST_0, \
-                                                  MODE_ARRAY, MODE_STR, MODE_UNICODE
 from rpython.jit.metainterp.history import ConstInt
+from rpython.jit.metainterp.optimize import InvalidLoop
 from rpython.jit.metainterp.optimizeopt.intutils import (IntBound, IntLowerBound,
     IntUpperBound)
+from rpython.jit.metainterp.optimizeopt.optimizer import (Optimization, CONST_1,
+    CONST_0, MODE_ARRAY, MODE_STR, MODE_UNICODE)
 from rpython.jit.metainterp.optimizeopt.util import make_dispatcher_method
 from rpython.jit.metainterp.resoperation import rop
-from rpython.jit.metainterp.optimize import InvalidLoop
-from rpython.rlib.rarithmetic import LONG_BIT
 
 
 class OptIntBounds(Optimization):
         assert not op.is_ovf()
         self.emit_operation(op)
 
-
     def propagate_bounds_backward(self, box):
         # FIXME: This takes care of the instruction where box is the reuslt
         #        but the bounds produced by all instructions where box is
         if v2.is_constant():
             val = v2.box.getint()
             if val >= 0:
-                r.intbound.intersect(IntBound(0,val))
+                r.intbound.intersect(IntBound(0, val))
         elif v1.is_constant():
             val = v1.box.getint()
             if val >= 0:
-                r.intbound.intersect(IntBound(0,val))
+                r.intbound.intersect(IntBound(0, val))
 
     def optimize_INT_SUB(self, op):
         v1 = self.getvalue(op.getarg(0))
     def optimize_INT_MOD(self, op):
         v1 = self.getvalue(op.getarg(0))
         v2 = self.getvalue(op.getarg(1))
-        known_nonneg = (v1.intbound.known_ge(IntBound(0, 0)) and 
+        known_nonneg = (v1.intbound.known_ge(IntBound(0, 0)) and
                         v2.intbound.known_ge(IntBound(0, 0)))
         if known_nonneg and v2.is_constant():
             val = v2.box.getint()
         if opnum not in (rop.INT_ADD_OVF, rop.INT_SUB_OVF, rop.INT_MUL_OVF):
             raise InvalidLoop('An INT_xxx_OVF was proven not to overflow but' +
                               'guarded with GUARD_OVERFLOW')
-                             
+
         self.emit_operation(op)
 
     def optimize_INT_ADD_OVF(self, op):
 
     def optimize_ARRAYLEN_GC(self, op):
         self.emit_operation(op)
-        array  = self.getvalue(op.getarg(0))
+        array = self.getvalue(op.getarg(0))
         result = self.getvalue(op.result)
         array.make_len_gt(MODE_ARRAY, op.getdescr(), -1)
         array.lenbound.bound.intersect(result.intbound)
 
     def optimize_STRLEN(self, op):
         self.emit_operation(op)
-        array  = self.getvalue(op.getarg(0))
+        array = self.getvalue(op.getarg(0))
         result = self.getvalue(op.result)
         array.make_len_gt(MODE_STR, op.getdescr(), -1)
         array.lenbound.bound.intersect(result.intbound)
 
     def optimize_UNICODELEN(self, op):
         self.emit_operation(op)
-        array  = self.getvalue(op.getarg(0))
+        array = self.getvalue(op.getarg(0))
         result = self.getvalue(op.result)
         array.make_len_gt(MODE_UNICODE, op.getdescr(), -1)
         array.lenbound.bound.intersect(result.intbound)
         if v1.intbound.intersect(b):
             self.propagate_bounds_backward(op.getarg(0))
 
-    propagate_bounds_INT_ADD_OVF  = propagate_bounds_INT_ADD
-    propagate_bounds_INT_SUB_OVF  = propagate_bounds_INT_SUB
-    propagate_bounds_INT_MUL_OVF  = propagate_bounds_INT_MUL
+    propagate_bounds_INT_ADD_OVF = propagate_bounds_INT_ADD
+    propagate_bounds_INT_SUB_OVF = propagate_bounds_INT_SUB
+    propagate_bounds_INT_MUL_OVF = propagate_bounds_INT_MUL
 
 
 dispatch_opt = make_dispatcher_method(OptIntBounds, 'optimize_',