Backed out changeset 6cb9adc02c12
authorDão Gottwald <dao@mozilla.com>
Thu, 29 Mar 2012 20:35:49 +0200
changeset 94387 f094990ed17dddc971c819deb389717a52b61457
parent 94382 6cb9adc02c12a0079976b7514e18243bb455ab7f
child 94388 42639be584318304121181e12a5f93e252b675c6
push id160
push userlsblakk@mozilla.com
push dateFri, 13 Jul 2012 18:18:57 +0000
treeherdermozilla-release@228ba1a111fc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone14.0a1
backs out6cb9adc02c12a0079976b7514e18243bb455ab7f
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
Backed out changeset 6cb9adc02c12
js/src/jsexn.cpp
--- a/js/src/jsexn.cpp
+++ b/js/src/jsexn.cpp
@@ -1184,44 +1184,22 @@ js_ErrorToException(JSContext *cx, const
 
     JS_SetPendingException(cx, OBJECT_TO_JSVAL(errObject));
 
     /* Flag the error report passed in to indicate an exception was raised. */
     reportp->flags |= JSREPORT_EXCEPTION;
     return true;
 }
 
-static bool
-IsDuckTypedErrorObject(JSContext *cx, JSObject *exnObject, const char **filename_strp)
-{
-    JSBool found;
-    if (!JS_HasProperty(cx, exnObject, js_message_str, &found) || !found)
-        return false;
-
-    const char *filename_str = *filename_strp;
-    if (!JS_HasProperty(cx, exnObject, filename_str, &found) || !found) {
-        // DOMException duck quacks "filename" (all lowercase)
-        filename_str = "filename";
-        if (!JS_HasProperty(cx, exnObject, filename_str, &found) || !found)
-            return false;
-    }
-
-    if (!JS_HasProperty(cx, exnObject, js_lineNumber_str, &found) || !found)
-        return false;
-
-    *filename_strp = filename_str;
-    return true;
-}
-
 JSBool
 js_ReportUncaughtException(JSContext *cx)
 {
     jsval exn;
     JSObject *exnObject;
-    jsval roots[6];
+    jsval roots[5];
     JSErrorReport *reportp, report;
     JSString *str;
     const char *bytes;
 
     if (!JS_IsExceptionPending(cx))
         return true;
 
     if (!JS_GetPendingException(cx, &exn))
@@ -1244,70 +1222,57 @@ js_ReportUncaughtException(JSContext *cx
     }
 
     JS_ClearPendingException(cx);
     reportp = js_ErrorFromException(cx, exn);
 
     /* XXX L10N angels cry once again. see also everywhere else */
     str = ToString(cx, exn);
     JSAutoByteString bytesStorage;
-    bytes = "unknown (can't convert to string)";
-    if (str) {
+    if (!str) {
+        bytes = "unknown (can't convert to string)";
+    } else {
         roots[1] = StringValue(str);
-        if (bytesStorage.encode(cx, str))
-            bytes = bytesStorage.ptr();
+        if (!bytesStorage.encode(cx, str))
+            return false;
+        bytes = bytesStorage.ptr();
     }
 
-    const char *filename_str = js_fileName_str;
     JSAutoByteString filename;
-    if (!reportp && exnObject &&
-        (exnObject->isError() ||
-         IsDuckTypedErrorObject(cx, exnObject, &filename_str)))
-    {
-        JSString *tmp = NULL;
-        if (JS_GetProperty(cx, exnObject, js_name_str, &roots[2]) &&
-            JSVAL_IS_STRING(roots[2]))
-        {
-            str = JSVAL_TO_STRING(roots[2]);
-            tmp = JS_NewStringCopyZ(cx, ": ");
-            if (tmp)
-                tmp = JS_ConcatStrings(cx, str, tmp);
+    if (!reportp && exnObject && exnObject->isError()) {
+        if (!JS_GetProperty(cx, exnObject, js_message_str, &roots[2]))
+            return false;
+        if (JSVAL_IS_STRING(roots[2])) {
+            bytesStorage.clear();
+            if (!bytesStorage.encode(cx, str))
+                return false;
+            bytes = bytesStorage.ptr();
         }
 
-        if (!JS_GetProperty(cx, exnObject, js_message_str, &roots[3]))
+        if (!JS_GetProperty(cx, exnObject, js_fileName_str, &roots[3]))
             return false;
-        if (JSVAL_IS_STRING(roots[3])) {
-            str = JSVAL_TO_STRING(roots[3]);
-            if (tmp)
-                str = JS_ConcatStrings(cx, tmp, str);
-            else if (bytesStorage.encode(cx, str))
-                bytes = bytesStorage.ptr();
-        }
+        str = ToString(cx, roots[3]);
+        if (!str || !filename.encode(cx, str))
+            return false;
 
-        if (JS_GetProperty(cx, exnObject, filename_str, &roots[4])) {
-            tmp = ToString(cx, roots[4]);
-            if (tmp)
-                filename.encode(cx, tmp);
-        }
-
+        if (!JS_GetProperty(cx, exnObject, js_lineNumber_str, &roots[4]))
+            return false;
         uint32_t lineno;
-        if (!JS_GetProperty(cx, exnObject, js_lineNumber_str, &roots[5]) ||
-            !ToUint32(cx, roots[5], &lineno))
-        {
-            lineno = 0;
-        }
+        if (!ToUint32(cx, roots[4], &lineno))
+            return false;
 
         reportp = &report;
         PodZero(&report);
         report.filename = filename.ptr();
         report.lineno = (unsigned) lineno;
-        if (str) {
-            JSFixedString *fixed = str->ensureFixed(cx);
-            if (fixed)
-                report.ucmessage = fixed->chars();
+        if (JSVAL_IS_STRING(roots[2])) {
+            JSFixedString *fixed = JSVAL_TO_STRING(roots[2])->ensureFixed(cx);
+            if (!fixed)
+                return false;
+            report.ucmessage = fixed->chars();
         }
     }
 
     if (!reportp) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
                              JSMSG_UNCAUGHT_EXCEPTION, bytes);
     } else {
         /* Flag the error as an exception. */