[pypy-svn] pypy jitypes2: revert 3ed3b3e80e5c because it did not really fix the test. Moreover, we now
antocuni
commits-noreply at bitbucket.org
Mon Dec 27 19:04:30 CET 2010
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: jitypes2
Changeset: r40242:3578fdb200ed
Date: 2010-12-27 17:23 +0100
http://bitbucket.org/pypy/pypy/changeset/3578fdb200ed/
Log: revert 3ed3b3e80e5c because it did not really fix the test.
Moreover, we now need to tell call() whether we expect the restype
to be a struct, because else the annotator might mix two different
paths and degenerate to SomeObject
diff --git a/pypy/rlib/libffi.py b/pypy/rlib/libffi.py
--- a/pypy/rlib/libffi.py
+++ b/pypy/rlib/libffi.py
@@ -274,8 +274,8 @@
# ========================================================================
@jit.unroll_safe
- @specialize.arg(2)
- def call(self, argchain, RESULT):
+ @specialize.arg(2, 3)
+ def call(self, argchain, RESULT, is_struct=False):
# WARNING! This code is written carefully in a way that the JIT
# optimizer will see a sequence of calls like the following:
#
@@ -300,9 +300,11 @@
i += 1
arg = arg.next
#
- if types.is_struct(self.restype):
+ if is_struct:
+ assert types.is_struct(self.restype)
res = self._do_call_raw(self.funcsym, ll_args)
elif _fits_into_long(RESULT):
+ assert not types.is_struct(self.restype)
res = self._do_call_int(self.funcsym, ll_args)
elif RESULT is rffi.DOUBLE:
return self._do_call_float(self.funcsym, ll_args)
diff --git a/pypy/rlib/test/test_libffi.py b/pypy/rlib/test/test_libffi.py
--- a/pypy/rlib/test/test_libffi.py
+++ b/pypy/rlib/test/test_libffi.py
@@ -107,7 +107,7 @@
def get_libfoo(self):
return self.CDLL(self.libfoo_name)
- def call(self, funcspec, args, RESULT, init_result=0, before_iteration_hook=None):
+ def call(self, funcspec, args, RESULT, init_result=0, is_struct=False):
"""
Call the specified function after constructing and ArgChain with the
arguments in ``args``.
@@ -137,7 +137,7 @@
meth(arg)
else:
chain.arg(arg)
- return func.call(chain, RESULT)
+ return func.call(chain, RESULT, is_struct=is_struct)
def check_loops(self, *args, **kwds):
"""
@@ -426,14 +426,9 @@
libfoo = CDLL(self.libfoo_name)
make_point = (libfoo, 'make_point', [types.slong, types.slong], ffi_point)
#
- def before_iteration_hook(p):
- # this is needed else in metainterp/test/test_fficall we leak all
- # the intermediate results
- lltype.free(p, flavor='raw')
- #
PTR = lltype.Ptr(rffi.CArray(rffi.LONG))
p = self.call(make_point, [12, 34], PTR, init_result=lltype.nullptr(PTR.TO),
- before_iteration_hook=before_iteration_hook)
+ is_struct=True)
assert p[0] == 12
assert p[1] == 34
lltype.free(p, flavor='raw')
diff --git a/pypy/jit/metainterp/test/test_fficall.py b/pypy/jit/metainterp/test/test_fficall.py
--- a/pypy/jit/metainterp/test/test_fficall.py
+++ b/pypy/jit/metainterp/test/test_fficall.py
@@ -14,8 +14,7 @@
# ===> ../../../rlib/test/test_libffi.py
- def call(self, funcspec, args, RESULT, init_result=0,
- before_iteration_hook=None):
+ def call(self, funcspec, args, RESULT, init_result=0, is_struct=False):
"""
Call the function specified by funcspec in a loop, and let the jit to
see and optimize it.
@@ -50,14 +49,12 @@
while n < 10:
driver.jit_merge_point(n=n, res=res, func=func)
driver.can_enter_jit(n=n, res=res, func=func)
- if before_iteration_hook:
- before_iteration_hook(res)
func = hint(func, promote=True)
argchain = ArgChain()
# this loop is unrolled
for method_name, argval in method_and_args:
getattr(argchain, method_name)(argval)
- res = func.call(argchain, RESULT)
+ res = func.call(argchain, RESULT, is_struct=is_struct)
n += 1
return res
#
More information about the Pypy-commit
mailing list