[pypy-commit] pypy default: (fijal, arigo) Kill random stupid subclasses
arigo
noreply at buildbot.pypy.org
Tue Feb 24 15:57:30 CET 2015
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r76101:32ed1868d4fa
Date: 2015-02-24 15:20 +0100
http://bitbucket.org/pypy/pypy/changeset/32ed1868d4fa/
Log: (fijal, arigo) Kill random stupid subclasses
diff --git a/rpython/jit/metainterp/optimizeopt/intutils.py b/rpython/jit/metainterp/optimizeopt/intutils.py
--- a/rpython/jit/metainterp/optimizeopt/intutils.py
+++ b/rpython/jit/metainterp/optimizeopt/intutils.py
@@ -252,42 +252,21 @@
guards.append(op)
-class IntUpperBound(IntBound):
- def __init__(self, upper):
- self.has_upper = True
- self.has_lower = False
- self.upper = upper
- self.lower = 0
+def IntUpperBound(upper):
+ b = IntBound(lower=0, upper=upper)
+ b.has_lower = False
+ return b
-class IntLowerBound(IntBound):
- def __init__(self, lower):
- self.has_upper = False
- self.has_lower = True
- self.upper = 0
- self.lower = lower
+def IntLowerBound(lower):
+ b = IntBound(upper=0, lower=lower)
+ b.has_upper = False
+ return b
-class IntUnbounded(IntBound):
- def __init__(self):
- self.has_upper = False
- self.has_lower = False
- self.upper = 0
- self.lower = 0
-
-class ImmutableIntUnbounded(IntUnbounded):
- def _raise(self):
- raise TypeError('ImmutableIntUnbounded is immutable')
- def make_le(self, other):
- self._raise()
- def make_lt(self, other):
- self._raise()
- def make_ge(self, other):
- self._raise()
- def make_gt(self, other):
- self._raise()
- def make_constant(self, value):
- self._raise()
- def intersect(self, other):
- self._raise()
+def IntUnbounded():
+ b = IntBound(upper=0, lower=0)
+ b.has_lower = False
+ b.has_upper = False
+ return b
def min4(t):
return min(min(t[0], t[1]), min(t[2], t[3]))
diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py b/rpython/jit/metainterp/optimizeopt/optimizer.py
--- a/rpython/jit/metainterp/optimizeopt/optimizer.py
+++ b/rpython/jit/metainterp/optimizeopt/optimizer.py
@@ -3,7 +3,6 @@
from rpython.jit.metainterp.history import BoxInt, BoxFloat, Const, ConstInt,\
REF, BoxPtr, ConstPtr, ConstFloat
from rpython.jit.metainterp.optimizeopt.intutils import IntBound, IntUnbounded,\
- ImmutableIntUnbounded, \
IntLowerBound, MININT,\
MAXINT
from rpython.jit.metainterp.optimizeopt.util import make_dispatcher_method
@@ -323,19 +322,17 @@
class IntOptValue(OptValue):
_attrs_ = ('intbound',)
- intbound = ImmutableIntUnbounded()
-
def __init__(self, box, level=None, known_class=None, intbound=None):
OptValue.__init__(self, box, level, None, None)
if isinstance(box, Const):
+ value = box.getint()
+ self.intbound = IntBound(value, value)
return
if intbound:
self.intbound = intbound
else:
- if isinstance(box, BoxInt):
- self.intbound = IntBound(MININT, MAXINT)
- else:
- self.intbound = IntUnbounded()
+ assert isinstance(box, BoxInt)
+ self.intbound = IntBound(MININT, MAXINT)
def copy_from(self, other_value):
assert isinstance(other_value, IntOptValue)
More information about the pypy-commit
mailing list