Bug 1283712 - Part 2: Add JSEXN_NOTE. r=jwalden
authorTooru Fujisawa <arai_a@mac.com>
Wed, 15 Feb 2017 23:53:05 +0900
changeset 343086 c7a11d17916df6fad0884230d1010621f0cd1311
parent 343085 cbcd8c6fe6bb6ddbb38bbdf72f6365a0faeb56f2
child 343087 f827db18261779031504eb8a5fe9f6e1fcc683d2
push id31369
push userkwierso@gmail.com
push dateThu, 16 Feb 2017 00:18:40 +0000
treeherdermozilla-central@e9b926463f9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalden
bugs1283712
milestone54.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 1283712 - Part 2: Add JSEXN_NOTE. r=jwalden
js/src/jsapi.h
js/src/jsexn.cpp
js/src/jsexn.h
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -632,16 +632,17 @@ typedef enum JSExnType {
         JSEXN_TYPEERR,
         JSEXN_URIERR,
         JSEXN_DEBUGGEEWOULDRUN,
         JSEXN_WASMCOMPILEERROR,
         JSEXN_WASMLINKERROR,
         JSEXN_WASMRUNTIMEERROR,
     JSEXN_ERROR_LIMIT,
     JSEXN_WARN = JSEXN_ERROR_LIMIT,
+    JSEXN_NOTE,
     JSEXN_LIMIT
 } JSExnType;
 
 typedef struct JSErrorFormatString {
      /** The error message name in ASCII. */
     const char* name;
 
     /** The error format string in ASCII. */
--- a/js/src/jsexn.cpp
+++ b/js/src/jsexn.cpp
@@ -614,17 +614,17 @@ ErrorObject::createConstructor(JSContext
 JS_FRIEND_API(JSFlatString*)
 js::GetErrorTypeName(JSContext* cx, int16_t exnType)
 {
     /*
      * JSEXN_INTERNALERR returns null to prevent that "InternalError: "
      * is prepended before "uncaught exception: "
      */
     if (exnType < 0 || exnType >= JSEXN_LIMIT ||
-        exnType == JSEXN_INTERNALERR || exnType == JSEXN_WARN)
+        exnType == JSEXN_INTERNALERR || exnType == JSEXN_WARN || exnType == JSEXN_NOTE)
     {
         return nullptr;
     }
     JSProtoKey key = GetExceptionProtoKey(JSExnType(exnType));
     return ClassName(key, cx);
 }
 
 void
@@ -644,16 +644,17 @@ js::ErrorToException(JSContext* cx, JSEr
 
     // Find the exception index associated with this error.
     JSErrNum errorNumber = static_cast<JSErrNum>(reportp->errorNumber);
     if (!callback)
         callback = GetErrorMessage;
     const JSErrorFormatString* errorString = callback(userRef, errorNumber);
     JSExnType exnType = errorString ? static_cast<JSExnType>(errorString->exnType) : JSEXN_ERR;
     MOZ_ASSERT(exnType < JSEXN_LIMIT);
+    MOZ_ASSERT(exnType != JSEXN_NOTE);
 
     if (exnType == JSEXN_WARN) {
         // werror must be enabled, so we use JSEXN_ERR.
         MOZ_ASSERT(cx->options().werror());
         exnType = JSEXN_ERR;
     }
 
     // Prevent infinite recursion.
@@ -727,17 +728,17 @@ ErrorReportToString(JSContext* cx, JSErr
     /*
      * We do NOT want to use GetErrorTypeName() here because it will not do the
      * "right thing" for JSEXN_INTERNALERR.  That is, the caller of this API
      * expects that "InternalError: " will be prepended but GetErrorTypeName
      * goes out of its way to avoid this.
      */
     JSExnType type = static_cast<JSExnType>(reportp->exnType);
     RootedString str(cx);
-    if (type != JSEXN_WARN)
+    if (type != JSEXN_WARN && type != JSEXN_NOTE)
         str = ClassName(GetExceptionProtoKey(type), cx);
 
     /*
      * If "str" is null at this point, that means we just want to use
      * message without prefixing it with anything.
      */
     if (str) {
         RootedString separator(cx, JS_NewUCStringCopyN(cx, u": ", 2));
--- a/js/src/jsexn.h
+++ b/js/src/jsexn.h
@@ -66,17 +66,18 @@ static_assert(JSEXN_ERR == 0 &&
               JSProto_Error + JSEXN_SYNTAXERR == JSProto_SyntaxError &&
               JSProto_Error + JSEXN_TYPEERR == JSProto_TypeError &&
               JSProto_Error + JSEXN_URIERR == JSProto_URIError &&
               JSProto_Error + JSEXN_DEBUGGEEWOULDRUN == JSProto_DebuggeeWouldRun &&
               JSProto_Error + JSEXN_WASMCOMPILEERROR == JSProto_CompileError &&
               JSProto_Error + JSEXN_WASMLINKERROR == JSProto_LinkError &&
               JSProto_Error + JSEXN_WASMRUNTIMEERROR == JSProto_RuntimeError &&
               JSEXN_WASMRUNTIMEERROR + 1 == JSEXN_WARN &&
-              JSEXN_WARN + 1 == JSEXN_LIMIT,
+              JSEXN_WARN + 1 == JSEXN_NOTE &&
+              JSEXN_NOTE + 1 == JSEXN_LIMIT,
               "GetExceptionProtoKey and ExnTypeFromProtoKey require that "
               "each corresponding JSExnType and JSProtoKey value be separated "
               "by the same constant value");
 
 static inline JSProtoKey
 GetExceptionProtoKey(JSExnType exn)
 {
     MOZ_ASSERT(JSEXN_ERR <= exn);