Bug 1038238 - Part 4: Rename JS::StringifySavedFrameStack to JS::BuildStackString; r=jorendorff
authorNick Fitzgerald <fitzgen@gmail.com>
Fri, 27 Mar 2015 13:08:46 -0700
changeset 265139 b336dc0af92c339da912b09f205fb9bffc9afdf3
parent 265138 7304e101be54728c10b1e6e465b18818dec2e941
child 265140 7264dc6085845a0018bbbdbb00b90cbcd538b2de
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1038238
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1038238 - Part 4: Rename JS::StringifySavedFrameStack to JS::BuildStackString; r=jorendorff
dom/bindings/Exceptions.cpp
js/src/jsapi-tests/testSavedStacks.cpp
js/src/jsapi.h
js/src/jsexn.cpp
js/src/vm/ErrorObject.cpp
js/src/vm/SavedStacks.cpp
--- a/dom/bindings/Exceptions.cpp
+++ b/dom/bindings/Exceptions.cpp
@@ -753,17 +753,17 @@ NS_IMETHODIMP JSStackFrame::GetFormatted
     aStack = mFormattedStack;
     return NS_OK;
   }
 
   JS::ExposeObjectToActiveJS(mStack);
   JS::Rooted<JSObject*> stack(cx, mStack);
 
   JS::Rooted<JSString*> formattedStack(cx);
-  if (!JS::StringifySavedFrameStack(cx, stack, &formattedStack)) {
+  if (!JS::BuildStackString(cx, stack, &formattedStack)) {
     JS_ClearPendingException(cx);
     aStack.Truncate();
     return NS_OK;
   }
 
   nsAutoJSString str;
   if (!str.init(cx, formattedStack)) {
     JS_ClearPendingException(cx);
--- a/js/src/jsapi-tests/testSavedStacks.cpp
+++ b/js/src/jsapi-tests/testSavedStacks.cpp
@@ -52,14 +52,14 @@ BEGIN_TEST(testSavedStacks_ApiDefaultVal
 
     // Parent
     JS::RootedObject parent(cx);
     result = JS::GetSavedFrameParent(cx, savedFrame, &parent);
     CHECK(result == JS::SavedFrameResult::AccessDenied);
     CHECK(parent.get() == nullptr);
 
     // Stack string
-    CHECK(JS::StringifySavedFrameStack(cx, savedFrame, &str));
+    CHECK(JS::BuildStackString(cx, savedFrame, &str));
     CHECK(str.get() == cx->runtime()->emptyString);
 
     return true;
 }
 END_TEST(testSavedStacks_ApiDefaultValues)
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -5257,15 +5257,19 @@ GetSavedFrameAsyncParent(JSContext *cx, 
  */
 extern JS_PUBLIC_API(SavedFrameResult)
 GetSavedFrameParent(JSContext *cx, HandleObject savedFrame, MutableHandleObject parentp);
 
 /*
  * Given a SavedFrame JSObject stack, stringify it in the same format as
  * Error.prototype.stack. The stringified stack out parameter is placed in the
  * cx's compartment. Defaults to the empty string.
+ *
+ * The same notes above about SavedFrame accessors applies here as well: cx
+ * doesn't need to be in stack's compartment, and stack can be null, a
+ * SavedFrame object, or a wrapper (CCW or Xray) around a SavedFrame object.
  */
 extern JS_PUBLIC_API(bool)
-StringifySavedFrameStack(JSContext *cx, HandleObject stack, MutableHandleString stringp);
+BuildStackString(JSContext *cx, HandleObject stack, MutableHandleString stringp);
 
 } /* namespace JS */
 
 #endif /* jsapi_h */
--- a/js/src/jsexn.cpp
+++ b/js/src/jsexn.cpp
@@ -287,17 +287,17 @@ js::ComputeStackString(JSContext *cx)
 {
     SuppressErrorsGuard seg(cx);
 
     RootedObject stack(cx);
     if (!CaptureStack(cx, &stack))
         return nullptr;
 
     RootedString str(cx);
-    if (!StringifySavedFrameStack(cx, stack, &str))
+    if (!BuildStackString(cx, stack, &str))
         return nullptr;
 
     return str.get();
 }
 
 static void
 exn_finalize(FreeOp *fop, JSObject *obj)
 {
--- a/js/src/vm/ErrorObject.cpp
+++ b/js/src/vm/ErrorObject.cpp
@@ -205,17 +205,17 @@ js::ErrorObject::getStack(JSContext *cx,
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     Rooted<ErrorObject*> error(cx);
     if (!checkAndUnwrapThis(cx, args, "(get stack)", &error))
         return false;
 
     RootedObject savedFrameObj(cx, error->stack());
     RootedString stackString(cx);
-    if (!StringifySavedFrameStack(cx, savedFrameObj, &stackString))
+    if (!BuildStackString(cx, savedFrameObj, &stackString))
         return false;
     args.rval().setString(stackString);
     return true;
 }
 
 static MOZ_ALWAYS_INLINE bool
 IsObject(HandleValue v)
 {
--- a/js/src/vm/SavedStacks.cpp
+++ b/js/src/vm/SavedStacks.cpp
@@ -626,17 +626,17 @@ GetSavedFrameParent(JSContext *cx, Handl
     if (subsumedParent && !(subsumedParent->getAsyncCause() || skippedAsync))
         parentp.set(parent);
     else
         parentp.set(nullptr);
     return SavedFrameResult::Ok;
 }
 
 JS_PUBLIC_API(bool)
-StringifySavedFrameStack(JSContext *cx, HandleObject stack, MutableHandleString stringp)
+BuildStackString(JSContext *cx, HandleObject stack, MutableHandleString stringp)
 {
     js::StringBuffer sb(cx);
 
     // Enter a new block to constrain the scope of possibly entering the stack's
     // compartment. This ensures that when we finish the StringBuffer, we are
     // back in the cx's original compartment, and fulfill our contract with
     // callers to place the output string in the cx's current compartment.
     {
@@ -774,17 +774,17 @@ SavedFrame::parentProperty(JSContext *cx
     return true;
 }
 
 /* static */ bool
 SavedFrame::toStringMethod(JSContext *cx, unsigned argc, Value *vp)
 {
     THIS_SAVEDFRAME(cx, argc, vp, "toString", args, frame);
     RootedString string(cx);
-    if (!JS::StringifySavedFrameStack(cx, frame, &string))
+    if (!JS::BuildStackString(cx, frame, &string))
         return false;
     args.rval().setString(string);
     return true;
 }
 
 bool
 SavedStacks::init()
 {