Bug 1573844 - Remove external references to js::Jsvalify and js::Valueify r=mccr8
authorJon Coppeard <jcoppeard@mozilla.com>
Wed, 14 Aug 2019 17:24:59 +0000
changeset 488202 7ecc384e1afe190ae13ef6fce9aaaadb0971ebea
parent 488201 afb443764498dee705a5e1e06cd1c2de3f222035
child 488203 3c8af6860ce4722fc04ff6808799a1c75a49147d
push id113904
push userncsoregi@mozilla.com
push dateThu, 15 Aug 2019 19:41:00 +0000
treeherdermozilla-inbound@b283a7ef186c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1573844
milestone70.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 1573844 - Remove external references to js::Jsvalify and js::Valueify r=mccr8 These are now no-ops so can be removed. Depends on D41983 Differential Revision: https://phabricator.services.mozilla.com/D41984
dom/bindings/BindingUtils.cpp
dom/bindings/DOMJSClass.h
dom/bindings/SimpleGlobalObject.cpp
js/xpconnect/public/xpc_map_end.h
js/xpconnect/src/Sandbox.cpp
js/xpconnect/src/XPCConvert.cpp
js/xpconnect/src/XPCJSID.cpp
js/xpconnect/src/XPCWrappedJSClass.cpp
js/xpconnect/src/XPCWrappedNative.cpp
js/xpconnect/src/XPCWrappedNativeProto.cpp
xpcom/base/CycleCollectedJSRuntime.cpp
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -730,18 +730,18 @@ static JSObject* CreateInterfaceObject(
     unsigned ctorNargs, const NamedConstructor* namedConstructors,
     JS::Handle<JSObject*> proto, const NativeProperties* properties,
     const NativeProperties* chromeOnlyProperties, const char* name,
     bool isChrome, bool defineOnGlobal,
     const char* const* legacyWindowAliases) {
   JS::Rooted<JSObject*> constructor(cx);
   MOZ_ASSERT(constructorProto);
   MOZ_ASSERT(constructorClass);
-  constructor = JS_NewObjectWithGivenProto(cx, Jsvalify(constructorClass),
-                                           constructorProto);
+  constructor =
+      JS_NewObjectWithGivenProto(cx, constructorClass, constructorProto);
   if (!constructor) {
     return nullptr;
   }
 
   if (!JS_DefineProperty(cx, constructor, "length", ctorNargs,
                          JSPROP_READONLY)) {
     return nullptr;
   }
@@ -856,17 +856,17 @@ static JSObject* CreateInterfaceObject(
 static JSObject* CreateInterfacePrototypeObject(
     JSContext* cx, JS::Handle<JSObject*> global,
     JS::Handle<JSObject*> parentProto, const js::Class* protoClass,
     const NativeProperties* properties,
     const NativeProperties* chromeOnlyProperties,
     const char* const* unscopableNames, const char* toStringTag,
     bool isGlobal) {
   JS::Rooted<JSObject*> ourProto(
-      cx, JS_NewObjectWithUniqueType(cx, Jsvalify(protoClass), parentProto));
+      cx, JS_NewObjectWithUniqueType(cx, protoClass, parentProto));
   if (!ourProto ||
       // We don't try to define properties on the global's prototype; those
       // properties go on the global itself.
       (!isGlobal &&
        !DefineProperties(cx, ourProto, properties, chromeOnlyProperties))) {
     return nullptr;
   }
 
@@ -1086,17 +1086,17 @@ bool TryPreserveWrapper(JS::Handle<JSObj
 
   // The addProperty hook for WebIDL classes does wrapper preservation, and
   // nothing else, so call it, if present.
   const DOMJSClass* domClass = GetDOMClass(obj);
   const JSClass* clasp = domClass->ToJSClass();
   JSAddPropertyOp addProperty = clasp->getAddProperty();
 
   // We expect all proxies to be nsISupports.
-  MOZ_RELEASE_ASSERT(!js::Valueify(clasp)->isProxy(),
+  MOZ_RELEASE_ASSERT(!clasp->isProxy(),
                      "Should not call addProperty for proxies.");
 
   // The class should have an addProperty hook iff it is a CC participant.
   MOZ_RELEASE_ASSERT(bool(domClass->mParticipant) == bool(addProperty));
 
   if (!addProperty) {
     return true;
   }
--- a/dom/bindings/DOMJSClass.h
+++ b/dom/bindings/DOMJSClass.h
@@ -447,17 +447,17 @@ struct DOMJSClass {
   // Null otherwise.
   WebIDLSerializer mSerializer;
 
   static const DOMJSClass* FromJSClass(const JSClass* base) {
     MOZ_ASSERT(base->flags & JSCLASS_IS_DOMJSCLASS);
     return reinterpret_cast<const DOMJSClass*>(base);
   }
 
-  const JSClass* ToJSClass() const { return Jsvalify(&mBase); }
+  const JSClass* ToJSClass() const { return &mBase; }
 };
 
 // Special JSClass for DOM interface and interface prototype objects.
 struct DOMIfaceAndProtoJSClass {
   // It would be nice to just inherit from js::Class, but that precludes pure
   // compile-time initialization of the form
   // |DOMJSInterfaceAndPrototypeClass = {...};|, since C++ only allows brace
   // initialization for aggregate/POD types.
@@ -483,17 +483,17 @@ struct DOMIfaceAndProtoJSClass {
 
   ProtoGetter mGetParentProto;
 
   static const DOMIfaceAndProtoJSClass* FromJSClass(const JSClass* base) {
     MOZ_ASSERT(base->flags & JSCLASS_IS_DOMIFACEANDPROTOJSCLASS);
     return reinterpret_cast<const DOMIfaceAndProtoJSClass*>(base);
   }
 
-  const JSClass* ToJSClass() const { return Jsvalify(&mBase); }
+  const JSClass* ToJSClass() const { return &mBase; }
 };
 
 class ProtoAndIfaceCache;
 
 inline bool DOMGlobalHasProtoAndIFaceCache(JSObject* global) {
   MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL);
   // This can be undefined if we GC while creating the global
   return !js::GetReservedSlot(global, DOM_PROTOTYPE_SLOT).isUndefined();
--- a/dom/bindings/SimpleGlobalObject.cpp
+++ b/dom/bindings/SimpleGlobalObject.cpp
@@ -106,20 +106,20 @@ JSObject* SimpleGlobalObject::Create(Glo
         // compartments.  This should help them be GCed quicker and take up
         // less memory before they're GCed.
         .setNewCompartmentInSystemZone();
 
     if (NS_IsMainThread()) {
       nsCOMPtr<nsIPrincipal> principal =
           NullPrincipal::CreateWithoutOriginAttributes();
       options.creationOptions().setTrace(xpc::TraceXPCGlobal);
-      global = xpc::CreateGlobalObject(cx, js::Jsvalify(&SimpleGlobalClass),
+      global = xpc::CreateGlobalObject(cx, &SimpleGlobalClass,
                                        nsJSPrincipals::get(principal), options);
     } else {
-      global = JS_NewGlobalObject(cx, js::Jsvalify(&SimpleGlobalClass), nullptr,
+      global = JS_NewGlobalObject(cx, &SimpleGlobalClass, nullptr,
                                   JS::DontFireOnNewGlobalHook, options);
     }
 
     if (!global) {
       jsapi.ClearException();
       return nullptr;
     }
 
--- a/js/xpconnect/public/xpc_map_end.h
+++ b/js/xpconnect/public/xpc_map_end.h
@@ -37,17 +37,17 @@ uint32_t XPC_MAP_CLASSNAME::GetScriptabl
 const js::Class* XPC_MAP_CLASSNAME::GetClass() {
   static const JSClassOps classOps = XPC_MAKE_CLASS_OPS(GetScriptableFlags());
   static const js::Class klass =
       XPC_MAKE_CLASS(XPC_MAP_QUOTED_CLASSNAME, GetScriptableFlags(), &classOps);
   return &klass;
 }
 
 // virtual
-const JSClass* XPC_MAP_CLASSNAME::GetJSClass() { return Jsvalify(GetClass()); }
+const JSClass* XPC_MAP_CLASSNAME::GetJSClass() { return GetClass(); }
 
 /**************************************************************/
 
 #if !((XPC_MAP_FLAGS)&XPC_SCRIPTABLE_WANT_PRECREATE)
 NS_IMETHODIMP XPC_MAP_CLASSNAME::PreCreate(nsISupports* nativeObj,
                                            JSContext* cx, JSObject* globalObj,
                                            JSObject** parentObj) {
   NS_ERROR("never called");
--- a/js/xpconnect/src/Sandbox.cpp
+++ b/js/xpconnect/src/Sandbox.cpp
@@ -1066,18 +1066,18 @@ nsresult xpc::CreateSandboxObject(JSCont
 
   creationOptions.setInvisibleToDebugger(options.invisibleToDebugger)
       .setTrace(TraceXPCGlobal);
 
   realmOptions.behaviors().setDiscardSource(options.discardSource);
 
   const js::Class* clasp = &SandboxClass;
 
-  RootedObject sandbox(cx, xpc::CreateGlobalObject(cx, js::Jsvalify(clasp),
-                                                   principal, realmOptions));
+  RootedObject sandbox(
+      cx, xpc::CreateGlobalObject(cx, clasp, principal, realmOptions));
   if (!sandbox) {
     return NS_ERROR_FAILURE;
   }
 
   // Use exclusive expandos for non-system-principal sandboxes.
   bool hasExclusiveExpandos = !isSystemPrincipal;
 
   // Set up the wantXrays flag, which indicates whether xrays are desired even
@@ -1148,17 +1148,17 @@ nsresult xpc::CreateSandboxObject(JSCont
         JSObject* unwrappedProto =
             js::CheckedUnwrapDynamic(options.proto, cx, false);
         if (!unwrappedProto) {
           JS_ReportErrorASCII(cx, "Sandbox must subsume sandboxPrototype");
           return NS_ERROR_INVALID_ARG;
         }
         const js::Class* unwrappedClass = js::GetObjectClass(unwrappedProto);
         useSandboxProxy = IS_WN_CLASS(unwrappedClass) ||
-                          mozilla::dom::IsDOMClass(Jsvalify(unwrappedClass));
+                          mozilla::dom::IsDOMClass(unwrappedClass);
       }
 
       if (useSandboxProxy) {
         // Wrap it up in a proxy that will do the right thing in terms
         // of this-binding for methods.
         RootedValue priv(cx, ObjectValue(*options.proto));
         options.proto =
             js::NewProxyObject(cx, &sandboxProxyHandler, priv, nullptr);
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -57,17 +57,17 @@ static JSObject* UnwrapNativeCPOW(nsISup
   }
   return nullptr;
 }
 
 /***************************************************************************/
 
 // static
 bool XPCConvert::GetISupportsFromJSObject(JSObject* obj, nsISupports** iface) {
-  const JSClass* jsclass = js::GetObjectJSClass(obj);
+  const JSClass* jsclass = js::GetObjectClass(obj);
   MOZ_ASSERT(jsclass, "obj has no class");
   if (jsclass && (jsclass->flags & JSCLASS_HAS_PRIVATE) &&
       (jsclass->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS)) {
     *iface = (nsISupports*)xpc_GetJSPrivate(obj);
     return true;
   }
   *iface = UnwrapDOMObjectToISupports(obj);
   return !!*iface;
--- a/js/xpconnect/src/XPCJSID.cpp
+++ b/js/xpconnect/src/XPCJSID.cpp
@@ -218,17 +218,17 @@ Maybe<nsID> JSValue2ID(JSContext* aCx, H
 }
 
 /**
  * Public ID Object Constructor Methods
  */
 static JSObject* NewIDObjectHelper(JSContext* aCx, const js::Class* aClass) {
   RootedObject proto(aCx, GetIDPrototype(aCx, aClass));
   if (proto) {
-    return JS_NewObjectWithGivenProto(aCx, Jsvalify(aClass), proto);
+    return JS_NewObjectWithGivenProto(aCx, aClass, proto);
   }
   return nullptr;
 }
 
 bool ID2JSValue(JSContext* aCx, const nsID& aId, MutableHandleValue aVal) {
   RootedObject obj(aCx, NewIDObjectHelper(aCx, &sID_Class));
   if (!obj) {
     return false;
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
@@ -1082,17 +1082,17 @@ pre_call_clean_up:
   }
 
   return retval;
 }
 
 static const JSClass XPCOutParamClass = {"XPCOutParam", 0, JS_NULL_CLASS_OPS};
 
 bool xpc::IsOutObject(JSContext* cx, JSObject* obj) {
-  return js::GetObjectJSClass(obj) == &XPCOutParamClass;
+  return js::GetObjectClass(obj) == &XPCOutParamClass;
 }
 
 JSObject* xpc::NewOutObject(JSContext* cx) {
   return JS_NewObject(cx, &XPCOutParamClass);
 }
 
 // static
 void nsXPCWrappedJS::DebugDumpInterfaceInfo(const nsXPTInterfaceInfo* aInfo,
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -629,18 +629,18 @@ void XPCWrappedNative::GatherScriptable(
 
 bool XPCWrappedNative::Init(JSContext* cx, nsIXPCScriptable* aScriptable) {
   // Setup our scriptable...
   MOZ_ASSERT(!mScriptable);
   mScriptable = aScriptable;
 
   // create our flatJSObject
 
-  const JSClass* jsclazz = mScriptable ? mScriptable->GetJSClass()
-                                       : Jsvalify(&XPC_WN_NoHelper_JSClass);
+  const JSClass* jsclazz =
+      mScriptable ? mScriptable->GetJSClass() : &XPC_WN_NoHelper_JSClass;
 
   // We should have the global jsclass flag if and only if we're a global.
   MOZ_ASSERT_IF(mScriptable, !!mScriptable->IsGlobalObject() ==
                                  !!(jsclazz->flags & JSCLASS_IS_GLOBAL));
 
   MOZ_ASSERT(jsclazz && jsclazz->name && jsclazz->flags &&
                  jsclazz->getResolve() && jsclazz->hasFinalize(),
              "bad class");
@@ -1039,17 +1039,17 @@ nsresult XPCWrappedNative::InitTearOff(J
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   return NS_OK;
 }
 
 bool XPCWrappedNative::InitTearOffJSObject(JSContext* cx,
                                            XPCWrappedNativeTearOff* to) {
-  JSObject* obj = JS_NewObject(cx, Jsvalify(&XPC_WN_Tearoff_JSClass));
+  JSObject* obj = JS_NewObject(cx, &XPC_WN_Tearoff_JSClass);
   if (!obj) {
     return false;
   }
 
   JS_SetPrivate(obj, to);
   to->SetJSObject(obj);
 
   js::SetReservedSlot(obj, XPC_WN_TEAROFF_FLAT_OBJECT_SLOT,
--- a/js/xpconnect/src/XPCWrappedNativeProto.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeProto.cpp
@@ -47,18 +47,17 @@ XPCWrappedNativeProto::~XPCWrappedNative
 
   DeferredFinalize(mClassInfo.forget().take());
 }
 
 bool XPCWrappedNativeProto::Init(JSContext* cx, nsIXPCScriptable* scriptable) {
   mScriptable = scriptable;
 
   JS::RootedObject proto(cx, JS::GetRealmObjectPrototype(cx));
-  mJSProtoObject = JS_NewObjectWithUniqueType(
-      cx, js::Jsvalify(&XPC_WN_Proto_JSClass), proto);
+  mJSProtoObject = JS_NewObjectWithUniqueType(cx, &XPC_WN_Proto_JSClass, proto);
 
   bool success = !!mJSProtoObject;
   if (success) {
     JS_SetPrivate(mJSProtoObject, this);
   }
 
   return success;
 }
--- a/xpcom/base/CycleCollectedJSRuntime.cpp
+++ b/xpcom/base/CycleCollectedJSRuntime.cpp
@@ -1180,17 +1180,17 @@ void CycleCollectedJSRuntime::GarbageCol
 
 void CycleCollectedJSRuntime::JSObjectsTenured() {
   for (auto iter = mNurseryObjects.Iter(); !iter.Done(); iter.Next()) {
     nsWrapperCache* cache = iter.Get();
     JSObject* wrapper = cache->GetWrapperMaybeDead();
     MOZ_DIAGNOSTIC_ASSERT(wrapper || recordreplay::IsReplaying());
     if (!JS::ObjectIsTenured(wrapper)) {
       MOZ_ASSERT(!cache->PreservingWrapper());
-      const JSClass* jsClass = js::GetObjectJSClass(wrapper);
+      const JSClass* jsClass = js::GetObjectClass(wrapper);
       jsClass->doFinalize(nullptr, wrapper);
     }
   }
 
 #ifdef DEBUG
   for (auto iter = mPreservedNurseryObjects.Iter(); !iter.Done(); iter.Next()) {
     MOZ_ASSERT(JS::ObjectIsTenured(iter.Get().get()));
   }