Bug 1531027 - Add an explicit copy constructor to StackTrace. r=ehsan
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 28 Feb 2019 11:00:14 +1100
changeset 461878 c59e07cae80fcf325ff695b5e24e4aa823f034fd
parent 461877 75dd13876d89896a73a456d92fb0f3de4e3c72dc
child 461879 10df6785552dcb1aaac3dfbbd1b6fe099fee3437
push id35631
push userrgurzau@mozilla.com
push dateFri, 01 Mar 2019 13:06:03 +0000
treeherdermozilla-central@d4e19870e27f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1531027
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1531027 - Add an explicit copy constructor to StackTrace. r=ehsan This only copies the first `mLength` elements in `mPcs`. Differential Revision: https://phabricator.services.mozilla.com/D21488
memory/replace/dmd/DMD.cpp
--- a/memory/replace/dmd/DMD.cpp
+++ b/memory/replace/dmd/DMD.cpp
@@ -34,18 +34,18 @@
 #include "mozilla/Assertions.h"
 #include "mozilla/FastBernoulliTrial.h"
 #include "mozilla/HashFunctions.h"
 #include "mozilla/HashTable.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/JSONWriter.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MemoryReporting.h"
+#include "mozilla/PodOperations.h"
 #include "mozilla/StackWalk.h"
-#include "mozilla/Vector.h"
 
 // CodeAddressService is defined entirely in the header, so this does not make
 // DMD depend on XPCOM's object file.
 #include "CodeAddressService.h"
 
 // replace_malloc.h needs to be included before replace_malloc_bridge.h,
 // which DMD.h includes, so DMD.h needs to be included after replace_malloc.h.
 #include "replace_malloc.h"
@@ -591,16 +591,19 @@ class StackTrace {
   static const uint32_t MaxFrames = 24;
 
  private:
   uint32_t mLength;             // The number of PCs.
   const void* mPcs[MaxFrames];  // The PCs themselves.
 
  public:
   StackTrace() : mLength(0) {}
+  StackTrace(const StackTrace& aOther) : mLength(aOther.mLength) {
+    PodCopy(mPcs, aOther.mPcs, mLength);
+  }
 
   uint32_t Length() const { return mLength; }
   const void* Pc(uint32_t i) const {
     MOZ_ASSERT(i < mLength);
     return mPcs[i];
   }
 
   uint32_t Size() const { return mLength * sizeof(mPcs[0]); }