[pypy-svn] r59070 - in pypy/dist/pypy/translator/backendopt: . test

arigo at codespeak.net arigo at codespeak.net
Mon Oct 13 15:12:11 CEST 2008


Author: arigo
Date: Mon Oct 13 15:12:10 2008
New Revision: 59070

Modified:
   pypy/dist/pypy/translator/backendopt/mallocv.py
   pypy/dist/pypy/translator/backendopt/test/test_mallocv.py
Log:
Test and fix.


Modified: pypy/dist/pypy/translator/backendopt/mallocv.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/mallocv.py	(original)
+++ pypy/dist/pypy/translator/backendopt/mallocv.py	Mon Oct 13 15:12:10 2008
@@ -945,6 +945,15 @@
         self.nodes = calleeframe.get_nodes_in_use()
         return []
 
+    def handle_op_indirect_call(self, op):
+        v_func = self.rename_nonvirtual(op.args[0], op)
+        if isinstance(v_func, Constant):
+            op = SpaceOperation('direct_call', [v_func] + op.args[1:-1],
+                                op.result)
+            return self.handle_op_direct_call(op)
+        else:
+            return self.handle_default(op)
+
 
 class FutureReturnValue(object):
     def __init__(self, op):

Modified: pypy/dist/pypy/translator/backendopt/test/test_mallocv.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/test/test_mallocv.py	(original)
+++ pypy/dist/pypy/translator/backendopt/test/test_mallocv.py	Mon Oct 13 15:12:10 2008
@@ -10,6 +10,7 @@
 from pypy.rpython.llinterp import LLInterpreter, LLException
 from pypy.rpython.lltypesystem import lltype, llmemory, lloperation
 from pypy.rpython.ootypesystem import ootype
+from pypy.rpython.annlowlevel import llhelper
 from pypy.rlib import objectmodel
 from pypy.rlib.rarithmetic import ovfcheck
 from pypy.conftest import option
@@ -480,7 +481,18 @@
         self.check(fn13, [int], [10], 4)
 
     def test_constfold_indirect_call(self):
-        skip("write me")
+        F = lltype.Ptr(lltype.FuncType([lltype.Signed], lltype.Signed))
+        class A:
+            pass
+        def h1(n):
+            return n - 1
+        def fn16(n):
+            a = A()
+            a.n = n
+            h = llhelper(F, h1)
+            h2 = lloperation.llop.same_as(F, h)
+            return h2(a.n)
+        self.check(fn16, [int], [10], 9, expected_calls=1)
 
     def test_bug_on_links_to_return(self):
         class A:



More information about the Pypy-commit mailing list