[pypy-svn] r62622 - in pypy/branch/pyjitpl5/pypy: jit/metainterp translator/backendopt
fijal at codespeak.net
fijal at codespeak.net
Fri Mar 6 01:30:14 CET 2009
Author: fijal
Date: Fri Mar 6 01:30:13 2009
New Revision: 62622
Modified:
pypy/branch/pyjitpl5/pypy/jit/metainterp/policy.py
pypy/branch/pyjitpl5/pypy/translator/backendopt/support.py
Log:
add an optional memo to find_calls_from, combined with previous checkin lets
me run a pypy jit in just below one minute, progress :-)
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/policy.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/policy.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/policy.py Fri Mar 6 01:30:13 2009
@@ -59,6 +59,7 @@
self.translator = translator
self.bookkeeper = translator.annotator.bookkeeper
self.enabled_graphs = {}
+ self.memo = {}
self.fill_seen_graphs()
def look_inside_graph(self, graph):
@@ -80,7 +81,7 @@
for tofunc in tofuncs:
targetgraphs[self._graph(tofunc)] = True
graphs = graphs_on_the_path_to(self.translator, self._graph(fromfunc),
- targetgraphs)
+ targetgraphs, self.memo)
for graph in graphs:
if graph not in self.enabled_graphs:
self.enabled_graphs[graph] = True
@@ -99,7 +100,7 @@
else:
print '--', graph
-def enumerate_reachable_graphs(translator, startgraph):
+def enumerate_reachable_graphs(translator, startgraph, memo=None):
from pypy.translator.backendopt.support import find_calls_from
pending = [(startgraph, None)]
yield pending[0]
@@ -110,7 +111,7 @@
nextseen = {}
for node in pending:
head, tail = node
- for block, callee in find_calls_from(translator, head):
+ for block, callee in find_calls_from(translator, head, memo):
if callee not in seen:
newnode = callee, node
yield newnode
@@ -120,11 +121,11 @@
seen.update(nextseen)
yield None
-def graphs_on_the_path_to(translator, startgraph, targetgraphs):
+def graphs_on_the_path_to(translator, startgraph, targetgraphs, memo=None):
targetgraphs = targetgraphs.copy()
result = {}
found = {}
- for node in enumerate_reachable_graphs(translator, startgraph):
+ for node in enumerate_reachable_graphs(translator, startgraph, memo):
if node is None: # hack: a separator meaning "length increases now"
for graph in found:
del targetgraphs[graph]
Modified: pypy/branch/pyjitpl5/pypy/translator/backendopt/support.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/translator/backendopt/support.py (original)
+++ pypy/branch/pyjitpl5/pypy/translator/backendopt/support.py Fri Mar 6 01:30:13 2009
@@ -107,7 +107,14 @@
afterblock.operations[pos:pos] = generate_keepalive(keep_alive_vars)
return splitlink
-def find_calls_from(translator, graph):
+def find_calls_from(translator, graph, memo=None):
+ if memo and graph in memo:
+ return memo[graph]
+ res = [i for i in _find_calls_from(translator, graph)]
+ memo[graph] = res
+ return res
+
+def _find_calls_from(translator, graph):
for block in graph.iterblocks():
for op in block.operations:
if op.opname == "direct_call":
More information about the Pypy-commit
mailing list