[pypy-svn] r32311 - in pypy/branch/kill-keepalives/pypy/translator/backendopt: . test
mwh at codespeak.net
mwh at codespeak.net
Thu Sep 14 15:43:05 CEST 2006
Author: mwh
Date: Thu Sep 14 15:43:04 2006
New Revision: 32311
Modified:
pypy/branch/kill-keepalives/pypy/translator/backendopt/malloc.py
pypy/branch/kill-keepalives/pypy/translator/backendopt/test/test_malloc.py
Log:
constant fold in between runs of remove_mallocs_once.
remove recreation of remove_mallocs_once in test_malloc in favour of having a
callback argument to remove_simple_mallocs
Modified: pypy/branch/kill-keepalives/pypy/translator/backendopt/malloc.py
==============================================================================
--- pypy/branch/kill-keepalives/pypy/translator/backendopt/malloc.py (original)
+++ pypy/branch/kill-keepalives/pypy/translator/backendopt/malloc.py Thu Sep 14 15:43:04 2006
@@ -4,6 +4,7 @@
from pypy.rpython.lltypesystem import lltype
from pypy.translator.simplify import remove_identical_vars
from pypy.translator.backendopt.support import log
+from pypy.translator.backendopt.constfold import constant_fold_graph
class LifeTime:
@@ -479,13 +480,16 @@
progress += _try_inline_malloc(info)
return progress
-def remove_simple_mallocs(graph):
+def remove_simple_mallocs(graph, callback=None):
"""Iteratively remove (inline) the mallocs that can be simplified away."""
tot = 0
while True:
count = remove_mallocs_once(graph)
if count:
log.malloc('%d simple mallocs removed in %r' % (count, graph.name))
+ constant_fold_graph(graph)
+ if callback:
+ callback()
tot += count
else:
break
Modified: pypy/branch/kill-keepalives/pypy/translator/backendopt/test/test_malloc.py
==============================================================================
--- pypy/branch/kill-keepalives/pypy/translator/backendopt/test/test_malloc.py (original)
+++ pypy/branch/kill-keepalives/pypy/translator/backendopt/test/test_malloc.py Thu Sep 14 15:43:04 2006
@@ -1,5 +1,5 @@
import py
-from pypy.translator.backendopt.malloc import remove_mallocs_once
+from pypy.translator.backendopt.malloc import remove_simple_mallocs
from pypy.translator.backendopt.malloc import union_wrapper
from pypy.translator.backendopt.inline import inline_function
from pypy.translator.backendopt.all import backend_optimizations
@@ -33,19 +33,15 @@
graph = graphof(t, fn)
if option.view:
t.view()
- # to detect missing keepalives and broken intermediate graphs,
- # we do the loop ourselves instead of calling remove_simple_mallocs()
- while True:
- progress = remove_mallocs_once(graph)
- simplify.transform_dead_op_vars_in_blocks(list(graph.iterblocks()))
+ def callback(progress=True):
if progress and option.view:
t.view()
if expected_result is not Ellipsis:
interp = LLInterpreter(t.rtyper)
res = interp.eval_graph(graph, args)
assert res == expected_result
- if not progress:
- break
+ remove_simple_mallocs(graph, callback)
+ callback(False)
if must_be_removed:
check_malloc_removed(graph)
More information about the Pypy-commit
mailing list