[pypy-svn] r77560 - in pypy/branch/jitffi/pypy: jit/codewriter jit/metainterp/optimizeopt rlib
antocuni at codespeak.net
antocuni at codespeak.net
Mon Oct 4 11:24:15 CEST 2010
Author: antocuni
Date: Mon Oct 4 11:24:13 2010
New Revision: 77560
Modified:
pypy/branch/jitffi/pypy/jit/codewriter/support.py
pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py
pypy/branch/jitffi/pypy/rlib/libffi.py
Log:
use separate methods for pushing ints and floats. This is needed because
oopspec and specialize don't really play well togheter
Modified: pypy/branch/jitffi/pypy/jit/codewriter/support.py
==============================================================================
--- pypy/branch/jitffi/pypy/jit/codewriter/support.py (original)
+++ pypy/branch/jitffi/pypy/jit/codewriter/support.py Mon Oct 4 11:24:13 2010
@@ -222,20 +222,21 @@
# libffi support
# --------------
-def _ll_1_libffi_prepare_call(llfunc):
+def func(llfunc):
from pypy.rlib.libffi import Func
- func = cast_base_ptr_to_instance(Func, llfunc)
- return func._prepare()
+ return cast_base_ptr_to_instance(Func, llfunc)
-def _ll_4_libffi_push_arg(llfunc, value, ll_args, i):
- from pypy.rlib.libffi import Func
- func = cast_base_ptr_to_instance(Func, llfunc)
- return func._push_arg(value, ll_args, i)
+def _ll_1_libffi_prepare_call(llfunc):
+ return func(llfunc)._prepare()
+
+def _ll_4_libffi_push_int(llfunc, value, ll_args, i):
+ return func(llfunc)._push_int(value, ll_args, i)
+
+def _ll_4_libffi_push_float(llfunc, value, ll_args, i):
+ return func(llfunc)._push_float(value, ll_args, i)
def _ll_4_libffi_call(llfunc, funcsym, ll_args, RESULT):
- from pypy.rlib.libffi import Func
- func = cast_base_ptr_to_instance(Func, llfunc)
- return func._do_call(funcsym, ll_args, lltype.Signed)
+ return func(llfunc)._do_call(funcsym, ll_args, lltype.Signed)
# XXX: should be RESULT, but it doesn't work
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 Mon Oct 4 11:24:13 2010
@@ -63,7 +63,7 @@
funcname = str(funcval.box)
if '_libffi_prepare_call' in funcname:
return 'prepare_call'
- elif '_libffi_push_arg' in funcname:
+ elif '_libffi_push_' in funcname:
return 'push_arg'
elif '_libffi_call' in funcname:
return 'call'
Modified: pypy/branch/jitffi/pypy/rlib/libffi.py
==============================================================================
--- pypy/branch/jitffi/pypy/rlib/libffi.py (original)
+++ pypy/branch/jitffi/pypy/rlib/libffi.py Mon Oct 4 11:24:13 2010
@@ -51,7 +51,7 @@
self.intval = intval
def push(self, func, ll_args, i):
- func._push_arg(self.intval, ll_args, i)
+ func._push_int(self.intval, ll_args, i)
class FloatArg(AbstractArg):
""" An argument holding a float
@@ -61,7 +61,7 @@
self.floatval = floatval
def push(self, func, ll_args, i):
- func._push_arg(self.floatval, ll_args, i)
+ func._push_float(self.floatval, ll_args, i)
class Func(AbstractFuncPtr):
@@ -110,18 +110,23 @@
return ll_args
_prepare.oopspec = 'libffi_prepare_call(self)'
- def _push_arg(self, value, ll_args, i):
+ @specialize.arg(1)
+ def _push_arg(self, TYPE, value, ll_args, i):
# XXX: check the type is not translated?
argtype = self.argtypes[i]
c_size = intmask(argtype.c_size)
ll_buf = lltype.malloc(rffi.CCHARP.TO, c_size, flavor='raw')
push_arg_as_ffiptr(argtype, value, ll_buf)
ll_args[i] = ll_buf
- # XXX this is bad, fix it somehow in the future, but specialize:argtype
- # doesn't work correctly with mixing non-negative and normal integers
- _push_arg._annenforceargs_ = [None, int, None, int]
- #_push_arg._annspecialcase_ = 'specialize:argtype(1)'
- _push_arg.oopspec = 'libffi_push_arg(self, value, ll_args, i)'
+
+ def _push_int(self, value, ll_args, i):
+ self._push_arg(lltype.Signed, value, ll_args, i)
+ _push_int.oopspec = 'libffi_push_int(self, value, ll_args, i)'
+ _push_int._annenforceargs_ = [None, int, None, int]
+
+ def _push_float(self, value, ll_args, i):
+ self._push_arg(lltype.Float, value, ll_args, i)
+ _push_float.oopspec = 'libffi_push_float(self, value, ll_args, i)'
def _do_call(self, funcsym, ll_args, RESULT):
# XXX: check len(args)?
More information about the Pypy-commit
mailing list