Author: Carl Friedrich Bolz <[email protected]>
Branch:
Changeset: r45408:2ce2e3e205d8
Date: 2011-07-07 15:35 +0200
http://bitbucket.org/pypy/pypy/changeset/2ce2e3e205d8/
Log: don't repeat guard_isnull
diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py
--- a/pypy/jit/metainterp/pyjitpl.py
+++ b/pypy/jit/metainterp/pyjitpl.py
@@ -317,7 +317,10 @@
if box not in self.metainterp.known_class_boxes:
self.generate_guard(rop.GUARD_NONNULL, box, resumepc=orgpc)
else:
- self.generate_guard(rop.GUARD_ISNULL, box, resumepc=orgpc)
+ if not isinstance(box, Const):
+ self.generate_guard(rop.GUARD_ISNULL, box, resumepc=orgpc)
+ promoted_box = box.constbox()
+ self.metainterp.replace_box(box, promoted_box)
return value
@arguments("orgpc", "box", "label")
diff --git a/pypy/jit/metainterp/test/test_ajit.py
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -1040,6 +1040,29 @@
res = self.interp_operations(fn, [1])
assert not res
+ def test_guard_isnull_nullifies(self):
+ class A:
+ pass
+ a = A()
+ a.x = None
+ def fn(n):
+ if n == -7:
+ a.x = ""
+ obj = a.x
+ res = 0
+ if not obj:
+ res += 1
+ if obj:
+ res += 1
+ if obj is None:
+ res += 1
+ if obj is not None:
+ res += 1
+ return res
+ res = self.interp_operations(fn, [0])
+ assert res == 2
+ self.check_operations_history(guard_isnull=1)
+
def test_assert_isinstance(self):
class A:
pass
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit