Bug 1278947 part 1 - Stop using JSContext callback in XPConnect. r=bz

--HG--
extra : rebase_source : 1e971a2a2a2a2b9068bd59d98156fa84b8f4b105
This commit is contained in:
Jan de Mooij 2016-06-10 09:27:14 +02:00
Родитель a80ba6c225
Коммит 8c1aaa3154
5 изменённых файлов: 9 добавлений и 37 удалений

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

@ -22,6 +22,7 @@ using mozilla::dom::DestroyProtoAndIfaceCache;
XPCJSContextStack::~XPCJSContextStack()
{
if (mSafeJSContext) {
delete XPCContext::GetXPCContext(mSafeJSContext);
JS_DestroyContextNoGC(mSafeJSContext);
mSafeJSContext = nullptr;
}
@ -59,11 +60,14 @@ XPCJSContextStack::GetSafeJSContext()
return mSafeJSContext;
}
JSContext*
void
XPCJSContextStack::InitSafeJSContext()
{
MOZ_ASSERT(!mSafeJSContext);
mSafeJSContext = JS_NewContext(XPCJSRuntime::Get()->Runtime(), 8192);
MOZ_RELEASE_ASSERT(mSafeJSContext, "JS_NewContext failed");
return mSafeJSContext;
if (!mRuntime->InitXPCContext(mSafeJSContext))
MOZ_CRASH("InitXPCContext failed");
}

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

@ -132,20 +132,6 @@ xpc::SharedMemoryEnabled() { return sSharedMemoryEnabled; }
// So, in mClassInfo2NativeSetMap we just clear references to the unmarked.
// In mNativeSetMap we clear the references to the unmarked *and* delete them.
bool
XPCJSRuntime::CustomContextCallback(JSContext* cx, unsigned operation)
{
if (operation == JSCONTEXT_NEW) {
if (!OnJSContextNew(cx)) {
return false;
}
} else if (operation == JSCONTEXT_DESTROY) {
delete XPCContext::GetXPCContext(cx);
}
return true;
}
class AsyncFreeSnowWhite : public Runnable
{
public:
@ -3662,7 +3648,7 @@ XPCJSRuntime::newXPCJSRuntime()
}
bool
XPCJSRuntime::OnJSContextNew(JSContext* cx)
XPCJSRuntime::InitXPCContext(JSContext* cx)
{
// If we were the first cx ever created (like the SafeJSContext), the caller
// would have had no way to enter a request. Enter one now before doing the

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

@ -466,7 +466,7 @@ public:
XPCWrappedNativeProtoMap* GetDetachedWrappedNativeProtoMap() const
{return mDetachedWrappedNativeProtoMap;}
bool OnJSContextNew(JSContext* cx);
bool InitXPCContext(JSContext* cx);
virtual bool
DescribeCustomObjects(JSObject* aObject, const js::Class* aClasp,
@ -556,7 +556,6 @@ public:
void CustomGCCallback(JSGCStatus status) override;
void CustomOutOfMemoryCallback() override;
void CustomLargeAllocationFailureCallback() override;
bool CustomContextCallback(JSContext* cx, unsigned operation) override;
static void GCSliceCallback(JSRuntime* rt,
JS::GCProgress progress,
const JS::GCDescription& desc);
@ -2786,7 +2785,7 @@ public:
return mStack.IsEmpty() ? nullptr : mStack[mStack.Length() - 1];
}
JSContext* InitSafeJSContext();
void InitSafeJSContext();
JSContext* GetSafeJSContext();
private:

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

@ -527,7 +527,6 @@ CycleCollectedJSRuntime::Initialize(JSRuntime* aParentRuntime,
JS::SetOutOfMemoryCallback(mJSRuntime, OutOfMemoryCallback, this);
JS::SetLargeAllocationFailureCallback(mJSRuntime,
LargeAllocationFailureCallback, this);
JS_SetContextCallback(mJSRuntime, ContextCallback, this);
JS_SetDestroyZoneCallback(mJSRuntime, XPCStringConvert::FreeZoneCache);
JS_SetSweepZoneCallback(mJSRuntime, XPCStringConvert::ClearZoneCache);
JS::SetBuildIdOp(mJSRuntime, GetBuildId);
@ -906,18 +905,6 @@ CycleCollectedJSRuntime::LargeAllocationFailureCallback(void* aData)
self->OnLargeAllocationFailure();
}
/* static */ bool
CycleCollectedJSRuntime::ContextCallback(JSContext* aContext,
unsigned aOperation,
void* aData)
{
CycleCollectedJSRuntime* self = static_cast<CycleCollectedJSRuntime*>(aData);
MOZ_ASSERT(JS_GetRuntime(aContext) == self->Runtime());
return self->CustomContextCallback(aContext, aOperation);
}
class PromiseJobRunnable final : public Runnable
{
public:

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

@ -157,10 +157,6 @@ protected:
virtual void CustomGCCallback(JSGCStatus aStatus) {}
virtual void CustomOutOfMemoryCallback() {}
virtual void CustomLargeAllocationFailureCallback() {}
virtual bool CustomContextCallback(JSContext* aCx, unsigned aOperation)
{
return true; // Don't block context creation.
}
std::queue<nsCOMPtr<nsIRunnable>> mPromiseMicroTaskQueue;
std::queue<nsCOMPtr<nsIRunnable>> mDebuggerPromiseMicroTaskQueue;