Bug 1031880 - Remove JS_SetSingleStepMode. r=jorendorff
authorTom Schuster <evilpies@gmail.com>
Sun, 31 Aug 2014 19:08:41 +0200
changeset 224388 674b44ed649099c1604e296e01aef0a0a23050ba
parent 224387 bec4694a3c6ff6f766f3e6fb7d037bf57774833f
child 224389 ef40d40dd8c955582a22f065d29741fb10eb21da
child 224463 504e18c45b864be7c395d91a673cbb13dc1d096f
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1031880
milestone34.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 1031880 - Remove JS_SetSingleStepMode. r=jorendorff
js/public/OldDebugAPI.h
js/src/jsscript.cpp
js/src/jsscript.h
js/src/vm/OldDebugAPI.cpp
--- a/js/public/OldDebugAPI.h
+++ b/js/public/OldDebugAPI.h
@@ -93,20 +93,16 @@ JS_FRIEND_API(bool)
 JS_SetDebugModeForCompartment(JSContext *cx, JSCompartment *comp, bool debug);
 
 /*
  * Turn on/off debugging mode for a context's compartment.
  */
 JS_FRIEND_API(bool)
 JS_SetDebugMode(JSContext *cx, bool debug);
 
-/* Turn on single step mode. */
-extern JS_PUBLIC_API(bool)
-JS_SetSingleStepMode(JSContext *cx, JS::HandleScript script, bool singleStep);
-
 
 /************************************************************************/
 
 // Raw JSScript* because this needs to be callable from a signal handler.
 extern JS_PUBLIC_API(unsigned)
 JS_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc);
 
 extern JS_PUBLIC_API(jsbytecode *)
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -3197,55 +3197,37 @@ JSScript::setNewStepMode(FreeOp *fop, ui
             baseline->toggleDebugTraps(this, nullptr);
 
         if (!stepModeEnabled() && !debug->numSites)
             fop->free_(releaseDebugScript());
     }
 }
 
 bool
-JSScript::setStepModeFlag(JSContext *cx, bool step)
-{
-    if (!ensureHasDebugScript(cx))
-        return false;
-
-    setNewStepMode(cx->runtime()->defaultFreeOp(),
-                   (debugScript()->stepMode & stepCountMask) |
-                   (step ? stepFlagMask : 0));
-    return true;
-}
-
-bool
 JSScript::incrementStepModeCount(JSContext *cx)
 {
     assertSameCompartment(cx, this);
     MOZ_ASSERT(cx->compartment()->debugMode());
 
     if (!ensureHasDebugScript(cx))
         return false;
 
     DebugScript *debug = debugScript();
-    uint32_t count = debug->stepMode & stepCountMask;
-    MOZ_ASSERT(((count + 1) & stepCountMask) == count + 1);
-
-    setNewStepMode(cx->runtime()->defaultFreeOp(),
-                   (debug->stepMode & stepFlagMask) |
-                   ((count + 1) & stepCountMask));
+    uint32_t count = debug->stepMode;
+    setNewStepMode(cx->runtime()->defaultFreeOp(), count + 1);
     return true;
 }
 
 void
 JSScript::decrementStepModeCount(FreeOp *fop)
 {
     DebugScript *debug = debugScript();
-    uint32_t count = debug->stepMode & stepCountMask;
-
-    setNewStepMode(fop,
-                   (debug->stepMode & stepFlagMask) |
-                   ((count - 1) & stepCountMask));
+    uint32_t count = debug->stepMode;
+    JS_ASSERT(count > 0);
+    setNewStepMode(fop, count - 1);
 }
 
 BreakpointSite *
 JSScript::getOrCreateBreakpointSite(JSContext *cx, jsbytecode *pc)
 {
     if (!ensureHasDebugScript(cx))
         return nullptr;
 
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -712,19 +712,16 @@ XDRLazyScript(XDRState<mode> *xdr, Handl
 template<XDRMode mode>
 bool
 XDRScriptConst(XDRState<mode> *xdr, MutableHandleValue vp);
 
 } /* namespace js */
 
 class JSScript : public js::gc::BarrieredCell<JSScript>
 {
-    static const uint32_t stepFlagMask = 0x80000000U;
-    static const uint32_t stepCountMask = 0x7fffffffU;
-
     template <js::XDRMode mode>
     friend
     bool
     js::XDRScript(js::XDRState<mode> *xdr, js::HandleObject enclosingScope, js::HandleScript enclosingScript,
                   js::HandleFunction fun, js::MutableHandleScript scriptp);
 
     friend JSScript *
     js::CloneScript(JSContext *cx, js::HandleObject enclosingScope, js::HandleFunction fun, js::HandleScript src,
@@ -1575,38 +1572,28 @@ class JSScript : public js::gc::Barriere
 
     js::BreakpointSite *getOrCreateBreakpointSite(JSContext *cx, jsbytecode *pc);
 
     void destroyBreakpointSite(js::FreeOp *fop, jsbytecode *pc);
 
     void clearBreakpointsIn(js::FreeOp *fop, js::Debugger *dbg, JSObject *handler);
 
     /*
-     * Set or clear the single-step flag. If the flag is set or the count
-     * (adjusted by changeStepModeCount) is non-zero, then the script is in
-     * single-step mode. (JSD uses an on/off-style interface; Debugger uses a
-     * count-style interface.)
-     */
-    bool setStepModeFlag(JSContext *cx, bool step);
-
-    /*
-     * Increment or decrement the single-step count. If the count is non-zero or
-     * the flag (set by setStepModeFlag) is set, then the script is in
-     * single-step mode. (JSD uses an on/off-style interface; Debugger uses a
-     * count-style interface.)
+     * Increment or decrement the single-step count. If the count is non-zero
+     * then the script is in single-step mode.
      *
      * Only incrementing is fallible, as it could allocate a DebugScript.
      */
     bool incrementStepModeCount(JSContext *cx);
     void decrementStepModeCount(js::FreeOp *fop);
 
     bool stepModeEnabled() { return hasDebugScript_ && !!debugScript()->stepMode; }
 
 #ifdef DEBUG
-    uint32_t stepModeCount() { return hasDebugScript_ ? (debugScript()->stepMode & stepCountMask) : 0; }
+    uint32_t stepModeCount() { return hasDebugScript_ ? debugScript()->stepMode : 0; }
 #endif
 
     void finalize(js::FreeOp *fop);
 
     static inline js::ThingRootKind rootKind() { return js::THING_ROOT_SCRIPT; }
 
     void markChildren(JSTracer *trc);
 };
--- a/js/src/vm/OldDebugAPI.cpp
+++ b/js/src/vm/OldDebugAPI.cpp
@@ -149,44 +149,16 @@ JS_SetDebugModeForAllCompartments(JSCont
 
 JS_FRIEND_API(bool)
 JS_SetDebugModeForCompartment(JSContext *cx, JSCompartment *comp, bool debug)
 {
     AutoDebugModeInvalidation invalidate(comp);
     return comp->setDebugModeFromC(cx, !!debug, invalidate);
 }
 
-static bool
-CheckDebugMode(JSContext *cx)
-{
-    bool debugMode = JS_GetDebugMode(cx);
-    /*
-     * :TODO:
-     * This probably should be an assertion, since it's indicative of a severe
-     * API misuse.
-     */
-    if (!debugMode) {
-        JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage,
-                                     nullptr, JSMSG_NEED_DEBUG_MODE);
-    }
-    return debugMode;
-}
-
-JS_PUBLIC_API(bool)
-JS_SetSingleStepMode(JSContext *cx, HandleScript script, bool singleStep)
-{
-    assertSameCompartment(cx, script);
-
-    if (!CheckDebugMode(cx))
-        return false;
-
-    return script->setStepModeFlag(cx, singleStep);
-}
-
-
 /************************************************************************/
 
 JS_PUBLIC_API(unsigned)
 JS_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc)
 {
     return js::PCToLineNumber(script, pc);
 }