Alex Gaynor avatar Alex Gaynor committed 34b8e7d

random pep8 cleanups

Comments (0)

Files changed (11)

rpython/jit/metainterp/compile.py

 from rpython.tool.sourcetools import func_with_new_name
 
 from rpython.jit.metainterp.resoperation import ResOperation, rop, get_deep_immutable_oplist
-from rpython.jit.metainterp.history import TreeLoop, Box, JitCellToken, TargetToken
-from rpython.jit.metainterp.history import AbstractFailDescr, BoxInt
-from rpython.jit.metainterp.history import BoxPtr, BoxFloat, ConstInt
-from rpython.jit.metainterp import history, resume, jitexc
+from rpython.jit.metainterp.history import (TreeLoop, Box, JitCellToken,
+    TargetToken, AbstractFailDescr, BoxInt, BoxPtr, BoxFloat, ConstInt)
+from rpython.jit.metainterp import history, jitexc
 from rpython.jit.metainterp.optimize import InvalidLoop
 from rpython.jit.metainterp.inliner import Inliner
 from rpython.jit.metainterp.resume import NUMBERING, PENDINGFIELDSP, ResumeDataDirectReader
 from rpython.jit.codewriter import heaptracker, longlong
 
+
 def giveup():
     from rpython.jit.metainterp.pyjitpl import SwitchToBlackhole
     raise SwitchToBlackhole(Counters.ABORT_BRIDGE)
 
+
 def show_procedures(metainterp_sd, procedure=None, error=None):
     # debugging
     if option and (option.view or option.viewloops):
 class AllVirtuals:
     llopaque = True
     cache = None
+
     def __init__(self, cache):
         self.cache = cache
+
     def hide(self, cpu):
         ptr = cpu.ts.cast_instance_to_base_ref(self)
         return cpu.ts.cast_to_ref(ptr)
+
     @staticmethod
     def show(cpu, gcref):
         from rpython.rtyper.annlowlevel import cast_base_ptr_to_instance
         ptr = cpu.ts.cast_to_baseclass(gcref)
         return cast_base_ptr_to_instance(AllVirtuals, ptr)
 
+
 class ResumeGuardForcedDescr(ResumeGuardDescr):
 
     def __init__(self, metainterp_sd, jitdriver_sd):
     b = c = -1
     for i in range(1, 5):
         if self.counters[i] > self.counters[a]:
-            c = b; b = a; a = i
+            c = b
+            b = a
+            a = i
         elif b < 0 or self.counters[i] > self.counters[b]:
-            c = b; b = i
+            c = b
+            b = i
         elif c < 0 or self.counters[i] > self.counters[c]:
             c = i
     self.counters[c] = 1
     assert len(redargtypes) == nb_red_args
     inputargs = []
     for kind in redargtypes:
-        if   kind == history.INT:   box = BoxInt()
-        elif kind == history.REF:   box = BoxPtr()
-        elif kind == history.FLOAT: box = BoxFloat()
-        else: raise AssertionError
+        if kind == history.INT:
+            box = BoxInt()
+        elif kind == history.REF:
+            box = BoxPtr()
+        elif kind == history.FLOAT:
+            box = BoxFloat()
+        else:
+            raise AssertionError
         inputargs.append(box)
     k = jitdriver_sd.portal_runner_adr
     funcbox = history.ConstInt(heaptracker.adr2int(k))
         ResOperation(rop.CALL, callargs, result, descr=jd.portal_calldescr),
         ResOperation(rop.GUARD_NO_EXCEPTION, [], None, descr=faildescr),
         ResOperation(rop.FINISH, finishargs, None, descr=jd.portal_finishtoken)
-        ]
+    ]
     operations[1].setfailargs([])
     operations = get_deep_immutable_oplist(operations)
     cpu.compile_loop(inputargs, operations, jitcell_token, log=False)

rpython/jit/metainterp/inliner.py

 from rpython.jit.metainterp.history import Const
 from rpython.jit.metainterp.resume import Snapshot
 
+
 class Inliner(object):
     def __init__(self, inputargs, jump_args):
         assert len(inputargs) == len(jump_args)
         new_snapshot = Snapshot(self.inline_snapshot(snapshot.prev), boxes)
         self.snapshot_map[snapshot] = new_snapshot
         return new_snapshot
-

rpython/jit/metainterp/jitprof.py

 
 class EmptyProfiler(BaseProfiler):
     initialized = True
-    
+
     def start(self):
         pass
 
     def end_backend(self):     self._end  (Counters.BACKEND)
 
     def count(self, kind, inc=1):
-        self.counters[kind] += inc        
+        self.counters[kind] += inc
 
     def get_counter(self, num):
         if num == Counters.TOTAL_COMPILED_LOOPS:

rpython/jit/metainterp/logger.py

-
-from rpython.rlib.debug import have_debug_prints
-from rpython.rlib.debug import debug_start, debug_stop, debug_print
+from rpython.jit.metainterp.history import (ConstInt, BoxInt, ConstFloat,
+    BoxFloat, TargetToken)
+from rpython.jit.metainterp.resoperation import rop
+from rpython.rlib.debug import (have_debug_prints, debug_start, debug_stop,
+    debug_print)
 from rpython.rlib.objectmodel import we_are_translated, compute_unique_id
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
-from rpython.jit.metainterp.resoperation import rop
-from rpython.jit.metainterp.history import ConstInt, \
-     BoxInt, ConstFloat, BoxFloat, TargetToken
+
 
 class Logger(object):
-
     def __init__(self, metainterp_sd, guard_number=False):
         self.metainterp_sd = metainterp_sd
         self.guard_number = guard_number
             debug_stop("jit-log-compiling-loop")
         else:
             debug_start("jit-log-opt-loop")
-            debug_print("# Loop", number, '(%s)' % name , ":", type,
+            debug_print("# Loop", number, '(%s)' % name, ":", type,
                         "with", len(operations), "ops")
             logops = self._log_operations(inputargs, operations, ops_offset)
             debug_stop("jit-log-opt-loop")
             else:
                 r = self.repr_of_descr(descr)
             if args:
-                args += ', descr=' +  r
+                args += ', descr=' + r
             else:
                 args = "descr=" + r
         if is_guard and op.getfailargs() is not None:

rpython/jit/metainterp/optimize.py

 from rpython.rlib.debug import debug_start, debug_stop, debug_print
 from rpython.jit.metainterp.jitexc import JitException
 
+
 class InvalidLoop(JitException):
     """Raised when the optimize*.py detect that the loop that
     we are trying to build cannot possibly make sense as a

rpython/jit/metainterp/optimizeopt/earlyforce.py

 from rpython.jit.codewriter.effectinfo import EffectInfo
 from rpython.jit.metainterp.optimizeopt.optimizer import Optimization
-from rpython.jit.metainterp.optimizeopt.vstring import VAbstractStringValue
-from rpython.jit.metainterp.resoperation import rop, ResOperation
+from rpython.jit.metainterp.resoperation import rop
+
 
 def is_raw_free(op, opnum):
     if opnum != rop.CALL:
     def propagate_forward(self, op):
         opnum = op.getopnum()
 
-        if (opnum != rop.SETFIELD_GC and 
+        if (opnum != rop.SETFIELD_GC and
             opnum != rop.SETARRAYITEM_GC and
             opnum != rop.SETARRAYITEM_RAW and
             opnum != rop.QUASIIMMUT_FIELD and
             opnum != rop.SAME_AS and
             opnum != rop.MARK_OPAQUE_PTR and
             not is_raw_free(op, opnum)):
-               
+
             for arg in op.getarglist():
                 if arg in self.optimizer.values:
                     value = self.getvalue(arg)
 
     def setup(self):
         self.optimizer.optearlyforce = self
-
-    

rpython/jit/metainterp/optimizeopt/test/test_multilabel.py

 from rpython.jit.metainterp.optimizeopt.optimizer import Optimization
 from rpython.jit.metainterp.optimizeopt.util import make_dispatcher_method
 
+
 class BaseTestMultiLabel(BaseTest):
     enable_opts = "intbounds:rewrite:virtualize:string:earlyforce:pure:heap:unroll"
 
         optimized = TreeLoop('optimized')
         optimized.inputargs = loop.inputargs
         optimized.operations = []
-        
+
         labels = [i for i, op in enumerate(loop.operations) \
                   if op.getopnum()==rop.LABEL]
         prv = 0
                 last_label = [part.operations.pop()]
             else:
                 last_label = []
-            
+
             optimized.operations.extend(part.operations)
             prv = nxt + 1
-        
+
         #
         print
         print "Optimized:"
                 self.assert_equal(short_preamble, expected_short,
                                   text_right='expected short preamble')
 
-        
+
         return optimized
 
 class OptimizeoptTestMultiLabel(BaseTestMultiLabel):
         [p1]
         p2 = new_array(3, descr=arraydescr)
         label(p2)
-        p4 = new_array(2, descr=arraydescr)        
+        p4 = new_array(2, descr=arraydescr)
         jump(p4)
         """
         with raises(InvalidLoop):
             self.optimize_loop(ops, ops)
-        
+
     def test_nonmatching_arraystruct_1(self):
         ops = """
         [p1, f0]
         """
         with raises(InvalidLoop):
             self.optimize_loop(ops, ops)
-        
+
     def test_nonmatching_arraystruct_2(self):
         ops = """
         [p1, f0]
         setinteriorfield_gc(p2, 2, f0, descr=complexrealdescr)
         label(p2, f0)
         p4 = new_array(2, descr=complexarraydescr)
-        setinteriorfield_gc(p4, 0, f0, descr=complexrealdescr)        
+        setinteriorfield_gc(p4, 0, f0, descr=complexrealdescr)
         jump(p4, f0)
         """
         with raises(InvalidLoop):
         """
         with raises(InvalidLoop):
             self.optimize_loop(ops, ops)
-        
+
     def test_virtuals_turns_not_equal(self):
         ops = """
         [p1, p2]
         short = """
         [p1, i1]
         label(p1, i1)
-        i2 = getfield_gc(p1, descr=valuedescr)        
+        i2 = getfield_gc(p1, descr=valuedescr)
         jump(p1, i1, i2)
         """
         self.optimize_loop(ops, expected, expected_shorts=[short, short])
         jump(p1, i5)
         """
         self.optimize_loop(ops, exported)
-    
+
     def test_import_virtual_across_multiple_labels(self):
         ops = """
         [p0, i1]
     def test_boxed_opaque_unknown_class(self):
         ops = """
         [p1]
-        p2 = getfield_gc(p1, descr=nextdescr) 
-        mark_opaque_ptr(p2)        
+        p2 = getfield_gc(p1, descr=nextdescr)
+        mark_opaque_ptr(p2)
         i3 = getfield_gc(p2, descr=otherdescr)
         label(p1)
         i4 = getfield_gc(p1, descr=otherdescr)
         label(p1)
-        p5 = getfield_gc(p1, descr=nextdescr) 
-        mark_opaque_ptr(p5)        
+        p5 = getfield_gc(p1, descr=nextdescr)
+        mark_opaque_ptr(p5)
         i6 = getfield_gc(p5, descr=otherdescr)
         i7 = call(i6, descr=nonwritedescr)
         """
         expected = """
         [p1]
-        p2 = getfield_gc(p1, descr=nextdescr) 
+        p2 = getfield_gc(p1, descr=nextdescr)
         i3 = getfield_gc(p2, descr=otherdescr)
         label(p1)
         i4 = getfield_gc(p1, descr=otherdescr)
         label(p1)
-        p5 = getfield_gc(p1, descr=nextdescr) 
+        p5 = getfield_gc(p1, descr=nextdescr)
         i6 = getfield_gc(p5, descr=otherdescr)
         i7 = call(i6, descr=nonwritedescr)
         """
     def test_opaque_pointer_fails_to_close_loop(self):
         ops = """
         [p1, p11]
-        p2 = getfield_gc(p1, descr=nextdescr) 
+        p2 = getfield_gc(p1, descr=nextdescr)
         guard_class(p2, ConstClass(node_vtable)) []
-        mark_opaque_ptr(p2)        
+        mark_opaque_ptr(p2)
         i3 = getfield_gc(p2, descr=otherdescr)
         label(p1, p11)
-        p12 = getfield_gc(p1, descr=nextdescr) 
+        p12 = getfield_gc(p1, descr=nextdescr)
         i13 = getfield_gc(p2, descr=otherdescr)
-        i14 = call(i13, descr=nonwritedescr)        
+        i14 = call(i13, descr=nonwritedescr)
         jump(p11, p1)
         """
         with raises(InvalidLoop):
             self.optimize_loop(ops, ops)
 
-            
+
 
 
 class OptRenameStrlen(Optimization):
         newop.result = op.result.clonebox()
         self.emit_operation(newop)
         self.make_equal_to(op.result, self.getvalue(newop.result))
-    
+
 dispatch_opt = make_dispatcher_method(OptRenameStrlen, 'optimize_',
                                       default=OptRenameStrlen.emit_operation)
 
         jump(p1, i11)
         """
         self.optimize_loop(ops, expected)
-        
+
 
 class TestLLtype(OptimizeoptTestMultiLabel, LLtypeMixin):
     pass

rpython/jit/metainterp/quasiimmut.py

 class QuasiImmut(object):
     llopaque = True
     compress_limit = 30
-    
+
     def __init__(self, cpu):
         self.cpu = cpu
         # list of weakrefs to the LoopTokens that must be invalidated if

rpython/jit/metainterp/resoperation.py

 from rpython.rlib.objectmodel import we_are_translated
 
+
 def ResOperation(opnum, args, result, descr=None):
     cls = opclasses[opnum]
     op = cls(result)
     def numargs(self):
         raise NotImplementedError
 
-
     # methods implemented by GuardResOp
     # ---------------------------------
 
 class PlainResOp(AbstractResOp):
     pass
 
+
 class ResOpWithDescr(AbstractResOp):
 
     _descr = None
         else:
             raise IndexError
 
+
 class N_aryOp(object):
     _mixin_ = True
     _args = None
         opclasses.append(cls)
         oparity.append(arity)
         opwithdescr.append(withdescr)
-    assert len(opclasses)==len(oparity)==len(opwithdescr)==len(_oplist)
+    assert len(opclasses) == len(oparity) == len(opwithdescr) == len(_oplist)
 
 def get_base_class(mixin, base):
     try:
         1: UnaryOp,
         2: BinaryOp,
         3: TernaryOp
-        }
+    }
 
     is_guard = name.startswith('GUARD')
     if is_guard:
 
     rop.PTR_EQ: rop.PTR_NE,
     rop.PTR_NE: rop.PTR_EQ,
-    }
+}
 
 opboolreflex = {
     rop.INT_EQ: rop.INT_EQ,
 
     rop.PTR_EQ: rop.PTR_EQ,
     rop.PTR_NE: rop.PTR_NE,
-    }
+}
 
 
 def get_deep_immutable_oplist(operations):

rpython/jit/metainterp/warmspot.py

-import sys, py
+import sys
+
+import py
+
 from rpython.tool.sourcetools import func_with_new_name
 from rpython.rtyper.lltypesystem import lltype, llmemory
-from rpython.rtyper.annlowlevel import llhelper, MixLevelHelperAnnotator,\
-     cast_base_ptr_to_instance, hlstr
+from rpython.rtyper.annlowlevel import (llhelper, MixLevelHelperAnnotator,
+    cast_base_ptr_to_instance, hlstr)
 from rpython.annotator import model as annmodel
 from rpython.rtyper.llinterp import LLException
 from rpython.rtyper.test.test_llinterp import get_interpreter, clear_tcache
 from rpython.jit.metainterp.pyjitpl import MetaInterpStaticData
 from rpython.jit.metainterp.jitprof import Profiler, EmptyProfiler
 from rpython.jit.metainterp.jitdriver import JitDriverStaticData
-from rpython.jit.codewriter import support, codewriter, longlong
+from rpython.jit.codewriter import support, codewriter
 from rpython.jit.codewriter.policy import JitPolicy
 from rpython.jit.codewriter.effectinfo import EffectInfo
 from rpython.jit.metainterp.optimizeopt import ALL_OPTS_NAMES
 
+
 # ____________________________________________________________
 # Bootstrapping
 
     warmrunnerdesc = WarmRunnerDesc(translator,
                                     translate_support_code=True,
                                     listops=True,
-                                    no_stats = True,
-                                    ProfilerClass = ProfilerClass,
+                                    no_stats=True,
+                                    ProfilerClass=ProfilerClass,
                                     **kwds)
     for jd in warmrunnerdesc.jitdrivers_sd:
         jd.warmstate.set_param_inlining(inline)
             c_new_driver = Constant(new_driver, v_driver.concretetype)
             op.args[1] = c_new_driver
 
-
     def find_portals(self):
         self.jitdrivers_sd = []
         graphs = self.translator.graphs
             self.annhelper = MixLevelHelperAnnotator(self.translator.rtyper)
         cpu = CPUClass(self.translator.rtyper, self.stats, self.opt,
                        translate_support_code, gcdescr=self.gcdescr)
-        if not supports_floats:       cpu.supports_floats       = False
-        if not supports_longlong:     cpu.supports_longlong     = False
-        if not supports_singlefloats: cpu.supports_singlefloats = False
+        if not supports_floats:
+            cpu.supports_floats = False
+        if not supports_longlong:
+            cpu.supports_longlong = False
+        if not supports_singlefloats:
+            cpu.supports_singlefloats = False
         self.cpu = cpu
 
     def build_meta_interp(self, ProfilerClass):
             # get special treatment since we rewrite it to a call that accepts
             # jit driver
             func = func_with_new_name(func, func.func_name + '_compiled')
+
             def new_func(ignored, *args):
                 return func(self, *args)
             ARGS = [lltype.Void] + [arg.concretetype for arg in op.args[3:]]
         from rpython.jit.metainterp.warmstate import specialize_value
         from rpython.jit.metainterp.warmstate import unspecialize_value
         portal_ptr = self.cpu.ts.functionptr(PORTALFUNC, 'portal',
-                                         graph = portalgraph)
+                                         graph=portalgraph)
         jd._portal_ptr = portal_ptr
         #
         portalfunc_ARGS = []
         ts = self.cpu.ts
         state = jd.warmstate
         maybe_compile_and_run = jd._maybe_compile_and_run_fn
-        cpu = jd.warmstate.cpu
 
         def ll_portal_runner(*args):
             start = True
 
         if self.cpu.translate_support_code:
             call_final_function(self.translator, finish,
-                                annhelper = self.annhelper)
+                                annhelper=self.annhelper)
 
     def rewrite_set_param_and_get_stats(self):
         from rpython.rtyper.lltypesystem.rstr import STR
             return Constant(funcptr, TP)
         #
         for graph, block, i in find_set_param(graphs):
-            
+
             op = block.operations[i]
             if op.args[1].value is not None:
                 for jd in self.jitdrivers_sd:

rpython/jit/metainterp/warmstate.py

-import sys, weakref
+import sys
+import weakref
+
+from rpython.jit.codewriter import support, heaptracker, longlong
+from rpython.jit.metainterp import history
+from rpython.rlib.debug import debug_start, debug_stop, debug_print
+from rpython.rlib.jit import PARAMETERS, BaseJitCell
+from rpython.rlib.nonconst import NonConstant
+from rpython.rlib.objectmodel import specialize, we_are_translated, r_dict
+from rpython.rlib.rarithmetic import intmask
+from rpython.rlib.unroll import unrolling_iterable
+from rpython.rtyper.annlowlevel import (hlstr, cast_base_ptr_to_instance,
+    cast_object_to_ptr)
 from rpython.rtyper.lltypesystem import lltype, llmemory, rstr, rffi
 from rpython.rtyper.ootypesystem import ootype
-from rpython.rtyper.annlowlevel import hlstr, cast_base_ptr_to_instance
-from rpython.rtyper.annlowlevel import cast_object_to_ptr
-from rpython.rlib.objectmodel import specialize, we_are_translated, r_dict
-from rpython.rlib.rarithmetic import intmask
-from rpython.rlib.nonconst import NonConstant
-from rpython.rlib.unroll import unrolling_iterable
-from rpython.rlib.jit import PARAMETERS
-from rpython.rlib.jit import BaseJitCell
-from rpython.rlib.debug import debug_start, debug_stop, debug_print
-from rpython.jit.metainterp import history
-from rpython.jit.codewriter import support, heaptracker, longlong
 
 # ____________________________________________________________
 
                 fn = support.maybe_on_top_of_llinterp(rtyper, inline_ptr)
                 return fn(*greenargs)
         self.should_unroll_one_iteration = should_unroll_one_iteration
-        
+
         redargtypes = ''.join([kind[0] for kind in jd.red_args_types])
 
         def get_assembler_token(greenkey):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.