Fixed js_Disassemble1 decoding JOF_ATOM+JSOP_DOUBLE as astom (bug 570285).
authorDavid Anderson <danderson@mozilla.com>
Fri, 04 Jun 2010 22:19:53 -0700
changeset 52701 215ec672df104c419b38e2b16f69e16cbcff9cd3
parent 52698 a49a04a4de0b7ab60b002f2123b9b8ce71e1cec1
child 52702 cb2d305330698e5b44ccd6d9748427f715bd3cad
child 52709 255c3f564cf6a2605bc45ddbc676a67c6135633a
push idunknown
push userunknown
push dateunknown
bugs570285
milestone1.9.3a5pre
Fixed js_Disassemble1 decoding JOF_ATOM+JSOP_DOUBLE as astom (bug 570285).
js/src/jsopcode.cpp
js/src/shell/js.cpp
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -366,18 +366,22 @@ js_Disassemble1(JSContext *cx, JSScript 
         fprintf(fp, " %u (%d)", loc + (intN) off, (intN) off);
         break;
 
       case JOF_ATOM:
       case JOF_OBJECT:
       case JOF_REGEXP:
         index = js_GetIndexFromBytecode(cx, script, pc, 0);
         if (type == JOF_ATOM) {
-            JS_GET_SCRIPT_ATOM(script, pc, index, atom);
-            v = ATOM_TO_JSVAL(atom);
+            if (op == JSOP_DOUBLE) {
+                v = Jsvalify(script->getConst(index));
+            } else {
+                JS_GET_SCRIPT_ATOM(script, pc, index, atom);
+                v = ATOM_TO_JSVAL(atom);
+            }
         } else {
             if (type == JOF_OBJECT)
                 obj = script->getObject(index);
             else
                 obj = script->getRegExp(index);
             v = OBJECT_TO_JSVAL(obj);
         }
         bytes = ToDisassemblySource(cx, v);
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -1873,16 +1873,19 @@ DisassFile(JSContext *cx, JSObject *obj,
     filename = JS_GetStringBytes(str);
     oldopts = JS_GetOptions(cx);
     JS_SetOptions(cx, oldopts | JSOPTION_COMPILE_N_GO | JSOPTION_NO_SCRIPT_RVAL);
     script = JS_CompileFile(cx, obj, filename);
     JS_SetOptions(cx, oldopts);
     if (!script)
         return JS_FALSE;
 
+    if (script->isEmpty())
+        return JS_TRUE;
+
     obj = JS_NewScriptObject(cx, script);
     if (!obj)
         return JS_FALSE;
 
     *rval = OBJECT_TO_JSVAL(obj); /* I like to root it, root it. */
     ok = Disassemble(cx, obj, 1, rval, rval); /* gross, but works! */
     *rval = JSVAL_VOID;