[pypy-svn] r34684 - in pypy/dist/pypy/translator: . backendopt
ac at codespeak.net
ac at codespeak.net
Thu Nov 16 18:18:02 CET 2006
Author: ac
Date: Thu Nov 16 18:18:01 2006
New Revision: 34684
Modified:
pypy/dist/pypy/translator/backendopt/all.py
pypy/dist/pypy/translator/backendopt/inline.py
pypy/dist/pypy/translator/driver.py
Log:
(pedronis, arre) Tweak the inlining.
Modified: pypy/dist/pypy/translator/backendopt/all.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/all.py (original)
+++ pypy/dist/pypy/translator/backendopt/all.py Thu Nov 16 18:18:01 2006
@@ -47,14 +47,9 @@
inline_malloc_removal_phase(config, translator, graphs,
config.inline_threshold*.5) # xxx tune!
inline.instrument_inline_candidates(graphs, config.inline_threshold)
- data = translator.driver_instrument_result(
+ counters = translator.driver_instrument_result(
config.profile_based_inline)
- import array, struct
- n = data.size()//struct.calcsize('L')
- data = data.open('rb')
- counters = array.array('L')
- counters.fromfile(data, n)
- data.close()
+ n = len(counters)
def call_count_pred(label):
if label >= n:
return False
@@ -102,9 +97,10 @@
# inline functions in each other
if inline_threshold:
callgraph = inline.inlinable_static_callers(graphs)
- inline.auto_inlining(translator, inline_threshold,
- callgraph=callgraph,
- call_count_pred=call_count_pred)
+ count = inline.auto_inlining(translator, inline_threshold,
+ callgraph=callgraph,
+ call_count_pred=call_count_pred)
+ log.inlining('inlined %d callsites.'% (count,))
for graph in graphs:
removenoops.remove_superfluous_keep_alive(graph)
removenoops.remove_duplicate_casts(graph, translator)
@@ -129,3 +125,8 @@
if config.print_statistics:
print "after malloc removal:"
print_statistics(translator.graphs[0], translator)
+
+ if config.constfold:
+ for graph in graphs:
+ constant_fold_graph(graph)
+
Modified: pypy/dist/pypy/translator/backendopt/inline.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/inline.py (original)
+++ pypy/dist/pypy/translator/backendopt/inline.py Thu Nov 16 18:18:01 2006
@@ -642,15 +642,17 @@
for parentgraph in callers[graph]:
if parentgraph == graph:
continue
+ subcount = 0
try:
- res = bool(inline_function(translator, graph, parentgraph,
+ subcount = inline_function(translator, graph, parentgraph,
lltype_to_classdef, raise_analyzer,
- call_count_pred))
+ call_count_pred)
+ res = bool(subcount)
except CannotInline:
couldnt_inline[graph] = True
res = CannotInline
if res is True:
- count += 1
+ count += subcount
# the parentgraph should now contain all calls that were
# done by 'graph'
for graph2 in callees.get(graph, {}):
Modified: pypy/dist/pypy/translator/driver.py
==============================================================================
--- pypy/dist/pypy/translator/driver.py (original)
+++ pypy/dist/pypy/translator/driver.py Thu Nov 16 18:18:01 2006
@@ -235,7 +235,13 @@
raise Exception, "instrumentation child failed: %d" % status
else:
raise Exception, "instrumentation child aborted"
- return datafile
+ import array, struct
+ n = datafile.size()//struct.calcsize('L')
+ datafile = datafile.open('rb')
+ counters = array.array('L')
+ counters.fromfile(datafile, n)
+ datafile.close()
+ return counters
def info(self, msg):
log.info(msg)
More information about the Pypy-commit
mailing list