Bug 1646266 - CorePS buffer access - r=gregtatum

The upcoming profiler-specific add-marker function will need to know which `ProfileChunkedBuffer` to serialize to, `profiler_get_core_buffer()` give access to the profiler's buffer, and `CachedCoreBuffer()` keeps it stored in a function-static object.

Differential Revision: https://phabricator.services.mozilla.com/D87256
This commit is contained in:
Gerald Squelart 2020-09-01 01:32:13 +00:00
parent 80e6ec3baf
commit 56dc2f7c14
4 changed files with 42 additions and 1 deletions

View File

@ -419,7 +419,7 @@ class CorePS {
PS_GET_LOCKLESS(int, MainThreadId)
// No PSLockRef is needed for this field because it's immutable.
PS_GET_LOCKLESS(TimeStamp, ProcessStartTime)
PS_GET_LOCKLESS(const TimeStamp&, ProcessStartTime)
// No PSLockRef is needed for this field because it's thread-safe.
PS_GET_LOCKLESS(ProfileChunkedBuffer&, CoreBuffer)
@ -568,6 +568,11 @@ class CorePS {
CorePS* CorePS::sInstance = nullptr;
ProfileChunkedBuffer& profiler_get_core_buffer() {
MOZ_ASSERT(CorePS::Exists());
return CorePS::CoreBuffer();
}
class SamplerThread;
static SamplerThread* NewSamplerThread(PSLockRef aLock, uint32_t aGeneration,

View File

@ -22,6 +22,23 @@
# include <limits>
namespace mozilla::baseprofiler {
// Implemented in platform.cpp
MFBT_API ProfileChunkedBuffer& profiler_get_core_buffer();
} // namespace mozilla::baseprofiler
namespace mozilla::base_profiler_markers_detail {
// Get the core buffer from the profiler, and cache it in a
// non-templated-function static reference.
inline ProfileChunkedBuffer& CachedBaseCoreBuffer() {
static ProfileChunkedBuffer& coreBuffer =
baseprofiler::profiler_get_core_buffer();
return coreBuffer;
}
} // namespace mozilla::base_profiler_markers_detail
namespace mozilla {
// ----------------------------------------------------------------------------

View File

@ -695,6 +695,11 @@ class CorePS {
CorePS* CorePS::sInstance = nullptr;
ProfileChunkedBuffer& profiler_get_core_buffer() {
MOZ_ASSERT(CorePS::Exists());
return CorePS::CoreBuffer();
}
class SamplerThread;
static SamplerThread* NewSamplerThread(PSLockRef aLock, uint32_t aGeneration,

View File

@ -23,6 +23,20 @@
// Header that specializes the (de)serializers for xpcom types.
# include "mozilla/ProfileBufferEntrySerializationGeckoExtensions.h"
// Implemented in platform.cpp
mozilla::ProfileChunkedBuffer& profiler_get_core_buffer();
namespace profiler_markers_detail {
// Get the core buffer from the profiler, and cache it in a
// non-templated-function static reference.
inline mozilla::ProfileChunkedBuffer& CachedCoreBuffer() {
static mozilla::ProfileChunkedBuffer& coreBuffer = profiler_get_core_buffer();
return coreBuffer;
}
} // namespace profiler_markers_detail
#endif // MOZ_GECKO_PROFILER
#endif // ProfilerMarkersDetail_h