Bug 1177825 - Remove JSVAL_* constants. r=evilpie
authorJan de Mooij <jdemooij@mozilla.com>
Mon, 29 Jun 2015 18:36:44 -0700
changeset 250659 67d1702bfb1f475f414d99ffc4f1cc963e030332
parent 250658 12cdd010b2504fbe77c983a6057f3201d43badd7
child 250660 2e2c01585a9865e3569ae911a156ff643d6f1e18
push id28966
push usercbook@mozilla.com
push dateTue, 30 Jun 2015 11:23:37 +0000
treeherdermozilla-central@291614a686f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersevilpie
bugs1177825
milestone42.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 1177825 - Remove JSVAL_* constants. r=evilpie
dom/base/nsJSEnvironment.cpp
dom/devicestorage/nsDeviceStorage.cpp
dom/ipc/TabChild.cpp
dom/mobilemessage/MobileMessageCallback.cpp
dom/plugins/base/nsJSNPRuntime.cpp
dom/system/OSFileConstants.cpp
dom/workers/XMLHttpRequest.cpp
dom/workers/XMLHttpRequest.h
ipc/testshell/XPCShellEnvironment.cpp
js/ipc/JavaScriptShared.cpp
js/public/Value.h
js/src/ctypes/CTypes.cpp
js/src/jsapi-tests/testArgumentsObject.cpp
js/src/jsapi-tests/testArrayBuffer.cpp
js/src/jsapi-tests/testDeepFreeze.cpp
js/src/jsapi-tests/testFunctionProperties.cpp
js/src/jsapi-tests/testLookup.cpp
js/src/jsapi-tests/testLooselyEqual.cpp
js/src/jsapi-tests/testNewObject.cpp
js/src/jsapi-tests/testObjectEmulatingUndefined.cpp
js/src/jsapi-tests/testParseJSON.cpp
js/src/jsapi-tests/testResolveRecursion.cpp
js/src/jsapi-tests/testXDR.cpp
js/src/jsapi.cpp
js/src/jsapi.h
js/src/vm/Value.cpp
js/xpconnect/src/XPCConvert.cpp
js/xpconnect/src/XPCWrappedNative.cpp
js/xpconnect/src/XPCWrappedNativeJSOps.cpp
js/xpconnect/wrappers/XrayWrapper.cpp
storage/mozStorageStatementJSHelper.cpp
storage/mozStorageStatementRow.cpp
toolkit/devtools/server/nsJSInspector.cpp
xpcom/base/CycleCollectedJSRuntime.cpp
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -1087,22 +1087,22 @@ nsJSContext::AddSupportsPrimitiveTojsval
       break;
     }
     case nsISupportsPrimitive::TYPE_ID :
     case nsISupportsPrimitive::TYPE_PRUINT64 :
     case nsISupportsPrimitive::TYPE_PRINT64 :
     case nsISupportsPrimitive::TYPE_PRTIME :
     case nsISupportsPrimitive::TYPE_VOID : {
       NS_WARNING("Unsupported primitive type used");
-      *aArgv = JSVAL_NULL;
+      aArgv->setNull();
       break;
     }
     default : {
       NS_WARNING("Unknown primitive type used");
-      *aArgv = JSVAL_NULL;
+      aArgv->setNull();
       break;
     }
   }
   return NS_OK;
 }
 
 #ifdef MOZ_JPROF
 
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -1908,22 +1908,22 @@ InterfaceToJsval(nsPIDOMWindow* aWindow,
 
 JS::Value
 nsIFileToJsval(nsPIDOMWindow* aWindow, DeviceStorageFile* aFile)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aWindow);
 
   if (!aFile) {
-    return JSVAL_NULL;
+    return JS::NullValue();
   }
 
   if (aFile->mEditable) {
     // TODO - needs janv's file handle support.
-    return JSVAL_NULL;
+    return JS::NullValue();
   }
 
   nsString fullPath;
   aFile->GetFullPath(fullPath);
 
   // This check is useful to know if somewhere the DeviceStorageFile
   // has not been properly set. Mimetype is not checked because it can be
   // empty.
@@ -2526,17 +2526,17 @@ public:
   {
     MOZ_ASSERT(NS_IsMainThread());
     nsCOMPtr<nsPIDOMWindow> window = mRequest->GetOwner();
     if (!window) {
       return NS_OK;
     }
 
     AutoJSContext cx;
-    JS::Rooted<JS::Value> result(cx, JSVAL_NULL);
+    JS::Rooted<JS::Value> result(cx, JS::NullValue());
 
     if (mFile) {
       result = nsIFileToJsval(window, mFile);
     } else if (mPath.Length()) {
       StringToJsval(window, mPath, &result);
     }
     else {
       result = JS_NumberValue(double(mValue));
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -498,17 +498,17 @@ TabChildBase::GetPresShell() const
   return result.forget();
 }
 
 void
 TabChildBase::DispatchMessageManagerMessage(const nsAString& aMessageName,
                                             const nsAString& aJSONData)
 {
     AutoSafeJSContext cx;
-    JS::Rooted<JS::Value> json(cx, JSVAL_NULL);
+    JS::Rooted<JS::Value> json(cx, JS::NullValue());
     StructuredCloneData cloneData;
     JSAutoStructuredCloneBuffer buffer;
     if (JS_ParseJSON(cx,
                       static_cast<const char16_t*>(aJSONData.BeginReading()),
                       aJSONData.Length(),
                       &json)) {
         WriteStructuredClone(cx, json, buffer, cloneData.mClosure);
         cloneData.mData = buffer.data();
--- a/dom/mobilemessage/MobileMessageCallback.cpp
+++ b/dom/mobilemessage/MobileMessageCallback.cpp
@@ -200,17 +200,17 @@ MobileMessageCallback::NotifyGetMessageF
   return NotifyError(aError);
 }
 
 NS_IMETHODIMP
 MobileMessageCallback::NotifyMessageDeleted(bool *aDeleted, uint32_t aSize)
 {
   if (aSize == 1) {
     AutoJSContext cx;
-    JS::Rooted<JS::Value> val(cx, aDeleted[0] ? JSVAL_TRUE : JSVAL_FALSE);
+    JS::Rooted<JS::Value> val(cx, JS::BooleanValue(*aDeleted));
     return NotifySuccess(val);
   }
 
   AutoJSAPI jsapi;
   if (NS_WARN_IF(!jsapi.Init(mDOMRequest->GetOwner()))) {
     return NS_ERROR_FAILURE;
   }
   JSContext* cx = jsapi.cx();
@@ -229,17 +229,17 @@ MobileMessageCallback::NotifyDeleteMessa
 {
   return NotifyError(aError);
 }
 
 NS_IMETHODIMP
 MobileMessageCallback::NotifyMessageMarkedRead(bool aRead)
 {
   AutoJSContext cx;
-  JS::Rooted<JS::Value> val(cx, aRead ? JSVAL_TRUE : JSVAL_FALSE);
+  JS::Rooted<JS::Value> val(cx, JS::BooleanValue(aRead));
   return NotifySuccess(val);
 }
 
 NS_IMETHODIMP
 MobileMessageCallback::NotifyMarkMessageReadFailed(int32_t aError)
 {
   return NotifyError(aError);
 }
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -482,17 +482,17 @@ LookupNPP(NPObject *npobj);
 
 static JS::Value
 NPVariantToJSVal(NPP npp, JSContext *cx, const NPVariant *variant)
 {
   switch (variant->type) {
   case NPVariantType_Void :
     return JS::UndefinedValue();
   case NPVariantType_Null :
-    return JSVAL_NULL;
+    return JS::NullValue();
   case NPVariantType_Bool :
     return BOOLEAN_TO_JSVAL(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));
     }
--- a/dom/system/OSFileConstants.cpp
+++ b/dom/system/OSFileConstants.cpp
@@ -910,17 +910,17 @@ bool DefineOSFileConstants(JSContext *cx
     JS::Rooted<JS::Value> valVersion(cx, STRING_TO_JSVAL(strVersion));
     if (!JS_SetProperty(cx, objSys, "Name", valVersion)) {
       return false;
     }
   }
 #endif // defined(MOZ_WIDGET_GONK)
 
 #if defined(DEBUG)
-  JS::Rooted<JS::Value> valDebug(cx, JSVAL_TRUE);
+  JS::Rooted<JS::Value> valDebug(cx, JS::TrueValue());
   if (!JS_SetProperty(cx, objSys, "DEBUG", valDebug)) {
     return false;
   }
 #endif
 
 #if defined(HAVE_64BIT_BUILD)
   JS::Rooted<JS::Value> valBits(cx, INT_TO_JSVAL(64));
 #else
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -1182,17 +1182,17 @@ EventRunnable::PreDispatch(JSContext* aC
   if (NS_FAILED(xhr->GetResponseType(mResponseType))) {
     MOZ_ASSERT(false, "This should never fail!");
   }
 
   mResponseTextResult = xhr->GetResponseText(mResponseText);
   if (NS_SUCCEEDED(mResponseTextResult)) {
     mResponseResult = mResponseTextResult;
     if (mResponseText.IsVoid()) {
-      mResponse = JSVAL_NULL;
+      mResponse.setNull();
     }
   }
   else {
     JS::Rooted<JS::Value> response(aCx);
     mResponseResult = xhr->GetResponse(aCx, &response);
     if (NS_SUCCEEDED(mResponseResult)) {
       if (!response.isGCThing()) {
         mResponse = response;
--- a/dom/workers/XMLHttpRequest.h
+++ b/dom/workers/XMLHttpRequest.h
@@ -246,17 +246,17 @@ public:
 
   void
   UpdateState(const StateData& aStateData, bool aUseCachedArrayBufferResponse);
 
   void
   NullResponseText()
   {
     mStateData.mResponseText.SetIsVoid(true);
-    mStateData.mResponse = JSVAL_NULL;
+    mStateData.mResponse.setNull();
   }
 
   bool MozAnon() const
   {
     return mMozAnon;
   }
 
   bool MozSystem() const
--- a/ipc/testshell/XPCShellEnvironment.cpp
+++ b/ipc/testshell/XPCShellEnvironment.cpp
@@ -362,17 +362,17 @@ XPCShellEnvironment::ProcessFile(JSConte
         JS_ClearPendingException(cx);
         JS::CompileOptions options(cx);
         options.setFileAndLine("typein", startline);
         JS::Rooted<JSScript*> script(cx);
         if (JS_CompileScript(cx, buffer, strlen(buffer), options, &script)) {
             JSErrorReporter older;
 
             ok = JS_ExecuteScript(cx, script, &result);
-            if (ok && result != JSVAL_VOID) {
+            if (ok && !result.isUndefined()) {
                 /* Suppress error reports from JS::ToString(). */
                 older = JS_SetErrorReporter(JS_GetRuntime(cx), nullptr);
                 str = JS::ToString(cx, result);
                 JSAutoByteString bytes;
                 if (str)
                     bytes.encodeLatin1(cx, str);
                 JS_SetErrorReporter(JS_GetRuntime(cx), older);
 
@@ -579,17 +579,17 @@ XPCShellEnvironment::EvaluateString(cons
   }
 
   if (aResult) {
       aResult->Truncate();
   }
 
   JS::Rooted<JS::Value> result(cx);
   bool ok = JS_ExecuteScript(cx, script, &result);
-  if (ok && result != JSVAL_VOID) {
+  if (ok && !result.isUndefined()) {
       JSErrorReporter old = JS_SetErrorReporter(JS_GetRuntime(cx), nullptr);
       JSString* str = JS::ToString(cx, result);
       nsAutoJSString autoStr;
       if (str)
           autoStr.init(cx, str);
       JS_SetErrorReporter(JS_GetRuntime(cx), old);
 
       if (!autoStr.IsEmpty() && aResult) {
--- a/js/ipc/JavaScriptShared.cpp
+++ b/js/ipc/JavaScriptShared.cpp
@@ -265,17 +265,17 @@ JavaScriptShared::toVariant(JSContext* c
         *to = UndefinedVariant();
         return true;
 
       case JSTYPE_OBJECT:
       case JSTYPE_FUNCTION:
       {
         RootedObject obj(cx, from.toObjectOrNull());
         if (!obj) {
-            MOZ_ASSERT(from == JSVAL_NULL);
+            MOZ_ASSERT(from.isNull());
             *to = NullVariant();
             return true;
         }
 
         if (xpc_JSObjectIsID(cx, obj)) {
             JSIID iid;
             const nsID* id = xpc_JSObjectToID(cx, obj);
             ConvertID(*id, &iid);
--- a/js/public/Value.h
+++ b/js/public/Value.h
@@ -1671,16 +1671,17 @@ class ValueOperations
   public:
     bool isUndefined() const { return value()->isUndefined(); }
     bool isNull() const { return value()->isNull(); }
     bool isBoolean() const { return value()->isBoolean(); }
     bool isTrue() const { return value()->isTrue(); }
     bool isFalse() const { return value()->isFalse(); }
     bool isNumber() const { return value()->isNumber(); }
     bool isInt32() const { return value()->isInt32(); }
+    bool isInt32(int32_t i32) const { return value()->isInt32(i32); }
     bool isDouble() const { return value()->isDouble(); }
     bool isString() const { return value()->isString(); }
     bool isSymbol() const { return value()->isSymbol(); }
     bool isObject() const { return value()->isObject(); }
     bool isMagic() const { return value()->isMagic(); }
     bool isMagic(JSWhyMagic why) const { return value()->isMagic(why); }
     bool isMarkable() const { return value()->isMarkable(); }
     bool isPrimitive() const { return value()->isPrimitive(); }
@@ -1993,27 +1994,16 @@ BOOLEAN_TO_JSVAL(bool 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));
 }
 
-// JS constants. For efficiency, prefer predicates (e.g. v.isNull()) and
-// constructing values from scratch (e.g. Int32Value(0)).  These constants are
-// stored in memory and initialized at startup, so testing against them and
-// using them requires memory loads and will be correspondingly slow.
-extern JS_PUBLIC_DATA(const jsval) JSVAL_NULL;
-extern JS_PUBLIC_DATA(const jsval) JSVAL_ZERO;
-extern JS_PUBLIC_DATA(const jsval) JSVAL_ONE;
-extern JS_PUBLIC_DATA(const jsval) JSVAL_FALSE;
-extern JS_PUBLIC_DATA(const jsval) JSVAL_TRUE;
-extern JS_PUBLIC_DATA(const jsval) JSVAL_VOID;
-
 namespace JS {
 
 extern JS_PUBLIC_DATA(const HandleValue) NullHandleValue;
 extern JS_PUBLIC_DATA(const HandleValue) UndefinedHandleValue;
 extern JS_PUBLIC_DATA(const HandleValue) TrueHandleValue;
 extern JS_PUBLIC_DATA(const HandleValue) FalseHandleValue;
 
 }
--- a/js/src/ctypes/CTypes.cpp
+++ b/js/src/ctypes/CTypes.cpp
@@ -1884,17 +1884,18 @@ InitTypeClasses(JSContext* cx, HandleObj
   // that are still using jschar (bug 1064935).
   if (!JS_DefineProperty(cx, ctypesObj, "jschar", typeObj_char16_t,
                          JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT))
     return false;
 
   // Create objects representing the special types void_t and voidptr_t.
   RootedObject typeObj(cx,
     CType::DefineBuiltin(cx, ctypesObj, "void_t", CTypeProto, CDataProto, "void",
-                         TYPE_void_t, JSVAL_VOID, JSVAL_VOID, &ffi_type_void));
+                         TYPE_void_t, JS::UndefinedValue(), JS::UndefinedValue(),
+                         &ffi_type_void));
   if (!typeObj)
     return false;
 
   typeObj = PointerType::CreateInternal(cx, typeObj);
   if (!typeObj)
     return false;
   if (!JS_DefineProperty(cx, ctypesObj, "voidptr_t", typeObj,
                          JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT))
@@ -4186,17 +4187,17 @@ CType::TypesEqual(JSObject* t1, JSObject
 
 bool
 CType::GetSafeSize(JSObject* obj, size_t* result)
 {
   MOZ_ASSERT(CType::IsCType(obj));
 
   jsval size = JS_GetReservedSlot(obj, SLOT_SIZE);
 
-  // The "size" property can be an int, a double, or JSVAL_VOID
+  // The "size" property can be an int, a double, or JS::UndefinedValue()
   // (for arrays of undefined length), and must always fit in a size_t.
   if (size.isInt32()) {
     *result = size.toInt32();
     return true;
   }
   if (size.isDouble()) {
     *result = Convert<size_t>(size.toDouble());
     return true;
@@ -4210,32 +4211,33 @@ size_t
 CType::GetSize(JSObject* obj)
 {
   MOZ_ASSERT(CType::IsCType(obj));
 
   jsval size = JS_GetReservedSlot(obj, SLOT_SIZE);
 
   MOZ_ASSERT(!size.isUndefined());
 
-  // The "size" property can be an int, a double, or JSVAL_VOID
+  // The "size" property can be an int, a double, or JS::UndefinedValue()
   // (for arrays of undefined length), and must always fit in a size_t.
-  // For callers who know it can never be JSVAL_VOID, return a size_t directly.
+  // For callers who know it can never be JS::UndefinedValue(), return a size_t
+  // directly.
   if (size.isInt32())
     return size.toInt32();
   return Convert<size_t>(size.toDouble());
 }
 
 bool
 CType::IsSizeDefined(JSObject* obj)
 {
   MOZ_ASSERT(CType::IsCType(obj));
 
   jsval size = JS_GetReservedSlot(obj, SLOT_SIZE);
 
-  // The "size" property can be an int, a double, or JSVAL_VOID
+  // The "size" property can be an int, a double, or JS::UndefinedValue()
   // (for arrays of undefined length), and must always fit in a size_t.
   MOZ_ASSERT(size.isInt32() || size.isDouble() || size.isUndefined());
   return !size.isUndefined();
 }
 
 size_t
 CType::GetAlignment(JSObject* obj)
 {
@@ -4704,17 +4706,17 @@ PointerType::ConstructData(JSContext* cx
     } else if (!JS_ValueToObject(cx, args[1], &thisObj)) {
       return false;
     }
   }
 
   // The third argument is an optional error sentinel that js-ctypes will return
   // if an exception is raised while executing the closure. The type must match
   // the return type of the callback.
-  jsval errVal = JSVAL_VOID;
+  Value errVal = JS::UndefinedValue();
   if (args.length() == 3)
     errVal = args[2];
 
   RootedObject fnObj(cx, &args[0].toObject());
   return FunctionType::ConstructData(cx, baseObj, result, fnObj, thisObj, errVal);
 }
 
 JSObject*
@@ -4925,18 +4927,18 @@ ArrayType::CreateInternal(JSContext* cx,
   // The size of the base type must be defined.
   // If our length is undefined, both our size and length will be undefined.
   size_t baseSize;
   if (!CType::GetSafeSize(baseType, &baseSize)) {
     JS_ReportError(cx, "base size must be defined");
     return nullptr;
   }
 
-  RootedValue sizeVal(cx, JSVAL_VOID);
-  RootedValue lengthVal(cx, JSVAL_VOID);
+  RootedValue sizeVal(cx, JS::UndefinedValue());
+  RootedValue lengthVal(cx, JS::UndefinedValue());
   if (lengthDefined) {
     // Check for overflow, and convert to an int or double as required.
     size_t size = length * baseSize;
     if (length > 0 && size / length != baseSize) {
       JS_ReportError(cx, "size overflow");
       return nullptr;
     }
     if (!SizeTojsval(cx, size, &sizeVal) ||
@@ -5079,17 +5081,17 @@ ArrayType::GetBaseType(JSObject* obj)
 bool
 ArrayType::GetSafeLength(JSObject* obj, size_t* result)
 {
   MOZ_ASSERT(CType::IsCType(obj));
   MOZ_ASSERT(CType::GetTypeCode(obj) == TYPE_array);
 
   jsval length = JS_GetReservedSlot(obj, SLOT_LENGTH);
 
-  // The "length" property can be an int, a double, or JSVAL_VOID
+  // The "length" property can be an int, a double, or JS::UndefinedValue()
   // (for arrays of undefined length), and must always fit in a size_t.
   if (length.isInt32()) {
     *result = length.toInt32();
     return true;
   }
   if (length.isDouble()) {
     *result = Convert<size_t>(length.toDouble());
     return true;
@@ -5104,19 +5106,20 @@ ArrayType::GetLength(JSObject* obj)
 {
   MOZ_ASSERT(CType::IsCType(obj));
   MOZ_ASSERT(CType::GetTypeCode(obj) == TYPE_array);
 
   jsval length = JS_GetReservedSlot(obj, SLOT_LENGTH);
 
   MOZ_ASSERT(!length.isUndefined());
 
-  // The "length" property can be an int, a double, or JSVAL_VOID
+  // The "length" property can be an int, a double, or JS::UndefinedValue()
   // (for arrays of undefined length), and must always fit in a size_t.
-  // For callers who know it can never be JSVAL_VOID, return a size_t directly.
+  // For callers who know it can never be JS::UndefinedValue(), return a size_t
+  // directly.
   if (length.isInt32())
     return length.toInt32();
   return Convert<size_t>(length.toDouble());
 }
 
 UniquePtrFFIType
 ArrayType::BuildFFIType(JSContext* cx, JSObject* obj)
 {
@@ -5436,17 +5439,18 @@ 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,
-                                        name.toString(), JSVAL_VOID, JSVAL_VOID, nullptr));
+                                        name.toString(), JS::UndefinedValue(),
+                                        JS::UndefinedValue(), nullptr));
   if (!result)
     return false;
 
   if (args.length() == 2) {
     RootedObject arr(cx, args[1].isPrimitive() ? nullptr : &args[1].toObject());
     if (!arr || !JS_IsArrayObject(cx, arr)) {
       return ArgumentTypeMismatch(cx, "second ", "StructType", "an array");
     }
@@ -6421,17 +6425,18 @@ FunctionType::CreateInternal(JSContext* 
   if (!typeProto)
     return nullptr;
   RootedObject dataProto(cx, CType::GetProtoFromType(cx, returnType, SLOT_FUNCTIONDATAPROTO));
   if (!dataProto)
     return nullptr;
 
   // Create a new CType object with the common properties and slots.
   RootedObject typeObj(cx, CType::Create(cx, typeProto, dataProto, TYPE_function,
-                                         nullptr, JSVAL_VOID, JSVAL_VOID, nullptr));
+                                         nullptr, JS::UndefinedValue(),
+                                         JS::UndefinedValue(), nullptr));
   if (!typeObj)
     return nullptr;
 
   // Determine and check the types, and prepare the function CIF.
   if (!CreateFunctionInfo(cx, typeObj, abi, returnType, args))
       return nullptr;
 
   return typeObj;
@@ -7946,17 +7951,17 @@ CDataFinalizer::Methods::Dispose(JSConte
   MOZ_ASSERT(valCodePtrType.isObject());
   JSObject* objCodePtrType = &valCodePtrType.toObject();
 
   JSObject* objCodeType = PointerType::GetBaseType(objCodePtrType);
   MOZ_ASSERT(objCodeType);
   MOZ_ASSERT(CType::GetTypeCode(objCodeType) == TYPE_function);
 
   RootedObject resultType(cx, FunctionType::GetFunctionInfo(objCodeType)->mReturnType);
-  RootedValue result(cx, JSVAL_VOID);
+  RootedValue result(cx, JS::UndefinedValue());
 
   int errnoStatus;
 #if defined(XP_WIN)
   int32_t lastErrorStatus;
   CDataFinalizer::CallFinalizer(p, &errnoStatus, &lastErrorStatus);
 #else
   CDataFinalizer::CallFinalizer(p, &errnoStatus, nullptr);
 #endif // defined(XP_WIN)
@@ -8024,17 +8029,17 @@ CDataFinalizer::Cleanup(CDataFinalizer::
   if (!obj) {
     return;  // No slots to clean up
   }
 
   MOZ_ASSERT(CDataFinalizer::IsCDataFinalizer(obj));
 
   JS_SetPrivate(obj, nullptr);
   for (int i = 0; i < CDATAFINALIZER_SLOTS; ++i) {
-    JS_SetReservedSlot(obj, i, JSVAL_NULL);
+    JS_SetReservedSlot(obj, i, JS::NullValue());
   }
 }
 
 
 /*******************************************************************************
 ** Int64 and UInt64 implementation
 *******************************************************************************/
 
--- a/js/src/jsapi-tests/testArgumentsObject.cpp
+++ b/js/src/jsapi-tests/testArgumentsObject.cpp
@@ -89,17 +89,17 @@ ExhaustiveTest(const char funcode[])
 
     for (size_t i = 0; i <= ArgCount; i++) {
         for (size_t j = 0; j <= ArgCount - i; j++) {
             ClearElements(elems);
             CHECK(argsobj->maybeGetElements(i, j, elems.begin()));
             for (size_t k = 0; k < j; k++)
                 CHECK_SAME(elems[k], INT_TO_JSVAL(i + k));
             for (size_t k = j; k < MAX_ELEMS - 1; k++)
-                CHECK_SAME(elems[k], JSVAL_NULL);
+                CHECK(elems[k].isNull());
             CHECK_SAME(elems[MAX_ELEMS - 1], INT_TO_JSVAL(42));
         }
     }
 
     return true;
 }
 
 template <size_t N>
--- a/js/src/jsapi-tests/testArrayBuffer.cpp
+++ b/js/src/jsapi-tests/testArrayBuffer.cpp
@@ -63,19 +63,19 @@ BEGIN_TEST(testArrayBuffer_bug720949_ste
         CHECK_SAME(v, INT_TO_JSVAL(0));
         CHECK(JS_GetProperty(cx, view, "byteLength", &v));
         CHECK_SAME(v, INT_TO_JSVAL(0));
         CHECK(JS_GetProperty(cx, view, "byteOffset", &v));
         CHECK_SAME(v, INT_TO_JSVAL(0));
         CHECK(JS_GetProperty(cx, view, "length", &v));
         CHECK_SAME(v, INT_TO_JSVAL(0));
         CHECK_EQUAL(JS_GetArrayBufferByteLength(obj), 0u);
-        v = JSVAL_VOID;
+        v.setUndefined();
         JS_GetElement(cx, obj, 0, &v);
-        CHECK_SAME(v, JSVAL_VOID);
+        CHECK(v.isUndefined());
 
         // Transfer to a new ArrayBuffer
         JS::RootedObject dst(cx, JS_NewArrayBufferWithContents(cx, size, contents));
         CHECK(JS_IsArrayBufferObject(dst));
         {
             JS::AutoCheckCannotGC nogc;
             (void) JS_GetArrayBufferData(obj, nogc);
         }
--- a/js/src/jsapi-tests/testDeepFreeze.cpp
+++ b/js/src/jsapi-tests/testDeepFreeze.cpp
@@ -9,17 +9,17 @@
 
 BEGIN_TEST(testDeepFreeze_bug535703)
 {
     JS::RootedValue v(cx);
     EVAL("var x = {}; x;", &v);
     JS::RootedObject obj(cx, v.toObjectOrNull());
     CHECK(JS_DeepFreezeObject(cx, obj));  // don't crash
     EVAL("Object.isFrozen(x)", &v);
-    CHECK_SAME(v, JSVAL_TRUE);
+    CHECK(v.isTrue());
     return true;
 }
 END_TEST(testDeepFreeze_bug535703)
 
 BEGIN_TEST(testDeepFreeze_deep)
 {
     JS::RootedValue a(cx), o(cx);
     EXEC("var a = {}, o = a;\n"
@@ -28,33 +28,33 @@ BEGIN_TEST(testDeepFreeze_deep)
     EVAL("a", &a);
     EVAL("o", &o);
 
     JS::RootedObject aobj(cx, a.toObjectOrNull());
     CHECK(JS_DeepFreezeObject(cx, aobj));
 
     JS::RootedValue b(cx);
     EVAL("Object.isFrozen(a)", &b);
-    CHECK_SAME(b, JSVAL_TRUE);
+    CHECK(b.isTrue());
     EVAL("Object.isFrozen(o)", &b);
-    CHECK_SAME(b, JSVAL_TRUE);
+    CHECK(b.isTrue());
     return true;
 }
 END_TEST(testDeepFreeze_deep)
 
 BEGIN_TEST(testDeepFreeze_loop)
 {
     JS::RootedValue x(cx), y(cx);
     EXEC("var x = [], y = {x: x}; y.y = y; x.push(x, y);");
     EVAL("x", &x);
     EVAL("y", &y);
 
     JS::RootedObject xobj(cx, x.toObjectOrNull());
     CHECK(JS_DeepFreezeObject(cx, xobj));
 
     JS::RootedValue b(cx);
     EVAL("Object.isFrozen(x)", &b);
-    CHECK_SAME(b, JSVAL_TRUE);
+    CHECK(b.isTrue());
     EVAL("Object.isFrozen(y)", &b);
-    CHECK_SAME(b, JSVAL_TRUE);
+    CHECK(b.isTrue());
     return true;
 }
 END_TEST(testDeepFreeze_loop)
--- a/js/src/jsapi-tests/testFunctionProperties.cpp
+++ b/js/src/jsapi-tests/testFunctionProperties.cpp
@@ -11,16 +11,16 @@ BEGIN_TEST(testFunctionProperties)
 {
     JS::RootedValue x(cx);
     EVAL("(function f() {})", &x);
 
     JS::RootedObject obj(cx, x.toObjectOrNull());
 
     JS::RootedValue y(cx);
     CHECK(JS_GetProperty(cx, obj, "arguments", &y));
-    CHECK_SAME(y, JSVAL_NULL);
+    CHECK(y.isNull());
 
     CHECK(JS_GetProperty(cx, obj, "caller", &y));
-    CHECK_SAME(y, JSVAL_NULL);
+    CHECK(y.isNull());
 
     return true;
 }
 END_TEST(testFunctionProperties)
--- a/js/src/jsapi-tests/testLookup.cpp
+++ b/js/src/jsapi-tests/testLookup.cpp
@@ -14,17 +14,17 @@
 BEGIN_TEST(testLookup_bug522590)
 {
     // Define a function that makes method-bearing objects.
     JS::RootedValue x(cx);
     EXEC("function mkobj() { return {f: function () {return 2;}} }");
 
     // Calling mkobj() multiple times must create multiple functions in ES5.
     EVAL("mkobj().f !== mkobj().f", &x);
-    CHECK_SAME(x, JSVAL_TRUE);
+    CHECK(x.isTrue());
 
     // Now make x.f a method.
     EVAL("mkobj()", &x);
     JS::RootedObject xobj(cx, x.toObjectOrNull());
 
     // This lookup must not return an internal function object.
     JS::RootedValue r(cx);
     CHECK(JS_GetProperty(cx, xobj, "f", &r));
@@ -81,14 +81,14 @@ static const JSClass document_class = {
 
 BEGIN_TEST(testLookup_bug570195)
 {
     JS::RootedObject obj(cx, JS_NewObject(cx, &document_class));
     CHECK(obj);
     CHECK(JS_DefineProperty(cx, global, "document", obj, 0));
     JS::RootedValue v(cx);
     EVAL("document.all ? true : false", &v);
-    CHECK_SAME(v, JSVAL_FALSE);
+    CHECK(v.isFalse());
     EVAL("document.hasOwnProperty('all')", &v);
-    CHECK_SAME(v, JSVAL_TRUE);
+    CHECK(v.isTrue());
     return true;
 }
 END_TEST(testLookup_bug570195)
--- a/js/src/jsapi-tests/testLooselyEqual.cpp
+++ b/js/src/jsapi-tests/testLooselyEqual.cpp
@@ -50,18 +50,18 @@ struct LooseEqualityData
         obj(cx),
         poszero(cx),
         negzero(cx)
     {
         qNaN = DOUBLE_TO_JSVAL(numeric_limits<double>::quiet_NaN());
         sNaN = DOUBLE_TO_JSVAL(numeric_limits<double>::signaling_NaN());
         d42 = DOUBLE_TO_JSVAL(42.0);
         i42 = INT_TO_JSVAL(42);
-        undef = JSVAL_VOID;
-        null = JSVAL_NULL;
+        undef = JS::UndefinedValue();
+        null = JS::NullValue();
         obj = OBJECT_TO_JSVAL(JS::CurrentGlobalOrNull(cx));
         poszero = DOUBLE_TO_JSVAL(0.0);
         negzero = DOUBLE_TO_JSVAL(-0.0);
 #ifdef XP_WIN
 # define copysign _copysign
 #endif
         MOZ_RELEASE_ASSERT(copysign(1.0, poszero.toDouble()) == 1.0);
         MOZ_RELEASE_ASSERT(copysign(1.0, negzero.toDouble()) == -1.0);
--- a/js/src/jsapi-tests/testNewObject.cpp
+++ b/js/src/jsapi-tests/testNewObject.cpp
@@ -101,13 +101,13 @@ BEGIN_TEST(testNewObject_1)
         nullptr, nullptr, nullptr, constructHook
     };
     JS::RootedObject ctor(cx, JS_NewObject(cx, &cls));
     CHECK(ctor);
     JS::RootedValue rt2(cx, OBJECT_TO_JSVAL(ctor));
     obj = JS_New(cx, ctor, JS::HandleValueArray::subarray(argv, 0, 3));
     CHECK(obj);
     CHECK(JS_GetElement(cx, ctor, 0, &v));
-    CHECK_SAME(v, JSVAL_ZERO);
+    CHECK(v.isInt32(0));
 
     return true;
 }
 END_TEST(testNewObject_1)
--- a/js/src/jsapi-tests/testObjectEmulatingUndefined.cpp
+++ b/js/src/jsapi-tests/testObjectEmulatingUndefined.cpp
@@ -24,80 +24,80 @@ BEGIN_TEST(testObjectEmulatingUndefined_
 {
     CHECK(JS_InitClass(cx, global, nullptr, &ObjectEmulatingUndefinedClass,
                        ObjectEmulatingUndefinedConstructor, 0,
                        nullptr, nullptr, nullptr, nullptr));
 
     JS::RootedValue result(cx);
 
     EVAL("if (new ObjectEmulatingUndefined()) true; else false;", &result);
-    CHECK_SAME(result, JSVAL_FALSE);
+    CHECK(result.isFalse());
 
     EVAL("if (!new ObjectEmulatingUndefined()) true; else false;", &result);
-    CHECK_SAME(result, JSVAL_TRUE);
+    CHECK(result.isTrue());
 
     EVAL("var obj = new ObjectEmulatingUndefined(); \n"
          "var res = []; \n"
          "for (var i = 0; i < 50; i++) \n"
          "  res.push(Boolean(obj)); \n"
          "res.every(function(v) { return v === false; });",
          &result);
-    CHECK_SAME(result, JSVAL_TRUE);
+    CHECK(result.isTrue());
 
     return true;
 }
 END_TEST(testObjectEmulatingUndefined_truthy)
 
 BEGIN_TEST(testObjectEmulatingUndefined_equal)
 {
     CHECK(JS_InitClass(cx, global, nullptr, &ObjectEmulatingUndefinedClass,
                        ObjectEmulatingUndefinedConstructor, 0,
                        nullptr, nullptr, nullptr, nullptr));
 
     JS::RootedValue result(cx);
 
     EVAL("if (new ObjectEmulatingUndefined() == undefined) true; else false;", &result);
-    CHECK_SAME(result, JSVAL_TRUE);
+    CHECK(result.isTrue());
 
     EVAL("if (new ObjectEmulatingUndefined() == null) true; else false;", &result);
-    CHECK_SAME(result, JSVAL_TRUE);
+    CHECK(result.isTrue());
 
     EVAL("if (new ObjectEmulatingUndefined() != undefined) true; else false;", &result);
-    CHECK_SAME(result, JSVAL_FALSE);
+    CHECK(result.isFalse());
 
     EVAL("if (new ObjectEmulatingUndefined() != null) true; else false;", &result);
-    CHECK_SAME(result, JSVAL_FALSE);
+    CHECK(result.isFalse());
 
     EVAL("var obj = new ObjectEmulatingUndefined(); \n"
          "var res = []; \n"
          "for (var i = 0; i < 50; i++) \n"
          "  res.push(obj == undefined); \n"
          "res.every(function(v) { return v === true; });",
          &result);
-    CHECK_SAME(result, JSVAL_TRUE);
+    CHECK(result.isTrue());
 
     EVAL("var obj = new ObjectEmulatingUndefined(); \n"
          "var res = []; \n"
          "for (var i = 0; i < 50; i++) \n"
          "  res.push(obj == null); \n"
          "res.every(function(v) { return v === true; });",
          &result);
-    CHECK_SAME(result, JSVAL_TRUE);
+    CHECK(result.isTrue());
 
     EVAL("var obj = new ObjectEmulatingUndefined(); \n"
          "var res = []; \n"
          "for (var i = 0; i < 50; i++) \n"
          "  res.push(obj != undefined); \n"
          "res.every(function(v) { return v === false; });",
          &result);
-    CHECK_SAME(result, JSVAL_TRUE);
+    CHECK(result.isTrue());
 
     EVAL("var obj = new ObjectEmulatingUndefined(); \n"
          "var res = []; \n"
          "for (var i = 0; i < 50; i++) \n"
          "  res.push(obj != null); \n"
          "res.every(function(v) { return v === false; });",
          &result);
-    CHECK_SAME(result, JSVAL_TRUE);
+    CHECK(result.isTrue());
 
     return true;
 }
 END_TEST(testObjectEmulatingUndefined_equal)
--- a/js/src/jsapi-tests/testParseJSON.cpp
+++ b/js/src/jsapi-tests/testParseJSON.cpp
@@ -34,23 +34,23 @@ class AutoInflatedString {
     const char16_t* chars() const { return chars_; }
     size_t length() const { return length_; }
 };
 
 BEGIN_TEST(testParseJSON_success)
 {
     // Primitives
     JS::RootedValue expected(cx);
-    expected = JSVAL_TRUE;
+    expected = JS::TrueValue();
     CHECK(TryParse(cx, "true", expected));
 
-    expected = JSVAL_FALSE;
+    expected = JS::FalseValue();
     CHECK(TryParse(cx, "false", expected));
 
-    expected = JSVAL_NULL;
+    expected = JS::NullValue();
     CHECK(TryParse(cx, "null", expected));
 
     expected = INT_TO_JSVAL(0);
     CHECK(TryParse(cx, "0", expected));
 
     expected = INT_TO_JSVAL(1);
     CHECK(TryParse(cx, "1", expected));
 
@@ -102,26 +102,26 @@ BEGIN_TEST(testParseJSON_success)
     JS::RootedValue v(cx), v2(cx);
     JS::RootedObject obj(cx);
 
     CHECK(Parse(cx, "[]", &v));
     CHECK(v.isObject());
     obj = &v.toObject();
     CHECK(JS_IsArrayObject(cx, obj));
     CHECK(JS_GetProperty(cx, obj, "length", &v2));
-    CHECK_SAME(v2, JSVAL_ZERO);
+    CHECK(v2.isInt32(0));
 
     CHECK(Parse(cx, "[1]", &v));
     CHECK(v.isObject());
     obj = &v.toObject();
     CHECK(JS_IsArrayObject(cx, obj));
     CHECK(JS_GetProperty(cx, obj, "0", &v2));
-    CHECK_SAME(v2, JSVAL_ONE);
+    CHECK(v2.isInt32(1));
     CHECK(JS_GetProperty(cx, obj, "length", &v2));
-    CHECK_SAME(v2, JSVAL_ONE);
+    CHECK(v2.isInt32(1));
 
 
     // Objects
     CHECK(Parse(cx, "{}", &v));
     CHECK(v.isObject());
     obj = &v.toObject();
     CHECK(!JS_IsArrayObject(cx, obj));
 
@@ -356,12 +356,12 @@ BEGIN_TEST(testParseJSON_reviver)
 
 template<size_t N> inline bool
 TryParse(JSContext* cx, const char (&input)[N], JS::HandleValue filter)
 {
     AutoInflatedString str(cx);
     JS::RootedValue v(cx);
     str = input;
     CHECK(JS_ParseJSONWithReviver(cx, str.chars(), str.length(), filter, &v));
-    CHECK_SAME(v, JSVAL_NULL);
+    CHECK(v.isNull());
     return true;
 }
 END_TEST(testParseJSON_reviver)
--- a/js/src/jsapi-tests/testResolveRecursion.cpp
+++ b/js/src/jsapi-tests/testResolveRecursion.cpp
@@ -37,17 +37,17 @@ BEGIN_TEST(testResolveRecursion)
     CHECK(JS_DefineProperty(cx, global, "obj2", obj2Val, 0));
 
     resolveEntryCount = 0;
     resolveExitCount = 0;
 
     /* Start the essence of the test via invoking the first resolve hook. */
     JS::RootedValue v(cx);
     EVAL("obj1.x", &v);
-    CHECK_SAME(v, JSVAL_FALSE);
+    CHECK(v.isFalse());
     CHECK_EQUAL(resolveEntryCount, 4);
     CHECK_EQUAL(resolveExitCount, 4);
 
     obj1 = nullptr;
     obj2 = nullptr;
     return true;
 }
 
@@ -81,49 +81,49 @@ doResolve(JS::HandleObject obj, JS::Hand
     JSFlatString* str = JS_FlattenString(cx, JSID_TO_STRING(id));
     CHECK(str);
     JS::RootedValue v(cx);
     if (JS_FlatStringEqualsAscii(str, "x")) {
         if (obj == obj1) {
             /* First resolve hook invocation. */
             CHECK_EQUAL(resolveEntryCount, 1);
             EVAL("obj2.y = true", &v);
-            CHECK_SAME(v, JSVAL_TRUE);
+            CHECK(v.isTrue());
             CHECK(JS_DefinePropertyById(cx, obj, id, JS::FalseHandleValue, JSPROP_RESOLVING));
             *resolvedp = true;
             return true;
         }
         if (obj == obj2) {
             CHECK_EQUAL(resolveEntryCount, 4);
             *resolvedp = false;
             return true;
         }
     } else if (JS_FlatStringEqualsAscii(str, "y")) {
         if (obj == obj2) {
             CHECK_EQUAL(resolveEntryCount, 2);
             CHECK(JS_DefinePropertyById(cx, obj, id, JS::NullHandleValue, JSPROP_RESOLVING));
             EVAL("obj1.x", &v);
             CHECK(v.isUndefined());
             EVAL("obj1.y", &v);
-            CHECK_SAME(v, JSVAL_ZERO);
+            CHECK(v.isInt32(0));
             *resolvedp = true;
             return true;
         }
         if (obj == obj1) {
             CHECK_EQUAL(resolveEntryCount, 3);
             EVAL("obj1.x", &v);
             CHECK(v.isUndefined());
             EVAL("obj1.y", &v);
             CHECK(v.isUndefined());
             EVAL("obj2.y", &v);
             CHECK(v.isNull());
             EVAL("obj2.x", &v);
             CHECK(v.isUndefined());
             EVAL("obj1.y = 0", &v);
-            CHECK_SAME(v, JSVAL_ZERO);
+            CHECK(v.isInt32(0));
             *resolvedp = true;
             return true;
         }
     }
     CHECK(false);
     return false;
 }
 
--- a/js/src/jsapi-tests/testXDR.cpp
+++ b/js/src/jsapi-tests/testXDR.cpp
@@ -62,17 +62,17 @@ BEGIN_TEST(testXDR_bug506491)
     JS::RootedValue v2(cx);
     CHECK(JS_ExecuteScript(cx, script, &v2));
 
     // try to break the Block object that is the parent of f
     JS_GC(rt);
 
     // confirm
     EVAL("f() === 'ok';\n", &v2);
-    JS::RootedValue trueval(cx, JSVAL_TRUE);
+    JS::RootedValue trueval(cx, JS::TrueValue());
     CHECK_SAME(v2, trueval);
     return true;
 }
 END_TEST(testXDR_bug506491)
 
 BEGIN_TEST(testXDR_bug516827)
 {
     // compile an empty script
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1434,17 +1434,17 @@ JS::CurrentGlobalOrNull(JSContext* cx)
 
 JS_PUBLIC_API(jsval)
 JS_ComputeThis(JSContext* cx, jsval* vp)
 {
     AssertHeapIsIdle(cx);
     assertSameCompartment(cx, JSValueArray(vp, 2));
     CallReceiver call = CallReceiverFromVp(vp);
     if (!BoxNonStrictThis(cx, call))
-        return JSVAL_NULL;
+        return NullValue();
     return call.thisv();
 }
 
 JS_PUBLIC_API(void*)
 JS_malloc(JSContext* cx, size_t nbytes)
 {
     AssertHeapIsIdle(cx);
     CHECK_REQUEST(cx);
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -2509,17 +2509,17 @@ JS_New(JSContext* cx, JS::HandleObject c
 struct JSPropertyDescriptor {
     JSObject* obj;
     unsigned attrs;
     JSGetterOp getter;
     JSSetterOp setter;
     JS::Value value;
 
     JSPropertyDescriptor()
-      : obj(nullptr), attrs(0), getter(nullptr), setter(nullptr), value(JSVAL_VOID)
+      : obj(nullptr), attrs(0), getter(nullptr), setter(nullptr), value(JS::UndefinedValue())
     {}
 
     void trace(JSTracer* trc);
 
     static js::ThingRootKind rootKind() { return js::THING_ROOT_PROPERTY_DESCRIPTOR; }
 };
 
 namespace JS {
--- a/js/src/vm/Value.cpp
+++ b/js/src/vm/Value.cpp
@@ -1,22 +1,20 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "js/Value.h"
 
-const jsval JSVAL_NULL  = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_NULL,      0));
-const jsval JSVAL_ZERO  = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_INT32,     0));
-const jsval JSVAL_ONE   = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_INT32,     1));
-const jsval JSVAL_FALSE = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_BOOLEAN,   false));
-const jsval JSVAL_TRUE  = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_BOOLEAN,   true));
-const jsval JSVAL_VOID  = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_UNDEFINED, 0));
+static const jsval JSVAL_NULL  = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_NULL,      0));
+static const jsval JSVAL_FALSE = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_BOOLEAN,   false));
+static const jsval JSVAL_TRUE  = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_BOOLEAN,   true));
+static const jsval JSVAL_VOID  = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_UNDEFINED, 0));
 
 namespace JS {
 
 const HandleValue NullHandleValue = HandleValue::fromMarkedLocation(&JSVAL_NULL);
 const HandleValue UndefinedHandleValue = HandleValue::fromMarkedLocation(&JSVAL_VOID);
 const HandleValue TrueHandleValue = HandleValue::fromMarkedLocation(&JSVAL_TRUE);
 const HandleValue FalseHandleValue = HandleValue::fromMarkedLocation(&JSVAL_FALSE);
 
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -1269,17 +1269,17 @@ XPCConvert::NativeArray2JS(MutableHandle
     RootedObject array(cx, JS_NewArrayObject(cx, count));
     if (!array)
         return false;
 
     if (pErr)
         *pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
 
     uint32_t i;
-    RootedValue current(cx, JSVAL_NULL);
+    RootedValue current(cx, JS::NullValue());
 
 #define POPULATE(_t)                                                                    \
     PR_BEGIN_MACRO                                                                      \
         for (i = 0; i < count; i++) {                                                   \
             if (!NativeData2JS(&current, ((_t*)*s)+i, type, iid, pErr) ||               \
                 !JS_DefineElement(cx, array, i, current, JSPROP_ENUMERATE))             \
                 goto failure;                                                           \
         }                                                                               \
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -1382,17 +1382,17 @@ XPCWrappedNative::CallMethod(XPCCallCont
     }
 
     return CallMethodHelper(ccx).Call();
 }
 
 bool
 CallMethodHelper::Call()
 {
-    mCallContext.SetRetVal(JSVAL_VOID);
+    mCallContext.SetRetVal(JS::UndefinedValue());
 
     XPCJSRuntime::Get()->SetPendingException(nullptr);
 
     if (mVTableIndex == 0) {
         return QueryInterfaceFastPath();
     }
 
     if (!mMethodInfo) {
@@ -1531,24 +1531,24 @@ bool
 CallMethodHelper::GetOutParamSource(uint8_t paramIndex, MutableHandleValue srcp) const
 {
     const nsXPTParamInfo& paramInfo = mMethodInfo->GetParam(paramIndex);
 
     MOZ_ASSERT(!paramInfo.IsDipper(), "Dipper params are handled separately");
     if (paramInfo.IsOut() && !paramInfo.IsRetval()) {
         MOZ_ASSERT(paramIndex < mArgc || paramInfo.IsOptional(),
                    "Expected either enough arguments or an optional argument");
-        jsval arg = paramIndex < mArgc ? mArgv[paramIndex] : JSVAL_NULL;
+        jsval arg = paramIndex < mArgc ? mArgv[paramIndex] : JS::NullValue();
         if (paramIndex < mArgc) {
             RootedObject obj(mCallContext);
             if (!arg.isPrimitive())
                 obj = &arg.toObject();
             if (!obj || !JS_GetPropertyById(mCallContext, obj, mIdxValueId, srcp)) {
                 // Explicitly passed in unusable value for out param.  Note
-                // that if i >= mArgc we already know that |arg| is JSVAL_NULL,
+                // that if i >= mArgc we already know that |arg| is JS::NullValue(),
                 // and that's ok.
                 ThrowBadParam(NS_ERROR_XPC_NEED_OUT_OBJECT, paramIndex,
                               mCallContext);
                 return false;
             }
         }
     }
 
@@ -1802,17 +1802,17 @@ CallMethodHelper::ConvertIndependentPara
     // Specify the correct storage/calling semantics.
     if (paramInfo.IsIndirect())
         dp->SetIndirect();
 
     // The JSVal proper is always stored within the 'val' union and passed
     // indirectly, regardless of in/out-ness.
     if (type_tag == nsXPTType::T_JSVAL) {
         // Root the value.
-        dp->val.j = JSVAL_VOID;
+        dp->val.j.setUndefined();
         if (!js::AddRawValueRoot(mCallContext, &dp->val.j, "XPCWrappedNative::CallMethod param"))
             return false;
     }
 
     // Flag cleanup for anything that isn't self-contained.
     if (!type.IsArithmetic())
         dp->SetValNeedsCleanup();
 
@@ -1836,19 +1836,19 @@ CallMethodHelper::ConvertIndependentPara
     // so all that's left is 'in'.
     if (!paramInfo.IsOut()) {
         // Handle the 'in' case.
         MOZ_ASSERT(i < mArgc || paramInfo.IsOptional(),
                    "Expected either enough arguments or an optional argument");
         if (i < mArgc)
             src = mArgv[i];
         else if (type_tag == nsXPTType::T_JSVAL)
-            src = JSVAL_VOID;
+            src.setUndefined();
         else
-            src = JSVAL_NULL;
+            src.setNull();
     }
 
     nsID param_iid;
     if (type_tag == nsXPTType::T_INTERFACE &&
         NS_FAILED(mIFaceInfo->GetIIDForParamNoAlloc(mVTableIndex, &paramInfo,
                                                     &param_iid))) {
         ThrowBadParam(NS_ERROR_XPC_CANT_GET_PARAM_IFACE_INFO, i, mCallContext);
         return false;
@@ -1952,17 +1952,17 @@ CallMethodHelper::ConvertDependentParam(
     // We're definitely some variety of 'in' now, so there's something to
     // convert. The source value for conversion depends on whether we're
     // dealing with an 'in' or an 'inout' parameter. 'inout' was handled above,
     // so all that's left is 'in'.
     if (!paramInfo.IsOut()) {
         // Handle the 'in' case.
         MOZ_ASSERT(i < mArgc || paramInfo.IsOptional(),
                      "Expected either enough arguments or an optional argument");
-        src = i < mArgc ? mArgv[i] : JSVAL_NULL;
+        src = i < mArgc ? mArgv[i] : JS::NullValue();
     }
 
     nsID param_iid;
     if (datum_type.IsInterfacePointer() &&
         !GetInterfaceTypeFromParam(i, datum_type, &param_iid))
         return false;
 
     nsresult err;
--- a/js/xpconnect/src/XPCWrappedNativeJSOps.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeJSOps.cpp
@@ -474,17 +474,17 @@ XPC_WN_Shared_Convert(JSContext* cx, Han
                     }
                 }
             }
             return Throw(NS_ERROR_XPC_CANT_CONVERT_WN_TO_FUN, cx);
         case JSTYPE_NUMBER:
             vp.set(JS_GetNaNValue(cx));
             return true;
         case JSTYPE_BOOLEAN:
-            vp.set(JSVAL_TRUE);
+            vp.setBoolean(true);
             return true;
         case JSTYPE_VOID:
         case JSTYPE_STRING:
         {
             ccx.SetName(ccx.GetRuntime()->GetStringID(XPCJSRuntime::IDX_TO_STRING));
             ccx.SetArgsAndResultPtr(0, nullptr, vp.address());
 
             XPCNativeMember* member = ccx.GetMember();
--- a/js/xpconnect/wrappers/XrayWrapper.cpp
+++ b/js/xpconnect/wrappers/XrayWrapper.cpp
@@ -1250,19 +1250,19 @@ XPCWrappedNativeXrayTraits::resolveNativ
         return JS_DefinePropertyById(cx, holder, id, desc) &&
                JS_GetOwnPropertyDescriptorById(cx, holder, id, desc);
     }
 
     desc.object().set(holder);
     desc.setAttributes(JSPROP_ENUMERATE);
     desc.setGetter(nullptr);
     desc.setSetter(nullptr);
-    desc.value().set(JSVAL_VOID);
+    desc.value().setUndefined();
 
-    RootedValue fval(cx, JSVAL_VOID);
+    RootedValue fval(cx, JS::UndefinedValue());
     if (member->IsConstant()) {
         if (!member->GetConstantValue(ccx, iface, desc.value().address())) {
             JS_ReportError(cx, "Failed to convert constant native property to JS value");
             return false;
         }
     } else if (member->IsAttribute()) {
         // This is a getter/setter. Clone a function for it.
         if (!member->NewFunctionObject(ccx, iface, wrapper, fval.address())) {
--- a/storage/mozStorageStatementJSHelper.cpp
+++ b/storage/mozStorageStatementJSHelper.cpp
@@ -56,17 +56,17 @@ stepFunc(JSContext *aCtx,
 
   Statement *stmt = static_cast<Statement *>(
     static_cast<mozIStorageStatement *>(wrapper->Native())
   );
 
   bool hasMore = false;
   rv = stmt->ExecuteStep(&hasMore);
   if (NS_SUCCEEDED(rv) && !hasMore) {
-    *_vp = JSVAL_FALSE;
+    _vp->setBoolean(false);
     (void)stmt->Reset();
     return true;
   }
 
   if (NS_FAILED(rv)) {
     ::JS_ReportError(aCtx, "mozIStorageStatement::step() returned an error");
     return false;
   }
--- a/storage/mozStorageStatementRow.cpp
+++ b/storage/mozStorageStatementRow.cpp
@@ -97,17 +97,17 @@ StatementRow::GetProperty(nsIXPConnectWr
       for (uint32_t i = 0; i < length; i++) {
         if (!::JS_DefineElement(aCtx, scope, i, blob[i], JSPROP_ENUMERATE)) {
           *_retval = false;
           return NS_OK;
         }
       }
     }
     else if (type == mozIStorageValueArray::VALUE_TYPE_NULL) {
-      *_vp = JSVAL_NULL;
+      _vp->setNull();
     }
     else {
       NS_ERROR("unknown column type returned, what's going on?");
     }
   }
 
   return NS_OK;
 }
--- a/toolkit/devtools/server/nsJSInspector.cpp
+++ b/toolkit/devtools/server/nsJSInspector.cpp
@@ -47,17 +47,17 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsJSInspector)
   for (uint32_t i = 0; i < tmp->mRequestors.Length(); ++i) {
     NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mRequestors[i])
   }
   NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mLastRequestor)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
-nsJSInspector::nsJSInspector() : mNestedLoopLevel(0), mRequestors(1), mLastRequestor(JSVAL_NULL)
+nsJSInspector::nsJSInspector() : mNestedLoopLevel(0), mRequestors(1), mLastRequestor(JS::NullValue())
 {
 }
 
 nsJSInspector::~nsJSInspector()
 {
   MOZ_ASSERT(mRequestors.Length() == 0);
   MOZ_ASSERT(mLastRequestor.isNull());
   mozilla::DropJSObjects(this);
@@ -94,17 +94,17 @@ nsJSInspector::EnterNestedEventLoop(JS::
 NS_IMETHODIMP
 nsJSInspector::ExitNestedEventLoop(uint32_t *out)
 {
   if (mNestedLoopLevel > 0) {
     mRequestors.RemoveElementAt(--mNestedLoopLevel);
     if (mNestedLoopLevel > 0)
       mLastRequestor = mRequestors.ElementAt(mNestedLoopLevel - 1);
     else
-      mLastRequestor = JSVAL_NULL;
+      mLastRequestor = JS::NullValue();
   } else {
     return NS_ERROR_FAILURE;
   }
 
   *out = mNestedLoopLevel;
 
   return NS_OK;
 }
--- a/xpcom/base/CycleCollectedJSRuntime.cpp
+++ b/xpcom/base/CycleCollectedJSRuntime.cpp
@@ -844,17 +844,17 @@ CycleCollectedJSRuntime::AddJSHolder(voi
 {
   mJSHolders.Put(aHolder, aTracer);
 }
 
 struct ClearJSHolder : TraceCallbacks
 {
   virtual void Trace(JS::Heap<JS::Value>* aPtr, const char*, void*) const override
   {
-    *aPtr = JSVAL_VOID;
+    aPtr->setUndefined();
   }
 
   virtual void Trace(JS::Heap<jsid>* aPtr, const char*, void*) const override
   {
     *aPtr = JSID_VOID;
   }
 
   virtual void Trace(JS::Heap<JSObject*>* aPtr, const char*, void*) const override