Bug 1506200 - Remove ReadableStream EmbeddingFlags. r=baku,jwalden
authorJason Orendorff <jorendorff@mozilla.com>
Wed, 28 Nov 2018 22:20:55 +0000
changeset 505032 b1441844989695a3d9e979107bfaa36d531ca38c
parent 505031 0ed1cec73c666a422436ed04879fb8b5229fb9ca
child 505033 d1415db52fe837241d2d7bcc1cf242159806d837
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku, jwalden
bugs1506200
milestone65.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 1506200 - Remove ReadableStream EmbeddingFlags. r=baku,jwalden Differential Revision: https://phabricator.services.mozilla.com/D11903
dom/fetch/FetchStream.cpp
dom/fetch/FetchStream.h
js/public/Stream.h
js/src/builtin/Stream.cpp
js/src/builtin/Stream.h
js/src/jsapi-tests/testReadableStream.cpp
--- a/dom/fetch/FetchStream.cpp
+++ b/dom/fetch/FetchStream.cpp
@@ -6,18 +6,16 @@
 
 #include "FetchStream.h"
 #include "mozilla/dom/DOMException.h"
 #include "mozilla/dom/WorkerCommon.h"
 #include "mozilla/dom/WorkerPrivate.h"
 #include "nsProxyRelease.h"
 #include "nsStreamUtils.h"
 
-#define FETCH_STREAM_FLAG 0
-
 static NS_DEFINE_CID(kStreamTransportServiceCID,
                      NS_STREAMTRANSPORTSERVICE_CID);
 
 namespace mozilla {
 namespace dom {
 
 class FetchStream::WorkerShutdown final : public WorkerControlRunnable
 {
@@ -105,17 +103,17 @@ FetchStream::Create(JSContext* aCx, Fetc
                                    &FetchStream::CancelCallback,
                                    &FetchStream::ClosedCallback,
                                    &FetchStream::ErroredCallback,
                                    &FetchStream::FinalizeCallback);
   }
 
   aRv.MightThrowJSException();
   JS::Rooted<JSObject*> body(aCx,
-    JS::NewReadableExternalSourceStreamObject(aCx, stream, FETCH_STREAM_FLAG));
+    JS::NewReadableExternalSourceStreamObject(aCx, stream));
   if (!body) {
     aRv.StealExceptionFromJSContext(aCx);
     return;
   }
 
   // This will be released in FetchStream::FinalizeCallback().  We are
   // guaranteed the jsapi will call FinalizeCallback when ReadableStream
   // js object is finalized.
@@ -123,21 +121,19 @@ FetchStream::Create(JSContext* aCx, Fetc
 
   aStream.set(body);
 }
 
 /* static */ void
 FetchStream::RequestDataCallback(JSContext* aCx,
                                  JS::HandleObject aStream,
                                  void* aUnderlyingSource,
-                                 uint8_t aFlags,
                                  size_t aDesiredSize)
 {
   MOZ_DIAGNOSTIC_ASSERT(aUnderlyingSource);
-  MOZ_DIAGNOSTIC_ASSERT(aFlags == FETCH_STREAM_FLAG);
 #if MOZ_DIAGNOSTIC_ASSERT_ENABLED
   bool disturbed;
   if (!JS::ReadableStreamIsDisturbed(aCx, aStream, &disturbed)) {
     JS_ClearPendingException(aCx);
   } else {
     MOZ_DIAGNOSTIC_ASSERT(disturbed);
   }
 #endif
@@ -203,21 +199,20 @@ FetchStream::RequestDataCallback(JSConte
 
   // All good.
 }
 
 /* static */ void
 FetchStream::WriteIntoReadRequestCallback(JSContext* aCx,
                                           JS::HandleObject aStream,
                                           void* aUnderlyingSource,
-                                          uint8_t aFlags, void* aBuffer,
-                                          size_t aLength, size_t* aByteWritten)
+                                          void* aBuffer, size_t aLength,
+                                          size_t* aByteWritten)
 {
   MOZ_DIAGNOSTIC_ASSERT(aUnderlyingSource);
-  MOZ_DIAGNOSTIC_ASSERT(aFlags == FETCH_STREAM_FLAG);
   MOZ_DIAGNOSTIC_ASSERT(aBuffer);
   MOZ_DIAGNOSTIC_ASSERT(aByteWritten);
 
   RefPtr<FetchStream> stream = static_cast<FetchStream*>(aUnderlyingSource);
   stream->AssertIsOnOwningThread();
 
   MutexAutoLock lock(stream->mMutex);
 
@@ -247,21 +242,19 @@ FetchStream::WriteIntoReadRequestCallbac
     return;
   }
 
   // All good.
 }
 
 /* static */ JS::Value
 FetchStream::CancelCallback(JSContext* aCx, JS::HandleObject aStream,
-                            void* aUnderlyingSource, uint8_t aFlags,
-                            JS::HandleValue aReason)
+                            void* aUnderlyingSource, JS::HandleValue aReason)
 {
   MOZ_DIAGNOSTIC_ASSERT(aUnderlyingSource);
-  MOZ_DIAGNOSTIC_ASSERT(aFlags == FETCH_STREAM_FLAG);
 
   // This is safe because we created an extra reference in FetchStream::Create()
   // that won't be released until FetchStream::FinalizeCallback() is called.
   // We are guaranteed that won't happen until the js ReadableStream object
   // is finalized.
   FetchStream* stream = static_cast<FetchStream*>(aUnderlyingSource);
   stream->AssertIsOnOwningThread();
 
@@ -282,29 +275,26 @@ FetchStream::CancelCallback(JSContext* a
   }
 
   stream->ReleaseObjects();
   return JS::UndefinedValue();
 }
 
 /* static */ void
 FetchStream::ClosedCallback(JSContext* aCx, JS::HandleObject aStream,
-                            void* aUnderlyingSource, uint8_t aFlags)
+                            void* aUnderlyingSource)
 {
   MOZ_DIAGNOSTIC_ASSERT(aUnderlyingSource);
-  MOZ_DIAGNOSTIC_ASSERT(aFlags == FETCH_STREAM_FLAG);
 }
 
 /* static */ void
 FetchStream::ErroredCallback(JSContext* aCx, JS::HandleObject aStream,
-                             void* aUnderlyingSource, uint8_t aFlags,
-                             JS::HandleValue aReason)
+                             void* aUnderlyingSource, JS::HandleValue aReason)
 {
   MOZ_DIAGNOSTIC_ASSERT(aUnderlyingSource);
-  MOZ_DIAGNOSTIC_ASSERT(aFlags == FETCH_STREAM_FLAG);
 
   // This is safe because we created an extra reference in FetchStream::Create()
   // that won't be released until FetchStream::FinalizeCallback() is called.
   // We are guaranteed that won't happen until the js ReadableStream object
   // is finalized.
   FetchStream* stream = static_cast<FetchStream*>(aUnderlyingSource);
   stream->AssertIsOnOwningThread();
 
@@ -316,20 +306,19 @@ FetchStream::ErroredCallback(JSContext* 
   if (stream->mInputStream) {
     stream->mInputStream->CloseWithStatus(NS_BASE_STREAM_CLOSED);
   }
 
   stream->ReleaseObjects();
 }
 
 void
-FetchStream::FinalizeCallback(void* aUnderlyingSource, uint8_t aFlags)
+FetchStream::FinalizeCallback(void* aUnderlyingSource)
 {
   MOZ_DIAGNOSTIC_ASSERT(aUnderlyingSource);
-  MOZ_DIAGNOSTIC_ASSERT(aFlags == FETCH_STREAM_FLAG);
 
   // This can be called in any thread.
 
   // This takes ownership of the ref created in FetchStream::Create().
   RefPtr<FetchStream> stream =
     dont_AddRef(static_cast<FetchStream*>(aUnderlyingSource));
 
   stream->ReleaseObjects();
--- a/dom/fetch/FetchStream.h
+++ b/dom/fetch/FetchStream.h
@@ -56,41 +56,38 @@ private:
   AssertIsOnOwningThread();
 #else
   void
   AssertIsOnOwningThread() {}
 #endif
 
   static void
   RequestDataCallback(JSContext* aCx, JS::HandleObject aStream,
-                      void* aUnderlyingSource, uint8_t aFlags,
-                      size_t aDesiredSize);
+                      void* aUnderlyingSource, size_t aDesiredSize);
 
   static void
   WriteIntoReadRequestCallback(JSContext* aCx, JS::HandleObject aStream,
-                               void* aUnderlyingSource, uint8_t aFlags,
+                               void* aUnderlyingSource,
                                void* aBuffer, size_t aLength,
                                size_t* aByteWritten);
 
   static JS::Value
   CancelCallback(JSContext* aCx, JS::HandleObject aStream,
-                 void* aUnderlyingSource, uint8_t aFlags,
-                 JS::HandleValue aReason);
+                 void* aUnderlyingSource, JS::HandleValue aReason);
 
   static void
   ClosedCallback(JSContext* aCx, JS::HandleObject aStream,
-                 void* aUnderlyingSource, uint8_t aFlags);
+                 void* aUnderlyingSource);
 
   static void
   ErroredCallback(JSContext* aCx, JS::HandleObject aStream,
-                  void* aUnderlyingSource, uint8_t aFlags,
-                  JS::HandleValue reason);
+                  void* aUnderlyingSource, JS::HandleValue reason);
 
   static void
-  FinalizeCallback(void* aUnderlyingSource, uint8_t aFlags);
+  FinalizeCallback(void* aUnderlyingSource);
 
   void
   ErrorPropagation(JSContext* aCx,
                    const MutexAutoLock& aProofOfLock,
                    JS::HandleObject aStream, nsresult aRv);
 
   void
   CloseAndReleaseObjects(JSContext* aCx,
--- a/js/public/Stream.h
+++ b/js/public/Stream.h
@@ -15,23 +15,21 @@
  * ## External streams
  *
  * Embeddings can create ReadableStreams that read from custom C++ data
  * sources. Such streams are always byte streams: the chunks they produce are
  * typed arrays (and they will support ReadableStreamBYOBReader once we have
  * it).
  *
  * When creating an "external readable stream" using
- * JS::NewReadableExternalSourceStreamObject, an underlying source and a set of
- * flags can be passed to be stored on the stream. The underlying source is
- * treated as an opaque void* pointer by the JS engine: it's purely meant as a
- * reference to be used by the embedding to identify whatever actual source it
- * uses to supply data for the stream. Similarly, the flags aren't interpreted
- * by the JS engine, but are passed to some of the callbacks below and can be
- * retrieved using JS::ReadableStreamGetEmbeddingFlags.
+ * JS::NewReadableExternalSourceStreamObject, an underlying source can be
+ * passed to be stored on the stream. The underlying source is treated as an
+ * opaque void* pointer by the JS engine: it's purely meant as a reference to
+ * be used by the embedding to identify whatever actual source it uses to
+ * supply data for the stream.
  *
  * External readable streams are optimized to allow the embedding to interact
  * with them with a minimum of overhead: chunks aren't enqueued as individual
  * typed arrays; instead, the embedding only updates the amount of data
  * available using ReadableStreamUpdateDataAvailableFromSource. When JS
  * requests data from a reader, WriteIntoReadRequestBufferCallback is invoked,
  * asking the embedding to write data directly into the buffer we're about to
  * hand to JS.
@@ -74,17 +72,17 @@ namespace JS {
  * Invoked whenever a reader desires more data from a ReadableStream's
  * embedding-provided underlying source.
  *
  * The given |desiredSize| is the absolute size, not a delta from the previous
  * desired size.
  */
 typedef void
 (* RequestReadableStreamDataCallback)(JSContext* cx, HandleObject stream,
-                                      void* underlyingSource, uint8_t flags, size_t desiredSize);
+                                      void* underlyingSource, size_t desiredSize);
 
 /**
  * Invoked to cause the embedding to fill the given |buffer| with data from
  * the given embedding-provided underlying source.
  *
  * This can only happen after the embedding has updated the amount of data
  * available using JS::ReadableStreamUpdateDataAvailableFromSource. If at
  * least one read request is pending when
@@ -93,66 +91,65 @@ typedef void
  * the call to JS::WriteIntoReadRequestBufferCallback. If not, it is invoked
  * if and when a new read request is made.
  *
  * Note: This callback *must not cause GC*, because that could potentially
  * invalidate the |buffer| pointer.
  */
 typedef void
 (* WriteIntoReadRequestBufferCallback)(JSContext* cx, HandleObject stream,
-                                       void* underlyingSource, uint8_t flags, void* buffer,
-                                       size_t length, size_t* bytesWritten);
+                                       void* underlyingSource, void* buffer, size_t length,
+                                       size_t* bytesWritten);
 
 /**
  * Invoked in reaction to the ReadableStream being canceled to allow the
  * embedding to free the underlying source.
  *
  * This is equivalent to calling |cancel| on non-external underlying sources
  * provided to the ReadableStream constructor in JavaScript.
  *
  * The given |reason| is the JS::Value that was passed as an argument to
  * ReadableStream#cancel().
  *
  * The returned JS::Value will be used to resolve the Promise returned by
  * ReadableStream#cancel().
  */
 typedef Value
 (* CancelReadableStreamCallback)(JSContext* cx, HandleObject stream,
-                                 void* underlyingSource, uint8_t flags, HandleValue reason);
+                                 void* underlyingSource, HandleValue reason);
 
 /**
  * Invoked in reaction to a ReadableStream with an embedding-provided
  * underlying source being closed.
  */
 typedef void
-(* ReadableStreamClosedCallback)(JSContext* cx, HandleObject stream, void* underlyingSource,
-                                 uint8_t flags);
+(* ReadableStreamClosedCallback)(JSContext* cx, HandleObject stream, void* underlyingSource);
 
 /**
  * Invoked in reaction to a ReadableStream with an embedding-provided
  * underlying source being errored with the
  * given reason.
  */
 typedef void
 (* ReadableStreamErroredCallback)(JSContext* cx, HandleObject stream, void* underlyingSource,
-                                  uint8_t flags, HandleValue reason);
+                                  HandleValue reason);
 
 /**
  * Invoked in reaction to a ReadableStream with an embedding-provided
  * underlying source being finalized. Only the underlying source is passed
  * as an argument, while the ReadableStream itself is not to prevent the
  * embedding from operating on a JSObject that might not be in a valid state
  * anymore.
  *
  * Note: the ReadableStream might be finalized on a background thread. That
  * means this callback might be invoked from an arbitrary thread, which the
  * embedding must be able to handle.
  */
 typedef void
-(* ReadableStreamFinalizeCallback)(void* underlyingSource, uint8_t flags);
+(* ReadableStreamFinalizeCallback)(void* underlyingSource);
 
 /**
  * Sets runtime-wide callbacks to use for interacting with embedding-provided
  * hooks for operating on ReadableStream instances.
  *
  * See the documentation for the individual callback types for details.
  */
 extern JS_PUBLIC_API void
@@ -183,43 +180,27 @@ NewReadableDefaultStreamObject(JSContext
  * compartment, with the right slot layout. If a |proto| is passed, that gets
  * set as the instance's [[Prototype]] instead of the original value of
  * |ReadableStream.prototype|.
  *
  * The instance is optimized for operating as a byte stream backed by an
  * embedding-provided underlying source, using the callbacks set via
  * |JS::SetReadableStreamCallbacks|.
  *
- * The given |flags| will be passed to all applicable callbacks and can be
- * used to disambiguate between different types of stream sources the
- * embedding might support.
- *
  * Note: the embedding is responsible for ensuring that the pointer to the
  * underlying source stays valid as long as the stream can be read from.
  * The underlying source can be freed if the tree is canceled or errored.
  * It can also be freed if the stream is destroyed. The embedding is notified
  * of that using ReadableStreamFinalizeCallback.
  *
  * Note: |underlyingSource| must have an even address.
  */
 extern JS_PUBLIC_API JSObject*
 NewReadableExternalSourceStreamObject(JSContext* cx, void* underlyingSource,
-                                      uint8_t flags = 0, HandleObject proto = nullptr);
-
-/**
- * Returns the flags that were passed to NewReadableExternalSourceStreamObject
- * when creating the given stream.
- *
- * Asserts that |stream| is a ReadableStream object or an unwrappable wrapper
- * for one.
- *
- * Asserts that the given stream has an embedding-provided underlying source.
- */
-extern JS_PUBLIC_API bool
-ReadableStreamGetEmbeddingFlags(JSContext* cx, HandleObject stream, uint8_t* flags);
+                                      HandleObject proto = nullptr);
 
 /**
  * Returns the embedding-provided underlying source of the given |stream|.
  *
  * Can be used to optimize operations if both the underlying source and the
  * intended sink are embedding-provided. In that case it might be
  * preferrable to pipe data directly from source to sink without interacting
  * with the stream at all.
--- a/js/src/builtin/Stream.cpp
+++ b/js/src/builtin/Stream.cpp
@@ -44,24 +44,16 @@ ReadableStream::mode() const
     if (controller->is<ReadableStreamDefaultController>()) {
         return JS::ReadableStreamMode::Default;
     }
     return controller->as<ReadableByteStreamController>().hasExternalSource()
            ? JS::ReadableStreamMode::ExternalSource
            : JS::ReadableStreamMode::Byte;
 }
 
-uint8_t
-ReadableStream::embeddingFlags() const
-{
-    uint8_t flags = controller()->flags() >> ReadableStreamController::EmbeddingFlagsOffset;
-    MOZ_ASSERT_IF(flags, mode() == JS::ReadableStreamMode::ExternalSource);
-    return flags;
-}
-
 /**
  * Returns the stream associated with the given reader.
  */
 static MOZ_MUST_USE ReadableStream*
 UnwrapStreamFromReader(JSContext *cx, Handle<ReadableStreamReader*> reader)
 {
     MOZ_ASSERT(reader->hasStream());
     return UnwrapInternalSlot<ReadableStream>(cx, reader, ReadableStreamReader::Slot_Stream);
@@ -496,32 +488,30 @@ SetUpReadableStreamDefaultController(JSC
                                      HandleValue size);
 
 static MOZ_MUST_USE ReadableByteStreamController*
 CreateExternalReadableByteStreamController(JSContext* cx, Handle<ReadableStream*> stream,
                                            void* underlyingSource);
 
 ReadableStream*
 ReadableStream::createExternalSourceStream(JSContext* cx, void* underlyingSource,
-                                           uint8_t flags, HandleObject proto /* = nullptr */)
+                                           HandleObject proto /* = nullptr */)
 {
     Rooted<ReadableStream*> stream(cx, create(cx, proto));
     if (!stream) {
         return nullptr;
     }
 
     Rooted<ReadableStreamController*> controller(cx);
     controller = CreateExternalReadableByteStreamController(cx, stream, underlyingSource);
     if (!controller) {
         return nullptr;
     }
 
     stream->setController(controller);
-    controller->setEmbeddingFlags(flags);
-
     return stream;
 }
 
 static MOZ_MUST_USE bool
 MakeSizeAlgorithmFromSizeFunction(JSContext* cx, HandleValue size);
 
 static MOZ_MUST_USE bool
 ValidateAndNormalizeHighWaterMark(JSContext* cx,
@@ -1529,20 +1519,17 @@ ReadableStreamCloseInternal(JSContext* c
 
     if (unwrappedStream->mode() == JS::ReadableStreamMode::ExternalSource &&
         cx->runtime()->readableStreamClosedCallback)
     {
         // Make sure we're in the stream's compartment.
         AutoRealm ar(cx, unwrappedStream);
         ReadableStreamController* controller = unwrappedStream->controller();
         void* source = controller->underlyingSource().toPrivate();
-        cx->runtime()->readableStreamClosedCallback(cx,
-                                                    unwrappedStream,
-                                                    source,
-                                                    unwrappedStream->embeddingFlags());
+        cx->runtime()->readableStreamClosedCallback(cx, unwrappedStream, source);
     }
 
     return true;
 }
 
 /**
  * Streams spec, 3.4.5. ReadableStreamCreateReadResult ( value, done, forAuthorCode )
  */
@@ -1665,21 +1652,17 @@ ReadableStreamErrorInternal(JSContext* c
 
         // Ensure that the embedding doesn't have to deal with
         // mixed-compartment arguments to the callback.
         RootedValue error(cx, e);
         if (!cx->compartment()->wrap(cx, &error)) {
             return false;
         }
 
-        cx->runtime()->readableStreamErroredCallback(cx,
-                                                     unwrappedStream,
-                                                     source,
-                                                     unwrappedStream->embeddingFlags(),
-                                                     error);
+        cx->runtime()->readableStreamErroredCallback(cx, unwrappedStream, source, error);
     }
 
     return true;
 }
 
 /**
  * Streams spec, 3.4.7.
  *      ReadableStreamFulfillReadIntoRequest( stream, chunk, done )
@@ -2588,19 +2571,17 @@ ReadableStreamControllerCancelSteps(JSCo
             Rooted<ReadableStream*> stream(cx, unwrappedController->stream());
             void* source = unwrappedUnderlyingSource.toPrivate();
             RootedValue wrappedReason(cx, reason);
             if (!cx->compartment()->wrap(cx, &wrappedReason)) {
                 return nullptr;
             }
 
             cx->check(stream, wrappedReason);
-            rval = cx->runtime()->readableStreamCancelCallback(cx, stream, source,
-                                                               stream->embeddingFlags(),
-                                                               wrappedReason);
+            rval = cx->runtime()->readableStreamCancelCallback(cx, stream, source, wrappedReason);
         }
 
         if (!cx->compartment()->wrap(cx, &rval)) {
             return nullptr;
         }
         return PromiseObject::unforgeableResolve(cx, rval);
     }
 
@@ -2817,21 +2798,17 @@ ReadableStreamControllerCallPullIfNeeded
             &unwrappedUnderlyingSource.toObject().as<TeeState>());
         pullPromise = ReadableStreamTee_Pull(cx, unwrappedTeeState);
     } else if (unwrappedController->hasExternalSource()) {
         {
             AutoRealm ar(cx, unwrappedController);
             Rooted<ReadableStream*> stream(cx, unwrappedController->stream());
             void* source = unwrappedUnderlyingSource.toPrivate();
             double desiredSize = ReadableStreamControllerGetDesiredSizeUnchecked(unwrappedController);
-            cx->runtime()->readableStreamDataRequestCallback(cx,
-                                                             stream,
-                                                             source,
-                                                             stream->embeddingFlags(),
-                                                             desiredSize);
+            cx->runtime()->readableStreamDataRequestCallback(cx, stream, source, desiredSize);
         }
         pullPromise = PromiseObject::unforgeableResolve(cx, UndefinedHandleValue);
     } else {
         RootedValue underlyingSource(cx, unwrappedUnderlyingSource);
         if (!cx->compartment()->wrap(cx, &underlyingSource)) {
             return false;
         }
         pullPromise = PromiseInvokeOrNoop(cx, underlyingSource, cx->names().pull, controllerVal);
@@ -3426,20 +3403,18 @@ ReadableByteStreamControllerFinalize(Fre
     if (controller.getFixedSlot(ReadableStreamController::Slot_Flags).isUndefined()) {
         return;
     }
 
     if (!controller.hasExternalSource()) {
         return;
     }
 
-    uint8_t embeddingFlags = controller.flags() >> ReadableStreamController::EmbeddingFlagsOffset;
-
     void* underlyingSource = controller.underlyingSource().toPrivate();
-    obj->runtimeFromAnyThread()->readableStreamFinalizeCallback(underlyingSource, embeddingFlags);
+    obj->runtimeFromAnyThread()->readableStreamFinalizeCallback(underlyingSource);
 }
 
 static const ClassOps ReadableByteStreamControllerClassOps = {
     nullptr,        /* addProperty */
     nullptr,        /* delProperty */
     nullptr,        /* enumerate */
     nullptr,        /* newEnumerate */
     nullptr,        /* resolve */
@@ -3502,18 +3477,17 @@ ReadableByteStreamControllerPullSteps(JS
                 AutoRealm ar(cx, unwrappedStream);
                 JS::AutoSuppressGCAnalysis suppressGC(cx);
                 JS::AutoCheckCannotGC noGC;
                 bool dummy;
                 void* buffer = JS_GetArrayBufferViewData(view, &dummy, noGC);
 
                 auto cb = cx->runtime()->readableStreamWriteIntoReadRequestCallback;
                 MOZ_ASSERT(cb);
-                cb(cx, unwrappedStream, underlyingSource, unwrappedStream->embeddingFlags(),
-                   buffer, queueTotalSize, &bytesWritten);
+                cb(cx, unwrappedStream, underlyingSource, buffer, queueTotalSize, &bytesWritten);
             }
 
             queueTotalSize = queueTotalSize - bytesWritten;
         } else {
             // Step 3.b: Let entry be the first element of this.[[queue]].
             // Step 3.c: Remove entry from this.[[queue]], shifting all other
             //           elements downward (so that the second becomes the
             //           first, and so on).
@@ -4302,17 +4276,16 @@ JS::NewReadableDefaultStreamObject(JSCon
     RootedValue sourceVal(cx, ObjectValue(*source));
     RootedValue sizeVal(cx, size ? ObjectValue(*size) : UndefinedValue());
     return CreateReadableStream(cx, sourceVal, highWaterMark, sizeVal);
 }
 
 JS_PUBLIC_API JSObject*
 JS::NewReadableExternalSourceStreamObject(JSContext* cx,
                                           void* underlyingSource,
-                                          uint8_t flags /* = 0 */,
                                           HandleObject proto /* = nullptr */)
 {
     MOZ_ASSERT(!cx->zone()->isAtomsZone());
     AssertHeapIsIdle();
     CHECK_THREAD(cx);
     MOZ_ASSERT((uintptr_t(underlyingSource) & 1) == 0,
                "external underlying source pointers must be aligned");
     cx->check(proto);
@@ -4321,17 +4294,17 @@ JS::NewReadableExternalSourceStreamObjec
     MOZ_ASSERT(rt->readableStreamDataRequestCallback);
     MOZ_ASSERT(rt->readableStreamWriteIntoReadRequestCallback);
     MOZ_ASSERT(rt->readableStreamCancelCallback);
     MOZ_ASSERT(rt->readableStreamClosedCallback);
     MOZ_ASSERT(rt->readableStreamErroredCallback);
     MOZ_ASSERT(rt->readableStreamFinalizeCallback);
 #endif // DEBUG
 
-    return ReadableStream::createExternalSourceStream(cx, underlyingSource, flags, proto);
+    return ReadableStream::createExternalSourceStream(cx, underlyingSource, proto);
 }
 
 JS_PUBLIC_API bool
 JS::IsReadableStream(JSObject* obj)
 {
     return obj->canUnwrapAs<ReadableStream>();
 }
 
@@ -4386,28 +4359,16 @@ JS::ReadableStreamIsDisturbed(JSContext*
     if (!unwrappedStream) {
         return false;
     }
 
     *result = unwrappedStream->disturbed();
     return true;
 }
 
-JS_PUBLIC_API bool
-JS::ReadableStreamGetEmbeddingFlags(JSContext* cx, HandleObject streamObj, uint8_t* flags)
-{
-    ReadableStream* unwrappedStream = APIUnwrapAndDowncast<ReadableStream>(cx, streamObj);
-    if (!unwrappedStream) {
-        return false;
-    }
-
-    *flags = unwrappedStream->embeddingFlags();
-    return true;
-}
-
 JS_PUBLIC_API JSObject*
 JS::ReadableStreamCancel(JSContext* cx, HandleObject streamObj, HandleValue reason)
 {
     AssertHeapIsIdle();
     CHECK_THREAD(cx);
     cx->check(reason);
 
     Rooted<ReadableStream*> unwrappedStream(cx,
@@ -4578,18 +4539,17 @@ JS::ReadableStreamUpdateDataAvailableFro
         {
             AutoRealm ar(cx, unwrappedStream);
             JS::AutoSuppressGCAnalysis suppressGC(cx);
             JS::AutoCheckCannotGC noGC;
             bool dummy;
             void* buffer = JS_GetArrayBufferViewData(transferredView, &dummy, noGC);
             auto cb = cx->runtime()->readableStreamWriteIntoReadRequestCallback;
             MOZ_ASSERT(cb);
-            cb(cx, unwrappedStream, underlyingSource, unwrappedStream->embeddingFlags(), buffer,
-               availableData, &bytesWritten);
+            cb(cx, unwrappedStream, underlyingSource, buffer, availableData, &bytesWritten);
         }
 
         // Step iii: Perform ! ReadableStreamFulfillReadRequest(stream,
         //                                                      transferredView,
         //                                                      false).
         RootedValue chunk(cx, ObjectValue(*transferredView));
         if (!ReadableStreamFulfillReadOrReadIntoRequest(cx, unwrappedStream, chunk, false)) {
             return false;
--- a/js/src/builtin/Stream.h
+++ b/js/src/builtin/Stream.h
@@ -89,23 +89,22 @@ class ReadableStream : public NativeObje
     bool hasReader() const { return !getFixedSlot(Slot_Reader).isUndefined(); }
     void setReader(JSObject* reader) { setFixedSlot(Slot_Reader, JS::ObjectValue(*reader)); }
     void clearReader() { setFixedSlot(Slot_Reader, JS::UndefinedValue()); }
 
     Value storedError() const { return getFixedSlot(Slot_StoredError); }
     void setStoredError(HandleValue value) { setFixedSlot(Slot_StoredError, value); }
 
     JS::ReadableStreamMode mode() const;
-    uint8_t embeddingFlags() const;
 
     bool locked() const;
 
     static MOZ_MUST_USE ReadableStream* create(JSContext* cx, HandleObject proto = nullptr);
     static ReadableStream* createExternalSourceStream(JSContext* cx, void* underlyingSource,
-                                                      uint8_t flags, HandleObject proto = nullptr);
+                                                      HandleObject proto = nullptr);
 
     static bool constructor(JSContext* cx, unsigned argc, Value* vp);
     static const ClassSpec classSpec_;
     static const Class class_;
     static const ClassSpec protoClassSpec_;
     static const Class protoClass_;
 };
 
@@ -256,19 +255,16 @@ class ReadableStreamController : public 
         Flag_CloseRequested = 1 << 3,
         Flag_TeeBranch      = 1 << 4,
         Flag_TeeBranch1     = 1 << 5,
         Flag_TeeBranch2     = 1 << 6,
         Flag_ExternalSource = 1 << 7,
         Flag_SourceLocked   = 1 << 8,
     };
 
-    // Offset at which embedding flags are stored.
-    static constexpr uint8_t EmbeddingFlagsOffset = 24;
-
     ReadableStream* stream() const {
         return &getFixedSlot(Slot_Stream).toObject().as<ReadableStream>();
     }
     void setStream(ReadableStream* stream) { setFixedSlot(Slot_Stream, ObjectValue(*stream)); }
     Value underlyingSource() const { return getFixedSlot(Slot_UnderlyingSource); }
     void setUnderlyingSource(const Value& underlyingSource) {
         setFixedSlot(Slot_UnderlyingSource, underlyingSource);
     }
@@ -292,17 +288,16 @@ class ReadableStreamController : public 
     bool isTeeBranch1() const { return flags() & Flag_TeeBranch1; }
     void setTeeBranch1() { addFlags(Flag_TeeBranch | Flag_TeeBranch1); }
     bool isTeeBranch2() const { return flags() & Flag_TeeBranch2; }
     void setTeeBranch2() { addFlags(Flag_TeeBranch | Flag_TeeBranch2); }
     bool hasExternalSource() const { return flags() & Flag_ExternalSource; }
     bool sourceLocked() const { return flags() & Flag_SourceLocked; }
     void setSourceLocked() { addFlags(Flag_SourceLocked); }
     void clearSourceLocked() { removeFlags(Flag_SourceLocked); }
-    void setEmbeddingFlags(uint8_t flags) { addFlags(uint32_t(flags) << EmbeddingFlagsOffset); }
 
     static const Class class_;
 };
 
 class ReadableStreamDefaultController : public ReadableStreamController
 {
   private:
     /**
--- a/js/src/jsapi-tests/testReadableStream.cpp
+++ b/js/src/jsapi-tests/testReadableStream.cpp
@@ -32,81 +32,81 @@ NewDefaultStream(JSContext* cx, HandleOb
     RootedObject stream(cx, NewReadableDefaultStreamObject(cx, source, size, highWaterMark,
                                                            proto));
     MOZ_ASSERT_IF(stream, IsReadableStream(stream));
     return stream;
 }
 
 static bool dataRequestCBCalled = false;
 static void
-DataRequestCB(JSContext* cx, HandleObject stream, void* underlyingSource, uint8_t flags,
+DataRequestCB(JSContext* cx, HandleObject stream, void* underlyingSource,
               size_t desiredSize)
 {
     js::AssertSameCompartment(cx, stream);
     MOZ_ASSERT(!dataRequestCBCalled, "Invalid test setup");
     dataRequestCBCalled = true;
 }
 
 static bool writeIntoRequestBufferCBCalled = false;
 static void
-WriteIntoRequestBufferCB(JSContext* cx, HandleObject stream, void* underlyingSource, uint8_t flags,
+WriteIntoRequestBufferCB(JSContext* cx, HandleObject stream, void* underlyingSource,
                          void* buffer, size_t length, size_t* bytesWritten)
 {
     js::AssertSameCompartment(cx, stream);
     MOZ_ASSERT(!writeIntoRequestBufferCBCalled, "Invalid test setup");
     writeIntoRequestBufferCBCalled = true;
 
     MOZ_ASSERT(underlyingSource == &stubExternalUnderlyingSource);
     MOZ_ASSERT(stubExternalUnderlyingSource.buffer == testBufferData);
     MOZ_ASSERT(length <= sizeof(testBufferData));
     memcpy(buffer, testBufferData, length);
     *bytesWritten = length;
 }
 
 static bool cancelStreamCBCalled = false;
 static Value cancelStreamReason;
 static Value
-CancelStreamCB(JSContext* cx, HandleObject stream, void* underlyingSource, uint8_t flags,
+CancelStreamCB(JSContext* cx, HandleObject stream, void* underlyingSource,
                HandleValue reason)
 {
     js::AssertSameCompartment(cx, stream);
     js::AssertSameCompartment(cx, reason);
     MOZ_ASSERT(!cancelStreamCBCalled, "Invalid test setup");
     cancelStreamCBCalled = true;
     cancelStreamReason = reason;
     return reason;
 }
 
 static bool streamClosedCBCalled = false;
 static Value streamClosedReason;
 static void
-StreamClosedCB(JSContext* cx, HandleObject stream, void* underlyingSource, uint8_t flags)
+StreamClosedCB(JSContext* cx, HandleObject stream, void* underlyingSource)
 {
     js::AssertSameCompartment(cx, stream);
     MOZ_ASSERT(!streamClosedCBCalled, "Invalid test setup");
     streamClosedCBCalled = true;
 }
 
 static bool streamErroredCBCalled = false;
 static Value streamErroredReason;
 static void
-StreamErroredCB(JSContext* cx, HandleObject stream, void* underlyingSource, uint8_t flags,
+StreamErroredCB(JSContext* cx, HandleObject stream, void* underlyingSource,
                 HandleValue reason)
 {
     js::AssertSameCompartment(cx, stream);
     js::AssertSameCompartment(cx, reason);
     MOZ_ASSERT(!streamErroredCBCalled, "Invalid test setup");
     streamErroredCBCalled = true;
     streamErroredReason = reason;
 }
 
 static bool finalizeStreamCBCalled = false;
 static void* finalizedStreamUnderlyingSource;
 static void
-FinalizeStreamCB(void* underlyingSource, uint8_t flags)
+FinalizeStreamCB(void* underlyingSource)
 {
     MOZ_ASSERT(!finalizeStreamCBCalled, "Invalid test setup");
     finalizeStreamCBCalled = true;
     finalizedStreamUnderlyingSource = underlyingSource;
 }
 
 static void
 ResetCallbacks()
@@ -763,38 +763,16 @@ BEGIN_FIXTURE_TEST(StreamTestFixture,
     }
 
     return true;
 }
 END_FIXTURE_TEST(StreamTestFixture,
                  testReadableStream_ReadableStreamOtherGlobalDefaultReaderRead)
 
 BEGIN_FIXTURE_TEST(StreamTestFixture,
-                   testReadableStream_ReadableStreamGetEmbeddingFlags)
-{
-    RootedObject stream(cx, NewDefaultStream(cx));
-    CHECK(stream);
-    uint8_t flags;
-    CHECK(ReadableStreamGetEmbeddingFlags(cx, stream, &flags));
-
-    RootedObject otherGlobal(cx, createGlobal());
-    CHECK(otherGlobal);
-    {
-        JSAutoRealm ar(cx, otherGlobal);
-        CHECK(JS_WrapObject(cx, &stream));
-        uint8_t flags;
-        CHECK(ReadableStreamGetEmbeddingFlags(cx, stream, &flags));
-    }
-
-    return true;
-}
-END_FIXTURE_TEST(StreamTestFixture,
-                 testReadableStream_ReadableStreamGetEmbeddingFlags)
-
-BEGIN_FIXTURE_TEST(StreamTestFixture,
                    testReadableStream_ReadableStreamGetExternalUnderlyingSource)
 {
     ResetCallbacks();
 
     RootedObject stream(cx, NewExternalSourceStream(cx));
     CHECK(stream);
     void* source;
     CHECK(ReadableStreamGetExternalUnderlyingSource(cx, stream, &source));