Bug 1398393 - Set Servo thread state on cooperative threads. r=billm
authorBlake Kaplan <mrbkap@gmail.com>
Fri, 08 Sep 2017 16:50:34 -0700
changeset 431608 785910c8bee719b14fd14a2fe64b260429449b3a
parent 431607 b5be4a3d9f13e924f02cbb2ee6d5871c6f026486
child 431609 26f3a378ff0e95a74320d1dbe905776e30b67bda
push id7785
push userryanvm@gmail.com
push dateThu, 21 Sep 2017 13:39:55 +0000
treeherdermozilla-beta@06d4034a8a03 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1398393
milestone57.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 1398393 - Set Servo thread state on cooperative threads. r=billm By doing this we avoid triggering assertions in the Servo code that ensure we have registered the thread with Servo and set the proper state on it. MozReview-Commit-ID: K6qHrYoQDLm
layout/style/ServoBindingList.h
xpcom/threads/CooperativeThreadPool.cpp
xpcom/threads/Scheduler.cpp
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -544,16 +544,18 @@ SERVO_BINDING_FUNC(Servo_ComputedValues_
 // to RawServoStyleRule.
 SERVO_BINDING_FUNC(Servo_ComputedValues_GetStyleRuleList, void,
                    ServoStyleContextBorrowed values,
                    RawGeckoServoStyleRuleListBorrowedMut rules)
 
 // Initialize Servo components. Should be called exactly once at startup.
 SERVO_BINDING_FUNC(Servo_Initialize, void,
                    RawGeckoURLExtraData* dummy_url_data)
+// Initialize Servo on a cooperative Quantum DOM thread.
+SERVO_BINDING_FUNC(Servo_InitializeCooperativeThread, void);
 // Shut down Servo components. Should be called exactly once at shutdown.
 SERVO_BINDING_FUNC(Servo_Shutdown, void)
 
 // Restyle and change hints.
 SERVO_BINDING_FUNC(Servo_NoteExplicitHints, void, RawGeckoElementBorrowed element,
                    nsRestyleHint restyle_hint, nsChangeHint change_hint)
 // We'd like to return `nsChangeHint` here, but bindgen bitfield enums don't
 // work as return values with the Linux 32-bit ABI at the moment because
--- a/xpcom/threads/CooperativeThreadPool.cpp
+++ b/xpcom/threads/CooperativeThreadPool.cpp
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "CooperativeThreadPool.h"
 
 #include "base/message_loop.h"
 #include "mozilla/IOInterposer.h"
+#include "mozilla/ServoBindings.h"
 #include "nsError.h"
 #include "nsThreadUtils.h"
 
 using namespace mozilla;
 
 static bool gCooperativeSchedulingEnabled;
 MOZ_THREAD_LOCAL(CooperativeThreadPool::CooperativeThread*) CooperativeThreadPool::sTlsCurrentThread;
 
--- a/xpcom/threads/Scheduler.cpp
+++ b/xpcom/threads/Scheduler.cpp
@@ -648,16 +648,17 @@ SchedulerImpl::ThreadController::OnStart
   xpc::CreateCooperativeContext();
 
   JSContext* cx = dom::danger::GetJSContext();
   mScheduler->SetJSContext(aIndex, cx);
   if (sPrefPreemption) {
     JS_AddInterruptCallback(cx, SchedulerImpl::InterruptCallback);
   }
   js::SetCooperativeYieldCallback(cx, SchedulerImpl::YieldCallback);
+  Servo_InitializeCooperativeThread();
 }
 
 void
 SchedulerImpl::ThreadController::OnStopThread(size_t aIndex)
 {
   xpc::DestroyCooperativeContext();
 
   NS_UnsetMainThread();