Bug 1644600 - Move JSStructuredCloneData destructor into private impl. r=sfink, a=RyanVM
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Tue, 04 May 2021 14:05:08 +0000
changeset 600563 2abc0a4645aa6afb7aa55a52d8f7b5baf6823f85
parent 600562 b527fc1610192d2d16d08c843734e2d7c1bac665
child 600564 88c22fc68cbff697ba630f86de0484484346075c
push id254
push userryanvm@gmail.com
push dateThu, 13 May 2021 19:19:06 +0000
treeherdermozilla-esr78@6cdaa8e2957b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink, RyanVM
bugs1644600
milestone78.11.0
Bug 1644600 - Move JSStructuredCloneData destructor into private impl. r=sfink, a=RyanVM This is using js::SharedArrayRawBufferRefs that is a private API and not exported. Leaving it in the header makes linking not to work when using StructuredClone: JSStructuredCloneData::~JSStructuredCloneData()': /usr/include/mozjs-78/js/StructuredClone.h:459: undefined reference to `js::SharedArrayRawBufferRefs::~SharedArrayRawBufferRefs() Differential Revision: https://phabricator.services.mozilla.com/D114128
js/public/StructuredClone.h
js/src/vm/StructuredClone.cpp
--- a/js/public/StructuredClone.h
+++ b/js/public/StructuredClone.h
@@ -451,17 +451,17 @@ class MOZ_NON_MEMMOVABLE JS_PUBLIC_API J
         callbacks_(nullptr),
         closure_(nullptr),
         ownTransferables_(OwnTransferablePolicy::NoTransferables) {}
   MOZ_IMPLICIT JSStructuredCloneData(BufferList&& buffers)
       : JSStructuredCloneData(std::move(buffers),
                               JS::StructuredCloneScope::Unassigned) {}
   JSStructuredCloneData(JSStructuredCloneData&& other) = default;
   JSStructuredCloneData& operator=(JSStructuredCloneData&& other) = default;
-  ~JSStructuredCloneData() { discardTransferables(); }
+  ~JSStructuredCloneData();
 
   void setCallbacks(const JSStructuredCloneCallbacks* callbacks, void* closure,
                     OwnTransferablePolicy policy) {
     callbacks_ = callbacks;
     closure_ = closure;
     ownTransferables_ = policy;
   }
 
--- a/js/src/vm/StructuredClone.cpp
+++ b/js/src/vm/StructuredClone.cpp
@@ -933,16 +933,18 @@ bool SCOutput::writeChars(const Latin1Ch
                 "Latin1Char must fit in 1 byte");
   return writeBytes(p, nchars);
 }
 
 void SCOutput::discardTransferables() { buf.discardTransferables(); }
 
 }  // namespace js
 
+JSStructuredCloneData::~JSStructuredCloneData() { discardTransferables(); }
+
 // If the buffer contains Transferables, free them. Note that custom
 // Transferables will use the JSStructuredCloneCallbacks::freeTransfer() to
 // delete their transferables.
 void JSStructuredCloneData::discardTransferables() {
   if (!Size()) {
     return;
   }