Bug 1328964 - part 2b - WorkletThread - second part r?baku draft
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 19 Mar 2018 10:32:16 +1300
changeset 779547 58f6d315a27d15e877f39925b8d9158e830c47d8
parent 779537 79fe63a925f2bdf19b538e520353d892be81e9a1
child 779548 882f5bcb98076fbd0d2d32cb01f2b13d785e9666
push id105796
push userktomlinson@mozilla.com
push dateTue, 10 Apr 2018 06:02:17 +0000
reviewersbaku
bugs1328964
milestone61.0a1
Bug 1328964 - part 2b - WorkletThread - second part r?baku Initial version r=smaug. Rebased to c616a6fd5e4b by Jan-Ivar Bruaroey <jib@mozilla.com> r=karlt. Rebased from c616a6fd5e4b by Karl Tomlinson <karlt+@karlt.net>. MozReview-Commit-ID: HumXGy2mmH6
dom/worklet/Worklet.cpp
dom/worklet/WorkletPrincipal.cpp
dom/worklet/WorkletThread.cpp
--- a/dom/worklet/Worklet.cpp
+++ b/dom/worklet/Worklet.cpp
@@ -389,19 +389,16 @@ ExecutionRunnable::RunOnWorkletThread()
   JS::Rooted<JSObject*> globalObj(cx, globalScope->GetGlobalJSObject());
 
   NS_ConvertUTF16toUTF8 url(mHandler->URL());
 
   JS::CompileOptions compileOptions(cx);
   compileOptions.setIntroductionType("Worklet");
   compileOptions.setFileAndLine(url.get(), 0);
   compileOptions.setIsRunOnce(true);
-
-  // We only need the setNoScriptRval bit when compiling off-thread here,
-  // since otherwise nsJSUtils::EvaluateString will set it up for us.
   compileOptions.setNoScriptRval(true);
 
   JSAutoCompartment comp(cx, globalObj);
 
   JS::Rooted<JS::Value> unused(cx);
   if (!JS::Evaluate(cx, compileOptions, mBuffer, &unused)) {
     ErrorResult error;
     error.MightThrowJSException();
--- a/dom/worklet/WorkletPrincipal.cpp
+++ b/dom/worklet/WorkletPrincipal.cpp
@@ -9,17 +9,18 @@
 #include "mozilla/Assertions.h"
 
 namespace mozilla {
 namespace dom {
 namespace WorkletPrincipal {
 
 struct WorkletPrincipal final : public JSPrincipals
 {
-  bool write(JSContext* aCx, JSStructuredCloneWriter* aWriter) override {
+  bool write(JSContext* aCx, JSStructuredCloneWriter* aWriter) override
+  {
     MOZ_CRASH("WorkletPrincipal::write not implemented");
     return false;
   }
 };
 
 JSPrincipals*
 GetWorkletPrincipal()
 {
--- a/dom/worklet/WorkletThread.cpp
+++ b/dom/worklet/WorkletThread.cpp
@@ -202,27 +202,29 @@ public:
     return NS_OK;
   }
 
   void
   DispatchToMicroTask(already_AddRefed<MicroTaskRunnable> aRunnable) override
   {
     RefPtr<MicroTaskRunnable> runnable(aRunnable);
 
+#ifdef DEBUG
     MOZ_ASSERT(!NS_IsMainThread());
     MOZ_ASSERT(runnable);
 
     WorkletThread* workletThread = WorkletThread::Get();
     MOZ_ASSERT(workletThread);
 
     JSContext* cx = workletThread->GetJSContext();
     MOZ_ASSERT(cx);
 
     JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
     MOZ_ASSERT(global);
+#endif
 
     GetMicroTaskQueue().push(runnable.forget());
   }
 
 private:
   RefPtr<WorkletThread> mWorkletThread;
 };