Bug 1177892 part 1 - Remove BOOLEAN_TO_JSVAL and STRING_TO_JSVAL. r=evilpie
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 30 Jun 2015 11:20:56 -0700
changeset 274952 6e1b2b8ed9dd5e6e96e2e5167e9aa1f7c9f9b5c0
parent 274951 00b416370c90daac5323b4770d2285d6b1fc4dfc
child 274953 1dd794cb1591eb46944af5a2bf23a070eef55393
push id3140
push usertmielczarek@mozilla.com
push dateWed, 01 Jul 2015 15:52:58 +0000
reviewersevilpie
bugs1177892
milestone42.0a1
Bug 1177892 part 1 - Remove BOOLEAN_TO_JSVAL and STRING_TO_JSVAL. r=evilpie
dom/base/EventSource.cpp
dom/base/WebSocket.cpp
dom/base/nsDOMDataChannel.cpp
dom/base/nsJSEnvironment.cpp
dom/bluetooth/BluetoothUtils.cpp
dom/mobilemessage/MobileMessageCallback.cpp
dom/plugins/base/nsJSNPRuntime.cpp
dom/system/OSFileConstants.cpp
dom/workers/XMLHttpRequest.cpp
js/ipc/JavaScriptShared.cpp
js/public/Value.h
js/src/ctypes/CTypes.cpp
js/src/gdb/tests/test-Root.cpp
js/src/jsapi-tests/testParseJSON.cpp
js/src/jsapi.cpp
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/XPCLocale.cpp
js/xpconnect/src/XPCShellImpl.cpp
js/xpconnect/src/XPCWrappedNativeJSOps.cpp
storage/mozStorageStatementJSHelper.cpp
storage/mozStorageStatementRow.cpp
--- a/dom/base/EventSource.cpp
+++ b/dom/base/EventSource.cpp
@@ -1266,17 +1266,17 @@ EventSource::DispatchAllMessageEvents()
     JS::Rooted<JS::Value> jsData(cx);
     {
       JSString* jsString;
       jsString = JS_NewUCStringCopyN(cx,
                                      message->mData.get(),
                                      message->mData.Length());
       NS_ENSURE_TRUE_VOID(jsString);
 
-      jsData = STRING_TO_JSVAL(jsString);
+      jsData.setString(jsString);
     }
 
     // create an event that uses the MessageEvent interface,
     // which does not bubble, is not cancelable, and has no default action
 
     nsCOMPtr<nsIDOMEvent> event;
     rv = NS_NewDOMMessageEvent(getter_AddRefs(event), this, nullptr, nullptr);
     if (NS_FAILED(rv)) {
--- a/dom/base/WebSocket.cpp
+++ b/dom/base/WebSocket.cpp
@@ -1771,17 +1771,17 @@ WebSocket::CreateAndDispatchMessageEvent
     }
   } else {
     // JS string
     NS_ConvertUTF8toUTF16 utf16Data(aData);
     JSString* jsString;
     jsString = JS_NewUCStringCopyN(aCx, utf16Data.get(), utf16Data.Length());
     NS_ENSURE_TRUE(jsString, NS_ERROR_FAILURE);
 
-    jsData = STRING_TO_JSVAL(jsString);
+    jsData.setString(jsString);
   }
 
   // create an event that uses the MessageEvent interface,
   // which does not bubble, is not cancelable, and has no default action
 
   nsCOMPtr<nsIDOMEvent> event;
   rv = NS_NewDOMMessageEvent(getter_AddRefs(event), this, nullptr, nullptr);
   NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/base/nsDOMDataChannel.cpp
+++ b/dom/base/nsDOMDataChannel.cpp
@@ -394,17 +394,17 @@ nsDOMDataChannel::DoOnMessageAvailable(c
       NS_RUNTIMEABORT("Unknown binary type!");
       return NS_ERROR_UNEXPECTED;
     }
   } else {
     NS_ConvertUTF8toUTF16 utf16data(aData);
     JSString* jsString = JS_NewUCStringCopyN(cx, utf16data.get(), utf16data.Length());
     NS_ENSURE_TRUE(jsString, NS_ERROR_FAILURE);
 
-    jsData = STRING_TO_JSVAL(jsString);
+    jsData.setString(jsString);
   }
 
   nsCOMPtr<nsIDOMEvent> event;
   rv = NS_NewDOMMessageEvent(getter_AddRefs(event), this, nullptr, nullptr);
   NS_ENSURE_SUCCESS(rv,rv);
 
   nsCOMPtr<nsIDOMMessageEvent> messageEvent = do_QueryInterface(event);
   rv = messageEvent->InitMessageEvent(NS_LITERAL_STRING("message"),
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -926,17 +926,17 @@ nsJSContext::AddSupportsPrimitiveTojsval
       nsAutoCString data;
 
       p->GetData(data);
 
 
       JSString *str = ::JS_NewStringCopyN(cx, data.get(), data.Length());
       NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
 
-      *aArgv = STRING_TO_JSVAL(str);
+      aArgv->setString(str);
 
       break;
     }
     case nsISupportsPrimitive::TYPE_STRING : {
       nsCOMPtr<nsISupportsString> p(do_QueryInterface(argPrimitive));
       NS_ENSURE_TRUE(p, NS_ERROR_UNEXPECTED);
 
       nsAutoString data;
@@ -944,28 +944,28 @@ nsJSContext::AddSupportsPrimitiveTojsval
       p->GetData(data);
 
       // cast is probably safe since wchar_t and char16_t are expected
       // to be equivalent; both unsigned 16-bit entities
       JSString *str =
         ::JS_NewUCStringCopyN(cx, data.get(), data.Length());
       NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
 
-      *aArgv = STRING_TO_JSVAL(str);
+      aArgv->setString(str);
       break;
     }
     case nsISupportsPrimitive::TYPE_PRBOOL : {
       nsCOMPtr<nsISupportsPRBool> p(do_QueryInterface(argPrimitive));
       NS_ENSURE_TRUE(p, NS_ERROR_UNEXPECTED);
 
       bool data;
 
       p->GetData(&data);
 
-      *aArgv = BOOLEAN_TO_JSVAL(data);
+      aArgv->setBoolean(data);
 
       break;
     }
     case nsISupportsPrimitive::TYPE_PRUINT8 : {
       nsCOMPtr<nsISupportsPRUint8> p(do_QueryInterface(argPrimitive));
       NS_ENSURE_TRUE(p, NS_ERROR_UNEXPECTED);
 
       uint8_t data;
@@ -1006,17 +1006,17 @@ nsJSContext::AddSupportsPrimitiveTojsval
 
       char data;
 
       p->GetData(&data);
 
       JSString *str = ::JS_NewStringCopyN(cx, &data, 1);
       NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
 
-      *aArgv = STRING_TO_JSVAL(str);
+      aArgv->setString(str);
 
       break;
     }
     case nsISupportsPrimitive::TYPE_PRINT16 : {
       nsCOMPtr<nsISupportsPRInt16> p(do_QueryInterface(argPrimitive));
       NS_ENSURE_TRUE(p, NS_ERROR_UNEXPECTED);
 
       int16_t data;
--- a/dom/bluetooth/BluetoothUtils.cpp
+++ b/dom/bluetooth/BluetoothUtils.cpp
@@ -150,24 +150,24 @@ SetJsObject(JSContext* aContext,
     const BluetoothValue& v = arr[i].value();
 
     switch(v.type()) {
        case BluetoothValue::TnsString: {
         JSString* jsData = JS_NewUCStringCopyN(aContext,
                                      v.get_nsString().BeginReading(),
                                      v.get_nsString().Length());
         NS_ENSURE_TRUE(jsData, false);
-        val = STRING_TO_JSVAL(jsData);
+        val.setString(jsData);
         break;
       }
       case BluetoothValue::Tuint32_t:
         val = INT_TO_JSVAL(v.get_uint32_t());
         break;
       case BluetoothValue::Tbool:
-        val = BOOLEAN_TO_JSVAL(v.get_bool());
+        val.setBoolean(v.get_bool());
         break;
       default:
         BT_WARNING("SetJsObject: Parameter is not handled");
         break;
     }
 
     if (!JS_SetProperty(aContext, aObj,
                         NS_ConvertUTF16toUTF8(arr[i].name()).get(),
@@ -192,17 +192,17 @@ BroadcastSystemMessage(const nsAString& 
     do_GetService("@mozilla.org/system-message-internal;1");
   NS_ENSURE_TRUE(systemMessenger, false);
 
   JS::Rooted<JS::Value> value(cx);
   if (aData.type() == BluetoothValue::TnsString) {
     JSString* jsData = JS_NewUCStringCopyN(cx,
                                            aData.get_nsString().BeginReading(),
                                            aData.get_nsString().Length());
-    value = STRING_TO_JSVAL(jsData);
+    value.setString(jsData);
   } else if (aData.type() == BluetoothValue::TArrayOfBluetoothNamedValue) {
     JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     if (!obj) {
       BT_WARNING("Failed to new JSObject for system message!");
       return false;
     }
 
     if (!SetJsObject(cx, aData, obj)) {
--- a/dom/mobilemessage/MobileMessageCallback.cpp
+++ b/dom/mobilemessage/MobileMessageCallback.cpp
@@ -285,17 +285,17 @@ MobileMessageCallback::NotifyGetSmscAddr
   JSContext* cx = jsapi.cx();
   JSString* smsc = JS_NewUCStringCopyN(cx, aSmscAddress.BeginReading(),
                                        aSmscAddress.Length());
 
   if (!smsc) {
     return NotifyError(nsIMobileMessageCallback::INTERNAL_ERROR);
   }
 
-  JS::Rooted<JS::Value> val(cx, STRING_TO_JSVAL(smsc));
+  JS::Rooted<JS::Value> val(cx, JS::StringValue(smsc));
   return NotifySuccess(val);
 }
 
 NS_IMETHODIMP
 MobileMessageCallback::NotifyGetSmscAddressFailed(int32_t aError)
 {
   return NotifyError(aError);
 }
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -484,17 +484,17 @@ static JS::Value
 NPVariantToJSVal(NPP npp, JSContext *cx, const NPVariant *variant)
 {
   switch (variant->type) {
   case NPVariantType_Void :
     return JS::UndefinedValue();
   case NPVariantType_Null :
     return JS::NullValue();
   case NPVariantType_Bool :
-    return BOOLEAN_TO_JSVAL(NPVARIANT_TO_BOOLEAN(*variant));
+    return JS::BooleanValue(NPVARIANT_TO_BOOLEAN(*variant));
   case NPVariantType_Int32 :
     {
       // Don't use INT_TO_JSVAL directly to prevent bugs when dealing
       // with ints larger than what fits in a integer JS::Value.
       return ::JS_NumberValue(NPVARIANT_TO_INT32(*variant));
     }
   case NPVariantType_Double :
     {
@@ -504,17 +504,17 @@ NPVariantToJSVal(NPP npp, JSContext *cx,
     {
       const NPString *s = &NPVARIANT_TO_STRING(*variant);
       NS_ConvertUTF8toUTF16 utf16String(s->UTF8Characters, s->UTF8Length);
 
       JSString *str =
         ::JS_NewUCStringCopyN(cx, utf16String.get(), utf16String.Length());
 
       if (str) {
-        return STRING_TO_JSVAL(str);
+        return JS::StringValue(str);
       }
 
       break;
     }
   case NPVariantType_Object:
     {
       if (npp) {
         JSObject *obj =
--- a/dom/system/OSFileConstants.cpp
+++ b/dom/system/OSFileConstants.cpp
@@ -819,17 +819,17 @@ JSObject *GetOrCreateObjectProperty(JSCo
 bool SetStringProperty(JSContext *cx, JS::Handle<JSObject*> aObject, const char *aProperty,
                        const nsString aValue)
 {
   if (aValue.IsVoid()) {
     return true;
   }
   JSString* strValue = JS_NewUCStringCopyZ(cx, aValue.get());
   NS_ENSURE_TRUE(strValue, false);
-  JS::Rooted<JS::Value> valValue(cx, STRING_TO_JSVAL(strValue));
+  JS::Rooted<JS::Value> valValue(cx, JS::StringValue(strValue));
   return JS_SetProperty(cx, aObject, aProperty, valValue);
 }
 
 /**
  * Define OS-specific constants.
  *
  * This function creates or uses JS object |OS.Constants| to store
  * all its constants.
@@ -886,33 +886,33 @@ bool DefineOSFileConstants(JSContext *cx
     return false;
   }
 
 #if defined(MOZ_WIDGET_GONK)
     JSString* strVersion = JS_NewStringCopyZ(cx, "Gonk");
     if (!strVersion){
       return false;
     }
-    JS::Rooted<JS::Value> valVersion(cx, STRING_TO_JSVAL(strVersion));
+    JS::Rooted<JS::Value> valVersion(cx, JS::StringValue(strVersion));
     if (!JS_SetProperty(cx, objSys, "Name", valVersion)) {
       return false;
   }
 #else
   nsCOMPtr<nsIXULRuntime> runtime = do_GetService(XULRUNTIME_SERVICE_CONTRACTID);
   if (runtime) {
     nsAutoCString os;
     DebugOnly<nsresult> rv = runtime->GetOS(os);
     MOZ_ASSERT(NS_SUCCEEDED(rv));
 
     JSString* strVersion = JS_NewStringCopyZ(cx, os.get());
     if (!strVersion) {
       return false;
     }
 
-    JS::Rooted<JS::Value> valVersion(cx, STRING_TO_JSVAL(strVersion));
+    JS::Rooted<JS::Value> valVersion(cx, JS::StringValue(strVersion));
     if (!JS_SetProperty(cx, objSys, "Name", valVersion)) {
       return false;
     }
   }
 #endif // defined(MOZ_WIDGET_GONK)
 
 #if defined(DEBUG)
   JS::Rooted<JS::Value> valDebug(cx, JS::TrueValue());
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -2452,17 +2452,17 @@ XMLHttpRequest::GetResponse(JSContext* /
                             mStateData.mResponseText.get(),
                             mStateData.mResponseText.Length());
 
       if (!str) {
         aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
         return;
       }
 
-      mStateData.mResponse = STRING_TO_JSVAL(str);
+      mStateData.mResponse.setString(str);
     }
   }
 
   JS::ExposeValueToActiveJS(mStateData.mResponse);
   aRv = mStateData.mResponseResult;
   aResponse.set(mStateData.mResponse);
 }
 
--- a/js/ipc/JavaScriptShared.cpp
+++ b/js/ipc/JavaScriptShared.cpp
@@ -357,17 +357,17 @@ JavaScriptShared::fromVariant(JSContext*
           return true;
         }
 
         case JSVariant::Tdouble:
           to.set(JS_NumberValue(from.get_double()));
           return true;
 
         case JSVariant::Tbool:
-          to.set(BOOLEAN_TO_JSVAL(from.get_bool()));
+          to.setBoolean(from.get_bool());
           return true;
 
         case JSVariant::TnsString:
         {
           const nsString& old = from.get_nsString();
           JSString* str = JS_NewUCStringCopyN(cx, old.BeginReading(), old.Length());
           if (!str)
               return false;
--- a/js/public/Value.h
+++ b/js/public/Value.h
@@ -1967,35 +1967,23 @@ static inline JS_VALUE_CONSTEXPR jsval
 UINT_TO_JSVAL(uint32_t i)
 {
     return i <= JSVAL_INT_MAX
            ? INT_TO_JSVAL((int32_t)i)
            : DOUBLE_TO_JSVAL((double)i);
 }
 
 static inline jsval
-STRING_TO_JSVAL(JSString* str)
-{
-    return IMPL_TO_JSVAL(STRING_TO_JSVAL_IMPL(str));
-}
-
-static inline jsval
 OBJECT_TO_JSVAL(JSObject* obj)
 {
     if (obj)
         return IMPL_TO_JSVAL(OBJECT_TO_JSVAL_IMPL(obj));
     return IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_NULL, 0));
 }
 
-static inline jsval
-BOOLEAN_TO_JSVAL(bool b)
-{
-    return IMPL_TO_JSVAL(BOOLEAN_TO_JSVAL_IMPL(b));
-}
-
 /* To be GC-safe, privates are tagged as doubles. */
 
 static inline jsval
 PRIVATE_TO_JSVAL(void* ptr)
 {
     return IMPL_TO_JSVAL(PRIVATE_PTR_TO_JSVAL_IMPL(ptr));
 }
 
--- a/js/src/ctypes/CTypes.cpp
+++ b/js/src/ctypes/CTypes.cpp
@@ -3926,17 +3926,17 @@ CType::Create(JSContext* cx,
   if (!typeObj)
     return nullptr;
 
   // Set up the reserved slots.
   JS_SetReservedSlot(typeObj, SLOT_TYPECODE, INT_TO_JSVAL(type));
   if (ffiType)
     JS_SetReservedSlot(typeObj, SLOT_FFITYPE, PRIVATE_TO_JSVAL(ffiType));
   if (name)
-    JS_SetReservedSlot(typeObj, SLOT_NAME, STRING_TO_JSVAL(name));
+    JS_SetReservedSlot(typeObj, SLOT_NAME, StringValue(name));
   JS_SetReservedSlot(typeObj, SLOT_SIZE, size);
   JS_SetReservedSlot(typeObj, SLOT_ALIGN, align);
 
   if (dataProto) {
     // Set up the 'prototype' and 'prototype.constructor' properties.
     RootedObject prototype(cx, JS_NewObjectWithGivenProto(cx, &sCDataProtoClass, dataProto));
     if (!prototype)
       return nullptr;
@@ -4286,17 +4286,17 @@ CType::GetName(JSContext* cx, HandleObje
   jsval string = JS_GetReservedSlot(obj, SLOT_NAME);
   if (!string.isUndefined())
     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));
+  JS_SetReservedSlot(obj, SLOT_NAME, StringValue(name));
   return name;
 }
 
 JSObject*
 CType::GetProtoFromCtor(JSObject* obj, CTypeProtoSlot slot)
 {
   // Get ctypes.{Pointer,Array,Struct}Type.prototype from a reserved slot
   // on the type constructor.
@@ -7081,17 +7081,17 @@ CData::Create(JSContext* cx,
   // set the CData's associated type
   JS_SetReservedSlot(dataObj, SLOT_CTYPE, OBJECT_TO_JSVAL(typeObj));
 
   // Stash the referent object, if any, for GC safety.
   if (refObj)
     JS_SetReservedSlot(dataObj, SLOT_REFERENT, OBJECT_TO_JSVAL(refObj));
 
   // Set our ownership flag.
-  JS_SetReservedSlot(dataObj, SLOT_OWNS, BOOLEAN_TO_JSVAL(ownResult));
+  JS_SetReservedSlot(dataObj, SLOT_OWNS, BooleanValue(ownResult));
 
   // attach the buffer. since it might not be 2-byte aligned, we need to
   // allocate an aligned space for it and store it there. :(
   char** buffer = cx->new_<char*>();
   if (!buffer) {
     JS_ReportOutOfMemory(cx);
     return nullptr;
   }
--- a/js/src/gdb/tests/test-Root.cpp
+++ b/js/src/gdb/tests/test-Root.cpp
@@ -23,17 +23,17 @@ void callee(JS::Handle<JSObject*> obj, J
 
 FRAGMENT(Root, handle) {
   JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
   callee(global, &global);
   (void) global;
 }
 
 FRAGMENT(Root, HeapSlot) {
-  JS::Rooted<jsval> plinth(cx, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, "plinth")));
+  JS::Rooted<jsval> plinth(cx, JS::StringValue(JS_NewStringCopyZ(cx, "plinth")));
   JS::Rooted<JSObject*> array(cx, JS_NewArrayObject(cx, JS::HandleValueArray(plinth)));
 
   breakpoint();
 
   (void) plinth;
   (void) array;
 }
 
--- a/js/src/jsapi-tests/testParseJSON.cpp
+++ b/js/src/jsapi-tests/testParseJSON.cpp
@@ -69,36 +69,36 @@ BEGIN_TEST(testParseJSON_success)
     expected = DOUBLE_TO_JSVAL(std::numeric_limits<double>::infinity());
     CHECK(TryParse(cx, "9e99999", expected));
 
     JS::Rooted<JSFlatString*> str(cx);
 
     const char16_t emptystr[] = { '\0' };
     str = js::NewStringCopyN<CanGC>(cx, emptystr, 0);
     CHECK(str);
-    expected = STRING_TO_JSVAL(str);
+    expected = JS::StringValue(str);
     CHECK(TryParse(cx, "\"\"", expected));
 
     const char16_t nullstr[] = { '\0' };
     str = NewString(cx, nullstr);
     CHECK(str);
-    expected = STRING_TO_JSVAL(str);
+    expected = JS::StringValue(str);
     CHECK(TryParse(cx, "\"\\u0000\"", expected));
 
     const char16_t backstr[] = { '\b' };
     str = NewString(cx, backstr);
     CHECK(str);
-    expected = STRING_TO_JSVAL(str);
+    expected = JS::StringValue(str);
     CHECK(TryParse(cx, "\"\\b\"", expected));
     CHECK(TryParse(cx, "\"\\u0008\"", expected));
 
     const char16_t newlinestr[] = { '\n', };
     str = NewString(cx, newlinestr);
     CHECK(str);
-    expected = STRING_TO_JSVAL(str);
+    expected = JS::StringValue(str);
     CHECK(TryParse(cx, "\"\\n\"", expected));
     CHECK(TryParse(cx, "\"\\u000A\"", expected));
 
 
     // Arrays
     JS::RootedValue v(cx), v2(cx);
     JS::RootedObject obj(cx);
 
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -282,17 +282,17 @@ JS_PUBLIC_API(jsval)
 JS_GetPositiveInfinityValue(JSContext* cx)
 {
     return cx->runtime()->positiveInfinityValue;
 }
 
 JS_PUBLIC_API(jsval)
 JS_GetEmptyStringValue(JSContext* cx)
 {
-    return STRING_TO_JSVAL(cx->runtime()->emptyString);
+    return StringValue(cx->runtime()->emptyString);
 }
 
 JS_PUBLIC_API(JSString*)
 JS_GetEmptyString(JSRuntime* rt)
 {
     MOZ_ASSERT(rt->hasContexts());
     return rt->emptyString;
 }
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -3527,17 +3527,17 @@ XPCJSRuntime::OnJSContextNew(JSContext* 
         RootedString str(cx);
         for (unsigned i = 0; i < IDX_TOTAL_COUNT; i++) {
             str = JS_InternString(cx, mStrings[i]);
             if (!str) {
                 mStrIDs[0] = JSID_VOID;
                 return false;
             }
             mStrIDs[i] = INTERNED_STRING_TO_JSID(cx, str);
-            mStrJSVals[i] = STRING_TO_JSVAL(str);
+            mStrJSVals[i].setString(str);
         }
 
         if (!mozilla::dom::DefineStaticJSVals(cx)) {
             return false;
         }
     }
 
     XPCContext* xpc = new XPCContext(this, cx);
--- a/js/xpconnect/src/XPCLocale.cpp
+++ b/js/xpconnect/src/XPCLocale.cpp
@@ -110,17 +110,17 @@ private:
     changeCaseFnc(autoStr, result);
 
     JSString* ucstr =
       JS_NewUCStringCopyN(cx, result.get(), result.Length());
     if (!ucstr) {
       return false;
     }
 
-    rval.set(STRING_TO_JSVAL(ucstr));
+    rval.setString(ucstr);
     return true;
   }
 
   bool
   Compare(JSContext* cx, HandleString src1, HandleString src2, MutableHandleValue rval)
   {
     nsresult rv;
 
--- a/js/xpconnect/src/XPCShellImpl.cpp
+++ b/js/xpconnect/src/XPCShellImpl.cpp
@@ -707,17 +707,17 @@ env_setProperty(JSContext* cx, HandleObj
     }
 #else
     rv = setenv(name.ptr(), value.ptr(), 1);
 #endif
     if (rv < 0) {
         JS_ReportError(cx, "can't set envariable %s to %s", name.ptr(), value.ptr());
         return false;
     }
-    vp.set(STRING_TO_JSVAL(valstr));
+    vp.setString(valstr);
 #endif /* !defined SOLARIS */
     return result.succeed();
 }
 
 static bool
 env_enumerate(JSContext* cx, HandleObject obj)
 {
     static bool reflected;
--- a/js/xpconnect/src/XPCWrappedNativeJSOps.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeJSOps.cpp
@@ -56,17 +56,17 @@ ToStringGuts(XPCCallContext& ccx)
         return false;
     }
 
     JSString* str = JS_NewStringCopyZ(ccx, sz);
     JS_smprintf_free(sz);
     if (!str)
         return false;
 
-    ccx.SetRetVal(STRING_TO_JSVAL(str));
+    ccx.SetRetVal(JS::StringValue(str));
     return true;
 }
 
 /***************************************************************************/
 
 static bool
 XPC_WN_Shared_ToString(JSContext* cx, unsigned argc, jsval* vp)
 {
--- a/storage/mozStorageStatementJSHelper.cpp
+++ b/storage/mozStorageStatementJSHelper.cpp
@@ -66,17 +66,17 @@ stepFunc(JSContext *aCtx,
     return true;
   }
 
   if (NS_FAILED(rv)) {
     ::JS_ReportError(aCtx, "mozIStorageStatement::step() returned an error");
     return false;
   }
 
-  *_vp = BOOLEAN_TO_JSVAL(hasMore);
+  _vp->setBoolean(hasMore);
   return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 //// StatementJSHelper
 
 nsresult
 StatementJSHelper::getRow(Statement *aStatement,
--- a/storage/mozStorageStatementRow.cpp
+++ b/storage/mozStorageStatementRow.cpp
@@ -75,17 +75,17 @@ StatementRow::GetProperty(nsIXPConnectWr
         static_cast<mozIStorageStatement *>(mStatement)->
           AsSharedWString(idx, &bytes)
       );
       JSString *str = ::JS_NewUCStringCopyN(aCtx, sval, bytes / 2);
       if (!str) {
         *_retval = false;
         return NS_OK;
       }
-      *_vp = STRING_TO_JSVAL(str);
+      _vp->setString(str);
     }
     else if (type == mozIStorageValueArray::VALUE_TYPE_BLOB) {
       uint32_t length;
       const uint8_t *blob = static_cast<mozIStorageStatement *>(mStatement)->
         AsSharedBlob(idx, &length);
       JSObject *obj = ::JS_NewArrayObject(aCtx, length);
       if (!obj) {
         *_retval = false;