Author: Armin Rigo <[email protected]>
Branch:
Changeset: r44291:5d7d8c44407e
Date: 2011-05-18 19:01 +0200
http://bitbucket.org/pypy/pypy/changeset/5d7d8c44407e/
Log: Test and fix. Showed up for me on recent pypy-c's in
optimizeopt.unroll.sameop() that would (rarely) crash.
diff --git a/pypy/jit/metainterp/history.py b/pypy/jit/metainterp/history.py
--- a/pypy/jit/metainterp/history.py
+++ b/pypy/jit/metainterp/history.py
@@ -294,8 +294,8 @@
cpu.set_future_value_int(j, self.value)
def same_constant(self, other):
- if isinstance(other, Const):
- return self.value == other.getint()
+ if isinstance(other, ConstInt):
+ return self.value == other.value
return False
def nonnull(self):
diff --git a/pypy/jit/metainterp/test/test_history.py
b/pypy/jit/metainterp/test/test_history.py
--- a/pypy/jit/metainterp/test/test_history.py
+++ b/pypy/jit/metainterp/test/test_history.py
@@ -9,3 +9,20 @@
s = lltype.cast_pointer(lltype.Ptr(S), t)
const = ConstPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s))
assert const._getrepr_() == "*T"
+
+def test_same_constant():
+ c1a = ConstInt(0)
+ c1b = ConstInt(0)
+ c2a = ConstPtr(lltype.nullptr(llmemory.GCREF.TO))
+ c2b = ConstPtr(lltype.nullptr(llmemory.GCREF.TO))
+ c3a = Const._new(0.0)
+ c3b = Const._new(0.0)
+ assert c1a.same_constant(c1b)
+ assert not c1a.same_constant(c2b)
+ assert not c1a.same_constant(c3b)
+ assert not c2a.same_constant(c1b)
+ assert c2a.same_constant(c2b)
+ assert not c2a.same_constant(c3b)
+ assert not c3a.same_constant(c1b)
+ assert not c3a.same_constant(c2b)
+ assert c3a.same_constant(c3b)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit