Bug 1283855 part 22 - Make GetErrorTypeName take JSContext instead of JSRuntime. r=arai
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 05 Jul 2016 16:49:48 +0200
changeset 303706 eee13ff3e4d86e4edbab4e2e1112edac55de0c5a
parent 303705 bdc9d813908682539916c32134673f30fbcf3fa1
child 303707 358e634a8fd0d7cbd7f321ba80c3097986d004a2
push id79145
push userjandemooij@gmail.com
push dateTue, 05 Jul 2016 14:54:28 +0000
treeherdermozilla-inbound@eee13ff3e4d8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1283855
milestone50.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 1283855 part 22 - Make GetErrorTypeName take JSContext instead of JSRuntime. r=arai
js/src/jsexn.cpp
js/src/jsfriendapi.h
js/src/shell/js.cpp
js/xpconnect/src/nsXPConnect.cpp
--- a/js/src/jsexn.cpp
+++ b/js/src/jsexn.cpp
@@ -505,29 +505,29 @@ ErrorObject::createConstructor(JSContext
     if (!ctor)
         return nullptr;
 
     ctor->as<JSFunction>().setExtendedSlot(0, Int32Value(ExnTypeFromProtoKey(key)));
     return ctor;
 }
 
 JS_FRIEND_API(JSFlatString*)
-js::GetErrorTypeName(JSRuntime* rt, int16_t exnType)
+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)
     {
         return nullptr;
     }
     JSProtoKey key = GetExceptionProtoKey(JSExnType(exnType));
-    return ClassName(key, rt->contextFromMainThread());
+    return ClassName(key, cx);
 }
 
 void
 js::ErrorToException(JSContext* cx, const char* message, JSErrorReport* reportp,
                      JSErrorCallback callback, void* userRef)
 {
     MOZ_ASSERT(reportp);
     MOZ_ASSERT(!JSREPORT_IS_WARNING(reportp->flags));
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -1150,17 +1150,17 @@ CastToJSFreeOp(FreeOp* fop)
 
 /* Implemented in jsexn.cpp. */
 
 /**
  * Get an error type name from a JSExnType constant.
  * Returns nullptr for invalid arguments and JSEXN_INTERNALERR
  */
 extern JS_FRIEND_API(JSFlatString*)
-GetErrorTypeName(JSRuntime* rt, int16_t exnType);
+GetErrorTypeName(JSContext* cx, int16_t exnType);
 
 #ifdef JS_DEBUG
 extern JS_FRIEND_API(unsigned)
 GetEnterCompartmentDepth(JSContext* cx);
 #endif
 
 class RegExpGuard;
 extern JS_FRIEND_API(bool)
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -5868,17 +5868,17 @@ CreateLastWarningObject(JSContext* cx, J
     RootedObject warningObj(cx, JS_NewObject(cx, nullptr));
     if (!warningObj)
         return false;
 
     RootedString nameStr(cx);
     if (report->exnType == JSEXN_WARN)
         nameStr = JS_NewStringCopyZ(cx, "Warning");
     else
-        nameStr = GetErrorTypeName(cx->runtime(), report->exnType);
+        nameStr = GetErrorTypeName(cx, report->exnType);
     if (!nameStr)
         return false;
     RootedValue nameVal(cx, StringValue(nameStr));
     if (!DefineProperty(cx, warningObj, cx->names().name, nameVal))
         return false;
 
     RootedString messageStr(cx, JS_NewUCStringCopyZ(cx, report->ucmessage));
     if (!messageStr)
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -288,17 +288,17 @@ xpc::ErrorReport::LogToConsoleWithStack(
 /* static */
 void
 xpc::ErrorReport::ErrorReportToMessageString(JSErrorReport* aReport,
                                              nsAString& aString)
 {
     aString.Truncate();
     const char16_t* m = aReport->ucmessage;
     if (m) {
-        JSFlatString* name = js::GetErrorTypeName(CycleCollectedJSRuntime::Get()->Runtime(), aReport->exnType);
+        JSFlatString* name = js::GetErrorTypeName(CycleCollectedJSRuntime::Get()->Context(), aReport->exnType);
         if (name) {
             AssignJSFlatString(aString, name);
             aString.AppendLiteral(": ");
         }
         aString.Append(m);
     }
 }