Bug 1514051 - Part 2: Drop the underlying source along with other GC edges in ReadableStreamControllerClearAlgorithms. r=arai
☠☠ backed out by 547d738dabfa ☠ ☠
authorJason Orendorff <jorendorff@mozilla.com>
Mon, 14 Jan 2019 20:42:08 +0000
changeset 510931 4b9bf0633280fa3fc6994e45700d1626be970cab
parent 510930 bd071dbcecad945f22ef53c976e312d3a2ee0c21
child 510932 797e7094701deb120cf9ba0c4d8b8a8200003899
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1514051
milestone66.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 1514051 - Part 2: Drop the underlying source along with other GC edges in ReadableStreamControllerClearAlgorithms. r=arai Differential Revision: https://phabricator.services.mozilla.com/D14512
js/src/builtin/Stream.cpp
js/src/builtin/Stream.h
--- a/js/src/builtin/Stream.cpp
+++ b/js/src/builtin/Stream.cpp
@@ -2942,20 +2942,22 @@ static bool ReadableStreamControllerShou
  * Streams spec, 3.9.4.
  *      ReadableStreamDefaultControllerClearAlgorithms ( controller )
  * and 3.12.4.
  *      ReadableByteStreamControllerClearAlgorithms ( controller )
  */
 static void ReadableStreamControllerClearAlgorithms(
     ReadableStreamController* controller) {
   // Step 1: Set controller.[[pullAlgorithm]] to undefined.
+  // Step 2: Set controller.[[cancelAlgorithm]] to undefined.
+  // (In this implementation, the UnderlyingSource slot is part of the
+  // representation of these algorithms.)
   controller->setPullMethod(UndefinedHandleValue);
-
-  // Step 2: Set controller.[[cancelAlgorithm]] to undefined.
   controller->setCancelMethod(UndefinedHandleValue);
+  controller->clearUnderlyingSource();
 
   // Step 3 (of 3.9.4 only) : Set controller.[[strategySizeAlgorithm]] to
   // undefined.
   if (controller->is<ReadableStreamDefaultController>()) {
     controller->as<ReadableStreamDefaultController>().setStrategySize(
         UndefinedHandleValue);
   }
 }
--- a/js/src/builtin/Stream.h
+++ b/js/src/builtin/Stream.h
@@ -311,16 +311,23 @@ class ReadableStreamController : public 
     MOZ_ASSERT(hasExternalSource());
     return static_cast<JS::ReadableStreamUnderlyingSource*>(
         underlyingSource().toPrivate());
   }
   void setExternalSource(JS::ReadableStreamUnderlyingSource* underlyingSource) {
     setUnderlyingSource(JS::PrivateValue(underlyingSource));
     addFlags(Flag_ExternalSource);
   }
+  void clearUnderlyingSource() {
+    if (hasExternalSource()) {
+      externalSource()->finalize();
+      setFlags(flags() & ~Flag_ExternalSource);
+    }
+    setUnderlyingSource(JS::UndefinedHandleValue);
+  }
   double strategyHWM() const {
     return getFixedSlot(Slot_StrategyHWM).toNumber();
   }
   void setStrategyHWM(double highWaterMark) {
     setFixedSlot(Slot_StrategyHWM, NumberValue(highWaterMark));
   }
   uint32_t flags() const { return getFixedSlot(Slot_Flags).toInt32(); }
   void setFlags(uint32_t flags) { setFixedSlot(Slot_Flags, Int32Value(flags)); }