Bug 952650 (part 8) - Remove JSVAL_TO_STRING. r=njn.
authorRodrigo Rodriguez Jr. <rrodrigue96@hotmail.com>
Sun, 27 Apr 2014 19:45:46 -0700
changeset 180916 bdc9683e85bab7229e24e7345b8bfbd691828c0a
parent 180915 061b0af0e45b3a7e74def211dcbc7f517b170209
child 180917 762a93154b1e38110d2c063315be84ff9a396d9d
push id26686
push usercbook@mozilla.com
push dateWed, 30 Apr 2014 13:00:57 +0000
treeherdermozilla-central@c8b374bf936b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs952650
milestone32.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 952650 (part 8) - Remove JSVAL_TO_STRING. r=njn.
dom/base/nsJSUtils.h
dom/bindings/BindingUtils.cpp
dom/network/src/TCPSocketParent.cpp
dom/plugins/base/nsJSNPRuntime.cpp
gfx/skia/trunk/src/xml/SkJS.cpp
js/jsd/jsd_val.cpp
js/public/Value.h
js/src/ctypes/CTypes.cpp
js/src/ctypes/Library.cpp
js/src/jsapi-tests/testChromeBuffer.cpp
js/src/jsapi-tests/testConservativeGC.cpp
js/src/jsapi-tests/testIntString.cpp
js/src/jsapi-tests/testLookup.cpp
js/src/jscntxt.cpp
js/src/jsopcode.cpp
js/src/shell/js.cpp
js/xpconnect/src/XPCConvert.cpp
js/xpconnect/src/XPCQuickStubs.h
toolkit/components/places/History.cpp
--- a/dom/base/nsJSUtils.h
+++ b/dom/base/nsJSUtils.h
@@ -180,17 +180,17 @@ public:
       NS_ASSERTION(IsEmpty(), "init() on initialized string");
       nsDependentString* base = this;
       new(base) nsDependentString(chars, length);
       return true;
   }
 
   bool init(JSContext* aContext, const JS::Value &v)
   {
-      return init(aContext, JSVAL_TO_STRING(v));
+      return init(aContext, v.toString());
   }
 
   void init(JSFlatString* fstr)
   {
       MOZ_ASSERT(IsEmpty(), "init() on initialized string");
       new(this) nsDependentJSString(fstr);
   }
 
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -347,17 +347,17 @@ InterfaceObjectToString(JSContext* cx, u
     return false;
   }
 
   JS::Value v = js::GetFunctionNativeReserved(callee,
                                               TOSTRING_CLASS_RESERVED_SLOT);
   const JSClass* clasp = static_cast<const JSClass*>(v.toPrivate());
 
   v = js::GetFunctionNativeReserved(callee, TOSTRING_NAME_RESERVED_SLOT);
-  JSString* jsname = static_cast<JSString*>(JSVAL_TO_STRING(v));
+  JSString* jsname = static_cast<JSString*>(v.toString());
   size_t length;
   const jschar* name = JS_GetInternedStringCharsAndLength(jsname, &length);
 
   if (js::GetObjectJSClass(&args.thisv().toObject()) != clasp) {
     JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr,
                          JSMSG_INCOMPATIBLE_PROTO,
                          NS_ConvertUTF16toUTF8(name).get(), "toString",
                          "object");
--- a/dom/network/src/TCPSocketParent.cpp
+++ b/dom/network/src/TCPSocketParent.cpp
@@ -236,17 +236,17 @@ TCPSocketParent::SendEvent(const nsAStri
 
     } else {
       nsDependentJSString name;
 
       JS::Rooted<JS::Value> val(aCx);
       if (!JS_GetProperty(aCx, obj, "name", &val)) {
         NS_ERROR("No name property on supposed error object");
       } else if (val.isString()) {
-        if (!name.init(aCx, JSVAL_TO_STRING(val))) {
+        if (!name.init(aCx, val.toString())) {
           NS_WARNING("couldn't initialize string");
         }
       }
 
       data = TCPError(name);
     }
   } else {
     NS_ERROR("Unexpected JS value encountered");
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -394,17 +394,17 @@ JSValToNPVariant(NPP npp, JSContext *cx,
       double d = val.toDouble();
       int i;
       if (JS_DoubleIsInt32(d, &i)) {
         INT32_TO_NPVARIANT(i, *variant);
       } else {
         DOUBLE_TO_NPVARIANT(d, *variant);
       }
     } else if (val.isString()) {
-      JSString *jsstr = JSVAL_TO_STRING(val);
+      JSString *jsstr = val.toString();
       size_t length;
       const jschar *chars = ::JS_GetStringCharsZAndLength(cx, jsstr, &length);
       if (!chars) {
           return false;
       }
 
       nsDependentString str(chars, length);
 
--- a/gfx/skia/trunk/src/xml/SkJS.cpp
+++ b/gfx/skia/trunk/src/xml/SkJS.cpp
@@ -113,17 +113,17 @@ global_resolve(JSContext *cx, JSObject *
         if (!id.isString())
             return JS_TRUE;
         path = getenv("PATH");
         if (!path)
             return JS_TRUE;
         path = JS_strdup(cx, path);
         if (!path)
             return JS_FALSE;
-        name = JS_GetStringBytes(JSVAL_TO_STRING(id));
+        name = JS_GetStringBytes(id.toString());
         ok = JS_TRUE;
         for (comp = strtok(path, ":"); comp; comp = strtok(NULL, ":")) {
             if (*comp != '\0') {
                 full = JS_smprintf("%s/%s", comp, name);
                 if (!full) {
                     JS_ReportOutOfMemory(cx);
                     ok = JS_FALSE;
                     break;
--- a/js/jsd/jsd_val.cpp
+++ b/js/jsd/jsd_val.cpp
@@ -175,17 +175,17 @@ jsd_GetValueString(JSDContext* jsdc, JSD
     JS::RootedString string(cx);
     JS::RootedObject scopeObj(cx);
 
     if(jsdval->string)
         return jsdval->string;
 
     /* Reuse the string without copying or re-rooting it */
     if(jsdval->val.isString()) {
-        jsdval->string = JSVAL_TO_STRING(jsdval->val);
+        jsdval->string = jsdval->val.toString();
         return jsdval->string;
     }
 
     /* Objects call JS_ValueToString in their own compartment. */
     scopeObj = !JSVAL_IS_PRIMITIVE(jsdval->val) ? JSVAL_TO_OBJECT(jsdval->val) : jsdc->glob;
     {
         JSAutoCompartment ac(cx, scopeObj);
         AutoSaveExceptionState as(cx);
@@ -196,17 +196,17 @@ jsd_GetValueString(JSDContext* jsdc, JSD
     JSAutoCompartment ac2(cx, jsdc->glob);
     if(string) {
         stringval = STRING_TO_JSVAL(string);
     }
     if(!string || !JS_WrapValue(cx, &stringval)) {
         return nullptr;
     }
 
-    jsdval->string = JSVAL_TO_STRING(stringval);
+    jsdval->string = stringval.toString();
     if(!JS::AddNamedStringRoot(cx, &jsdval->string, "ValueString"))
         jsdval->string = nullptr;
 
     return jsdval->string;
 }
 
 JSString*
 jsd_GetValueFunctionId(JSDContext* jsdc, JSDValue* jsdval)
--- a/js/public/Value.h
+++ b/js/public/Value.h
@@ -1872,23 +1872,16 @@ UINT_TO_JSVAL(uint32_t i)
 }
 
 static inline bool
 JSVAL_IS_NUMBER(jsval v)
 {
     return JSVAL_IS_NUMBER_IMPL(JSVAL_TO_IMPL(v));
 }
 
-static inline JSString *
-JSVAL_TO_STRING(jsval v)
-{
-    MOZ_ASSERT(v.isString());
-    return JSVAL_TO_STRING_IMPL(JSVAL_TO_IMPL(v));
-}
-
 static inline jsval
 STRING_TO_JSVAL(JSString *str)
 {
     return IMPL_TO_JSVAL(STRING_TO_JSVAL_IMPL(str));
 }
 
 static inline JSObject *
 JSVAL_TO_OBJECT(jsval v)
--- a/js/src/ctypes/CTypes.cpp
+++ b/js/src/ctypes/CTypes.cpp
@@ -1820,17 +1820,17 @@ jsvalToBigInteger(JSContext* cx,
     double d = val.toDouble();
     return ConvertExact(d, result);
   }
   if (allowString && val.isString()) {
     // Allow conversion from base-10 or base-16 strings, provided the result
     // fits in IntegerType. (This allows an Int64 or UInt64 object to be passed
     // to the JS array element operator, which will automatically call
     // toString() on the object for us.)
-    return StringToInteger(cx, JSVAL_TO_STRING(val), result);
+    return StringToInteger(cx, val.toString(), result);
   }
   if (!JSVAL_IS_PRIMITIVE(val)) {
     // Allow conversion from an Int64 or UInt64 object directly.
     JSObject* obj = JSVAL_TO_OBJECT(val);
 
     if (UInt64::IsUInt64(obj)) {
       // Make sure the integer fits in IntegerType.
       uint64_t i = Int64Base::GetInt(obj);
@@ -2308,17 +2308,17 @@ ImplicitConvert(JSContext* cx,
   }
 #define DEFINE_CHAR_TYPE(x, y, z) DEFINE_INT_TYPE(x, y, z)
 #define DEFINE_JSCHAR_TYPE(name, type, ffiType)                                \
   case TYPE_##name: {                                                          \
     /* Convert from a 1-character string, regardless of encoding, */           \
     /* or from an integer, provided the result fits in 'type'. */              \
     type result;                                                               \
     if (val.isString()) {                                                \
-      JSString* str = JSVAL_TO_STRING(val);                                    \
+      JSString* str = val.toString();                                    \
       if (str->length() != 1)                                                  \
         return TypeError(cx, #name, val);                                      \
       const jschar *chars = str->getChars(cx);                                 \
       if (!chars)                                                              \
         return false;                                                          \
       result = chars[0];                                                       \
     } else if (!jsvalToInteger(cx, val, &result)) {                            \
       return TypeError(cx, #name, val);                                        \
@@ -2355,17 +2355,17 @@ ImplicitConvert(JSContext* cx,
           break;
         }
       }
 
     } else if (isArgument && val.isString()) {
       // Convert the string for the ffi call. This requires allocating space
       // which the caller assumes ownership of.
       // TODO: Extend this so we can safely convert strings at other times also.
-      JSString* sourceString = JSVAL_TO_STRING(val);
+      JSString* sourceString = val.toString();
       size_t sourceLength = sourceString->length();
       const jschar* sourceChars = sourceString->getChars(cx);
       if (!sourceChars)
         return false;
 
       switch (CType::GetTypeCode(baseType)) {
       case TYPE_char:
       case TYPE_signed_char:
@@ -2431,17 +2431,17 @@ ImplicitConvert(JSContext* cx,
     }
     return TypeError(cx, "pointer", val);
   }
   case TYPE_array: {
     RootedObject baseType(cx, ArrayType::GetBaseType(targetType));
     size_t targetLength = ArrayType::GetLength(targetType);
 
     if (val.isString()) {
-      JSString* sourceString = JSVAL_TO_STRING(val);
+      JSString* sourceString = val.toString();
       size_t sourceLength = sourceString->length();
       const jschar* sourceChars = sourceString->getChars(cx);
       if (!sourceChars)
         return false;
 
       switch (CType::GetTypeCode(baseType)) {
       case TYPE_char:
       case TYPE_signed_char:
@@ -2647,17 +2647,17 @@ ExplicitConvert(JSContext* cx, HandleVal
   }
 #define DEFINE_INT_TYPE(name, type, ffiType)                                   \
   case TYPE_##name: {                                                          \
     /* Convert numeric values with a C-style cast, and */                      \
     /* allow conversion from a base-10 or base-16 string. */                   \
     type result;                                                               \
     if (!jsvalToIntegerExplicit(val, &result) &&                               \
         (!val.isString() ||                                              \
-         !StringToInteger(cx, JSVAL_TO_STRING(val), &result)))                 \
+         !StringToInteger(cx, val.toString(), &result)))                 \
       return TypeError(cx, #name, val);                                        \
     *static_cast<type*>(buffer) = result;                                      \
     break;                                                                     \
   }
 #define DEFINE_WRAPPED_INT_TYPE(x, y, z) DEFINE_INT_TYPE(x, y, z)
 #define DEFINE_CHAR_TYPE(x, y, z) DEFINE_INT_TYPE(x, y, z)
 #define DEFINE_JSCHAR_TYPE(x, y, z) DEFINE_CHAR_TYPE(x, y, z)
 #include "ctypes/typedefs.h"
@@ -3566,17 +3566,17 @@ CType::GetFFIType(JSContext* cx, JSObjec
 
 JSString*
 CType::GetName(JSContext* cx, HandleObject obj)
 {
   JS_ASSERT(CType::IsCType(obj));
 
   jsval string = JS_GetReservedSlot(obj, SLOT_NAME);
   if (!string.isUndefined())
-    return JSVAL_TO_STRING(string);
+    return string.toString();
 
   // Build the type name lazily.
   JSString* name = BuildTypeName(cx, obj);
   if (!name)
     return nullptr;
   JS_SetReservedSlot(obj, SLOT_NAME, STRING_TO_JSVAL(name));
   return name;
 }
@@ -4732,17 +4732,17 @@ StructType::Create(JSContext* cx, unsign
 
   // Get ctypes.StructType.prototype from the ctypes.StructType constructor.
   RootedObject typeProto(cx, CType::GetProtoFromCtor(&args.callee(), SLOT_STRUCTPROTO));
 
   // Create a simple StructType with no defined fields. The result will be
   // non-instantiable as CData, will have no 'prototype' property, and will
   // have undefined size and alignment and no ffi_type.
   RootedObject result(cx, CType::Create(cx, typeProto, NullPtr(), TYPE_struct,
-                                        JSVAL_TO_STRING(name), JSVAL_VOID, JSVAL_VOID, nullptr));
+                                        name.toString(), JSVAL_VOID, JSVAL_VOID, nullptr));
   if (!result)
     return false;
 
   if (args.length() == 2) {
     RootedObject arr(cx, JSVAL_IS_PRIMITIVE(args[1]) ? nullptr : &args[1].toObject());
     if (!arr || !JS_IsArrayObject(cx, arr)) {
       JS_ReportError(cx, "second argument must be an array");
       return false;
@@ -5407,17 +5407,17 @@ PrepareReturnType(JSContext* cx, jsval t
 }
 
 static MOZ_ALWAYS_INLINE bool
 IsEllipsis(JSContext* cx, jsval v, bool* isEllipsis)
 {
   *isEllipsis = false;
   if (!v.isString())
     return true;
-  JSString* str = JSVAL_TO_STRING(v);
+  JSString* str = v.toString();
   if (str->length() != 3)
     return true;
   const jschar* chars = str->getChars(cx);
   if (!chars)
     return false;
   jschar dot = '.';
   *isEllipsis = (chars[0] == dot &&
                  chars[1] == dot &&
--- a/js/src/ctypes/Library.cpp
+++ b/js/src/ctypes/Library.cpp
@@ -54,19 +54,18 @@ Library::Name(JSContext* cx, unsigned ar
   if (args.length() != 1) {
     JS_ReportError(cx, "libraryName takes one argument");
     return false;
   }
 
   Value arg = args[0];
   JSString* str = nullptr;
   if (arg.isString()) {
-    str = JSVAL_TO_STRING(arg);
-  }
-  else {
+    str = arg.toString();
+  } else {
     JS_ReportError(cx, "name argument must be a string");
     return false;
   }
 
   AutoString resultString;
   AppendString(resultString, DLL_PREFIX);
   AppendString(resultString, str);
   AppendString(resultString, DLL_SUFFIX);
@@ -97,17 +96,17 @@ Library::Create(JSContext* cx, jsval pat
     return nullptr;
 
   if (!path.isString()) {
     JS_ReportError(cx, "open takes a string argument");
     return nullptr;
   }
 
   PRLibSpec libSpec;
-  RootedFlatString pathStr(cx, JS_FlattenString(cx, JSVAL_TO_STRING(path)));
+  RootedFlatString pathStr(cx, JS_FlattenString(cx, path.toString()));
   if (!pathStr)
     return nullptr;
 #ifdef XP_WIN
   // On Windows, converting to native charset may corrupt path string.
   // So, we have to use Unicode path directly.
   char16ptr_t pathChars = JS_GetFlatStringChars(pathStr);
   if (!pathChars)
     return nullptr;
--- a/js/src/jsapi-tests/testChromeBuffer.cpp
+++ b/js/src/jsapi-tests/testChromeBuffer.cpp
@@ -134,17 +134,17 @@ BEGIN_TEST(testChromeBuffer)
         JS::CompileOptions options(cx);
         options.setFileAndLine("", 0);
         CHECK(fun = JS_CompileFunction(cx, global, "untrusted", 1, &paramName,
                                        bytes, strlen(bytes), options));
 
         JS::RootedValue rval(cx);
         CHECK(JS_CallFunction(cx, JS::NullPtr(), fun, v, &rval));
         bool match;
-        CHECK(JS_StringEqualsAscii(cx, JSVAL_TO_STRING(rval), "From trusted: InternalError: too much recursion", &match));
+        CHECK(JS_StringEqualsAscii(cx, rval.toString(), "From trusted: InternalError: too much recursion", &match));
         CHECK(match);
     }
 
     /*
      * Check that JS_SaveFrameChain called on the way from content to chrome
      * (say, as done by XPCJSContextSTack::Push) works.
      */
     {
--- a/js/src/jsapi-tests/testConservativeGC.cpp
+++ b/js/src/jsapi-tests/testConservativeGC.cpp
@@ -16,44 +16,44 @@ BEGIN_TEST(testConservativeGC)
     CHECK(v2.isObject());
     char objCopy[sizeof(JSObject)];
     js_memcpy(&objCopy, JSVAL_TO_OBJECT(v2), sizeof(JSObject));
 
     JS::RootedValue v3(cx);
     EVAL("String(Math.PI);", &v3);
     CHECK(v3.isString());
     char strCopy[sizeof(JSString)];
-    js_memcpy(&strCopy, JSVAL_TO_STRING(v3), sizeof(JSString));
+    js_memcpy(&strCopy, v3.toString(), sizeof(JSString));
 
     JS::RootedValue tmp(cx);
     EVAL("({foo2: 'bar2'});", &tmp);
     CHECK(tmp.isObject());
     JS::RootedObject obj2(cx, JSVAL_TO_OBJECT(tmp));
     char obj2Copy[sizeof(JSObject)];
     js_memcpy(&obj2Copy, obj2, sizeof(JSObject));
 
     EVAL("String(Math.sqrt(3));", &tmp);
     CHECK(tmp.isString());
-    JS::RootedString str2(cx, JSVAL_TO_STRING(tmp));
+    JS::RootedString str2(cx, tmp.toString());
     char str2Copy[sizeof(JSString)];
     js_memcpy(&str2Copy, str2, sizeof(JSString));
 
     tmp = JSVAL_NULL;
 
     JS_GC(rt);
 
     EVAL("var a = [];\n"
          "for (var i = 0; i != 10000; ++i) {\n"
          "a.push(i + 0.1, [1, 2], String(Math.sqrt(i)), {a: i});\n"
          "}", &tmp);
 
     JS_GC(rt);
 
     checkObjectFields((JSObject *)objCopy, JSVAL_TO_OBJECT(v2));
-    CHECK(!memcmp(strCopy, JSVAL_TO_STRING(v3), sizeof(strCopy)));
+    CHECK(!memcmp(strCopy, v3.toString(), sizeof(strCopy)));
 
     checkObjectFields((JSObject *)obj2Copy, obj2);
     CHECK(!memcmp(str2Copy, str2, sizeof(str2Copy)));
 
     return true;
 }
 
 bool checkObjectFields(JSObject *savedCopy, JSObject *obj)
--- a/js/src/jsapi-tests/testIntString.cpp
+++ b/js/src/jsapi-tests/testIntString.cpp
@@ -7,36 +7,36 @@
 
 #include "jsapi-tests/tests.h"
 
 BEGIN_TEST(testIntString_bug515273)
 {
     JS::RootedValue v(cx);
 
     EVAL("'1';", &v);
-    JSString *str = JSVAL_TO_STRING(v);
+    JSString *str = v.toString();
     CHECK(JS_StringHasBeenInterned(cx, str));
     CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(str), "1"));
 
     EVAL("'42';", &v);
-    str = JSVAL_TO_STRING(v);
+    str = v.toString();
     CHECK(JS_StringHasBeenInterned(cx, str));
     CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(str), "42"));
 
     EVAL("'111';", &v);
-    str = JSVAL_TO_STRING(v);
+    str = v.toString();
     CHECK(JS_StringHasBeenInterned(cx, str));
     CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(str), "111"));
 
     /* Test other types of static strings. */
     EVAL("'a';", &v);
-    str = JSVAL_TO_STRING(v);
+    str = v.toString();
     CHECK(JS_StringHasBeenInterned(cx, str));
     CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(str), "a"));
 
     EVAL("'bc';", &v);
-    str = JSVAL_TO_STRING(v);
+    str = v.toString();
     CHECK(JS_StringHasBeenInterned(cx, str));
     CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(str), "bc"));
 
     return true;
 }
 END_TEST(testIntString_bug515273)
--- a/js/src/jsapi-tests/testLookup.cpp
+++ b/js/src/jsapi-tests/testLookup.cpp
@@ -53,17 +53,17 @@ bool
 document_resolve(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
                  JS::MutableHandleObject objp)
 {
     // If id is "all", resolve document.all=true.
     JS::RootedValue v(cx);
     if (!JS_IdToValue(cx, id, &v))
         return false;
     if (v.isString()) {
-        JSString *str = JSVAL_TO_STRING(v);
+        JSString *str = v.toString();
         JSFlatString *flatStr = JS_FlattenString(cx, str);
         if (!flatStr)
             return false;
         if (JS_FlatStringEqualsAscii(flatStr, "all")) {
             JS::Rooted<JSObject*> docAll(cx,
                                          JS_NewObject(cx, &DocumentAllClass, JS::NullPtr(), JS::NullPtr()));
             if (!docAll)
                 return false;
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -542,17 +542,17 @@ js::ReportUsageError(JSContext *cx, Hand
 
     RootedValue usage(cx);
     if (!JS_LookupProperty(cx, callee, "usage", &usage))
         return;
 
     if (usage.isUndefined()) {
         JS_ReportError(cx, "%s", msg);
     } else {
-        JSString *str = JSVAL_TO_STRING(usage);
+        JSString *str = usage.toString();
         JS::Anchor<JSString *> a_str(str);
         const jschar *chars = JS_GetStringCharsZ(cx, str);
         if (!chars)
             return;
         JS_ReportError(cx, "%s. Usage: %hs", msg, chars);
     }
 }
 
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -799,17 +799,17 @@ QuoteString(Sprinter *sp, JSString *str,
 
 static bool
 ToDisassemblySource(JSContext *cx, HandleValue v, JSAutoByteString *bytes)
 {
     if (v.isString()) {
         Sprinter sprinter(cx);
         if (!sprinter.init())
             return false;
-        char *nbytes = QuoteString(&sprinter, JSVAL_TO_STRING(v), '"');
+        char *nbytes = QuoteString(&sprinter, v.toString(), '"');
         if (!nbytes)
             return false;
         nbytes = JS_sprintf_append(nullptr, "%s", nbytes);
         if (!nbytes)
             return false;
         bytes->initBytes(nbytes);
         return true;
     }
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -1792,17 +1792,17 @@ GetScriptAndPCArgs(JSContext *cx, unsign
 
     return true;
 }
 
 static JSTrapStatus
 TrapHandler(JSContext *cx, JSScript *, jsbytecode *pc, jsval *rvalArg,
             jsval closure)
 {
-    RootedString str(cx, JSVAL_TO_STRING(closure));
+    RootedString str(cx, closure.toString());
     RootedValue rval(cx, *rvalArg);
 
     ScriptFrameIter iter(cx);
     JS_ASSERT(!iter.done());
 
     /* Debug-mode currently disables Ion compilation. */
     JSAbstractFramePtr frame(iter.abstractFramePtr().raw(), iter.pc());
     RootedScript script(cx, iter.script());
@@ -4926,17 +4926,17 @@ static const JSFunctionSpecWithHelp fuzz
 #undef PROFILING_FUNCTION_COUNT
 #undef CALLGRIND_FUNCTION_COUNT
 #undef VTUNE_FUNCTION_COUNT
 #undef EXTERNAL_FUNCTION_COUNT
 
 static bool
 PrintHelpString(JSContext *cx, jsval v)
 {
-    JSString *str = JSVAL_TO_STRING(v);
+    JSString *str = v.toString();
     JS::Anchor<JSString *> a_str(str);
     const jschar *chars = JS_GetStringCharsZ(cx, str);
     if (!chars)
         return false;
 
     for (const jschar *p = chars; *p; p++)
         fprintf(gOutFile, "%c", char(*p));
 
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -723,17 +723,17 @@ XPCConvert::JSData2Native(void* d, Handl
             nsCOMPtr<nsIVariant> variant = XPCVariant::newVariant(cx, s);
             if (!variant)
                 return false;
 
             variant.forget(static_cast<nsISupports**>(d));
             return true;
         } else if (iid->Equals(NS_GET_IID(nsIAtom)) && s.isString()) {
             // We're trying to pass a string as an nsIAtom.  Let's atomize!
-            JSString* str = JSVAL_TO_STRING(s);
+            JSString* str = s.toString();
             const char16_t* chars = JS_GetStringCharsZ(cx, str);
             if (!chars) {
                 if (pErr)
                     *pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
                 return false;
             }
             uint32_t length = JS_GetStringLength(str);
             nsCOMPtr<nsIAtom> atom =
--- a/js/xpconnect/src/XPCQuickStubs.h
+++ b/js/xpconnect/src/XPCQuickStubs.h
@@ -229,17 +229,17 @@ protected:
     template<class traits>
     JSString* InitOrStringify(JSContext* cx, JS::HandleValue v,
                               JS::MutableHandleValue pval,
                               bool notpassed,
                               StringificationBehavior nullBehavior,
                               StringificationBehavior undefinedBehavior) {
         JSString *s;
         if (v.isString()) {
-            s = JSVAL_TO_STRING(v);
+            s = v.toString();
         } else {
             StringificationBehavior behavior = eStringify;
             if (v.isNull()) {
                 behavior = nullBehavior;
             } else if (v.isUndefined()) {
                 behavior = undefinedBehavior;
             }
 
--- a/toolkit/components/places/History.cpp
+++ b/toolkit/components/places/History.cpp
@@ -323,17 +323,17 @@ GetJSValueAsString(JSContext* aCtx,
 
   // |null| in JS maps to the empty string.
   if (aValue.isNull()) {
     _string.Truncate();
     return;
   }
   size_t length;
   const jschar* chars =
-    JS_GetStringCharsZAndLength(aCtx, JSVAL_TO_STRING(aValue), &length);
+    JS_GetStringCharsZAndLength(aCtx, aValue.toString(), &length);
   if (!chars) {
     _string.SetIsVoid(true);
     return;
   }
   _string.Assign(static_cast<const char16_t*>(chars), length);
 }
 
 /**