Bug 1366903 - Fix decompilation of JSOP_REGEXP and JSOP_NEWARRAY_COPYONWRITE. r=nbp a=jcristau
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 27 Jun 2017 19:52:34 -0400
changeset 411857 852280fdf31d738951fc5ba339cbacc7397d47f6
parent 411856 2baa0baa9d7b0dbbc4079b4e43716f3e4f18a401
child 411858 362e0eeb5919f062e6d9040d331075d4e0477493
push id7492
push usercbook@mozilla.com
push dateMon, 10 Jul 2017 13:10:59 +0000
treeherdermozilla-beta@507ce044e84f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp, jcristau
bugs1366903
milestone55.0
Bug 1366903 - Fix decompilation of JSOP_REGEXP and JSOP_NEWARRAY_COPYONWRITE. r=nbp a=jcristau
js/src/jsopcode.cpp
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -1881,19 +1881,42 @@ ExpressionDecompiler::decompilePC(jsbyte
       case JSOP_FUNAPPLY:
         return decompilePCForStackOperand(pc, -int32_t(GET_ARGC(pc) + 2)) &&
                write("(...)");
       case JSOP_SPREADCALL:
         return decompilePCForStackOperand(pc, -3) &&
                write("(...)");
       case JSOP_NEWARRAY:
         return write("[]");
-      case JSOP_REGEXP:
-      case JSOP_OBJECT:
+      case JSOP_REGEXP: {
+        RootedObject obj(cx, script->getObject(GET_UINT32_INDEX(pc)));
+        JSString* str = obj->as<RegExpObject>().toString(cx);
+        if (!str)
+            return false;
+        return write(str);
+      }
       case JSOP_NEWARRAY_COPYONWRITE: {
+        RootedObject obj(cx, script->getObject(GET_UINT32_INDEX(pc)));
+        Handle<ArrayObject*> aobj = obj.as<ArrayObject>();
+        if (!write("["))
+            return false;
+        for (size_t i = 0; i < aobj->getDenseInitializedLength(); i++) {
+            if (i > 0 && !write(", "))
+                return false;
+
+            RootedValue v(cx, aobj->getDenseElement(i));
+            MOZ_RELEASE_ASSERT(v.isPrimitive() && !v.isMagic());
+
+            JSString* str = ValueToSource(cx, v);
+            if (!str || !write(str))
+                return false;
+        }
+        return write("]");
+      }
+      case JSOP_OBJECT: {
         JSObject* obj = script->getObject(GET_UINT32_INDEX(pc));
         RootedValue objv(cx, ObjectValue(*obj));
         JSString* str = ValueToSource(cx, objv);
         if (!str)
             return false;
         return write(str);
       }
       case JSOP_VOID: