[pypy-svn] r23517 - in pypy/dist/pypy: annotation rpython rpython/memory
arigo at codespeak.net
arigo at codespeak.net
Mon Feb 20 17:25:52 CET 2006
Author: arigo
Date: Mon Feb 20 17:25:50 2006
New Revision: 23517
Modified:
pypy/dist/pypy/annotation/annrpython.py
pypy/dist/pypy/rpython/annlowlevel.py
pypy/dist/pypy/rpython/memory/gctransform.py
Log:
(pedronis, arigo)
Changed the interface to annlowlevel.annotate_mixlevel_helper() to allow
multiple mix-level helpers to be "registered" for annotation, and then
annotated and rtyped in a single pass. This is useful for interdependent
helpers, which are much more frequent in RPython code than in LL code.
Modified: pypy/dist/pypy/annotation/annrpython.py
==============================================================================
--- pypy/dist/pypy/annotation/annrpython.py (original)
+++ pypy/dist/pypy/annotation/annrpython.py Mon Feb 20 17:25:50 2006
@@ -94,7 +94,7 @@
return self.build_graph_types(flowgraph, inputcells)
- def annotate_helper(self, function, args_s, policy=None):
+ def annotate_helper(self, function, args_s, policy=None, complete_now=True):
saved = self.policy, self.added_blocks
if policy is None:
from pypy.annotation.policy import AnnotatorPolicy
@@ -104,15 +104,24 @@
self.added_blocks = {}
desc = self.bookkeeper.getdesc(function)
graph = desc.specialize(args_s)
- s = self.build_graph_types(graph, args_s)
+ s = self.build_graph_types(graph, args_s, complete_now=complete_now)
# invoke annotation simplifications for the new blocks
self.simplify(block_subset=self.added_blocks)
finally:
self.policy, self.added_blocks = saved
return graph
+ def complete_helpers(self, policy):
+ saved = self.policy, self.added_blocks
+ self.policy = policy
+ try:
+ self.added_blocks = {}
+ self.complete()
+ self.simplify(block_subset=self.added_blocks)
+ finally:
+ self.policy, self.added_blocks = saved
- def build_graph_types(self, flowgraph, inputcells):
+ def build_graph_types(self, flowgraph, inputcells, complete_now=True):
checkgraph(flowgraph)
nbarg = len(flowgraph.getargs())
@@ -123,7 +132,8 @@
# register the entry point
self.addpendinggraph(flowgraph, inputcells)
# recursively proceed until no more pending block is left
- self.complete()
+ if complete_now:
+ self.complete()
return self.binding(flowgraph.getreturnvar(), extquery=True)
def gettype(self, variable):
Modified: pypy/dist/pypy/rpython/annlowlevel.py
==============================================================================
--- pypy/dist/pypy/rpython/annlowlevel.py (original)
+++ pypy/dist/pypy/rpython/annlowlevel.py Mon Feb 20 17:25:50 2006
@@ -112,6 +112,19 @@
return funcdesc.cachedgraph(key, alt_name=valid_identifier(alt_name))
-def annotate_mixlevel_helper(rtyper, ll_function, args_s):
+def pre_annotate_mixlevel_helper(rtyper, ll_function, args_s, s_result):
+ # get the graph of the mix-level helper ll_function and prepare it for
+ # being annotated. Annotation and RTyping should be done in a single shot
+ # at the end with finish_mixlevel_helpers().
pol = MixLevelAnnotatorPolicy(rtyper)
- return rtyper.annotator.annotate_helper(ll_function, args_s, policy=pol)
+ graph = rtyper.annotator.annotate_helper(ll_function, args_s, policy=pol,
+ complete_now=False)
+ rtyper.annotator.setbinding(graph.getreturnvar(), s_result)
+ return graph
+
+def finish_mixlevel_helpers(rtyper):
+ pol = MixLevelAnnotatorPolicy(rtyper)
+ rtyper.annotator.complete_helpers(pol)
+ # XXX maybe check that the promized s_results are correct?
+ rtyper.type_system.perform_normalizations(rtyper)
+ rtyper.specialize_more_blocks()
Modified: pypy/dist/pypy/rpython/memory/gctransform.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform.py (original)
+++ pypy/dist/pypy/rpython/memory/gctransform.py Mon Feb 20 17:25:50 2006
@@ -666,17 +666,26 @@
gcdata.root_stack_top = top
return result
- self.frameworkgc_setup_ptr = self.mixlevel_helper(
- frameworkgc_setup, [], attach_empty_cleanup=True)
- self.push_root_ptr = self.mixlevel_helper(push_root,
- [annmodel.SomeAddress()])
- self.pop_root_ptr = self.mixlevel_helper(pop_root, [])
-
- def mixlevel_helper(self, helper, args_s, attach_empty_cleanup=False):
- graph = annlowlevel.annotate_mixlevel_helper(self.translator.rtyper, helper, args_s)
+ frameworkgc_setup_graph = self.mixlevel_helper(
+ frameworkgc_setup, [], annmodel.s_ImpossibleValue)
+ push_root_graph = self.mixlevel_helper(push_root,
+ [annmodel.SomeAddress()],
+ annmodel.s_ImpossibleValue)
+ pop_root_graph = self.mixlevel_helper(pop_root, [],
+ annmodel.SomeAddress())
+ annlowlevel.finish_mixlevel_helpers(self.translator.rtyper)
+ self.frameworkgc_setup_ptr = self.graph2funcptr(frameworkgc_setup_graph,
+ attach_empty_cleanup=True)
+ self.push_root_ptr = self.graph2funcptr(push_root_graph)
+ self.pop_root_ptr = self.graph2funcptr(pop_root_graph)
+
+ def mixlevel_helper(self, helper, args_s, result_s):
+ graph = annlowlevel.pre_annotate_mixlevel_helper(self.translator.rtyper,
+ helper, args_s, result_s)
self.seen_graphs[graph] = True
- perform_normalizations(self.translator.rtyper)
- self.specialize_more_blocks()
+ return graph
+
+ def graph2funcptr(self, graph, attach_empty_cleanup=False):
if attach_empty_cleanup:
MinimalGCTransformer(self.translator).transform_graph(graph)
return const_funcptr_fromgraph(graph)
More information about the Pypy-commit
mailing list