Bug 1265035 - Make ~WorkerJSRuntime() handle Initialize() failure better. r=khuey.

--HG--
extra : rebase_source : 4b2cb2ef8192f314a28556826044f010a52b90b4
This commit is contained in:
Nicholas Nethercote 2016-04-19 14:04:32 +10:00
Родитель a03b12c9e4
Коммит d84e6264da
3 изменённых файлов: 12 добавлений и 2 удалений

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

@ -880,8 +880,10 @@ public:
~WorkerJSRuntime()
{
JSRuntime* rt = Runtime();
MOZ_ASSERT(rt);
JSRuntime* rt = MaybeRuntime();
if (!rt) {
return; // Initialize() must have failed
}
delete static_cast<WorkerThreadRuntimePrivate*>(JS_GetRuntimePrivate(rt));
JS_SetRuntimePrivate(rt, nullptr);

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

@ -1591,6 +1591,10 @@ ReloadPrefsCallback(const char* pref, void* data)
XPCJSRuntime::~XPCJSRuntime()
{
// Elsewhere we abort immediately if XPCJSRuntime initialization fails.
// Therefore the runtime must be non-null.
MOZ_ASSERT(MaybeRuntime());
// This destructor runs before ~CycleCollectedJSRuntime, which does the
// actual JS_DestroyRuntime() call. But destroying the runtime triggers
// one final GC, which can call back into the runtime with various

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

@ -321,6 +321,10 @@ public:
return mJSRuntime;
}
protected:
JSRuntime* MaybeRuntime() const { return mJSRuntime; }
public:
// nsThread entrypoints
virtual void BeforeProcessTask(bool aMightBlock) { };
virtual void AfterProcessTask(uint32_t aRecursionDepth);