[pypy-svn] r17510 - in pypy/dist/pypy/translator: . test
arigo at codespeak.net
arigo at codespeak.net
Mon Sep 12 18:30:56 CEST 2005
Author: arigo
Date: Mon Sep 12 18:30:55 2005
New Revision: 17510
Modified:
pypy/dist/pypy/translator/backendoptimization.py
pypy/dist/pypy/translator/test/test_backendoptimization.py
Log:
Two typos in backendoptimization. Disabled a test, and added another disabled
test, about supporting catching exceptions while inlining a graph that contains
further direct_calls.
Modified: pypy/dist/pypy/translator/backendoptimization.py
==============================================================================
--- pypy/dist/pypy/translator/backendoptimization.py (original)
+++ pypy/dist/pypy/translator/backendoptimization.py Mon Sep 12 18:30:55 2005
@@ -159,6 +159,7 @@
for op in obj.operations:
if op.opname == "direct_call":
funcs[op.args[0]] = True
+ traverse(visit, graph)
return funcs
def inline_function(translator, inline_func, graph):
@@ -195,14 +196,14 @@
return ops[-4].args[2].value
def _inline_function(translator, graph, block, index_operation):
+ op = block.operations[index_operation]
+ graph_to_inline = translator.flowgraphs[op.args[0].value._obj._callable]
exception_guarded = False
if (block.exitswitch == Constant(last_exception) and
index_operation == len(block.operations) - 1):
exception_guarded = True
- assert len(collect_called_functions(graph)) == 0, (
+ assert len(collect_called_functions(graph_to_inline)) == 0, (
"can't handle exceptions yet")
- op = block.operations[index_operation]
- graph_to_inline = translator.flowgraphs[op.args[0].value._obj._callable]
entrymap = mkentrymap(graph_to_inline)
beforeblock = block
afterblock = split_block(translator, graph, block, index_operation)
Modified: pypy/dist/pypy/translator/test/test_backendoptimization.py
==============================================================================
--- pypy/dist/pypy/translator/test/test_backendoptimization.py (original)
+++ pypy/dist/pypy/translator/test/test_backendoptimization.py Mon Sep 12 18:30:55 2005
@@ -155,7 +155,9 @@
result = interp.eval_function(g, [42])
assert result == 1
-def test_inline_var_exception():
+def DONOTtest_inline_var_exception():
+ # this test is disabled for now, because f() contains a direct_call
+ # (at the end, to a ll helper, to get the type of the exception object)
def f(x):
e = None
if x == 0:
@@ -184,7 +186,32 @@
assert result == 3
result = interp.eval_function(g, [42])
assert result == 1
-
+
+def DONOTtest_call_call():
+ # for reference. Just remove this test if we decide not to support
+ # catching exceptions while inlining a graph that contains further
+ # direct_calls.
+ def e(x):
+ if x < 0:
+ raise KeyError
+ return x+1
+ def f(x):
+ return e(x)+2
+ def g(x):
+ try:
+ return f(x)+3
+ except KeyError:
+ return -1
+ t = Translator(g)
+ a = t.annotate([int])
+ a.simplify()
+ t.specialize()
+ inline_function(t, f, t.flowgraphs[g])
+ interp = LLInterpreter(t.flowgraphs, t.rtyper)
+ result = interp.eval_function(g, [100])
+ assert result == 106
+ result = interp.eval_function(g, [-100])
+ assert result == -1
def DONOTtest_for_loop():
def f(x):
More information about the Pypy-commit
mailing list