Bug 1244247 - Remove racey sScriptSettingsTLSInitialized. r=bzbarsky

Differential Revision: https://phabricator.services.mozilla.com/D49213

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Bobby Holley 2019-10-15 02:10:02 +00:00
Родитель 55204b4619
Коммит 1aac000114
3 изменённых файлов: 6 добавлений и 9 удалений

Просмотреть файл

@ -29,7 +29,6 @@ namespace mozilla {
namespace dom {
static MOZ_THREAD_LOCAL(ScriptSettingsStackEntry*) sScriptSettingsTLS;
static bool sScriptSettingsTLSInitialized;
class ScriptSettingsStack {
public:
@ -118,15 +117,12 @@ void InitScriptSettings() {
}
sScriptSettingsTLS.set(nullptr);
sScriptSettingsTLSInitialized = true;
}
void DestroyScriptSettings() {
MOZ_ASSERT(sScriptSettingsTLS.get() == nullptr);
}
bool ScriptSettingsInitialized() { return sScriptSettingsTLSInitialized; }
ScriptSettingsStackEntry::ScriptSettingsStackEntry(nsIGlobalObject* aGlobal,
Type aType)
: mGlobalObject(aGlobal), mType(aType), mOlder(nullptr) {

Просмотреть файл

@ -31,12 +31,11 @@ namespace dom {
class Document;
/*
* System-wide setup/teardown routines. Init and Destroy should be invoked
* once each, at startup and shutdown (respectively).
* Per thread setup/teardown routines. Init and Destroy should be invoked
* once each, at startup and shutdown of the script runtime (respectively).
*/
void InitScriptSettings();
void DestroyScriptSettings();
bool ScriptSettingsInitialized();
/*
* Static helpers in ScriptSettings which track the number of listeners

Просмотреть файл

@ -8,6 +8,7 @@
#include "mozilla/ipc/MessageChannel.h"
#include "mozilla/Assertions.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/ipc/ProcessChild.h"
@ -112,7 +113,6 @@ using namespace mozilla::ipc;
using mozilla::MonitorAutoLock;
using mozilla::MonitorAutoUnlock;
using mozilla::dom::AutoNoJSAPI;
using mozilla::dom::ScriptSettingsInitialized;
#define IPC_ASSERT(_cond, ...) \
do { \
@ -2079,7 +2079,9 @@ void MessageChannel::DispatchMessage(Message&& aMsg) {
RefPtr<ActorLifecycleProxy> listenerProxy = mListener->GetLifecycleProxy();
Maybe<AutoNoJSAPI> nojsapi;
if (ScriptSettingsInitialized() && NS_IsMainThread()) nojsapi.emplace();
if (NS_IsMainThread() && CycleCollectedJSContext::Get()) {
nojsapi.emplace();
}
nsAutoPtr<Message> reply;