mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1893668 - Make string stats more obviously debug-only. r=xpcom-reviewers,mccr8
Also, make them relaxed atomic. Sequentially consistent atomics might help paper concurrency issues in debug builds, and there's really no good reason these counts need to be sequentially consistent. Differential Revision: https://phabricator.services.mozilla.com/D208759
This commit is contained in:
parent
d416fbeae3
commit
de27e73e27
@ -9,12 +9,7 @@
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
# include "nsStringStats.h"
|
||||
#else
|
||||
# define STRING_STAT_INCREMENT(_s)
|
||||
#endif
|
||||
#include "nsStringStats.h"
|
||||
|
||||
void nsStringBuffer::AddRef() {
|
||||
// Memory synchronization is not required when incrementing a
|
||||
|
@ -6,20 +6,21 @@
|
||||
|
||||
#include "nsStringStats.h"
|
||||
|
||||
#include "mozilla/IntegerPrintfMacros.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "nsString.h"
|
||||
#ifdef DEBUG
|
||||
# include "mozilla/IntegerPrintfMacros.h"
|
||||
# include "mozilla/MemoryReporting.h"
|
||||
# include "nsString.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
# include <stdint.h>
|
||||
# include <stdio.h>
|
||||
|
||||
#ifdef XP_WIN
|
||||
# include <windows.h>
|
||||
# include <process.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# include <pthread.h>
|
||||
#endif
|
||||
# ifdef XP_WIN
|
||||
# include <windows.h>
|
||||
# include <process.h>
|
||||
# else
|
||||
# include <unistd.h>
|
||||
# include <pthread.h>
|
||||
# endif
|
||||
|
||||
nsStringStats gStringStats;
|
||||
|
||||
@ -54,13 +55,14 @@ nsStringStats::~nsStringStats() {
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
# ifdef XP_WIN
|
||||
auto pid = uintptr_t(_getpid());
|
||||
auto tid = uintptr_t(GetCurrentThreadId());
|
||||
#else
|
||||
# else
|
||||
auto pid = uintptr_t(getpid());
|
||||
auto tid = uintptr_t(pthread_self());
|
||||
#endif
|
||||
# endif
|
||||
|
||||
printf(" => Process ID: %" PRIuPTR ", Thread ID: %" PRIuPTR "\n", pid, tid);
|
||||
}
|
||||
#endif
|
||||
|
@ -7,7 +7,8 @@
|
||||
#ifndef nsStringStats_h
|
||||
#define nsStringStats_h
|
||||
|
||||
#include "mozilla/Atomics.h"
|
||||
#ifdef DEBUG
|
||||
# include "mozilla/Atomics.h"
|
||||
|
||||
class nsStringStats {
|
||||
public:
|
||||
@ -15,7 +16,7 @@ class nsStringStats {
|
||||
|
||||
~nsStringStats();
|
||||
|
||||
using AtomicInt = mozilla::Atomic<int32_t, mozilla::SequentiallyConsistent>;
|
||||
using AtomicInt = mozilla::Atomic<int32_t, mozilla::Relaxed>;
|
||||
|
||||
AtomicInt mAllocCount{0};
|
||||
AtomicInt mReallocCount{0};
|
||||
@ -26,7 +27,9 @@ class nsStringStats {
|
||||
};
|
||||
|
||||
extern nsStringStats gStringStats;
|
||||
|
||||
#define STRING_STAT_INCREMENT(_s) (gStringStats.m##_s##Count)++
|
||||
# define STRING_STAT_INCREMENT(_s) (gStringStats.m##_s##Count)++
|
||||
#else
|
||||
# define STRING_STAT_INCREMENT(_s)
|
||||
#endif
|
||||
|
||||
#endif // nsStringStats_h
|
||||
|
@ -16,12 +16,7 @@
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
# include "nsStringStats.h"
|
||||
#else
|
||||
# define STRING_STAT_INCREMENT(_s)
|
||||
#endif
|
||||
#include "nsStringStats.h"
|
||||
|
||||
// It's not worthwhile to reallocate the buffer and memcpy the
|
||||
// contents over when the size difference isn't large. With
|
||||
|
Loading…
Reference in New Issue
Block a user