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-08-31 23:28:56 +00:00
Родитель 4e9b0b4d1f
Коммит 8ff41618d2
4 изменённых файлов: 42 добавлений и 1 удалений

Просмотреть файл

@ -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,

Просмотреть файл

@ -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 {
// ----------------------------------------------------------------------------

Просмотреть файл

@ -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,

Просмотреть файл

@ -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