Bug 810525 - unregress DecompileValueGenerator change to handle object literal reference bases (r=luke)
authorBrendan Eich <brendan@mozilla.org>
Fri, 28 Dec 2012 16:09:25 -0800
changeset 117203 6bea4ccff670d9d5c6640b4d8bfddcecef7bbaac
parent 117202 22e38c3125e9ca2ac7e6e60448fdd8a7e2917e51
child 117204 96e5f3a75fcf828a0a29e694d5bba81798d30b10
push id20368
push userbrendan@mozilla.com
push dateSat, 29 Dec 2012 00:09:28 +0000
treeherdermozilla-inbound@6bea4ccff670 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs810525
milestone20.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 810525 - unregress DecompileValueGenerator change to handle object literal reference bases (r=luke)
js/src/jsopcode.cpp
js/src/tests/js1_5/Regress/regress-372364.js
js/src/tests/js1_8/extensions/regress-469625.js
js/src/tests/js1_8_5/regress/regress-469758.js
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -5969,17 +5969,17 @@ struct ExpressionDecompiler
     bool init();
     bool decompilePC(jsbytecode *pc);
     JSAtom *getVar(unsigned slot);
     JSAtom *getArg(unsigned slot);
     JSAtom *findLetVar(jsbytecode *pc, unsigned depth);
     JSAtom *loadAtom(jsbytecode *pc);
     bool quote(JSString *s, uint32_t quote);
     bool write(const char *s);
-    bool write(JSString *s);
+    bool write(JSString *str);
     bool getOutput(char **out);
 };
 
 bool
 ExpressionDecompiler::decompilePC(jsbytecode *pc)
 {
     JS_ASSERT(script->code <= pc && pc < script->code + script->length);
 
@@ -6052,24 +6052,23 @@ ExpressionDecompiler::decompilePC(jsbyte
         return write(atom);
       }
       case JSOP_LENGTH:
       case JSOP_GETPROP:
       case JSOP_CALLPROP: {
         JSAtom *prop = (op == JSOP_LENGTH) ? cx->names().length : loadAtom(pc);
         if (!decompilePC(pcstack[-1]))
             return false;
-        if (IsIdentifier(prop))
+        if (IsIdentifier(prop)) {
             return write(".") &&
                    quote(prop, '\0');
-        else
-            return write("[") &&
-                   quote(prop, '\'') &&
-                   write("]");
-        return true;
+        }
+        return write("[") &&
+               quote(prop, '\'') &&
+               write("]");
       }
       case JSOP_GETELEM:
       case JSOP_CALLELEM:
         return decompilePC(pcstack[-2]) &&
                write("[") &&
                decompilePC(pcstack[-1]) &&
                write("]");
       case JSOP_NULL:
@@ -6116,16 +6115,28 @@ ExpressionDecompiler::decompilePC(jsbyte
       case JSOP_THIS:
         // |this| could convert to a very long object initialiser, so cite it by
         // its keyword name.
         return write(js_this_str);
       case JSOP_CALL:
       case JSOP_FUNCALL:
         return decompilePC(pcstack[-int32_t(GET_ARGC(pc) + 2)]) &&
                write("(...)");
+      case JSOP_NEWARRAY:
+        return write("[]");
+      case JSOP_REGEXP:
+      case JSOP_OBJECT: {
+        JSObject *obj = (op == JSOP_REGEXP)
+                        ? script->getRegExp(GET_UINT32_INDEX(pc))
+                        : script->getObject(GET_UINT32_INDEX(pc));
+        JSString *str = js_ValueToSource(cx, ObjectValue(*obj));
+        if (!str)
+            return false;
+        return write(str);
+      }
       default:
         break;
     }
     return write("(intermediate value)");
 }
 
 ExpressionDecompiler::~ExpressionDecompiler()
 {
@@ -6150,19 +6161,19 @@ ExpressionDecompiler::init()
 
 bool
 ExpressionDecompiler::write(const char *s)
 {
     return sprinter.put(s) >= 0;
 }
 
 bool
-ExpressionDecompiler::write(JSString *s)
+ExpressionDecompiler::write(JSString *str)
 {
-    return sprinter.putString(s) >= 0;
+    return sprinter.putString(str) >= 0;
 }
 
 bool
 ExpressionDecompiler::quote(JSString *s, uint32_t quote)
 {
     return QuoteString(&sprinter, s, quote) >= 0;
 }
 
--- a/js/src/tests/js1_5/Regress/regress-372364.js
+++ b/js/src/tests/js1_5/Regress/regress-372364.js
@@ -27,17 +27,17 @@ function test()
     function a(){return null;} a(1)[0];
   }
   catch(ex)
   {
     actual = ex + '';
   }
   reportMatch(expect, actual, summary);
 
-  expect = /TypeError: \(intermediate value\).exec\(.+\) (has no properties|is null)/;
+  expect = /TypeError: \/a\/.exec\(.+\) (has no properties|is null)/;
   try
   {
     /a/.exec("b")[0];
   }
   catch(ex)
   {
     actual = ex + '';
   }
--- a/js/src/tests/js1_8/extensions/regress-469625.js
+++ b/js/src/tests/js1_8/extensions/regress-469625.js
@@ -17,17 +17,17 @@ test();
 //-----------------------------------------------------------------------------
 
 function test()
 {
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
  
-  expect = 'TypeError: (intermediate value).__proto__ is not a function';
+  expect = 'TypeError: [].__proto__ is not a function';
 
   jit(true);
 
   Array.prototype.__proto__ = function () 3; 
 
   try
   {
     [].__proto__();
--- a/js/src/tests/js1_8_5/regress/regress-469758.js
+++ b/js/src/tests/js1_8_5/regress/regress-469758.js
@@ -4,11 +4,11 @@
 var err;
 try {
     {let i=1}
     {let j=1; [][j][2]}
 } catch (e) {
     err = e;
 }
 assertEq(err instanceof TypeError, true);
-assertEq(err.message, "(intermediate value)[j] is undefined");
+assertEq(err.message, "[][j] is undefined");
 
 reportCompare(0, 0, 'ok');