[pypy-commit] pypy fix-vmprof-stacklet-switch-2: 1) we can't monkey-patch _get_vmprof because it's imported in two places; insead it's easier to monkey-patch the singleton it returns; 2) move vmprof_{start,stop}_sampling to the proper cintf namespace, so that they can no longer be called directly
antocuni
pypy.commits at gmail.com
Tue Nov 28 10:10:47 EST 2017
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: fix-vmprof-stacklet-switch-2
Changeset: r93193:b85210ca9c20
Date: 2017-11-28 15:54 +0100
http://bitbucket.org/pypy/pypy/changeset/b85210ca9c20/
Log: 1) we can't monkey-patch _get_vmprof because it's imported in two
places; insead it's easier to monkey-patch the singleton it returns;
2) move vmprof_{start,stop}_sampling to the proper cintf namespace,
so that they can no longer be called directly
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
@@ -122,32 +122,16 @@
lltype.Signed, compilation_info=eci,
_nowrapper=True)
+ vmprof_stop_sampling = rffi.llexternal("vmprof_stop_sampling", [],
+ rffi.INT, compilation_info=eci,
+ _nowrapper=True)
+ vmprof_start_sampling = rffi.llexternal("vmprof_start_sampling", [],
+ lltype.Void, compilation_info=eci,
+ _nowrapper=True)
+
return CInterface(locals())
-# this is always present, but compiles to no-op if RPYTHON_VMPROF is not
-# defined (i.e. if we don't actually use vmprof in the generated C)
-auto_eci = ExternalCompilationInfo(post_include_bits=["""
-#ifndef RPYTHON_VMPROF
-# define vmprof_stop_sampling() (-1)
-# define vmprof_start_sampling() ((void)0)
-#endif
-"""])
-
-if get_translation_config() is None:
- # tests need the full eci here
- _eci = global_eci
-else:
- _eci = auto_eci
-
-vmprof_stop_sampling = rffi.llexternal("vmprof_stop_sampling", [],
- rffi.INT, compilation_info=_eci,
- _nowrapper=True)
-vmprof_start_sampling = rffi.llexternal("vmprof_start_sampling", [],
- lltype.Void, compilation_info=_eci,
- _nowrapper=True)
-
-
class CInterface(object):
def __init__(self, namespace):
for k, v in namespace.iteritems():
diff --git a/rpython/rlib/rvmprof/test/support.py b/rpython/rlib/rvmprof/test/support.py
--- a/rpython/rlib/rvmprof/test/support.py
+++ b/rpython/rlib/rvmprof/test/support.py
@@ -30,8 +30,6 @@
@pytest.fixture
def fakevmprof(request, monkeypatch):
fake = FakeVMProf()
- def _get_fake_vmprof():
- return fake
- monkeypatch.setattr(rvmprof.rvmprof, '_get_vmprof', _get_fake_vmprof)
+ monkeypatch.setattr(rvmprof.rvmprof, '_vmprof_instance', fake)
return fake
diff --git a/rpython/rlib/rvmprof/test/test_support.py b/rpython/rlib/rvmprof/test/test_support.py
--- a/rpython/rlib/rvmprof/test/test_support.py
+++ b/rpython/rlib/rvmprof/test/test_support.py
@@ -28,7 +28,7 @@
def test_fixture(self, fakevmprof):
assert isinstance(fakevmprof, FakeVMProf)
- assert rvmprof.rvmprof._get_vmprof() is fakevmprof
+ assert rvmprof._get_vmprof() is fakevmprof
#
# tweak sampling using the "real" API, and check that we actually used
# the fake
More information about the pypy-commit
mailing list