Bug 1596761 - Clear native allocations feature when not supported; r=canaltinova

Differential Revision: https://phabricator.services.mozilla.com/D53655

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Greg Tatum 2019-11-19 20:27:55 +00:00
parent 47d35b097d
commit 677d68be28
2 changed files with 20 additions and 6 deletions

View File

@ -584,7 +584,7 @@ void enable_native_allocations(int aMainThreadId) {
// with the memory hook machinery, as the bloat log creates its own
// allocations. This means we can re-enter inside the bloat log machinery. At
// this time, the bloat log does not know about cannot handle the native
// allocation feature. For now just disable the feature.
// allocation feature.
//
// At the time of this writing, we hit this assertion:
// IsIdle(oldState) || IsRead(oldState) in Checker::StartReadOp()
@ -602,11 +602,13 @@ void enable_native_allocations(int aMainThreadId) {
// #11: NS_LogCtor
// #12: profiler_get_backtrace()
// ...
if (!PR_GetEnv("XPCOM_MEM_BLOAT_LOG")) {
EnsureBernoulliIsInstalled();
EnsureAllocationTrackerIsInstalled();
ThreadIntercept::EnableAllocationFeature(aMainThreadId);
}
MOZ_ASSERT(!PR_GetEnv("XPCOM_MEM_BLOAT_LOG"),
"The bloat log feature is not compatible with the native "
"allocations instrumentation.");
EnsureBernoulliIsInstalled();
EnsureAllocationTrackerIsInstalled();
ThreadIntercept::EnableAllocationFeature(aMainThreadId);
}
// This is safe to call even if native allocations hasn't been enabled.

View File

@ -214,6 +214,18 @@ static uint32_t AvailableFeatures() {
#endif
#if !defined(MOZ_TASK_TRACER)
ProfilerFeature::ClearTaskTracer(features);
#endif
#if defined(MOZ_REPLACE_MALLOC) && defined(MOZ_PROFILER_MEMORY)
if (getenv("XPCOM_MEM_BLOAT_LOG")) {
// The memory hooks are available, but the bloat log is enabled, which is
// not compatible with the native allocations tracking. See the comment in
// enable_native_allocations() (tools/profiler/core/memory_hooks.cpp) for
// more information.
ProfilerFeature::ClearNativeAllocations(features);
}
#else
// The memory hooks are not available.
ProfilerFeature::ClearNativeAllocations(features);
#endif
if (!JS::TraceLoggerSupported()) {
ProfilerFeature::ClearJSTracer(features);