Author: Alex Gaynor <alex.gay...@gmail.com> Branch: Changeset: r64942:8148f32245b6 Date: 2013-06-19 13:59 -0700 http://bitbucket.org/pypy/pypy/changeset/8148f32245b6/
Log: Soem cleanups. diff --git a/rpython/jit/metainterp/optimizeopt/virtualstate.py b/rpython/jit/metainterp/optimizeopt/virtualstate.py --- a/rpython/jit/metainterp/optimizeopt/virtualstate.py +++ b/rpython/jit/metainterp/optimizeopt/virtualstate.py @@ -1,22 +1,19 @@ from rpython.jit.metainterp import resume -from rpython.jit.metainterp.optimizeopt import virtualize -from rpython.jit.metainterp.optimizeopt.optimizer import LEVEL_CONSTANT, \ - LEVEL_KNOWNCLASS, \ - LEVEL_NONNULL, \ - LEVEL_UNKNOWN, \ - MININT, MAXINT, OptValue from rpython.jit.metainterp.history import BoxInt, ConstInt, BoxPtr, Const from rpython.jit.metainterp.optimize import InvalidLoop -from rpython.jit.metainterp.optimizeopt.intutils import IntBound, IntUnbounded +from rpython.jit.metainterp.optimizeopt import virtualize +from rpython.jit.metainterp.optimizeopt.intutils import IntUnbounded +from rpython.jit.metainterp.optimizeopt.optimizer import (LEVEL_CONSTANT, + LEVEL_KNOWNCLASS, LEVEL_NONNULL, LEVEL_UNKNOWN) from rpython.jit.metainterp.resoperation import rop, ResOperation -from rpython.rlib.objectmodel import we_are_translated from rpython.rlib.debug import debug_start, debug_stop, debug_print from rpython.rlib.objectmodel import we_are_translated -import os + class BadVirtualState(Exception): pass + class AbstractVirtualStateInfo(resume.AbstractVirtualInfo): position = -1 @@ -62,7 +59,6 @@ else: debug_print(indent + " ...") - def debug_header(self, indent): raise NotImplementedError @@ -143,6 +139,7 @@ def debug_header(self, indent): debug_print(indent + 'VirtualStateInfo(%d):' % self.position) + class VStructStateInfo(AbstractVirtualStructStateInfo): def __init__(self, typedescr, fielddescrs): AbstractVirtualStructStateInfo.__init__(self, fielddescrs) @@ -215,7 +212,6 @@ debug_print(indent + 'VArrayStateInfo(%d):' % self.position) - class VArrayStructStateInfo(AbstractVirtualStateInfo): def __init__(self, arraydescr, fielddescrs): self.arraydescr = arraydescr @@ -291,7 +287,6 @@ debug_print(indent + 'VArrayStructStateInfo(%d):' % self.position) - class NotVirtualStateInfo(AbstractVirtualStateInfo): def __init__(self, value, is_opaque=False): self.is_opaque = is_opaque @@ -382,21 +377,21 @@ extra_guards.append(op) return - if self.level == LEVEL_NONNULL and \ - other.level == LEVEL_UNKNOWN and \ - isinstance(box, BoxPtr) and \ - box.nonnull(): + if (self.level == LEVEL_NONNULL and + other.level == LEVEL_UNKNOWN and + isinstance(box, BoxPtr) and + box.nonnull()): op = ResOperation(rop.GUARD_NONNULL, [box], None) extra_guards.append(op) return - if self.level == LEVEL_UNKNOWN and \ - other.level == LEVEL_UNKNOWN and \ - isinstance(box, BoxInt) and \ - self.intbound.contains(box.getint()): + if (self.level == LEVEL_UNKNOWN and + other.level == LEVEL_UNKNOWN and + isinstance(box, BoxInt) and + self.intbound.contains(box.getint())): if self.intbound.has_lower: bound = self.intbound.lower - if not (other.intbound.has_lower and \ + if not (other.intbound.has_lower and other.intbound.lower >= bound): res = BoxInt() op = ResOperation(rop.INT_GE, [box, ConstInt(bound)], res) @@ -405,7 +400,7 @@ extra_guards.append(op) if self.intbound.has_upper: bound = self.intbound.upper - if not (other.intbound.has_upper and \ + if not (other.intbound.has_upper and other.intbound.upper <= bound): res = BoxInt() op = ResOperation(rop.INT_LE, [box, ConstInt(bound)], res) @@ -417,9 +412,6 @@ # Remaining cases are probably not interesting raise InvalidLoop('Generating guards for making the VirtualStates ' + 'at hand match have not been implemented') - if self.level == LEVEL_CONSTANT: - import pdb; pdb.set_trace() - raise NotImplementedError def enum_forced_boxes(self, boxes, value, optimizer): if self.level == LEVEL_CONSTANT: @@ -463,6 +455,7 @@ debug_print(indent + mark + 'NotVirtualInfo(%d' % self.position + ', ' + l + ', ' + self.intbound.__repr__() + lb + ')') + class VirtualState(object): def __init__(self, state): self.state = state @@ -521,6 +514,7 @@ for s in self.state: s.debug_print(" ", seen, bad) + class VirtualStateAdder(resume.ResumeDataVirtualAdder): def __init__(self, optimizer): self.fieldboxes = {} @@ -587,9 +581,11 @@ def make_vrawbuffer(self, size, offsets, descrs): raise NotImplementedError + class BoxNotProducable(Exception): pass + class ShortBoxes(object): def __init__(self, optimizer, surviving_boxes, availible_boxes=None): self.potential_ops = {} @@ -672,7 +668,7 @@ if self.availible_boxes is not None and box not in self.availible_boxes: raise BoxNotProducable self.short_boxes_in_production[box] = None - + if box in self.potential_ops: ops = self.prioritized_alternatives(box) produced_one = False _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit