[pypy-svn] r21042 - in pypy/dist/pypy/jit: . test
arigo at codespeak.net
arigo at codespeak.net
Sun Dec 11 15:31:51 CET 2005
Author: arigo
Date: Sun Dec 11 15:31:49 2005
New Revision: 21042
Modified:
pypy/dist/pypy/jit/llabstractinterp.py
pypy/dist/pypy/jit/test/test_llabstractinterp.py
Log:
Bug fix, with a test.
Modified: pypy/dist/pypy/jit/llabstractinterp.py
==============================================================================
--- pypy/dist/pypy/jit/llabstractinterp.py (original)
+++ pypy/dist/pypy/jit/llabstractinterp.py Sun Dec 11 15:31:49 2005
@@ -260,7 +260,13 @@
return None
def with_fresh_variables(self, memo):
- return LLVirtualPtr(self.containerobj.copy(memo))
+ if self in memo:
+ return memo[self]
+ else:
+ result = LLVirtualPtr(None)
+ memo[self] = result
+ result.containerobj = self.containerobj.copy(memo)
+ return result
def match(self, other, memo):
if isinstance(other, LLVirtualPtr):
Modified: pypy/dist/pypy/jit/test/test_llabstractinterp.py
==============================================================================
--- pypy/dist/pypy/jit/test/test_llabstractinterp.py (original)
+++ pypy/dist/pypy/jit/test/test_llabstractinterp.py Sun Dec 11 15:31:49 2005
@@ -239,3 +239,36 @@
return n1 * n2
graph2, insns = abstrinterp(ll_function, [7, 1], [0])
assert insns == {'int_is_true': 1, 'int_add': 1, 'int_mul': 1}
+
+def test_dont_merge_forced_and_not_forced():
+ S = lltype.GcStruct('S', ('n', lltype.Signed))
+ def ll_do_nothing(s):
+ s.n = 2
+ def ll_function(flag):
+ s = lltype.malloc(S)
+ s.n = 12
+ t = s.n
+ if flag:
+ ll_do_nothing(s)
+ return t + s.n
+ graph2, insns = abstrinterp(ll_function, [0], [])
+ # XXX fragile test: at the moment, the two branches of the 'if' are not
+ # being merged at all because 's' was forced in one case only.
+ assert insns == {'direct_call': 1, 'int_is_true': 1, 'int_add': 2,
+ 'malloc': 1, 'setfield': 2, 'getfield': 1}
+
+def test_unique_virtualptrs():
+ S = lltype.GcStruct('S', ('n', lltype.Signed))
+ def ll_do_nothing(s):
+ s.n = 2
+ def ll_function(flag, flag2):
+ s = lltype.malloc(S)
+ s.n = 12
+ if flag2: # flag2 should always be 0
+ t = lltype.nullptr(S)
+ else:
+ t = s
+ if flag:
+ ll_do_nothing(s)
+ return s.n * t.n
+ graph2, insns = abstrinterp(ll_function, [1, 0], [])
More information about the Pypy-commit
mailing list