Bug 835277 part 2 - Fix hasBreakpointsAt. r=bhackett
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 31 Jan 2013 11:50:01 +0100
changeset 130333 ccd9b78a80de58b3d3528e606848b18af7a80f22
parent 130332 e2d33e01fac4afb284298da37868a339d9f2d22d
child 130334 585183fb7a13a9fbba479c03f4515156d546a8c7
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs835277
milestone21.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 835277 part 2 - Fix hasBreakpointsAt. r=bhackett
js/src/jsscript.cpp
js/src/jsscript.h
js/src/vm/Debugger.cpp
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -2570,16 +2570,26 @@ JSScript::clearBreakpointsIn(FreeOp *fop
                 nextbp = bp->nextInSite();
                 if ((!dbg || bp->debugger == dbg) && (!handler || bp->getHandler() == handler))
                     bp->destroy(fop);
             }
         }
     }
 }
 
+bool
+JSScript::hasBreakpointsAt(jsbytecode *pc)
+{
+    BreakpointSite *site = getBreakpointSite(pc);
+    if (!site)
+        return false;
+
+    return site->enabledCount > 0 || site->trapHandler;
+}
+
 void
 JSScript::clearTraps(FreeOp *fop)
 {
     if (!hasAnyBreakpointsOrStepMode())
         return;
 
     jsbytecode *end = code + length;
     for (jsbytecode *pc = code; pc < end; pc++) {
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -876,17 +876,17 @@ class JSScript : public js::gc::Cell
     bool tryNewStepMode(JSContext *cx, uint32_t newValue);
 
     bool ensureHasDebugScript(JSContext *cx);
     js::DebugScript *debugScript();
     js::DebugScript *releaseDebugScript();
     void destroyDebugScript(js::FreeOp *fop);
 
   public:
-    bool hasBreakpointsAt(jsbytecode *pc) { return !!getBreakpointSite(pc); }
+    bool hasBreakpointsAt(jsbytecode *pc);
     bool hasAnyBreakpointsOrStepMode() { return hasDebugScript; }
 
     js::BreakpointSite *getBreakpointSite(jsbytecode *pc)
     {
         JS_ASSERT(size_t(pc - code) < length);
         return hasDebugScript ? debugScript()->breakpoints[pc - code] : NULL;
     }
 
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -244,37 +244,38 @@ BreakpointSite::recompile(FreeOp *fop)
         mjit::ReleaseScriptCode(fop, script);
     }
 #endif
 }
 
 void
 BreakpointSite::inc(FreeOp *fop)
 {
-    if (enabledCount == 0 && !trapHandler)
+    enabledCount++;
+    if (enabledCount == 1 && !trapHandler)
         recompile(fop);
-    enabledCount++;
 }
 
 void
 BreakpointSite::dec(FreeOp *fop)
 {
     JS_ASSERT(enabledCount > 0);
     enabledCount--;
     if (enabledCount == 0 && !trapHandler)
         recompile(fop);
 }
 
 void
 BreakpointSite::setTrap(FreeOp *fop, JSTrapHandler handler, const Value &closure)
 {
+    trapHandler = handler;
+    trapClosure = closure;
+
     if (enabledCount == 0)
         recompile(fop);
-    trapHandler = handler;
-    trapClosure = closure;
 }
 
 void
 BreakpointSite::clearTrap(FreeOp *fop, JSTrapHandler *handlerp, Value *closurep)
 {
     if (handlerp)
         *handlerp = trapHandler;
     if (closurep)