[pypy-svn] r26839 - pypy/dist/pypy/translator/backendopt
arigo at codespeak.net
arigo at codespeak.net
Sat May 6 00:01:23 CEST 2006
Author: arigo
Date: Sat May 6 00:01:22 2006
New Revision: 26839
Modified:
pypy/dist/pypy/translator/backendopt/inline.py
Log:
Try to minimize random effects of inlining by making sure
we inline all functions up to the threshold.
Modified: pypy/dist/pypy/translator/backendopt/inline.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/inline.py (original)
+++ pypy/dist/pypy/translator/backendopt/inline.py Sat May 6 00:01:22 2006
@@ -517,7 +517,7 @@
def auto_inlining(translator, multiplier=1, callgraph=None,
threshold=BASE_INLINE_THRESHOLD):
- from heapq import heappush, heappop, heapreplace
+ from heapq import heappush, heappop, heapreplace, heapify
threshold = threshold * multiplier
callers = {} # {graph: {graphs-that-call-it}}
callees = {} # {graph: {graphs-that-it-calls}}
@@ -543,7 +543,20 @@
continue
if weight >= threshold:
- break # finished
+ # finished... unless some graphs not in valid_weight would now
+ # have a weight below the threshold. Re-insert such graphs
+ # at the start of the heap
+ finished = True
+ for i in range(len(heap)):
+ graph = heap[i][2]
+ if not valid_weight.get(graph):
+ heap[i] = (0.0, heap[i][1], graph)
+ finished = False
+ if finished:
+ break
+ else:
+ heapify(heap)
+ continue
heappop(heap)
if callers[graph]:
More information about the Pypy-commit
mailing list