[pypy-svn] r52066 - in pypy/branch/jit-refactoring/pypy/jit/rainbow: . test
arigo at codespeak.net
arigo at codespeak.net
Sun Mar 2 19:18:46 CET 2008
Author: arigo
Date: Sun Mar 2 19:18:46 2008
New Revision: 52066
Modified:
pypy/branch/jit-refactoring/pypy/jit/rainbow/portal.py
pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py
Log:
For test_llinterp, we need to translate a function to fish for the
generated residual graph.
Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/portal.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/portal.py (original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/portal.py Sun Mar 2 19:18:46 2008
@@ -79,12 +79,20 @@
from pypy.annotation import model as annmodel
annhelper = annlowlevel.MixLevelHelperAnnotator(self.rtyper)
FUNC = self.PORTAL_FUNCTYPE
+ RESFUNC = self.RESIDUAL_FUNCTYPE
args_s = [annmodel.lltype_to_annotation(ARG) for ARG in FUNC.ARGS]
s_result = annmodel.lltype_to_annotation(FUNC.RESULT)
self.portal_entry_graph = annhelper.getgraph(
self.portal_entry, args_s, s_result)
portal_entry_graph_ptr = annhelper.graph2delayed(
self.portal_entry_graph, FUNC)
+ # debugging
+ state = self.state
+ def ll_get_residual_fnptr():
+ return state.get_residual_fnptr()
+ self.get_residual_fnptr_graph = annhelper.getgraph(
+ ll_get_residual_fnptr, [],
+ annmodel.lltype_to_annotation(lltype.Ptr(RESFUNC)))
annhelper.finish()
# the following gives a pdb prompt when portal_entry raises an exception
@@ -113,6 +121,17 @@
redportargdesccls = RedPortalArgDesc
return redportargdesccls(lowleveltype, self.RGenOp)
+ def get_residual_graph(self, llinterp):
+ # debugging helper
+ portalstate = self.state
+ if not self.translate_support_code:
+ residual_graph_ptr = portalstate.get_residual_fnptr()
+ else:
+ residual_graph_ptr = llinterp.eval_graph(
+ self.get_residual_fnptr_graph, [])
+ residual_graph = residual_graph_ptr._obj.graph
+ return residual_graph
+
def make_state_class(args_specification, RESIDUAL_FUNCTYPE, sigtoken,
portal_jitcode, rtyper, codewriter):
@@ -287,6 +306,16 @@
def readallportals(self):
return [gv_gen.revealconst(lltype.Ptr(RESIDUAL_FUNCTYPE))
for gv_gen in self.cache.values()]
+
+ def get_residual_fnptr(self):
+ lst = self.readallportals()
+ if len(lst) == 1:
+ return lst[0]
+ elif len(lst) == 0:
+ raise Exception("no residual graph!")
+ else:
+ raise Exception("multiple residual graphs")
+
return PortalState
Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py (original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py Sun Mar 2 19:18:46 2008
@@ -62,22 +62,14 @@
inline=inline, policy=policy,
backendoptimize=backendoptimize)
self.main_args = main_args
- self.main_is_portal = main is portal
- llinterp = LLInterpreter(self.rtyper,
+ self.llinterp = LLInterpreter(self.rtyper,
exc_data_ptr=
self.writer.exceptiondesc.exc_data_ptr)
- res = llinterp.eval_graph(self.maingraph, main_args)
+ res = self.llinterp.eval_graph(self.maingraph, main_args)
return res
def get_residual_graph(self):
- portalstate = self.rewriter.state
- if self.main_is_portal:
- residual_graph = portalstate.readportal(*self.main_args)._obj.graph
- else:
- residual_graphs = portalstate.readallportals()
- assert len(residual_graphs) == 1
- residual_graph = residual_graphs[0]._obj.graph
- return residual_graph
+ return self.rewriter.get_residual_graph(self.llinterp)
def count_direct_calls(self):
residual_graph = self.get_residual_graph()
More information about the pypy-svn
mailing list