Bug 1031143: Include omitted patch reject fixes. CLOSED TREE r=borked

This commit is contained in:
Jim Blandy 2014-07-03 12:26:18 -07:00
Родитель 88dfd9001c
Коммит ea5c73450b
3 изменённых файлов: 33 добавлений и 5 удалений

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

@ -880,8 +880,23 @@ static bool
SaveStack(JSContext *cx, unsigned argc, jsval *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
unsigned maxFrameCount = 0;
if (args.length() >= 1) {
double d;
if (!ToNumber(cx, args[0], &d))
return false;
if (d < 0) {
js_ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE,
JSDVG_SEARCH_STACK, args[0], JS::NullPtr(),
"not a valid maximum frame count", NULL);
return false;
}
maxFrameCount = d;
}
Rooted<JSObject*> stack(cx);
if (!JS::CaptureCurrentStack(cx, &stack))
if (!JS::CaptureCurrentStack(cx, &stack, maxFrameCount))
return false;
args.rval().setObjectOrNull(stack);
return true;

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

@ -498,8 +498,20 @@ SavedStacks::insertFrames(JSContext *cx, ScriptFrameIter &iter, MutableHandleSav
// script and callee should keep compartment alive.
JSCompartment *compartment = iter.compartment();
RootedSavedFrame parentFrame(cx);
if (!insertFrames(cx, ++iter, &parentFrame))
return false;
// If maxFrameCount is zero, then there's no limit on the number of frames.
if (maxFrameCount == 0) {
if (!insertFrames(cx, ++iter, &parentFrame, 0))
return false;
} else if (maxFrameCount == 1) {
// Since we were only asked to save one frame, the SavedFrame we're
// building here should have no parent, even if there are older frames
// on the stack.
parentFrame = nullptr;
} else {
if (!insertFrames(cx, ++iter, &parentFrame, maxFrameCount - 1))
return false;
}
AutoLocationValueRooter location(cx);
if (!getLocation(cx, script, pc, &location))

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

@ -104,7 +104,7 @@ class SavedStacks {
bool init();
bool initialized() const { return frames.initialized(); }
bool saveCurrentStack(JSContext *cx, MutableHandleSavedFrame frame);
bool saveCurrentStack(JSContext *cx, MutableHandleSavedFrame frame, unsigned maxFrameCount = 0);
void sweep(JSRuntime *rt);
void trace(JSTracer *trc);
uint32_t count();
@ -116,7 +116,8 @@ class SavedStacks {
SavedFrame::Set frames;
JSObject *savedFrameProto;
bool insertFrames(JSContext *cx, ScriptFrameIter &iter, MutableHandleSavedFrame frame);
bool insertFrames(JSContext *cx, ScriptFrameIter &iter, MutableHandleSavedFrame frame,
unsigned maxFrameCount = 0);
SavedFrame *getOrCreateSavedFrame(JSContext *cx, const SavedFrame::Lookup &lookup);
// |SavedFrame.prototype| is created lazily and held weakly. It should only
// be accessed through this method.