Bug 1125356 - Use JS_NewPlainObject in the browser. r=bz
authorTom Schuster <evilpies@gmail.com>
Sat, 24 Jan 2015 16:38:08 +0100
changeset 254324 ff86ca36785b561f655ad443ff487a76b421714c
parent 254323 09d0ebd5f0f407cf619158cc93e13f740fe97869
child 254325 0509d8753ae8c05dbde9bff25f865ee7606c1a8d
push id721
push userjlund@mozilla.com
push dateTue, 21 Apr 2015 23:03:33 +0000
treeherdermozilla-release@d27c9211ebb3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1125356
milestone38.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 1125356 - Use JS_NewPlainObject in the browser. r=bz
dom/base/nsContentPermissionHelper.cpp
dom/base/nsDOMClassInfo.cpp
dom/base/nsFrameMessageManager.cpp
dom/bindings/Codegen.py
dom/bluetooth/BluetoothService.cpp
dom/bluetooth/BluetoothUtils.cpp
dom/bluetooth2/bluedroid/BluetoothUtils.cpp
dom/bluetooth2/bluez/BluetoothUtils.cpp
dom/filehandle/MetadataHelper.cpp
dom/html/HTMLMediaElement.cpp
dom/indexedDB/IDBObjectStore.cpp
dom/indexedDB/KeyPath.cpp
dom/mobilemessage/MmsMessage.cpp
dom/mobilemessage/ipc/SmsParent.cpp
js/ipc/JavaScriptShared.cpp
js/xpconnect/src/XPCComponents.cpp
toolkit/components/startup/nsAppStartup.cpp
toolkit/components/telemetry/Telemetry.cpp
widget/GfxInfoCollector.cpp
xpcom/glue/tests/gtest/TestGCPostBarriers.cpp
--- a/dom/base/nsContentPermissionHelper.cpp
+++ b/dom/base/nsContentPermissionHelper.cpp
@@ -487,17 +487,17 @@ RemotePermissionRequest::Recv__delete__(
     // {"type1": "choice1", "type2": "choiceA"}
     AutoJSAPI jsapi;
     if (NS_WARN_IF(!jsapi.Init(mWindow))) {
       return true; // This is not an IPC error.
     }
 
     JSContext* cx = jsapi.cx();
     JS::Rooted<JSObject*> obj(cx);
-    obj = JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr());
+    obj = JS_NewPlainObject(cx);
     for (uint32_t i = 0; i < aChoices.Length(); ++i) {
       const nsString& choice = aChoices[i].choice();
       const nsCString& type = aChoices[i].type();
       JS::Rooted<JSString*> jChoice(cx, JS_NewUCStringCopyN(cx, choice.get(), choice.Length()));
       JS::Rooted<JS::Value> vChoice(cx, StringValue(jChoice));
       if (!JS_SetProperty(cx, obj, type.get(), vChoice)) {
         return false;
       }
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -2429,21 +2429,22 @@ LookupComponentsShim(JSContext *cx, JS::
 
   // Warn once.
   nsCOMPtr<nsIDocument> doc = win->GetExtantDoc();
   if (doc) {
     doc->WarnOnceAbout(nsIDocument::eComponents, /* asError = */ true);
   }
 
   // Create a fake Components object.
-  JS::Rooted<JSObject*> components(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), global));
+  AssertSameCompartment(cx, global);
+  JS::Rooted<JSObject*> components(cx, JS_NewPlainObject(cx));
   NS_ENSURE_TRUE(components, NS_ERROR_OUT_OF_MEMORY);
 
   // Create a fake interfaces object.
-  JS::Rooted<JSObject*> interfaces(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), global));
+  JS::Rooted<JSObject*> interfaces(cx, JS_NewPlainObject(cx));
   NS_ENSURE_TRUE(interfaces, NS_ERROR_OUT_OF_MEMORY);
   bool ok =
     JS_DefineProperty(cx, components, "interfaces", interfaces,
                       JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY,
                       JS_STUBGETTER, JS_STUBSETTER);
   NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
 
   // Define a bunch of shims from the Ci.nsIDOMFoo to window.Foo for DOM
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -976,34 +976,33 @@ nsFrameMessageManager::ReceiveMessage(ns
       nsIGlobalObject* nativeGlobal =
         xpc::NativeGlobal(js::GetGlobalForObjectCrossCompartment(wrappedJS->GetJSObject()));
       AutoEntryScript aes(nativeGlobal);
       aes.TakeOwnershipOfErrorReporting();
       JSContext* cx = aes.cx();
       JS::Rooted<JSObject*> object(cx, wrappedJS->GetJSObject());
 
       // The parameter for the listener function.
-      JS::Rooted<JSObject*> param(cx,
-        JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+      JS::Rooted<JSObject*> param(cx, JS_NewPlainObject(cx));
       NS_ENSURE_TRUE(param, NS_ERROR_OUT_OF_MEMORY);
 
       JS::Rooted<JS::Value> targetv(cx);
       js::AssertSameCompartment(cx, object);
       nsresult rv = nsContentUtils::WrapNative(cx, aTarget, &targetv);
       NS_ENSURE_SUCCESS(rv, rv);
 
       JS::Rooted<JSObject*> cpows(cx);
       if (aCpows) {
         if (!aCpows->ToObject(cx, &cpows)) {
           return NS_ERROR_UNEXPECTED;
         }
       }
 
       if (!cpows) {
-        cpows = JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr());
+        cpows = JS_NewPlainObject(cx);
         if (!cpows) {
           return NS_ERROR_UNEXPECTED;
         }
       }
 
       JS::Rooted<JS::Value> cpowsv(cx, JS::ObjectValue(*cpows));
 
       JS::Rooted<JS::Value> json(cx, JS::NullValue());
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -5697,17 +5697,17 @@ def getWrapTemplateForType(type, descrip
                 'typedArraysAreStructs': typedArraysAreStructs
             })
         mozMapWrapLevel -= 1
         code = fill(
             """
 
             nsTArray<nsString> keys;
             ${result}.GetKeys(keys);
-            JS::Rooted<JSObject*> returnObj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+            JS::Rooted<JSObject*> returnObj(cx, JS_NewPlainObject(cx));
             if (!returnObj) {
               $*{exceptionCode}
             }
             // Scope for 'tmp'
             {
               JS::Rooted<JS::Value> tmp(cx);
               for (size_t idx = 0; idx < keys.Length(); ++idx) {
                 auto& ${valueName} = ${result}.Get(keys[idx]);
@@ -7537,17 +7537,17 @@ class CGMethodPromiseWrapper(CGAbstractS
 
 class CGJsonifierMethod(CGSpecializedMethod):
     def __init__(self, descriptor, method):
         assert method.isJsonifier()
         CGSpecializedMethod.__init__(self, descriptor, method)
 
     def definition_body(self):
         ret = dedent("""
-            JS::Rooted<JSObject*> result(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+            JS::Rooted<JSObject*> result(cx, JS_NewPlainObject(cx));
             if (!result) {
               return false;
             }
             """)
 
         jsonInterfaces = []
         interface = self.descriptor.interface
         while interface:
@@ -11511,17 +11511,17 @@ class CGDictionary(CGThing):
                 }
                 JS::Rooted<JSObject*> obj(cx, &rval.toObject());
 
                 """,
                 dictName=self.makeClassName(self.dictionary.parent))
         else:
             body += fill(
                 """
-                JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+                JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
                 if (!obj) {
                   return false;
                 }
                 rval.set(JS::ObjectValue(*obj));
 
                 """)
 
         if self.memberInfo:
--- a/dom/bluetooth/BluetoothService.cpp
+++ b/dom/bluetooth/BluetoothService.cpp
@@ -717,18 +717,17 @@ BluetoothService::AdapterAddedReceived()
 }
 
 void
 BluetoothService::Notify(const BluetoothSignal& aData)
 {
   nsString type = NS_LITERAL_STRING("bluetooth-pairing-request");
 
   AutoSafeJSContext cx;
-  JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(),
-                                             JS::NullPtr()));
+  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
   NS_ENSURE_TRUE_VOID(obj);
 
   if (!SetJsObject(cx, aData.value(), obj)) {
     BT_WARNING("Failed to set properties of system message!");
     return;
   }
 
   BT_LOGD("[S] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aData.name()).get());
--- a/dom/bluetooth/BluetoothUtils.cpp
+++ b/dom/bluetooth/BluetoothUtils.cpp
@@ -79,18 +79,17 @@ BroadcastSystemMessage(const nsAString& 
 
   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);
   } else if (aData.type() == BluetoothValue::TArrayOfBluetoothNamedValue) {
-    JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(),
-                                               JS::NullPtr()));
+    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)) {
       BT_WARNING("Failed to set properties of system message!");
       return false;
@@ -110,18 +109,17 @@ BroadcastSystemMessage(const nsAString& 
 bool
 BroadcastSystemMessage(const nsAString& aType,
                        const InfallibleTArray<BluetoothNamedValue>& aData)
 {
   mozilla::AutoSafeJSContext cx;
   NS_ASSERTION(!::JS_IsExceptionPending(cx),
       "Shouldn't get here when an exception is pending!");
 
-  JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(),
-                                             JS::NullPtr()));
+  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)) {
     BT_WARNING("Failed to set properties of system message!");
     return false;
--- a/dom/bluetooth2/bluedroid/BluetoothUtils.cpp
+++ b/dom/bluetooth2/bluedroid/BluetoothUtils.cpp
@@ -111,18 +111,17 @@ BroadcastSystemMessage(const nsAString& 
 
   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);
   } else if (aData.type() == BluetoothValue::TArrayOfBluetoothNamedValue) {
-    JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(),
-                                               JS::NullPtr()));
+    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)) {
       BT_WARNING("Failed to set properties of system message!");
       return false;
--- a/dom/bluetooth2/bluez/BluetoothUtils.cpp
+++ b/dom/bluetooth2/bluez/BluetoothUtils.cpp
@@ -106,18 +106,17 @@ GetAddressFromObjectPath(const nsAString
 bool
 BroadcastSystemMessage(const nsAString& aType,
                        const InfallibleTArray<BluetoothNamedValue>& aData)
 {
   mozilla::AutoSafeJSContext cx;
   NS_ASSERTION(!::JS_IsExceptionPending(cx),
       "Shouldn't get here when an exception is pending!");
 
-  JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(),
-                                             JS::NullPtr()));
+  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)) {
     BT_WARNING("Failed to set properties of system message!");
     return false;
--- a/dom/filehandle/MetadataHelper.cpp
+++ b/dom/filehandle/MetadataHelper.cpp
@@ -31,18 +31,17 @@ MetadataHelper::DoAsyncRun(nsISupports* 
 
   return NS_OK;
 }
 
 nsresult
 MetadataHelper::GetSuccessResult(JSContext* aCx,
                                  JS::MutableHandle<JS::Value> aVal)
 {
-  JS::Rooted<JSObject*> obj(aCx, JS_NewObject(aCx, nullptr, JS::NullPtr(),
-                                              JS::NullPtr()));
+  JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
   NS_ENSURE_TRUE(obj, NS_ERROR_OUT_OF_MEMORY);
 
   if (mParams->SizeRequested()) {
     JS::Rooted<JS::Value> val(aCx, JS_NumberValue(mParams->Size()));
 
     if (!JS_DefineProperty(aCx, obj, "size", val, JSPROP_ENUMERATE)) {
       return NS_ERROR_FAILURE;
     }
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1738,17 +1738,17 @@ HTMLMediaElement::MozGetMetadata(JSConte
                                  JS::MutableHandle<JSObject*> aRetval,
                                  ErrorResult& aRv)
 {
   if (mReadyState < nsIDOMHTMLMediaElement::HAVE_METADATA) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
-  JS::Rooted<JSObject*> tags(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::Rooted<JSObject*> tags(cx, JS_NewPlainObject(cx));
   if (!tags) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
   if (mTags) {
     MetadataIterCx iter = {cx, tags, false};
     mTags->EnumerateRead(BuildObjectFromTags, static_cast<void*>(&iter));
     if (iter.error) {
--- a/dom/indexedDB/IDBObjectStore.cpp
+++ b/dom/indexedDB/IDBObjectStore.cpp
@@ -672,19 +672,17 @@ public:
                            IDBDatabase* aDatabase,
                            StructuredCloneFile& aFile,
                            const MutableFileData& aData,
                            JS::MutableHandle<JSObject*> aResult)
   {
     MOZ_ASSERT(!aDatabase);
 
     // MutableFile can't be used in index creation, so just make a dummy object.
-    JS::Rooted<JSObject*> obj(aCx,
-      JS_NewObject(aCx, nullptr, JS::NullPtr(), JS::NullPtr()));
-
+    JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
     if (NS_WARN_IF(!obj)) {
       return false;
     }
 
     aResult.set(obj);
     return true;
   }
 
@@ -700,18 +698,17 @@ public:
                aData.tag == SCTAG_DOM_BLOB);
 
     // The following properties are available for use in index creation
     //   Blob.size
     //   Blob.type
     //   File.name
     //   File.lastModifiedDate
 
-    JS::Rooted<JSObject*> obj(aCx,
-      JS_NewObject(aCx, nullptr, JS::NullPtr(), JS::NullPtr()));
+    JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
     if (NS_WARN_IF(!obj)) {
       return false;
     }
 
     // Technically these props go on the proto, but this detail won't change
     // the results of index creation.
 
     JS::Rooted<JSString*> type(aCx,
--- a/dom/indexedDB/KeyPath.cpp
+++ b/dom/indexedDB/KeyPath.cpp
@@ -149,18 +149,17 @@ GetJSValFromKeyPathString(JSContext* aCx
       // We have started inserting new objects or are about to just insert
       // the first one.
 
       aKeyJSVal->setUndefined();
 
       if (tokenizer.hasMoreTokens()) {
         // If we're not at the end, we need to add a dummy object to the
         // chain.
-        JS::Rooted<JSObject*> dummy(aCx, JS_NewObject(aCx, nullptr, JS::NullPtr(),
-                                                      JS::NullPtr()));
+        JS::Rooted<JSObject*> dummy(aCx, JS_NewPlainObject(aCx));
         if (!dummy) {
           IDB_REPORT_INTERNAL_ERR();
           rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
           break;
         }
 
         if (!JS_DefineUCProperty(aCx, obj, token.BeginReading(),
                                  token.Length(), dummy, JSPROP_ENUMERATE)) {
--- a/dom/mobilemessage/MmsMessage.cpp
+++ b/dom/mobilemessage/MmsMessage.cpp
@@ -541,18 +541,17 @@ MmsMessage::GetAttachments(JSContext* aC
 
   JS::Rooted<JSObject*> attachments(
     aCx, JS_NewArrayObject(aCx, length));
   NS_ENSURE_TRUE(attachments, NS_ERROR_OUT_OF_MEMORY);
 
   for (uint32_t i = 0; i < length; ++i) {
     const Attachment &attachment = mAttachments[i];
 
-    JS::Rooted<JSObject*> attachmentObj(
-      aCx, JS_NewObject(aCx, nullptr, JS::NullPtr(), JS::NullPtr()));
+    JS::Rooted<JSObject*> attachmentObj(aCx, JS_NewPlainObject(aCx));
     NS_ENSURE_TRUE(attachmentObj, NS_ERROR_OUT_OF_MEMORY);
 
     JS::Rooted<JSString*> tmpJsStr(aCx);
 
     // Get |attachment.mId|.
     tmpJsStr = JS_NewUCStringCopyN(aCx,
                                    attachment.id.get(),
                                    attachment.id.Length());
--- a/dom/mobilemessage/ipc/SmsParent.cpp
+++ b/dom/mobilemessage/ipc/SmsParent.cpp
@@ -28,18 +28,17 @@
 namespace mozilla {
 namespace dom {
 namespace mobilemessage {
 
 static JSObject*
 MmsAttachmentDataToJSObject(JSContext* aContext,
                             const MmsAttachmentData& aAttachment)
 {
-  JS::Rooted<JSObject*> obj(aContext, JS_NewObject(aContext, nullptr, JS::NullPtr(),
-                                                   JS::NullPtr()));
+  JS::Rooted<JSObject*> obj(aContext, JS_NewPlainObject(aContext));
   NS_ENSURE_TRUE(obj, nullptr);
 
   JS::Rooted<JSString*> idStr(aContext, JS_NewUCStringCopyN(aContext,
                                                             aAttachment.id().get(),
                                                             aAttachment.id().Length()));
   NS_ENSURE_TRUE(idStr, nullptr);
   if (!JS_DefineProperty(aContext, obj, "id", idStr, 0)) {
     return nullptr;
@@ -78,17 +77,17 @@ MmsAttachmentDataToJSObject(JSContext* a
   return obj;
 }
 
 static bool
 GetParamsFromSendMmsMessageRequest(JSContext* aCx,
                                    const SendMmsMessageRequest& aRequest,
                                    JS::Value* aParam)
 {
-  JS::Rooted<JSObject*> paramsObj(aCx, JS_NewObject(aCx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::Rooted<JSObject*> paramsObj(aCx, JS_NewPlainObject(aCx));
   NS_ENSURE_TRUE(paramsObj, false);
 
   // smil
   JS::Rooted<JSString*> smilStr(aCx, JS_NewUCStringCopyN(aCx,
                                                          aRequest.smil().get(),
                                                          aRequest.smil().Length()));
   NS_ENSURE_TRUE(smilStr, false);
   if(!JS_DefineProperty(aCx, paramsObj, "smil", smilStr, 0)) {
--- a/js/ipc/JavaScriptShared.cpp
+++ b/js/ipc/JavaScriptShared.cpp
@@ -694,17 +694,17 @@ bool
 JavaScriptShared::Unwrap(JSContext *cx, const InfallibleTArray<CpowEntry> &aCpows,
                          JS::MutableHandleObject objp)
 {
     objp.set(nullptr);
 
     if (!aCpows.Length())
         return true;
 
-    RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+    RootedObject obj(cx, JS_NewPlainObject(cx));
     if (!obj)
         return false;
 
     RootedValue v(cx);
     RootedString str(cx);
     for (size_t i = 0; i < aCpows.Length(); i++) {
         const nsString &name = aCpows[i].name();
 
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -3395,17 +3395,17 @@ nsXPCComponents_Utils::GetWatchdogTimest
         return NS_ERROR_INVALID_ARG;
     *aOut = XPCJSRuntime::Get()->GetWatchdogTimestamp(category);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXPCComponents_Utils::GetJSEngineTelemetryValue(JSContext *cx, MutableHandleValue rval)
 {
-    RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+    RootedObject obj(cx, JS_NewPlainObject(cx));
     if (!obj)
         return NS_ERROR_OUT_OF_MEMORY;
 
     unsigned attrs = JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT;
 
     size_t i = JS_SetProtoCalled(cx);
     RootedValue v(cx, DoubleValue(i));
     if (!JS_DefineProperty(cx, obj, "setProto", v, attrs))
--- a/toolkit/components/startup/nsAppStartup.cpp
+++ b/toolkit/components/startup/nsAppStartup.cpp
@@ -740,17 +740,17 @@ nsAppStartup::Observe(nsISupports *aSubj
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsAppStartup::GetStartupInfo(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval)
 {
-  JS::Rooted<JSObject*> obj(aCx, JS_NewObject(aCx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
 
   aRetval.setObject(*obj);
 
   TimeStamp procTime = StartupTimeline::Get(StartupTimeline::PROCESS_CREATION);
   TimeStamp now = TimeStamp::Now();
   PRTime absNow = PR_Now();
 
   if (procTime.IsNull()) {
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -772,17 +772,17 @@ KeyedHistogram::GetJSKeys(JSContext* cx,
   args.rval().setObject(*jsKeys);
   return NS_OK;
 }
 
 /* static */
 bool
 KeyedHistogram::ReflectKeyedHistogram(KeyedHistogramEntry* entry, JSContext* cx, JS::Handle<JSObject*> obj)
 {
-  JS::RootedObject histogramSnapshot(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::RootedObject histogramSnapshot(cx, JS_NewPlainObject(cx));
   if (!histogramSnapshot) {
     return false;
   }
 
   if (ReflectHistogramSnapshot(cx, histogramSnapshot, entry->mData) != REFLECT_OK) {
     return false;
   }
 
@@ -1236,17 +1236,17 @@ JSHistogram_Snapshot(JSContext *cx, unsi
 {
   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
   JSObject *obj = JS_THIS_OBJECT(cx, vp);
   if (!obj) {
     return false;
   }
 
   Histogram *h = static_cast<Histogram*>(JS_GetPrivate(obj));
-  JS::Rooted<JSObject*> snapshot(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::Rooted<JSObject*> snapshot(cx, JS_NewPlainObject(cx));
   if (!snapshot)
     return false;
 
   switch (ReflectHistogramSnapshot(cx, snapshot, h)) {
   case REFLECT_FAILURE:
     return false;
   case REFLECT_CORRUPT:
     JS_ReportError(cx, "Histogram is corrupt");
@@ -1379,17 +1379,17 @@ JSKeyedHistogram_Snapshot(JSContext *cx,
   KeyedHistogram* keyed = static_cast<KeyedHistogram*>(JS_GetPrivate(obj));
   if (!keyed) {
     return false;
   }
 
   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
 
   if (args.length() == 0) {
-    JS::RootedObject snapshot(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+    JS::RootedObject snapshot(cx, JS_NewPlainObject(cx));
     if (!snapshot) {
       JS_ReportError(cx, "Failed to create object");
       return false;
     }
 
     if (!NS_SUCCEEDED(keyed->GetJSSnapshot(cx, snapshot))) {
       JS_ReportError(cx, "Failed to reflect keyed histograms");
       return false;
@@ -1407,17 +1407,17 @@ JSKeyedHistogram_Snapshot(JSContext *cx,
 
   Histogram* h = nullptr;
   nsresult rv = keyed->GetHistogram(NS_ConvertUTF16toUTF8(key), &h);
   if (NS_FAILED(rv)) {
     JS_ReportError(cx, "Failed to get histogram");
     return false;
   }
 
-  JS::RootedObject snapshot(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::RootedObject snapshot(cx, JS_NewPlainObject(cx));
   if (!snapshot) {
     return false;
   }
 
   switch (ReflectHistogramSnapshot(cx, snapshot, h)) {
   case REFLECT_FAILURE:
     return false;
   case REFLECT_CORRUPT:
@@ -1836,17 +1836,17 @@ TelemetryImpl::ReflectOtherThreadsSQL(Sl
 {
   return ReflectSQL(entry, &entry->mData.otherThreads, cx, obj);
 }
 
 bool
 TelemetryImpl::AddSQLInfo(JSContext *cx, JS::Handle<JSObject*> rootObj, bool mainThread,
                           bool privateSQL)
 {
-  JS::Rooted<JSObject*> statsObj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::Rooted<JSObject*> statsObj(cx, JS_NewPlainObject(cx));
   if (!statsObj)
     return false;
 
   AutoHashtable<SlowSQLEntryType> &sqlMap =
     (privateSQL ? mPrivateSQL : mSanitizedSQL);
   AutoHashtable<SlowSQLEntryType>::ReflectEntryFunc reflectFunction =
     (mainThread ? ReflectMainThreadSQL : ReflectOtherThreadsSQL);
   if (!sqlMap.ReflectIntoJS(reflectFunction, cx, statsObj)) {
@@ -2111,17 +2111,17 @@ TelemetryImpl::UnregisterAddonHistograms
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TelemetryImpl::GetHistogramSnapshots(JSContext *cx, JS::MutableHandle<JS::Value> ret)
 {
-  JS::Rooted<JSObject*> root_obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::Rooted<JSObject*> root_obj(cx, JS_NewPlainObject(cx));
   if (!root_obj)
     return NS_ERROR_FAILURE;
   ret.setObject(*root_obj);
 
   // Ensure that all the HISTOGRAM_FLAG & HISTOGRAM_COUNT histograms have
   // been created, so that their values are snapshotted.
   for (size_t i = 0; i < Telemetry::HistogramCount; ++i) {
     if (gHistograms[i].keyed) {
@@ -2150,17 +2150,17 @@ TelemetryImpl::GetHistogramSnapshots(JSC
   // OK, now we can actually reflect things.
   JS::Rooted<JSObject*> hobj(cx);
   for (HistogramIterator it = hs.begin(); it != hs.end(); ++it) {
     Histogram *h = *it;
     if (!ShouldReflectHistogram(h) || IsEmpty(h) || IsExpired(h)) {
       continue;
     }
 
-    hobj = JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr());
+    hobj = JS_NewPlainObject(cx);
     if (!hobj) {
       return NS_ERROR_FAILURE;
     }
     switch (ReflectHistogramSnapshot(cx, hobj, h)) {
     case REFLECT_CORRUPT:
       // We can still hit this case even if ShouldReflectHistograms
       // returns true.  The histogram lies outside of our control
       // somehow; just skip it.
@@ -2212,17 +2212,17 @@ TelemetryImpl::AddonHistogramReflector(A
       return false;
     }
   }
 
   if (IsEmpty(info.h)) {
     return true;
   }
 
-  JS::Rooted<JSObject*> snapshot(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::Rooted<JSObject*> snapshot(cx, JS_NewPlainObject(cx));
   if (!snapshot) {
     // Just consider this to be skippable.
     return true;
   }
   switch (ReflectHistogramSnapshot(cx, snapshot, info.h)) {
   case REFLECT_FAILURE:
   case REFLECT_CORRUPT:
     return false;
@@ -2237,34 +2237,34 @@ TelemetryImpl::AddonHistogramReflector(A
   return true;
 }
 
 bool
 TelemetryImpl::AddonReflector(AddonEntryType *entry,
                               JSContext *cx, JS::Handle<JSObject*> obj)
 {
   const nsACString &addonId = entry->GetKey();
-  JS::Rooted<JSObject*> subobj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::Rooted<JSObject*> subobj(cx, JS_NewPlainObject(cx));
   if (!subobj) {
     return false;
   }
 
   AddonHistogramMapType *map = entry->mData;
   if (!(map->ReflectIntoJS(AddonHistogramReflector, cx, subobj)
         && JS_DefineProperty(cx, obj, PromiseFlatCString(addonId).get(),
                              subobj, JSPROP_ENUMERATE))) {
     return false;
   }
   return true;
 }
 
 NS_IMETHODIMP
 TelemetryImpl::GetAddonHistogramSnapshots(JSContext *cx, JS::MutableHandle<JS::Value> ret)
 {
-  JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
   if (!obj) {
     return NS_ERROR_FAILURE;
   }
 
   if (!mAddonMap.ReflectIntoJS(AddonReflector, cx, obj)) {
     return NS_ERROR_FAILURE;
   }
   ret.setObject(*obj);
@@ -2272,17 +2272,17 @@ TelemetryImpl::GetAddonHistogramSnapshot
 }
 
 /* static */
 PLDHashOperator
 TelemetryImpl::KeyedHistogramsReflector(const nsACString& key, nsAutoPtr<KeyedHistogram>& entry, void* arg)
 {
   KeyedHistogramReflectArgs* args = static_cast<KeyedHistogramReflectArgs*>(arg);
   JSContext *cx = args->jsContext;
-  JS::RootedObject snapshot(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::RootedObject snapshot(cx, JS_NewPlainObject(cx));
   if (!snapshot) {
     return PL_DHASH_STOP;
   }
 
   if (!NS_SUCCEEDED(entry->GetJSSnapshot(cx, snapshot))) {
     return PL_DHASH_STOP;
   }
 
@@ -2292,17 +2292,17 @@ TelemetryImpl::KeyedHistogramsReflector(
   }
 
   return PL_DHASH_NEXT;
 }
 
 NS_IMETHODIMP
 TelemetryImpl::GetKeyedHistogramSnapshots(JSContext *cx, JS::MutableHandle<JS::Value> ret)
 {
-  JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
   if (!obj) {
     return NS_ERROR_FAILURE;
   }
 
   KeyedHistogramReflectArgs reflectArgs = {cx, obj};
   const uint32_t num = mKeyedHistograms.Enumerate(&TelemetryImpl::KeyedHistogramsReflector,
                                                       static_cast<void*>(&reflectArgs));
   if (num != mKeyedHistograms.Count()) {
@@ -2311,17 +2311,17 @@ TelemetryImpl::GetKeyedHistogramSnapshot
 
   ret.setObject(*obj);
   return NS_OK;
 }
 
 bool
 TelemetryImpl::GetSQLStats(JSContext *cx, JS::MutableHandle<JS::Value> ret, bool includePrivateSql)
 {
-  JS::Rooted<JSObject*> root_obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::Rooted<JSObject*> root_obj(cx, JS_NewPlainObject(cx));
   if (!root_obj)
     return false;
   ret.setObject(*root_obj);
 
   MutexAutoLock hashMutex(mHashMutex);
   // Add info about slow SQL queries on the main thread
   if (!AddSQLInfo(cx, root_obj, true, includePrivateSql))
     return false;
@@ -2423,19 +2423,17 @@ TelemetryImpl::GetChromeHangs(JSContext 
       if (!keyValueArray) {
         return NS_ERROR_FAILURE;
       }
       JS::RootedValue indexValue(cx);
       indexValue.setNumber(annotationInfo[iterIndex].mHangIndex);
       if (!JS_SetElement(cx, keyValueArray, 0, indexValue)) {
         return NS_ERROR_FAILURE;
       }
-      JS::Rooted<JSObject*> jsAnnotation(cx, JS_NewObject(cx, nullptr,
-                                                          JS::NullPtr(),
-                                                          JS::NullPtr()));
+      JS::Rooted<JSObject*> jsAnnotation(cx, JS_NewPlainObject(cx));
       if (!jsAnnotation) {
         return NS_ERROR_FAILURE;
       }
       nsAutoPtr<HangAnnotations::Enumerator> annotationsEnum;
       if (!annotationInfo[iterIndex].mAnnotations->GetEnumerator(
             annotationsEnum.StartAssignment())) {
         return NS_ERROR_FAILURE;
       }
@@ -2459,17 +2457,17 @@ TelemetryImpl::GetChromeHangs(JSContext 
     }
   }
 
   return NS_OK;
 }
 
 static JSObject *
 CreateJSStackObject(JSContext *cx, const CombinedStacks &stacks) {
-  JS::Rooted<JSObject*> ret(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::Rooted<JSObject*> ret(cx, JS_NewPlainObject(cx));
   if (!ret) {
     return nullptr;
   }
 
   JS::Rooted<JSObject*> moduleArray(cx, JS_NewArrayObject(cx, 0));
   if (!moduleArray) {
     return nullptr;
   }
@@ -2648,17 +2646,17 @@ ReadStack(const char *aFileName, Telemet
   aStack = stack;
 }
 
 static JSObject*
 CreateJSTimeHistogram(JSContext* cx, const Telemetry::TimeHistogram& time)
 {
   /* Create JS representation of TimeHistogram,
      in the format of Chromium-style histograms. */
-  JS::RootedObject ret(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::RootedObject ret(cx, JS_NewPlainObject(cx));
   if (!ret) {
     return nullptr;
   }
 
   if (!JS_DefineProperty(cx, ret, "min", time.GetBucketMin(0),
                          JSPROP_ENUMERATE) ||
       !JS_DefineProperty(cx, ret, "max",
                          time.GetBucketMax(ArrayLength(time) - 1),
@@ -2715,18 +2713,17 @@ CreateJSHangStack(JSContext* cx, const T
     }
   }
   return ret;
 }
 
 static JSObject*
 CreateJSHangHistogram(JSContext* cx, const Telemetry::HangHistogram& hang)
 {
-  JS::RootedObject ret(cx,
-    JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::RootedObject ret(cx, JS_NewPlainObject(cx));
   if (!ret) {
     return nullptr;
   }
 
   JS::RootedObject stack(cx, CreateJSHangStack(cx, hang.GetStack()));
   JS::RootedObject time(cx, CreateJSTimeHistogram(cx, hang));
 
   if (!stack ||
@@ -2744,17 +2741,17 @@ CreateJSHangHistogram(JSContext* cx, con
     }
   }
   return ret;
 }
 
 static JSObject*
 CreateJSThreadHangStats(JSContext* cx, const Telemetry::ThreadHangStats& thread)
 {
-  JS::RootedObject ret(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+  JS::RootedObject ret(cx, JS_NewPlainObject(cx));
   if (!ret) {
     return nullptr;
   }
   JS::RootedString name(cx, JS_NewStringCopyZ(cx, thread.GetName()));
   if (!name ||
       !JS_DefineProperty(cx, ret, "name", name, JSPROP_ENUMERATE)) {
     return nullptr;
   }
@@ -3259,18 +3256,17 @@ const Module kTelemetryModule = {
   nullptr,
   TelemetryImpl::ShutdownTelemetry
 };
 
 NS_IMETHODIMP
 TelemetryImpl::GetFileIOReports(JSContext *cx, JS::MutableHandleValue ret)
 {
   if (sTelemetryIOObserver) {
-    JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(),
-                                               JS::NullPtr()));
+    JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     if (!obj) {
       return NS_ERROR_FAILURE;
     }
 
     if (!sTelemetryIOObserver->ReflectIntoJS(cx, obj)) {
       return NS_ERROR_FAILURE;
     }
     ret.setObject(*obj);
--- a/widget/GfxInfoCollector.cpp
+++ b/widget/GfxInfoCollector.cpp
@@ -43,12 +43,12 @@ void
 InfoObject::DefineProperty(const char *name, const char *value)
 {
   nsAutoString string = NS_ConvertASCIItoUTF16(value);
   DefineProperty(name, string);
 }
 
 InfoObject::InfoObject(JSContext *aCx) : mCx(aCx), mObj(aCx), mOk(true)
 {
-  mObj = JS_NewObject(mCx, nullptr, JS::NullPtr(), JS::NullPtr());
+  mObj = JS_NewPlainObject(aCx);
   if (!mObj)
     mOk = false;
 }
--- a/xpcom/glue/tests/gtest/TestGCPostBarriers.cpp
+++ b/xpcom/glue/tests/gtest/TestGCPostBarriers.cpp
@@ -49,17 +49,17 @@ RunTest(JSRuntime* rt, JSContext* cx, Ar
 
   /*
    * Create the array and fill it with new JS objects. With GGC these will be
    * allocated in the nursery.
    */
   RootedValue value(cx);
   const char* property = "foo";
   for (size_t i = 0; i < ElementCount; ++i) {
-    RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+    RootedObject obj(cx, JS_NewPlainObject(cx));
     ASSERT_FALSE(JS::ObjectIsTenured(obj));
     value = Int32Value(i);
     ASSERT_TRUE(JS_SetProperty(cx, obj, property, value));
     array->AppendElement(obj);
   }
 
   /*
    * If postbarriers are not working, we will crash here when we try to mark