[pypy-svn] r77836 - in pypy/branch/jitffi/pypy: jit/backend/x86/test jit/metainterp/optimizeopt rlib
antocuni at codespeak.net
antocuni at codespeak.net
Tue Oct 12 16:08:30 CEST 2010
Author: antocuni
Date: Tue Oct 12 16:08:28 2010
New Revision: 77836
Modified:
pypy/branch/jitffi/pypy/jit/backend/x86/test/test_ztranslation.py
pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py
pypy/branch/jitffi/pypy/rlib/libffi.py
Log:
fix translation of fficall optimization
Modified: pypy/branch/jitffi/pypy/jit/backend/x86/test/test_ztranslation.py
==============================================================================
--- pypy/branch/jitffi/pypy/jit/backend/x86/test/test_ztranslation.py (original)
+++ pypy/branch/jitffi/pypy/jit/backend/x86/test/test_ztranslation.py Tue Oct 12 16:08:28 2010
@@ -1,4 +1,4 @@
-import py, os
+import py, os, sys
from pypy.tool.udir import udir
from pypy.rlib.jit import JitDriver, OPTIMIZER_FULL, unroll_parameters
from pypy.rlib.jit import PARAMETERS, dont_look_inside
@@ -63,8 +63,32 @@
if k - abs(j): raise ValueError
if k - abs(-j): raise ValueError
return total * 10
+ #
+ from pypy.rpython.lltypesystem import lltype, rffi
+ from pypy.rlib.libffi import types, CDLL, ArgChain
+ from pypy.rlib.test.test_libffi import get_libm_name
+ libm_name = get_libm_name(sys.platform)
+ jitdriver2 = JitDriver(greens=[], reds = ['i', 'func', 'res', 'x'])
+ def libffi_stuff(i, j):
+ lib = CDLL(libm_name)
+ func = lib.getpointer('fabs', [types.double], types.double)
+ res = 0.0
+ x = float(j)
+ while i > 0:
+ jitdriver2.jit_merge_point(i=i, res=res, func=func, x=x)
+ jitdriver2.can_enter_jit(i=i, res=res, func=func, x=x)
+ func = hint(func, promote=True)
+ argchain = ArgChain()
+ argchain.arg(x)
+ res = func.call(argchain, rffi.DOUBLE)
+ i -= 1
+ return res
+ #
+ def main(i, j):
+ return f(i, j) + libffi_stuff(i, j)
+ expected = f(40, -49)
res = self.meta_interp(f, [40, -49])
- assert res == f(40, -49)
+ assert res == expected
def test_direct_assembler_call_translates(self):
class Thing(object):
Modified: pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py
==============================================================================
--- pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py (original)
+++ pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py Tue Oct 12 16:08:28 2010
@@ -8,6 +8,10 @@
class FuncInfo(object):
+ argtypes = None
+ restype = None
+ descr = None
+
def __init__(self, funcval, cpu):
self.opargs = []
argtypes, restype = self._get_signature(funcval)
@@ -36,7 +40,8 @@
llfunc = funcval.box.getref_base()
if we_are_translated():
- XXX
+ func = cast_base_ptr_to_instance(Func, llfunc)
+ return func.argtypes, func.restype
elif getattr(llfunc, '_fake_class', None) is Func:
# untranslated
return llfunc.argtypes, llfunc.restype
Modified: pypy/branch/jitffi/pypy/rlib/libffi.py
==============================================================================
--- pypy/branch/jitffi/pypy/rlib/libffi.py (original)
+++ pypy/branch/jitffi/pypy/rlib/libffi.py Tue Oct 12 16:08:28 2010
@@ -156,6 +156,9 @@
class Func(AbstractFuncPtr):
_immutable_fields_ = ['funcsym', 'argtypes', 'restype']
+ argtypes = []
+ restype = None
+ funcsym = None
def __init__(self, name, argtypes, restype, funcsym, flags=FUNCFLAG_CDECL,
keepalive=None):
More information about the Pypy-commit
mailing list