diff --git a/js/src/jsdbgapi.cpp b/js/src/jsdbgapi.cpp index e27c20c675d..15ff0cf9210 100644 --- a/js/src/jsdbgapi.cpp +++ b/js/src/jsdbgapi.cpp @@ -73,16 +73,18 @@ JS_SetRuntimeDebugMode(JSRuntime *rt, JSBool debug) } JSTrapStatus -js::ScriptDebugPrologue(JSContext *cx, StackFrame *fp) +js::ScriptDebugPrologue(JSContext *cx, AbstractFramePtr frame) { - JS_ASSERT(fp == cx->fp()); + JS_ASSERT_IF(frame.isStackFrame(), frame.asStackFrame() == cx->fp()); - if (fp->isFramePushedByExecute()) { + if (frame.isFramePushedByExecute()) { if (JSInterpreterHook hook = cx->runtime->debugHooks.executeHook) - fp->setHookData(hook(cx, Jsvalify(fp), true, 0, cx->runtime->debugHooks.executeHookData)); + frame.setHookData(hook(cx, Jsvalify(frame.asStackFrame()), true, 0, + cx->runtime->debugHooks.executeHookData)); } else { if (JSInterpreterHook hook = cx->runtime->debugHooks.callHook) - fp->setHookData(hook(cx, Jsvalify(fp), true, 0, cx->runtime->debugHooks.callHookData)); + frame.setHookData(hook(cx, Jsvalify(frame.asStackFrame()), true, 0, + cx->runtime->debugHooks.callHookData)); } Value rval; @@ -97,7 +99,7 @@ js::ScriptDebugPrologue(JSContext *cx, StackFrame *fp) cx->clearPendingException(); break; case JSTRAP_RETURN: - fp->setReturnValue(rval); + frame.setReturnValue(rval); break; default: JS_NOT_REACHED("bad Debugger::onEnterFrame JSTrapStatus value"); @@ -106,18 +108,18 @@ js::ScriptDebugPrologue(JSContext *cx, StackFrame *fp) } bool -js::ScriptDebugEpilogue(JSContext *cx, StackFrame *fp, bool okArg) +js::ScriptDebugEpilogue(JSContext *cx, AbstractFramePtr frame, bool okArg) { - JS_ASSERT(fp == cx->fp()); + JS_ASSERT_IF(frame.isStackFrame(), frame.asStackFrame() == cx->fp()); JSBool ok = okArg; - if (void *hookData = fp->maybeHookData()) { - if (fp->isFramePushedByExecute()) { + if (void *hookData = frame.maybeHookData()) { + if (frame.isFramePushedByExecute()) { if (JSInterpreterHook hook = cx->runtime->debugHooks.executeHook) - hook(cx, Jsvalify(fp), false, &ok, hookData); + hook(cx, Jsvalify(frame.asStackFrame()), false, &ok, hookData); } else { if (JSInterpreterHook hook = cx->runtime->debugHooks.callHook) - hook(cx, Jsvalify(fp), false, &ok, hookData); + hook(cx, Jsvalify(frame.asStackFrame()), false, &ok, hookData); } } diff --git a/js/src/jsinterp.h b/js/src/jsinterp.h index a0c9f58d964..2123b0992f3 100644 --- a/js/src/jsinterp.h +++ b/js/src/jsinterp.h @@ -22,7 +22,7 @@ namespace js { /* * Announce to the debugger that the thread has entered a new JavaScript frame, - * |fp|. Call whatever hooks have been registered to observe new frames, and + * |frame|. Call whatever hooks have been registered to observe new frames, and * return a JSTrapStatus code indication how execution should proceed: * * - JSTRAP_CONTINUE: Continue execution normally. @@ -35,18 +35,18 @@ namespace js { * exception. * * - JSTRAP_RETURN: Return from the new frame immediately. ScriptDebugPrologue - * has set |cx->fp()|'s return value appropriately. + * has set |frame|'s return value appropriately. */ extern JSTrapStatus -ScriptDebugPrologue(JSContext *cx, StackFrame *fp); +ScriptDebugPrologue(JSContext *cx, AbstractFramePtr frame); /* - * Announce to the debugger that the thread has exited a JavaScript frame, |fp|. + * Announce to the debugger that the thread has exited a JavaScript frame, |frame|. * If |ok| is true, the frame is returning normally; if |ok| is false, the frame * is throwing an exception or terminating. * * Call whatever hooks have been registered to observe frame exits. Change cx's - * current exception and |fp|'s return value to reflect the changes in behavior + * current exception and |frame|'s return value to reflect the changes in behavior * the hooks request, if any. Return the new error/success value. * * This function may be called twice for the same outgoing frame; only the @@ -56,7 +56,7 @@ ScriptDebugPrologue(JSContext *cx, StackFrame *fp); * alternative path, containing its own call to ScriptDebugEpilogue.) */ extern bool -ScriptDebugEpilogue(JSContext *cx, StackFrame *fp, bool ok); +ScriptDebugEpilogue(JSContext *cx, AbstractFramePtr frame, bool ok); /* * For a given |call|, convert null/undefined |this| into the global object for diff --git a/js/src/vm/Stack-inl.h b/js/src/vm/Stack-inl.h index 2ca994750dc..b934ff65cda 100644 --- a/js/src/vm/Stack-inl.h +++ b/js/src/vm/Stack-inl.h @@ -609,6 +609,35 @@ StackIter::ionForEachCanonicalActualArg(Op op) #endif } +inline void * +AbstractFramePtr::maybeHookData() const +{ + if (isStackFrame()) + return asStackFrame()->maybeHookData(); + JS_NOT_REACHED("Invalid frame"); + return NULL; +} + +inline void +AbstractFramePtr::setHookData(void *data) const +{ + if (isStackFrame()) { + asStackFrame()->setHookData(data); + return; + } + JS_NOT_REACHED("Invalid frame"); +} + +inline void +AbstractFramePtr::setReturnValue(const Value &rval) const +{ + if (isStackFrame()) { + asStackFrame()->setReturnValue(rval); + return; + } + JS_NOT_REACHED("Invalid frame"); +} + inline UnrootedObject AbstractFramePtr::scopeChain() const { diff --git a/js/src/vm/Stack.h b/js/src/vm/Stack.h index 6a8d8db1f94..5b09473d388 100644 --- a/js/src/vm/Stack.h +++ b/js/src/vm/Stack.h @@ -1790,6 +1790,9 @@ class AbstractFramePtr JS_NOT_REACHED("Invalid frame"); return false; } + bool isFramePushedByExecute() const { + return isGlobalFrame() || isEvalFrame(); + } bool isDebuggerFrame() const { if (isStackFrame()) return asStackFrame()->isDebuggerFrame(); @@ -1898,6 +1901,10 @@ class AbstractFramePtr JS_NOT_REACHED("Invalid frame"); return AbstractFramePtr(); } + + inline void *maybeHookData() const; + inline void setHookData(void *data) const; + inline void setReturnValue(const Value &rval) const; }; template <>