From dde5cae5bb7f860a8a5c63421c8839256ad9f6d3 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 22 Mar 2016 13:50:31 -0400 Subject: [PATCH] Bug 1257919 part 9. Make the asyncCause/asyncCaller getters on JSStackFrame take an explicit JSContext. r=khuey --- dom/base/Console.cpp | 4 ++-- dom/bindings/Exceptions.cpp | 20 ++++++++++---------- xpcom/base/nsIException.idl | 2 ++ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/dom/base/Console.cpp b/dom/base/Console.cpp index d5dc0fb56fbc..3b31c776aef2 100644 --- a/dom/base/Console.cpp +++ b/dom/base/Console.cpp @@ -1057,7 +1057,7 @@ StackFrameToStackEntry(JSContext* aCx, nsIStackFrame* aStackFrame, NS_ENSURE_SUCCESS(rv, rv); nsString cause; - rv = aStackFrame->GetAsyncCause(cause); + rv = aStackFrame->GetAsyncCause(aCx, cause); NS_ENSURE_SUCCESS(rv, rv); if (!cause.IsEmpty()) { aStackEntry.mAsyncCause.Construct(cause); @@ -1084,7 +1084,7 @@ ReifyStack(JSContext* aCx, nsIStackFrame* aStack, NS_ENSURE_SUCCESS(rv, rv); if (!caller) { - rv = stack->GetAsyncCaller(getter_AddRefs(caller)); + rv = stack->GetAsyncCaller(aCx, getter_AddRefs(caller)); NS_ENSURE_SUCCESS(rv, rv); } stack.swap(caller); diff --git a/dom/bindings/Exceptions.cpp b/dom/bindings/Exceptions.cpp index 99a0e4d14dcd..2eb959a220bd 100644 --- a/dom/bindings/Exceptions.cpp +++ b/dom/bindings/Exceptions.cpp @@ -474,17 +474,17 @@ NS_IMETHODIMP JSStackFrame::GetSourceLine(nsACString& aSourceLine) return NS_OK; } -NS_IMETHODIMP JSStackFrame::GetAsyncCause(nsAString& aAsyncCause) +NS_IMETHODIMP JSStackFrame::GetAsyncCause(JSContext* aCx, + nsAString& aAsyncCause) { if (!mStack) { aAsyncCause.Truncate(); return NS_OK; } - ThreadsafeAutoJSContext cx; - JS::Rooted asyncCause(cx); + JS::Rooted asyncCause(aCx); bool canCache = false, useCachedValue = false; - GetValueIfNotCached(cx, mStack, JS::GetSavedFrameAsyncCause, + GetValueIfNotCached(aCx, mStack, JS::GetSavedFrameAsyncCause, mAsyncCauseInitialized, &canCache, &useCachedValue, &asyncCause); @@ -495,8 +495,8 @@ NS_IMETHODIMP JSStackFrame::GetAsyncCause(nsAString& aAsyncCause) if (asyncCause) { nsAutoJSString str; - if (!str.init(cx, asyncCause)) { - JS_ClearPendingException(cx); + if (!str.init(aCx, asyncCause)) { + JS_ClearPendingException(aCx); aAsyncCause.Truncate(); return NS_OK; } @@ -513,17 +513,17 @@ NS_IMETHODIMP JSStackFrame::GetAsyncCause(nsAString& aAsyncCause) return NS_OK; } -NS_IMETHODIMP JSStackFrame::GetAsyncCaller(nsIStackFrame** aAsyncCaller) +NS_IMETHODIMP JSStackFrame::GetAsyncCaller(JSContext* aCx, + nsIStackFrame** aAsyncCaller) { if (!mStack) { *aAsyncCaller = nullptr; return NS_OK; } - ThreadsafeAutoJSContext cx; - JS::Rooted asyncCallerObj(cx); + JS::Rooted asyncCallerObj(aCx); bool canCache = false, useCachedValue = false; - GetValueIfNotCached(cx, mStack, JS::GetSavedFrameAsyncParent, + GetValueIfNotCached(aCx, mStack, JS::GetSavedFrameAsyncParent, mAsyncCallerInitialized, &canCache, &useCachedValue, &asyncCallerObj); diff --git a/xpcom/base/nsIException.idl b/xpcom/base/nsIException.idl index aea09ca3aa9c..83be00a7b097 100644 --- a/xpcom/base/nsIException.idl +++ b/xpcom/base/nsIException.idl @@ -26,7 +26,9 @@ interface nsIStackFrame : nsISupports [implicit_jscontext] readonly attribute int32_t columnNumber; readonly attribute AUTF8String sourceLine; + [implicit_jscontext] readonly attribute AString asyncCause; + [implicit_jscontext] readonly attribute nsIStackFrame asyncCaller; readonly attribute nsIStackFrame caller;