Author: Antonio Cuni <anto.c...@gmail.com> Branch: fix-vmprof-stacklet-switch Changeset: r93034:3e4e9ff62be1 Date: 2017-11-15 12:59 +0100 http://bitbucket.org/pypy/pypy/changeset/3e4e9ff62be1/
Log: make sure that vmprof don't sample the stack in the middle of stacklet switching, else it reads nonsense and BOOM 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 import rvmprof from rpython.rlib.rvmprof import cintf DEBUG = False @@ -40,11 +41,13 @@ def switch(self, stacklet): if DEBUG: debug.remove(stacklet) + rvmprof.stop_sampling(space=None) # XXX x = cintf.save_rvmprof_stack() try: h = self._gcrootfinder.switch(stacklet) finally: cintf.restore_rvmprof_stack(x) + rvmprof.start_sampling(space=None) # XXX if DEBUG: debug.add(h) return h diff --git a/rpython/rlib/test/test_rstacklet.py b/rpython/rlib/test/test_rstacklet.py --- a/rpython/rlib/test/test_rstacklet.py +++ b/rpython/rlib/test/test_rstacklet.py @@ -10,6 +10,8 @@ from rpython.config.translationoption import DEFL_ROOTFINDER_WITHJIT from rpython.rlib import rrandom, rgc from rpython.rlib.rarithmetic import intmask +from rpython.rlib.nonconst import NonConstant +from rpython.rlib import rvmprof from rpython.rtyper.lltypesystem import lltype, llmemory, rffi from rpython.translator.c.test.test_standalone import StandaloneTests @@ -273,7 +275,23 @@ llmemory.raw_free(raw) +# <vmprof-hack> +# bah, we need to make sure that vmprof_execute_code is annotated, else +# rvmprof.c does not compile correctly +class FakeVMProfCode(object): + pass +rvmprof.register_code_object_class(MyCode, lambda code: 'name') +@rvmprof.vmprof_execute_code("xcode1", lambda code, num: code) +def fake_vmprof_main(code, num): + return 42 +# </vmprof-hack> + def entry_point(argv): + # <vmprof-hack> + if NonConstant(False): + fake_vmprof_main(FakeVMProfCode(), 42) + # </vmprof-hack> + # seed = 0 if len(argv) > 1: seed = int(argv[1]) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit