[pypy-svn] r38265 - in pypy/dist/pypy/jit/codegen: ppc test

mwh at codespeak.net mwh at codespeak.net
Fri Feb 9 16:44:56 CET 2007


Author: mwh
Date: Fri Feb  9 16:44:54 2007
New Revision: 38265

Modified:
   pypy/dist/pypy/jit/codegen/ppc/rgenop.py
   pypy/dist/pypy/jit/codegen/test/rgenop_tests.py
Log:
add a test for calling things via AbstractRGenOpTests.directtesthelper
fix bug caused by me reading the ABI docs differently from whoever did libffi
for darwin... apparently, if you reserve any parameter space, you should
reserve at least 32 bytes.


Modified: pypy/dist/pypy/jit/codegen/ppc/rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/ppc/rgenop.py	(original)
+++ pypy/dist/pypy/jit/codegen/ppc/rgenop.py	Fri Feb  9 16:44:54 2007
@@ -596,7 +596,7 @@
         into our caller's linkage area."""
         assert lv <= 0
         if self.max_param_space >= 0:
-            param = self.max_param_space + 24
+            param = max(self.max_param_space, 32) + 24
         else:
             param = 0
         return ((4 + param - lv + 15) & ~15)

Modified: pypy/dist/pypy/jit/codegen/test/rgenop_tests.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/test/rgenop_tests.py	(original)
+++ pypy/dist/pypy/jit/codegen/test/rgenop_tests.py	Fri Feb  9 16:44:54 2007
@@ -767,6 +767,33 @@
         return cast(callback, c_void_p).value
         # NB. returns the address as an integer
 
+    def test_directtesthelper_direct(self):
+        # def callable(x, y):
+        #     return f(x) + x + y
+        rgenop = self.RGenOp()
+
+        def f(x):
+            return x + 1
+
+        gv_f = rgenop.genconst(self.directtesthelper(lltype.Ptr(FUNC), f))
+
+        signed_kind = rgenop.kindToken(lltype.Signed)
+        sigtoken1 = rgenop.sigToken(FUNC)
+        sigtoken2 = rgenop.sigToken(FUNC2)
+        builder, gv_callable, [gv_x, gv_y] = rgenop.newgraph(sigtoken2, "callable")
+        builder.start_writing()
+
+        gv_t1 = builder.genop_call(sigtoken1, gv_f, [gv_x])
+        gv_t2 = builder.genop2("int_add", gv_t1, gv_x)
+        gv_result = builder.genop2("int_add", gv_t2, gv_y)
+        builder.finish_and_return(sigtoken2, gv_result)
+        builder.end()
+
+        fnptr = self.cast(gv_callable, 2)
+
+        res = fnptr(10, 5)
+        assert res == 11 + 10 + 5
+
     def test_adder_direct(self):
         rgenop = self.RGenOp()
         gv_add_5 = make_adder(rgenop, 5)



More information about the Pypy-commit mailing list