[pypy-commit] pypy vmprof-multiple-eval-funcs: add new API to register more evaluation functions
plan_rich
pypy.commits at gmail.com
Mon Apr 3 17:19:18 EDT 2017
Author: Richard Plangger <planrichi at gmail.com>
Branch: vmprof-multiple-eval-funcs
Changeset: r90937:d9c9cd171e95
Date: 2017-04-03 17:18 -0400
http://bitbucket.org/pypy/pypy/changeset/d9c9cd171e95/
Log: add new API to register more evaluation functions
diff --git a/rpython/rlib/rvmprof/cintf.py b/rpython/rlib/rvmprof/cintf.py
--- a/rpython/rlib/rvmprof/cintf.py
+++ b/rpython/rlib/rvmprof/cintf.py
@@ -97,6 +97,10 @@
lltype.Signed, compilation_info=eci,
_nowrapper=True)
+ vmprof_register_eval = rffi.llexternal("vmprof_register_eval",
+ [rffi.VOIDP], rffi.INT,
+ compilation_info=eci)
+
return CInterface(locals())
diff --git a/rpython/rlib/rvmprof/src/rvmprof.c b/rpython/rlib/rvmprof/src/rvmprof.c
--- a/rpython/rlib/rvmprof/src/rvmprof.c
+++ b/rpython/rlib/rvmprof/src/rvmprof.c
@@ -20,12 +20,32 @@
#include "shared/vmprof_main_win32.h"
#endif
+int _vmprof_eval_count = 0;
+void _vmprof_eval_funcs[5];
-#ifdef RPYTHON_LL2CTYPES
-int IS_VMPROF_EVAL(void * ptr) { return 0; }
-#else
+int vmprof_register_eval(void * function)
+{
+ if (_vmprof_eval_count >= 5) {
+ fprintf(stderr, "WARNING: cannot register more than 5 rpython interpreter " \
+ "evaluation functions (you can increase the amount in rvmprof.c)\n");
+ return -1;
+ }
+ if (function == NULL) {
+ _vmprof_eval_count = 0;
+ } else {
+ _vmprof_eval_funcs[_vmprof_eval_count++] = function;
+ }
+
+ return 0;
+}
+
int IS_VMPROF_EVAL(void * ptr)
{
- return ptr == __vmprof_eval_vmprof;
+ int i = 0;
+ for (i = 0; i < _vmprof_eval_count; i++) {
+ if (ptr == _vmprof_eval_funcs[i]) {
+ return 1;
+ }
+ }
+ return 0;
}
-#endif
diff --git a/rpython/rlib/rvmprof/src/rvmprof.h b/rpython/rlib/rvmprof/src/rvmprof.h
--- a/rpython/rlib/rvmprof/src/rvmprof.h
+++ b/rpython/rlib/rvmprof/src/rvmprof.h
@@ -35,6 +35,15 @@
RPY_EXTERN long vmprof_stack_pop(void*);
RPY_EXTERN void vmprof_stack_free(void*);
RPY_EXTERN intptr_t vmprof_get_traceback(void *, void *, intptr_t*, intptr_t);
+/**
+ * Registers the first argument as a evaluation function. If NULL is provided,
+ * it resets the registers eval functions.
+ *
+ * Note that a maximum of 5 evaluation functions is supported.
+ *
+ * Return 0 on success, any other value on failure.
+ */
+RPY_EXTERN int vmprof_register_eval(void *);
long vmprof_write_header_for_jit_addr(intptr_t *result, long n,
intptr_t addr, int max_depth);
More information about the pypy-commit
mailing list