Bug 1276327. Remove the non-debug use of CxPusherIsStackTop(). r=bholley

This commit is contained in:
Boris Zbarsky 2016-06-20 17:40:39 -04:00
Родитель 94e97ec88d
Коммит 30a9fd5097
2 изменённых файлов: 6 добавлений и 26 удалений

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

@ -268,29 +268,6 @@ GetWebIDLCallerPrincipal()
}
AutoEntryScript* aes = static_cast<AutoEntryScript*>(entry);
// We can't yet rely on the Script Settings Stack to properly determine the
// entry script, because there are still lots of places in the tree where we
// don't yet use an AutoEntryScript (bug 951991 tracks this work). In the
// mean time though, we can make some observations to hack around the
// problem:
//
// (1) All calls into JS-implemented WebIDL go through CallSetup, which goes
// through AutoEntryScript.
// (2) The top candidate entry point in the Script Settings Stack is the
// entry point if and only if no other JSContexts have been pushed on
// top of the push made by that entry's AutoEntryScript.
//
// Because of (1), all of the cases where we might return a non-null
// WebIDL Caller are guaranteed to have put an entry on the Script Settings
// Stack, so we can restrict our search to that. Moreover, (2) gives us a
// criterion to determine whether an entry in the Script Setting Stack means
// that we should return a non-null WebIDL Caller.
//
// Once we fix bug 951991, this can all be simplified.
if (!aes->CxPusherIsStackTop()) {
return nullptr;
}
return aes->mWebIDLCallerPrincipal;
}
@ -755,9 +732,9 @@ danger::AutoCxPusher::AutoCxPusher(JSContext* cx, bool allowNull)
XPCJSContextStack *stack = XPCJSRuntime::Get()->GetJSContextStack();
stack->Push(cx);
mStackDepthAfterPush = stack->Count();
#ifdef DEBUG
mStackDepthAfterPush = stack->Count();
mPushedContext = cx;
mCompartmentDepthOnEntry = cx ? js::GetEnterCompartmentDepth(cx) : 0;
#endif
@ -781,11 +758,11 @@ danger::AutoCxPusher::~AutoCxPusher()
// pop is the same as it was right after we pushed.
MOZ_ASSERT_IF(mPushedContext, mCompartmentDepthOnEntry ==
js::GetEnterCompartmentDepth(mPushedContext));
DebugOnly<JSContext*> stackTop;
MOZ_ASSERT(mPushedContext == nsXPConnect::XPConnect()->GetCurrentJSContext());
XPCJSRuntime::Get()->GetJSContextStack()->Pop();
}
#ifdef DEBUG
bool
danger::AutoCxPusher::IsStackTop() const
{
@ -793,6 +770,7 @@ danger::AutoCxPusher::IsStackTop() const
MOZ_ASSERT(currentDepth >= mStackDepthAfterPush);
return currentDepth == mStackDepthAfterPush;
}
#endif
} // namespace dom

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

@ -46,8 +46,8 @@ public:
private:
mozilla::Maybe<JSAutoRequest> mAutoRequest;
uint32_t mStackDepthAfterPush;
#ifdef DEBUG
uint32_t mStackDepthAfterPush;
JSContext* mPushedContext;
unsigned mCompartmentDepthOnEntry;
#endif
@ -262,7 +262,9 @@ public:
return mCx;
}
#ifdef DEBUG
bool CxPusherIsStackTop() const { return mCxPusher->IsStackTop(); }
#endif
// If HasException, report it. Otherwise, a no-op.
void ReportException();