[pypy-commit] pypy vmprof-native: carry memory and native parameters through _vmprof to rvmprof.py, comment to only call vmprof_execute_code once
plan_rich
pypy.commits at gmail.com
Thu Feb 9 04:59:25 EST 2017
Author: Richard Plangger <planrichi at gmail.com>
Branch: vmprof-native
Changeset: r90016:cd5eb404324c
Date: 2017-02-09 10:58 +0100
http://bitbucket.org/pypy/pypy/changeset/cd5eb404324c/
Log: carry memory and native parameters through _vmprof to rvmprof.py,
comment to only call vmprof_execute_code once
diff --git a/pypy/module/_vmprof/interp_vmprof.py b/pypy/module/_vmprof/interp_vmprof.py
--- a/pypy/module/_vmprof/interp_vmprof.py
+++ b/pypy/module/_vmprof/interp_vmprof.py
@@ -50,8 +50,8 @@
return OperationError(w_VMProfError, space.wrap(e.msg))
- at unwrap_spec(fileno=int, period=float)
-def enable(space, fileno, period):
+ at unwrap_spec(fileno=int, period=float, memory=int, lines=int, native=int)
+def enable(space, fileno, period, memory, lines, native):
"""Enable vmprof. Writes go to the given 'fileno', a file descriptor
opened for writing. *The file descriptor must remain open at least
until disable() is called.*
@@ -65,7 +65,7 @@
# "with vmprof will crash"),
# space.w_RuntimeWarning)
try:
- rvmprof.enable(fileno, period)
+ rvmprof.enable(fileno, period, memory, native)
except rvmprof.VMProfError as e:
raise VMProfError(space, e)
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
@@ -1,5 +1,6 @@
import sys, os
-from rpython.rlib.objectmodel import specialize, we_are_translated, not_rpython
+from rpython.rlib.objectmodel import (specialize, we_are_translated,
+ not_rpython, we_are_translated_to_c)
from rpython.rlib import jit, rposix, rgc
from rpython.rlib.rvmprof import cintf
from rpython.rtyper.annlowlevel import cast_instance_to_gcref
@@ -177,6 +178,10 @@
arguments given to the decorated function.
'result_class' is ignored (backward compatibility).
+
+ NOTE Native profiling: this function can only be called once during
+ translation. To remove this restriction, one needs to extend the macro
+ IS_VMPROF_EVAL in the repo vmprof/vmprof-python.git.
"""
if _hack_update_stack_untranslated:
from rpython.rtyper.annlowlevel import llhelper
@@ -209,8 +214,8 @@
# have added a stack entry, but the function __vmprof_eval_vmprof
# is not entered. This behaviour will swallow one Python stack frame
#
- # Current fix: vmprof will discard this sample. those happen
- # very infrequent
+ # Current fix: vmprof will discard this sample. (happens
+ # very infrequently)
#
if not jit.we_are_jitted():
x = enter_code(unique_id)
diff --git a/rpython/rlib/rvmprof/src/shared/vmp_stack.c b/rpython/rlib/rvmprof/src/shared/vmp_stack.c
--- a/rpython/rlib/rvmprof/src/shared/vmp_stack.c
+++ b/rpython/rlib/rvmprof/src/shared/vmp_stack.c
@@ -194,7 +194,7 @@
//}
- if ((void*)pip.start_ip == (void*)VMPROF_EVAL()) {
+ if (IS_VMPROF_EVAL((void*)pip.start_ip)) {
// yes we found one stack entry of the python frames!
#ifndef RPYTHON_VMPROF
unw_word_t rbx = 0;
diff --git a/rpython/rlib/rvmprof/src/shared/vmprof.h b/rpython/rlib/rvmprof/src/shared/vmprof.h
--- a/rpython/rlib/rvmprof/src/shared/vmprof.h
+++ b/rpython/rlib/rvmprof/src/shared/vmprof.h
@@ -49,7 +49,7 @@
// the return type will default to int
typedef long Signed;
RPY_EXTERN Signed __vmprof_eval_vmprof();
-#define VMPROF_EVAL() __vmprof_eval_vmprof
+#define IS_VMPROF_EVAL(PTR) PTR == (void*)__vmprof_eval_vmprof
#else
#define RPY_EXTERN
// for cpython
@@ -63,6 +63,7 @@
#define FRAME_CODE(f) f->f_code
PY_EVAL_RETURN_T * vmprof_eval(PY_STACK_FRAME_T *f, int throwflag);
#define VMPROF_EVAL() vmprof_eval
+#define IS_VMPROF_EVAL(PTR) PTR == (void*)vmprof_eval
#endif
diff --git a/rpython/rlib/rvmprof/src/shared/vmprof_common.h b/rpython/rlib/rvmprof/src/shared/vmprof_common.h
--- a/rpython/rlib/rvmprof/src/shared/vmprof_common.h
+++ b/rpython/rlib/rvmprof/src/shared/vmprof_common.h
@@ -175,7 +175,12 @@
if (stack == NULL) {
stack = get_vmprof_stack();
}
+ int enabled = vmp_native_enabled();
+ vmp_native_disable();
n = get_stack_trace(stack, result_p, result_length - 2, pc);
+ if (enabled) {
+ vmp_native_enable();
+ }
return (intptr_t)n;
}
#endif
diff --git a/rpython/rlib/rvmprof/test/test_rvmprof.py b/rpython/rlib/rvmprof/test/test_rvmprof.py
--- a/rpython/rlib/rvmprof/test/test_rvmprof.py
+++ b/rpython/rlib/rvmprof/test/test_rvmprof.py
@@ -4,6 +4,8 @@
from rpython.translator.c.test.test_genc import compile
from rpython.rlib.objectmodel import we_are_translated
from rpython.rlib.nonconst import NonConstant
+from rpython.translator.tool.cbuild import ExternalCompilationInfo
+from rpython.rtyper.lltypesystem import rffi, lltype
def test_vmprof_execute_code_1():
@@ -148,8 +150,6 @@
assert os.path.exists(tmpfilename)
os.unlink(tmpfilename)
-from rpython.translator.tool.cbuild import ExternalCompilationInfo
-from rpython.rtyper.lltypesystem import rffi, lltype
def test_native():
eci = ExternalCompilationInfo(compile_extra=['-g','-O1'],
separate_module_sources=["""
More information about the pypy-commit
mailing list