Author: Maciej Fijalkowski <[email protected]>
Branch: result-in-resops
Changeset: r58497:eacd35d4d91a
Date: 2012-10-27 11:54 +0200
http://bitbucket.org/pypy/pypy/changeset/eacd35d4d91a/
Log: figure out isnull/isnonnull
diff --git a/pypy/jit/metainterp/optimizeopt/rewrite.py
b/pypy/jit/metainterp/optimizeopt/rewrite.py
--- a/pypy/jit/metainterp/optimizeopt/rewrite.py
+++ b/pypy/jit/metainterp/optimizeopt/rewrite.py
@@ -212,13 +212,6 @@
def postprocess_GUARD_FALSE(self, op):
self.postprocess_guard(op, CONST_0)
- def postprocess_GUARD_NO_OVERFLOW(self, op):
- pass # to be killed
-
- def postprocess_default(self, op):
- if op.is_guard():
- xxx
-
def optimize_GUARD_ISNULL(self, op):
value = self.getvalue(op.getarg(0))
if value.is_null():
@@ -229,14 +222,14 @@
value.make_constant(self.optimizer.cpu.ts.CONST_NULL)
def optimize_GUARD_NONNULL(self, op):
- value = self.getvalue(op.getarg(0))
+ value = self.getforwarded(op.getarg(0))
if value.is_nonnull():
return
elif value.is_null():
raise InvalidLoop('A GUARD_NONNULL was proven to always fail')
- pos = self.optimizer.get_pos()
- self.emit_operation(op)
- value.make_nonnull(op, pos)
+ value.setknownnonnull(True)
+ value.setlastguardpos(self.optimizer.getpos())
+ return op
def optimize_GUARD_VALUE(self, op):
value = self.getforwarded(op.getarg(0))
@@ -371,9 +364,9 @@
def _optimize_nullness(self, op, arg, expect_nonnull):
value = self.getforwarded(arg)
- if value.nonnull():
+ if value.is_nonnull():
self.make_constant_int(op, expect_nonnull)
- elif not value.nonnull():
+ elif value.is_null():
self.make_constant_int(op, not expect_nonnull)
else:
return op
diff --git a/pypy/jit/metainterp/optmodel.py b/pypy/jit/metainterp/optmodel.py
--- a/pypy/jit/metainterp/optmodel.py
+++ b/pypy/jit/metainterp/optmodel.py
@@ -22,6 +22,12 @@
def force(self, _):
return self
+ def is_nonnull(self):
+ return self.nonnull()
+
+ def is_null(self):
+ return not self.nonnull()
+
def create_mutable_subclasses():
def addattr(cls, attr, default_value=None):
cls.attributes_to_copy.append('_' + attr)
@@ -40,6 +46,18 @@
setattr(new, attr, getattr(self, attr))
cls._copy_extra_attrs = _copy_extra_attrs
+ def int_is_null(self):
+ return False
+
+ def int_is_nonnull(self):
+ xxx
+
+ def ref_is_null(self):
+ return False
+
+ def ref_is_nonnull(self):
+ return self.getknownclass() is not None or self.getknownnonnull()
+
imm_int_unbound = ImmutableIntUnbounded()
for i, cls in enumerate(opclasses):
if cls is None:
@@ -64,8 +82,13 @@
# all the integers have bounds
addattr(Mutable, 'intbound', imm_int_unbound)
addattr(Mutable, 'boolres', False)
+ Mutable.is_nonnull = int_is_nonnull
+ Mutable.is_null = int_is_null
elif cls.type == REF:
addattr(Mutable, 'knownclass', None)
+ addattr(Mutable, 'knownnonnull', False)
+ Mutable.is_nonnull = ref_is_nonnull
+ Mutable.is_null = ref_is_null
# for tracking last guard and merging GUARD_VALUE with
# GUARD_NONNULL etc
addattr(Mutable, 'lastguardpos', -1)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit