diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 0c88e31e218..a7face4175c 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -880,10 +880,10 @@ static bool SaveStack(JSContext *cx, unsigned argc, jsval *vp) { CallArgs args = CallArgsFromVp(argc, vp); - Rooted frame(cx); - if (!cx->compartment()->savedStacks().saveCurrentStack(cx, &frame)) + Rooted stack(cx); + if (!JS::CaptureCurrentStack(cx, &stack)) return false; - args.rval().setObject(*frame.get()); + args.rval().setObject(*stack); return true; } diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 1ce26875021..28660044e26 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -73,6 +73,7 @@ #include "vm/NumericConversions.h" #include "vm/RegExpStatics.h" #include "vm/Runtime.h" +#include "vm/SavedStacks.h" #include "vm/Shape.h" #include "vm/SharedArrayObject.h" #include "vm/StopIterationObject.h" @@ -6559,3 +6560,14 @@ JS::SetOutOfMemoryCallback(JSRuntime *rt, OutOfMemoryCallback cb, void *data) rt->oomCallbackData = data; } +JS_PUBLIC_API(bool) +JS::CaptureCurrentStack(JSContext *cx, JS::MutableHandleObject stackp) +{ + JSCompartment *compartment = cx->compartment(); + JS_ASSERT(compartment); + Rooted frame(cx); + if (!compartment->savedStacks().saveCurrentStack(cx, &frame)) + return false; + stackp.set(frame.get()); + return true; +} diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 86afaa0f2cb..007f5557d1a 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -5164,6 +5164,9 @@ typedef void extern JS_PUBLIC_API(void) SetOutOfMemoryCallback(JSRuntime *rt, OutOfMemoryCallback cb, void *data); +extern JS_PUBLIC_API(bool) +CaptureCurrentStack(JSContext *cx, MutableHandleObject stackp); + } /* namespace JS */ #endif /* jsapi_h */