Bug 1582348 - Save |underlyingSink| in a slot on the controller so that [[{write,close,abort}Algorithm]] can make later use of it. r=arai
authorJeff Walden <jwalden@mit.edu>
Tue, 05 Nov 2019 05:12:36 +0000
changeset 500546 2786d88246d44b290afc45561316e22f05619d40
parent 500545 db95a431fc207cae68c28654825d45622078e434
child 500547 ac4242e7f029764384385099fa55b4b1429ed635
push id114166
push userapavel@mozilla.com
push dateThu, 07 Nov 2019 10:04:01 +0000
treeherdermozilla-inbound@d271c572a9bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1582348
milestone72.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 1582348 - Save |underlyingSink| in a slot on the controller so that [[{write,close,abort}Algorithm]] can make later use of it. r=arai Differential Revision: https://phabricator.services.mozilla.com/D51048
js/src/builtin/streams/WritableStreamDefaultController.h
js/src/builtin/streams/WritableStreamDefaultControllerOperations.cpp
--- a/js/src/builtin/streams/WritableStreamDefaultController.h
+++ b/js/src/builtin/streams/WritableStreamDefaultController.h
@@ -34,16 +34,24 @@ class WritableStreamDefaultController : 
   enum Slots {
     /**
      * The stream that this controller controls.  Stream and controller are
      * initialized at the same time underneath the |WritableStream| constructor,
      * so they are same-compartment with each other.
      */
     Slot_Stream = StreamController::SlotCount,
 
+    /**
+     * The underlying sink object that this controller and its associated stream
+     * write to.
+     *
+     * This is a user-provided value, the first argument passed to
+     * |new WritableStream|, so it may be a cross-compartment wrapper around an
+     * object from another realm.
+     */
     Slot_UnderlyingSink,
 
     /** Number stored as DoubleValue. */
     Slot_StrategyHWM,
 
     /**
      * Either undefined if each chunk has size 1, or a callable object to be
      * invoked on each chunk to determine its size.  See
--- a/js/src/builtin/streams/WritableStreamDefaultControllerOperations.cpp
+++ b/js/src/builtin/streams/WritableStreamDefaultControllerOperations.cpp
@@ -279,16 +279,19 @@ MOZ_MUST_USE bool js::SetUpWritableStrea
   controller->setStrategySize(size);
 
   // Step 8: Set controller.[[strategyHWM]] to highWaterMark.
   controller->setStrategyHWM(highWaterMark);
 
   // Step 9: Set controller.[[writeAlgorithm]] to writeAlgorithm.
   // Step 10: Set controller.[[closeAlgorithm]] to closeAlgorithm.
   // Step 11: Set controller.[[abortAlgorithm]] to abortAlgorithm.
+  // (In this implementation, all [[*Algorithm]] are determined by the
+  // underlyingSink in combination with the corresponding *Method field.)
+  controller->setUnderlyingSink(underlyingSink);
   controller->setWriteMethod(writeMethod);
   controller->setCloseMethod(closeMethod);
   controller->setAbortMethod(abortMethod);
 
   // Step 12: Let backpressure be
   //          ! WritableStreamDefaultControllerGetBackpressure(controller).
   bool backpressure =
       WritableStreamDefaultControllerGetBackpressure(controller);