[pypy-svn] r21045 - in pypy/dist/pypy/jit: . test
arigo at codespeak.net
arigo at codespeak.net
Sun Dec 11 16:06:18 CET 2005
Author: arigo
Date: Sun Dec 11 16:06:16 2005
New Revision: 21045
Modified:
pypy/dist/pypy/jit/llabstractinterp.py
pypy/dist/pypy/jit/test/test_llabstractinterp.py
Log:
Cast_pointer support and test. Bug fix.
Modified: pypy/dist/pypy/jit/llabstractinterp.py
==============================================================================
--- pypy/dist/pypy/jit/llabstractinterp.py (original)
+++ pypy/dist/pypy/jit/llabstractinterp.py Sun Dec 11 16:06:16 2005
@@ -169,7 +169,7 @@
def forcevarorconst(self, builder):
v_result = newvar(lltype.Ptr(self.T))
if self.parent is not None:
- v_parent = self.parent.force(builder)
+ v_parent = self.parent.forcevarorconst(builder)
op = SpaceOperation('getsubstruct', [v_parent,
const(self.parentindex,
lltype.Void)],
@@ -679,6 +679,17 @@
return self.residualize(op, [a_ptr, a_index, a_value])
def op_cast_pointer(self, op, a_ptr):
+ if isinstance(a_ptr, LLVirtualStruct):
+ down_or_up = lltype.castable(op.result.concretetype,
+ a_ptr.getconcretetype())
+ a = a_ptr
+ if down_or_up >= 0:
+ for n in range(down_or_up):
+ a = a.getfield(a.T._names[0])
+ else:
+ for n in range(-down_or_up):
+ a = a.parent
+ return a
def constant_op(ptr):
return lltype.cast_pointer(op.result.concretetype, ptr)
return self.residualize(op, [a_ptr], constant_op)
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 16:06:16 2005
@@ -272,3 +272,15 @@
ll_do_nothing(s)
return s.n * t.n
graph2, insns = abstrinterp(ll_function, [1, 0], [])
+
+def test_cast_pointer():
+ S = lltype.GcStruct('S', ('n1', lltype.Signed), ('n2', lltype.Signed))
+ PS = lltype.Ptr(S)
+ T = lltype.GcStruct('T', ('s', S), ('n', lltype.Float))
+ def ll_function():
+ t = lltype.malloc(T)
+ s = lltype.cast_pointer(PS, t)
+ t.s.n1 = 12
+ return s.n1
+ graph2, insns = abstrinterp(ll_function, [], [])
+ assert insns == {}
More information about the Pypy-commit
mailing list