[pypy-svn] r33940 - in pypy/dist/pypy/jit/timeshifter: . test
pedronis at codespeak.net
pedronis at codespeak.net
Tue Oct 31 11:49:52 CET 2006
Author: pedronis
Date: Tue Oct 31 11:49:51 2006
New Revision: 33940
Modified:
pypy/dist/pypy/jit/timeshifter/rtyper.py
pypy/dist/pypy/jit/timeshifter/test/test_portal.py
pypy/dist/pypy/jit/timeshifter/test/test_promotion.py
Log:
(arre, pedronis)
add debug support to read graphs out of the portal cache. use it do check_isns. moved test_multiple_portal_calls to test_portal. doesn't
need avoiding caching anymore.
Modified: pypy/dist/pypy/jit/timeshifter/rtyper.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rtyper.py (original)
+++ pypy/dist/pypy/jit/timeshifter/rtyper.py Tue Oct 31 11:49:51 2006
@@ -201,6 +201,21 @@
state = PortalState()
rgenop = self.RGenOp()
+
+ # debug helper
+ def readportal(*args):
+ i = 0
+ key = ()
+ for color in argcolors:
+ if color == "green":
+ key = key + (args[i],)
+ i = i + 1
+ cache = state.cache
+ try:
+ return cache[key]
+ except KeyError:
+ return lltype.nullptr(FUNC)
+
def portalentry(*args):
i = 0
key = ()
@@ -254,6 +269,9 @@
origportalgraph.getreturnvar().concretetype)
portalentrygraph = annhelper.getgraph(portalentry, args_s, s_result)
+ self.readportalgraph = annhelper.getgraph(readportal, args_s,
+ annmodel.SomePtr(lltype.Ptr(FUNC)))
+
annhelper.finish()
origportalgraph.startblock = portalentrygraph.startblock
Modified: pypy/dist/pypy/jit/timeshifter/test/test_portal.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_portal.py (original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_portal.py Tue Oct 31 11:49:51 2006
@@ -4,7 +4,7 @@
from pypy.jit.timeshifter.rtyper import HintRTyper
from pypy.jit.timeshifter.test.test_timeshift import P_NOVIRTUAL
from pypy.rpython.llinterp import LLInterpreter
-from pypy.objspace.flow.model import checkgraph
+from pypy.objspace.flow.model import checkgraph, summary
from pypy.rpython.objectmodel import hint
from pypy.rpython.objectmodel import hint
@@ -27,7 +27,7 @@
key = main, portal, inline, policy, backendoptimize
try:
- maingraph, rtyper = self._cache[key]
+ maingraph, readportalgraph, rtyper = self._cache[key]
except KeyError:
if len(self._cache_order) >= 3:
del self._cache[self._cache_order.pop(0)]
@@ -51,12 +51,25 @@
if conftest.option.view:
t.view()
- self._cache[key] = maingraph, rtyper
+ readportalgraph = hrtyper.readportalgraph
+ self._cache[key] = maingraph, readportalgraph, rtyper
self._cache_order.append(key)
llinterp = LLInterpreter(rtyper)
- return llinterp.eval_graph(maingraph, main_args)
+ res = llinterp.eval_graph(maingraph, main_args)
+ self._residual_graph = llinterp.eval_graph(readportalgraph,
+ main_args)._obj.graph
+
+ return res
+
+ def check_insns(self, expected=None, **counts):
+ self.insns = summary(self._residual_graph)
+ if expected is not None:
+ assert self.insns == expected
+ for opname, count in counts.items():
+ assert self.insns.get(opname, 0) == count
+
def test_simple(self):
def main(code, x):
@@ -96,9 +109,9 @@
res = self.timeshift_from_portal(ll_function, ll_function, [4],
policy=P_NOVIRTUAL)
assert res == 68
- #self.check_insns(int_floordiv=1, int_mul=0)
+ self.check_insns(int_floordiv=1, int_mul=0)
res = self.timeshift_from_portal(ll_function, ll_function, [4],
policy=P_NOVIRTUAL)
assert res == 68
- #self.check_insns(int_floordiv=1, int_mul=0)
+ self.check_insns(int_floordiv=1, int_mul=0)
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 Tue Oct 31 11:49:51 2006
@@ -42,25 +42,6 @@
assert res == ll_function(10, 0)
self.check_insns(int_add=10, int_mul=0)
- def test_multiple_portal_calls(self):
- def ll_function(n):
- hint(None, global_merge_point=True)
- k = n
- if k > 5:
- k //= 2
- k = hint(k, promote=True)
- k *= 17
- return hint(k, variable=True)
- ll_function._dont_cache_ = 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):
S = lltype.GcStruct('S', ('x', lltype.Signed))
def ll_two(k, s):
More information about the Pypy-commit
mailing list