[pypy-commit] pypy vmprof-multiple-eval-funcs: register all functions passed to vmprof_execute_code and call vmprof_register_eval just before the module is enabled
plan_rich
pypy.commits at gmail.com
Tue Apr 4 16:45:23 EDT 2017
Author: Richard Plangger <planrichi at gmail.com>
Branch: vmprof-multiple-eval-funcs
Changeset: r90956:f7aa9fbfd4f0
Date: 2017-04-04 16:44 -0400
http://bitbucket.org/pypy/pypy/changeset/f7aa9fbfd4f0/
Log: register all functions passed to vmprof_execute_code and call
vmprof_register_eval just before the module is enabled
diff --git a/rpython/rlib/rvmprof/rvmprof.py b/rpython/rlib/rvmprof/rvmprof.py
--- a/rpython/rlib/rvmprof/rvmprof.py
+++ b/rpython/rlib/rvmprof/rvmprof.py
@@ -7,11 +7,16 @@
from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
from rpython.rtyper.lltypesystem.lloperation import llop
from rpython.rlib.rweaklist import RWeakListMixin
+from rpython.rlib.unroll import unrolling_iterable
MAX_FUNC_NAME = 1023
PLAT_WINDOWS = sys.platform == 'win32'
+EVAL_FUNCS = []
+EVAL_FUNC_TYPE = lltype.FuncType([rffi.VOIDP], rffi.INT)
+EVAL_FUNC_TYPE_P = lltype.Ptr(EVAL_FUNC_TYPE)
+
# ____________________________________________________________
# keep in sync with vmprof_stack.h
@@ -138,6 +143,15 @@
native = 0 # force disabled on Windows
lines = 0 # not supported on PyPy currently
+ if we_are_translated():
+ # clear all evaluation functions
+ self.cintf.vmprof_register_eval(rffi.NULL)
+ from rpython.rtyper.annlowlevel import llhelper
+ # pass all known function at translation down to the c implementation
+ for eval_func in unrolling_iterable(EVAL_FUNCS):
+ addr = llhelper(EVAL_FUNC_TYPE_P, eval_func)
+ self.cintf.vmprof_register_eval(rffi.cast(rffi.VOIDP, addr))
+
p_error = self.cintf.vmprof_init(fileno, interval, lines, memory, "pypy", native)
if p_error:
raise VMProfError(rffi.charp2str(p_error))
@@ -178,23 +192,6 @@
arguments given to the decorated function.
'result_class' is ignored (backward compatibility).
-
- ====================================
- TRANSLATION NOTE CALL THIS ONLY ONCE
- ====================================
-
- This function can only be called once during translation.
- It generates a C function called __vmprof_eval_vmprof which is used by
- the vmprof C source code and is bound as an extern function.
- This is necessary while walking the native stack.
- If you see __vmprof_eval_vmprof defined twice during
- translation, read on:
-
- To remove this restriction do the following:
-
- *) Extend the macro IS_VMPROF_EVAL in the vmprof source repo to check several
- sybmols.
- *) Give each function provided to this decorator a unique symbol name in C
"""
if _hack_update_stack_untranslated:
from rpython.rtyper.annlowlevel import llhelper
@@ -242,7 +239,7 @@
return decorated_jitted_function(unique_id, *args)
decorated_function.__name__ = func.__name__ + '_rvmprof'
- decorated_function.c_name = '__vmprof_eval_vmprof'
+ EVAL_FUNCS.append(decorated_function)
return decorated_function
return decorate
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
@@ -21,7 +21,7 @@
#endif
int _vmprof_eval_count = 0;
-void _vmprof_eval_funcs[5];
+void * _vmprof_eval_funcs[5];
int vmprof_register_eval(void * function)
{
More information about the pypy-commit
mailing list