[pypy-svn] pypy jitypes2: no longer leak memory in the test
antocuni
commits-noreply at bitbucket.org
Fri Dec 24 14:30:41 CET 2010
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: jitypes2
Changeset: r40224:3ed3b3e80e5c
Date: 2010-12-24 14:29 +0100
http://bitbucket.org/pypy/pypy/changeset/3ed3b3e80e5c/
Log: no longer leak memory in the test
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):
+ def call(self, funcspec, args, RESULT, init_result=0, before_iteration_hook=None):
"""
Call the specified function after constructing and ArgChain with the
arguments in ``args``.
@@ -426,8 +426,14 @@
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))
+ p = self.call(make_point, [12, 34], PTR, init_result=lltype.nullptr(PTR.TO),
+ before_iteration_hook=before_iteration_hook)
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,7 +14,8 @@
# ===> ../../../rlib/test/test_libffi.py
- def call(self, funcspec, args, RESULT, init_result=0):
+ def call(self, funcspec, args, RESULT, init_result=0,
+ before_iteration_hook=None):
"""
Call the function specified by funcspec in a loop, and let the jit to
see and optimize it.
@@ -49,6 +50,8 @@
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
More information about the Pypy-commit
mailing list