Bug 669043 - Don't assert when the decompiler temporarily changes script->code (r=waldo)
authorLuke Wagner <luke@mozilla.com>
Mon, 11 Jul 2011 10:21:31 -0700
changeset 76037 60b1a6a58531e9ce6c10445804b9a7f8fb4b4290
parent 75194 7abfbaac06931b3c242934eafb0742646216382a
child 76038 464f65a4cb87945fa52e73e7d4d57d1b0bd3b321
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewerswaldo
bugs669043
milestone8.0a1
Bug 669043 - Don't assert when the decompiler temporarily changes script->code (r=waldo)
js/src/jsopcode.cpp
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -238,39 +238,49 @@ js_GetEnterBlockStackDefs(JSContext *cx,
     return OBJ_BLOCK_COUNT(cx, obj);
 }
 
 class AutoScriptUntrapper {
     JSContext *cx;
     JSScript *script;
     jsbytecode *origPC;
     jsbytecode *newPC;
+#ifdef DEBUG
+    bool assertionBefore;
+#endif
 
 public:
     AutoScriptUntrapper(JSContext *cx, JSScript *script, jsbytecode **pc)
         : cx(cx), script(script), origPC(*pc)
     {
         jsbytecode *newCode = js_UntrapScriptCode(cx, script);
         if (newCode == script->code) {
             // No change needed
             newPC = origPC;
         } else {
             script->main += newCode - script->code;
             *pc = newPC = origPC + (newCode - script->code);
             script->code = newCode;
+#ifdef DEBUG
+            assertionBefore = cx->stackIterAssertionEnabled;
+            cx->stackIterAssertionEnabled = false;
+#endif
         }
     }
     ~AutoScriptUntrapper()
     {
         ptrdiff_t delta = newPC - origPC;
         if (delta) {
             jsbytecode *oldCode = script->code - delta;
             cx->free_(script->code);
             script->code = oldCode;
             script->main -= delta;
+#ifdef DEBUG
+            cx->stackIterAssertionEnabled = assertionBefore;
+#endif
         }
     }
 };
 
 #ifdef DEBUG
 
 /*
  * If pc != NULL, include a prefix indicating whether the PC is at the current line.