Author: Armin Rigo <ar...@tunes.org> Branch: improve-vmprof-testing Changeset: r86092:68cb0f468f13 Date: 2016-08-08 19:55 +0200 http://bitbucket.org/pypy/pypy/changeset/68cb0f468f13/
Log: Tentative proper fix for stacklet+vmprof diff --git a/rpython/rlib/rstacklet.py b/rpython/rlib/rstacklet.py --- a/rpython/rlib/rstacklet.py +++ b/rpython/rlib/rstacklet.py @@ -3,6 +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 DEBUG = False @@ -24,7 +25,12 @@ def new(self, callback, arg=llmemory.NULL): if DEBUG: callback = _debug_wrapper(callback) - h = self._gcrootfinder.new(self, callback, arg) + x = cintf.save_rvmprof_stack() + try: + cintf.empty_rvmprof_stack() + h = self._gcrootfinder.new(self, callback, arg) + finally: + cintf.restore_rvmprof_stack(x) if DEBUG: debug.add(h) return h @@ -34,7 +40,11 @@ def switch(self, stacklet): if DEBUG: debug.remove(stacklet) - h = self._gcrootfinder.switch(stacklet) + x = cintf.save_rvmprof_stack() + try: + h = self._gcrootfinder.switch(stacklet) + finally: + cintf.restore_rvmprof_stack(x) if DEBUG: debug.add(h) return h 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 @@ -98,9 +98,6 @@ def leave_code(s): if not we_are_translated(): - # xxx this assertion may be false in the presence of - # stacklets, but let's assume we never run untranslated - # tests with stacklets and rvmprof assert vmprof_tl_stack.getraw() == s vmprof_tl_stack.setraw(s.c_next) lltype.free(s, flavor='raw') @@ -143,9 +140,17 @@ enter_code(unique_id) # ignore the return value else: s = vmprof_tl_stack.getraw() - #assert s.c_value == unique_id and s.c_kind == VMPROF_CODE_TAG - #^^^ this is false in the presence of stacklets. - # we get random nonsense then; let's say it's ok for now - # and avoid crashing. - if s.c_value == unique_id and s.c_kind == VMPROF_CODE_TAG: - leave_code(s) + assert s.c_value == unique_id and s.c_kind == VMPROF_CODE_TAG + leave_code(s) + +# +# stacklet support + +def save_rvmprof_stack(): + 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) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit