Bug 1578623 permit SerializeStack() from worklet thread r=baku
☠☠ backed out by 92823ffcb1dc ☠ ☠
authorKarl Tomlinson <karlt+@karlt.net>
Fri, 06 Sep 2019 02:10:32 +0000
changeset 553501 71e58ee8f6844859714c5834098ce160e43d84ae
parent 553500 0128e12a910f1ba247271476732a55fa9394abed
child 553502 3badf921578876bb564ce1a8a92093be38ae2ea7
push id12169
push userffxbld-merge
push dateMon, 14 Oct 2019 16:59:29 +0000
treeherdermozilla-beta@c819687300ed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1578623
milestone71.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 1578623 permit SerializeStack() from worklet thread r=baku Differential Revision: https://phabricator.services.mozilla.com/D44606
dom/base/SerializedStackHolder.cpp
dom/base/SerializedStackHolder.h
--- a/dom/base/SerializedStackHolder.cpp
+++ b/dom/base/SerializedStackHolder.cpp
@@ -22,19 +22,19 @@ void SerializedStackHolder::WriteStack(J
                                        JS::HandleObject aStack) {
   JS::RootedValue stackValue(aCx, JS::ObjectValue(*aStack));
   mHolder.Write(aCx, stackValue, IgnoreErrors());
 
   // StructuredCloneHolder::Write can leave a pending exception on the context.
   JS_ClearPendingException(aCx);
 }
 
-void SerializedStackHolder::SerializeMainThreadStack(JSContext* aCx,
-                                                     JS::HandleObject aStack) {
-  MOZ_ASSERT(NS_IsMainThread());
+void SerializedStackHolder::SerializeMainThreadOrWorkletStack(
+    JSContext* aCx, JS::HandleObject aStack) {
+  MOZ_ASSERT(!IsCurrentThreadRunningWorker());
   WriteStack(aCx, aStack);
 }
 
 void SerializedStackHolder::SerializeWorkerStack(JSContext* aCx,
                                                  WorkerPrivate* aWorkerPrivate,
                                                  JS::HandleObject aStack) {
   MOZ_ASSERT(aWorkerPrivate->IsOnCurrentThread());
 
@@ -54,17 +54,17 @@ void SerializedStackHolder::SerializeCur
   JS::RootedObject stack(aCx);
   if (JS::CurrentGlobalOrNull(aCx) && !JS::CaptureCurrentStack(aCx, &stack)) {
     JS_ClearPendingException(aCx);
     return;
   }
 
   if (stack) {
     if (NS_IsMainThread()) {
-      SerializeMainThreadStack(aCx, stack);
+      SerializeMainThreadOrWorkletStack(aCx, stack);
     } else {
       WorkerPrivate* currentWorker = GetCurrentThreadWorkerPrivate();
       SerializeWorkerStack(aCx, currentWorker, stack);
     }
   }
 }
 
 JSObject* SerializedStackHolder::ReadStack(JSContext* aCx) {
--- a/dom/base/SerializedStackHolder.h
+++ b/dom/base/SerializedStackHolder.h
@@ -25,18 +25,19 @@ class SerializedStackHolder {
   RefPtr<ThreadSafeWorkerRef> mWorkerRef;
 
   // Write aStack's data into mHolder.
   void WriteStack(JSContext* aCx, JS::HandleObject aStack);
 
  public:
   SerializedStackHolder();
 
-  // Fill this holder with a main thread stack.
-  void SerializeMainThreadStack(JSContext* aCx, JS::HandleObject aStack);
+  // Fill this holder with a main or worklet thread stack.
+  void SerializeMainThreadOrWorkletStack(JSContext* aCx,
+                                         JS::HandleObject aStack);
 
   // Fill this holder with a worker thread stack.
   void SerializeWorkerStack(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
                             JS::HandleObject aStack);
 
   // Fill this holder with the current thread's current stack.
   void SerializeCurrentStack(JSContext* aCx);