[pypy-svn] r48870 - in pypy/branch/new-genc-tests-wrapper/pypy/translator: c/src llsupport

rxe at codespeak.net rxe at codespeak.net
Tue Nov 20 20:19:31 CET 2007


Author: rxe
Date: Tue Nov 20 20:19:30 2007
New Revision: 48870

Modified:
   pypy/branch/new-genc-tests-wrapper/pypy/translator/c/src/mem.h
   pypy/branch/new-genc-tests-wrapper/pypy/translator/llsupport/modwrapper.py
Log:
(cfbolz, rxe, pedronis watching) malloc counter support

Modified: pypy/branch/new-genc-tests-wrapper/pypy/translator/c/src/mem.h
==============================================================================
--- pypy/branch/new-genc-tests-wrapper/pypy/translator/c/src/mem.h	(original)
+++ pypy/branch/new-genc-tests-wrapper/pypy/translator/c/src/mem.h	Tue Nov 20 20:19:30 2007
@@ -69,15 +69,10 @@
 #else /*COUNT_OP_MALLOCS*/
 /*------------------------------------------------------------*/
 
-static int count_mallocs=0, count_frees=0;
+int pypy_g__count_mallocs=0, pypy_g__count_frees=0;
 
-#define COUNT_MALLOC	count_mallocs++
-#define COUNT_FREE	count_frees++
-
-PyObject* malloc_counters(PyObject* self, PyObject* args)
-{
-  return Py_BuildValue("ii", count_mallocs, count_frees);
-}
+#define COUNT_MALLOC	pypy_g__count_mallocs++
+#define COUNT_FREE	pypy_g__count_frees++
 
 /*------------------------------------------------------------*/
 #endif /*COUNT_OP_MALLOCS*/

Modified: pypy/branch/new-genc-tests-wrapper/pypy/translator/llsupport/modwrapper.py
==============================================================================
--- pypy/branch/new-genc-tests-wrapper/pypy/translator/llsupport/modwrapper.py	(original)
+++ pypy/branch/new-genc-tests-wrapper/pypy/translator/llsupport/modwrapper.py	Tue Nov 20 20:19:30 2007
@@ -30,6 +30,10 @@
 except AttributeError:
     pass # only if there is Boehm
 
+def malloc_counters():
+    return (ctypes.c_int.in_dll(_c, "pypy_g__count_frees").value,
+            ctypes.c_int.in_dll(_c, "pypy_g__count_mallocs").value)
+
 startup_code = _c.ctypes_RPython_StartupCode
 startup_code.argtypes = []
 startup_code.restype = ctypes.c_int



More information about the Pypy-commit mailing list