Author: Antonio Cuni <anto.c...@gmail.com> Branch: fix-vmprof-stacklet-switch-2 Changeset: r93195:2907f533041c Date: 2017-11-28 16:48 +0100 http://bitbucket.org/pypy/pypy/changeset/2907f533041c/
Log: move the vmprof API needed by rstacklet from cintf to rvmprof/__init__.py, to integrate better with fakevmprof diff --git a/rpython/rlib/rstacklet.py b/rpython/rlib/rstacklet.py --- a/rpython/rlib/rstacklet.py +++ b/rpython/rlib/rstacklet.py @@ -3,7 +3,7 @@ from rpython.rlib import jit from rpython.rlib.objectmodel import fetch_translated_config from rpython.rtyper.lltypesystem import lltype, llmemory -from rpython.rlib.rvmprof import cintf +from rpython.rlib import rvmprof DEBUG = False @@ -25,12 +25,12 @@ def new(self, callback, arg=llmemory.NULL): if DEBUG: callback = _debug_wrapper(callback) - x = cintf.save_rvmprof_stack() + x = rvmprof.save_stack() try: - cintf.empty_rvmprof_stack() + rvmprof.empty_stack() h = self._gcrootfinder.new(self, callback, arg) finally: - cintf.restore_rvmprof_stack(x) + rvmprof.restore_stack(x) if DEBUG: debug.add(h) return h @@ -40,11 +40,11 @@ def switch(self, stacklet): if DEBUG: debug.remove(stacklet) - x = cintf.save_rvmprof_stack() + x = rvmprof.save_stack() try: h = self._gcrootfinder.switch(stacklet) finally: - cintf.restore_rvmprof_stack(x) + rvmprof.restore_stack(x) if DEBUG: debug.add(h) return h diff --git a/rpython/rlib/rvmprof/__init__.py b/rpython/rlib/rvmprof/__init__.py --- a/rpython/rlib/rvmprof/__init__.py +++ b/rpython/rlib/rvmprof/__init__.py @@ -60,3 +60,23 @@ def start_sampling(): return _get_vmprof().start_sampling() + +# ---------------- +# stacklet support +# ---------------- +# +# Ideally, vmprof_tl_stack, VMPROFSTACK etc. should be part of "self.cintf": +# not sure why they are a global. Eventually, we should probably fix all this +# mess. +from rpython.rlib.rvmprof.cintf import vmprof_tl_stack, VMPROFSTACK + +def save_stack(): + stop_sampling() + return vmprof_tl_stack.get_or_make_raw() + +def empty_stack(): + vmprof_tl_stack.setraw(lltype.nullptr(VMPROFSTACK)) + +def restore_stack(x): + vmprof_tl_stack.setraw(x) + start_sampling() 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 @@ -216,20 +216,6 @@ leave_code(s) # -# stacklet support - -def save_rvmprof_stack(): - vmprof_stop_sampling() - return vmprof_tl_stack.get_or_make_raw() - -def empty_rvmprof_stack(): - vmprof_tl_stack.setraw(lltype.nullptr(VMPROFSTACK)) - -def restore_rvmprof_stack(x): - vmprof_tl_stack.setraw(x) - vmprof_start_sampling() - -# # traceback support def get_rvmprof_stack(): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit