[pypy-svn] r32771 - in pypy/dist/pypy/jit: codegen/llgraph timeshifter timeshifter/test
arigo at codespeak.net
arigo at codespeak.net
Sat Sep 30 20:49:16 CEST 2006
Author: arigo
Date: Sat Sep 30 20:49:14 2006
New Revision: 32771
Modified:
pypy/dist/pypy/jit/codegen/llgraph/rgenop.py
pypy/dist/pypy/jit/timeshifter/rtyper.py
pypy/dist/pypy/jit/timeshifter/test/test_promotion.py
Log:
(pedronis, arigo)
More tests, all failing (but skipped). Checked in anyway because
these tests were not easy to arrive at.
Modified: pypy/dist/pypy/jit/codegen/llgraph/rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/llgraph/rgenop.py (original)
+++ pypy/dist/pypy/jit/codegen/llgraph/rgenop.py Sat Sep 30 20:49:14 2006
@@ -195,6 +195,10 @@
return LLConst(llimpl.genconst(llvalue))
@staticmethod
+ def erasedType(T):
+ return lltype.erasedType(T)
+
+ @staticmethod
@specialize.memo()
def kindToken(T):
return LLConst(llimpl.constTYPE(T))
Modified: pypy/dist/pypy/jit/timeshifter/rtyper.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rtyper.py (original)
+++ pypy/dist/pypy/jit/timeshifter/rtyper.py Sat Sep 30 20:49:14 2006
@@ -133,6 +133,7 @@
self.ll_fresh_jitstate = ll_fresh_jitstate
def ll_finish_jitstate(jitstate, graphsigtoken):
+ assert jitstate.resuming is None
returnbox = rtimeshift.getreturnbox(jitstate)
gv_ret = returnbox.getgenvar(jitstate.curbuilder)
store_global_excdata(jitstate)
@@ -826,8 +827,7 @@
TYPE = originalconcretetype(hop.args_s[0])
r_arg = self.getredrepr(TYPE)
[v_box] = hop.inputargs(r_arg)
- r_result = self.getgreenrepr(TYPE)
- ERASED = annmodel.annotation_to_lltype(r_result.erased_annotation())
+ ERASED = self.RGenOp.erasedType(TYPE)
desc = rtimeshift.PromotionDesc(ERASED, self)
s_desc = self.rtyper.annotator.bookkeeper.immutablevalue(desc)
c_desc = hop.inputconst(lltype.Void, desc)
Modified: pypy/dist/pypy/jit/timeshifter/test/test_promotion.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_promotion.py (original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_promotion.py Sat Sep 30 20:49:14 2006
@@ -42,6 +42,47 @@
assert res == ll_function(10, 0)
self.check_insns(int_add=10, int_mul=0)
+ def test_multiple_portal_calls(self):
+ # so far, crashes when we call timeshift() multiple times
+ py.test.skip("in-progress")
+ def ll_function(n):
+ k = n
+ if k > 5:
+ k //= 2
+ k = hint(k, promote=True)
+ k *= 17
+ return hint(k, variable=True)
+ ll_function._global_merge_points_ = True
+
+ res = self.timeshift(ll_function, [4], [], policy=P_NOVIRTUAL)
+ assert res == 68
+ self.check_insns(int_floordiv=1, int_mul=0)
+
+ res = self.timeshift(ll_function, [4], [], policy=P_NOVIRTUAL)
+ assert res == 68
+ self.check_insns(int_floordiv=1, int_mul=0)
+
+ def test_promote_after_call(self):
+ py.test.skip("the next problem to fix")
+ S = lltype.GcStruct('S', ('x', lltype.Signed))
+ def ll_two(k, s):
+ if k > 5:
+ s.x = 20
+ else:
+ s.x = 10
+ def ll_function(n):
+ s = lltype.malloc(S)
+ ll_two(n, s)
+ k = hint(n, promote=True)
+ k *= 17
+ return hint(k, variable=True) + s.x
+ ll_function._global_merge_points_ = True
+
+ res = self.timeshift(ll_function, [4], [], policy=P_NOVIRTUAL)
+ assert res == 4*17 + 10
+ self.check_insns(int_mul=0, int_add=1)
+
+
def test_method_call_nonpromote(self):
class Base(object):
pass
@@ -72,6 +113,48 @@
res = self.timeshift(ll_function, [5], [], policy=P_NOVIRTUAL)
assert res == 10
+ self.check_insns(indirect_call=2)
res = self.timeshift(ll_function, [0], [], policy=P_NOVIRTUAL)
assert res == 123123
+ self.check_insns(indirect_call=2)
+
+
+ def test_method_call_promote(self):
+ py.test.skip("in-progress")
+ class Base(object):
+ pass
+ class Int(Base):
+ def __init__(self, n):
+ self.n = n
+ def double(self):
+ return Int(self.n * 2)
+ def get(self):
+ return self.n
+ class Str(Base):
+ def __init__(self, s):
+ self.s = s
+ def double(self):
+ return Str(self.s + self.s)
+ def get(self):
+ return ord(self.s[4])
+
+ def ll_make(n):
+ if n > 0:
+ return Int(n)
+ else:
+ return Str('123')
+
+ def ll_function(n):
+ o = ll_make(n)
+ hint(o.__class__, promote=True)
+ return o.double().get()
+ ll_function._global_merge_points_ = True
+
+ res = self.timeshift(ll_function, [5], [], policy=P_NOVIRTUAL)
+ assert res == 10
+ self.check_insns(indirect_call=0, direct_call=1)
+
+ res = self.timeshift(ll_function, [0], [], policy=P_NOVIRTUAL)
+ assert res == ord('2')
+ self.check_insns(indirect_call=0, direct_call=1)
More information about the Pypy-commit
mailing list