Bug 603045 - JM: don't optimize away JSFRAME_HAS_RVAL check in debug mode (r=bhackett)
authorLuke Wagner <lw@mozilla.com>
Mon, 08 Nov 2010 09:28:12 -0800
changeset 57727 af75274bc041ef14c04295721f933e1b870fb518
parent 57726 5f6bdc7a4f5c7976f9b74dd1d6abe6b82a76ce1e
child 57728 f048a94e5f27febb7a8f57ceecbdacba02d9e904
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersbhackett
bugs603045
milestone2.0b8pre
Bug 603045 - JM: don't optimize away JSFRAME_HAS_RVAL check in debug mode (r=bhackett)
dom/base/nsJSEnvironment.cpp
js/src/jsanalyze.cpp
js/src/jsdbgapi.cpp
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -1114,17 +1114,17 @@ nsJSContext::DOMOperationCallback(JSCont
   else if ((buttonPressed == 2) && debugPossible) {
     // Debug the script
     jsval rval;
     switch(cx->debugHooks->debuggerHandler(cx, script, ::JS_GetFramePC(cx, fp),
                                            &rval,
                                            cx->debugHooks->
                                            debuggerHandlerData)) {
       case JSTRAP_RETURN:
-        fp->setReturnValue(js::Valueify(rval));
+        JS_SetFrameReturnValue(cx, fp, rval);
         return JS_TRUE;
       case JSTRAP_ERROR:
         cx->throwing = JS_FALSE;
         return JS_FALSE;
       case JSTRAP_THROW:
         JS_SetPendingException(cx, rval);
         return JS_FALSE;
       case JSTRAP_CONTINUE:
--- a/js/src/jsanalyze.cpp
+++ b/js/src/jsanalyze.cpp
@@ -322,16 +322,23 @@ Script::analyze(JSContext *cx, JSScript 
 
     for (uint32 i = 0; i < script->nClosedVars; i++) {
         uint32 slot = script->getClosedVar(i);
         if (slot < nfixed)
             setLocal(slot, LOCAL_USE_BEFORE_DEF);
     }
 
     /*
+     * If the script is in debug mode, JS_SetFrameReturnValue can be called at
+     * any safe point.
+     */
+    if (cx->compartment->debugMode)
+        usesRval = true;
+
+    /*
      * If we are in the middle of one or more jumps, the offset of the highest
      * target jumping over this bytecode.  Includes implicit jumps from
      * try/catch/finally blocks.
      */
     unsigned forwardJump = 0;
 
     /*
      * If we are in the middle of a try block, the offset of the highest
--- a/js/src/jsdbgapi.cpp
+++ b/js/src/jsdbgapi.cpp
@@ -1284,16 +1284,19 @@ JS_PUBLIC_API(jsval)
 JS_GetFrameReturnValue(JSContext *cx, JSStackFrame *fp)
 {
     return Jsvalify(fp->returnValue());
 }
 
 JS_PUBLIC_API(void)
 JS_SetFrameReturnValue(JSContext *cx, JSStackFrame *fp, jsval rval)
 {
+#ifdef JS_METHODJIT
+    JS_ASSERT_IF(fp->isScriptFrame(), fp->script()->debugMode);
+#endif
     assertSameCompartment(cx, fp, rval);
     fp->setReturnValue(Valueify(rval));
 }
 
 /************************************************************************/
 
 JS_PUBLIC_API(const char *)
 JS_GetScriptFilename(JSContext *cx, JSScript *script)