Bug 1140573 part 1. Drop the parent argument from JS_NewFunction. r=waldo
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 09 Mar 2015 12:50:03 -0400
changeset 232579 0ba66387063628463083f36d458c9282e77b0129
parent 232578 b45b569aa36516ff66b3bb313199ce7f483ca49a
child 232580 04c874c968379e9ecc32950978ae1a3f6201f7aa
push id28386
push userkwierso@gmail.com
push dateTue, 10 Mar 2015 01:27:56 +0000
treeherdermozilla-central@9d54f24596e9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswaldo
bugs1140573
milestone39.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 1140573 part 1. Drop the parent argument from JS_NewFunction. r=waldo
dom/base/nsDocument.cpp
dom/bindings/BindingUtils.cpp
js/ipc/WrapperOwner.cpp
js/src/gdb/tests/test-JSObject.cpp
js/src/jsapi-tests/testCallNonGenericMethodOnProxy.cpp
js/src/jsapi-tests/testChromeBuffer.cpp
js/src/jsapi-tests/testDefineGetterSetterNonEnumerable.cpp
js/src/jsapi-tests/testParseJSON.cpp
js/src/jsapi.cpp
js/src/jsapi.h
js/xpconnect/src/XPCWrappedNativeJSOps.cpp
js/xpconnect/wrappers/XrayWrapper.cpp
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -6370,17 +6370,17 @@ nsDocument::RegisterElement(JSContext* a
 
       EnqueueLifecycleCallback(nsIDocument::eCreated, elem, nullptr, definition);
     }
   }
 
   // Create constructor to return. Store the name of the custom element as the
   // name of the function.
   JSFunction* constructor = JS_NewFunction(aCx, nsDocument::CustomElementConstructor, 0,
-                                           JSFUN_CONSTRUCTOR, JS::NullPtr(),
+                                           JSFUN_CONSTRUCTOR,
                                            NS_ConvertUTF16toUTF8(lcType).get());
   if (!constructor) {
     rv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return;
   }
 
   JS::Rooted<JSObject*> constructorObj(aCx, JS_GetFunctionObject(constructor));
   if (!JS_LinkConstructorAndPrototype(aCx, constructorObj, protoObject)) {
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -1387,17 +1387,17 @@ XrayResolveOwnProperty(JSContext* cx, JS
                                            nativePropertyHooks->mPrototypeID,
                                            JSPROP_PERMANENT | JSPROP_READONLY,
                                            desc, cacheOnHolder);
     }
 
     if (IdEquals(id, "toString") && !JS_ObjectIsFunction(cx, obj)) {
       MOZ_ASSERT(IsDOMIfaceAndProtoClass(js::GetObjectClass(obj)));
 
-      JS::Rooted<JSFunction*> toString(cx, JS_NewFunction(cx, InterfaceObjectToString, 0, 0, wrapper, "toString"));
+      JS::Rooted<JSFunction*> toString(cx, JS_NewFunction(cx, InterfaceObjectToString, 0, 0, "toString"));
       if (!toString) {
         return false;
       }
 
       cacheOnHolder = true;
 
       FillPropertyDescriptor(desc, wrapper, 0,
                              JS::ObjectValue(*JS_GetFunctionObject(toString)));
--- a/js/ipc/WrapperOwner.cpp
+++ b/js/ipc/WrapperOwner.cpp
@@ -416,17 +416,18 @@ WrapperOwner::get(JSContext *cx, HandleO
     if (!ok(cx, status))
         return false;
 
     if (!fromVariant(cx, val, vp))
         return false;
 
     if (idVar.type() == JSIDVariant::TnsString &&
         idVar.get_nsString().EqualsLiteral("toString")) {
-        RootedFunction toString(cx, JS_NewFunction(cx, CPOWToString, 0, 0, proxy, "toString"));
+        RootedFunction toString(cx, JS_NewFunction(cx, CPOWToString, 0, 0,
+                                                   "toString"));
         if (!toString)
             return false;
 
         RootedObject toStringObj(cx, JS_GetFunctionObject(toString));
 
         if (!JS_DefineProperty(cx, toStringObj, "__cpow__", vp, JSPROP_PERMANENT | JSPROP_READONLY))
             return false;
 
--- a/js/src/gdb/tests/test-JSObject.cpp
+++ b/js/src/gdb/tests/test-JSObject.cpp
@@ -1,20 +1,20 @@
 #include "gdb-tests.h"
 #include "jsapi.h"
 
 FRAGMENT(JSObject, simple) {
   JS::Rooted<JSObject *> glob(cx, JS::CurrentGlobalOrNull(cx));
   JS::Rooted<JSObject *> plain(cx, JS_NewPlainObject(cx));
   JS::Rooted<JSObject *> global(cx, JS::CurrentGlobalOrNull(cx));
   JS::Rooted<JSObject *> func(cx, (JSObject *) JS_NewFunction(cx, (JSNative) 1, 0, 0,
-                                                              global, "dys"));
-  JS::Rooted<JSObject *> anon(cx, (JSObject *) JS_NewFunction(cx, (JSNative) 1, 0, 0, global, 0));
+                                                              "dys"));
+  JS::Rooted<JSObject *> anon(cx, (JSObject *) JS_NewFunction(cx, (JSNative) 1, 0, 0, nullptr));
   JS::Rooted<JSFunction *> funcPtr(cx, JS_NewFunction(cx, (JSNative) 1, 0, 0,
-                                                      global, "formFollows"));
+                                                      "formFollows"));
 
   JSObject &plainRef = *plain;
   JSFunction &funcRef = *funcPtr;
   JSObject *plainRaw = plain;
   JSObject *funcRaw = func;
 
   breakpoint();
 
--- a/js/src/jsapi-tests/testCallNonGenericMethodOnProxy.cpp
+++ b/js/src/jsapi-tests/testCallNonGenericMethodOnProxy.cpp
@@ -40,17 +40,17 @@ BEGIN_TEST(test_CallNonGenericMethodOnPr
   JS::RootedObject globalA(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr, JS::FireOnNewGlobalHook));
   CHECK(globalA);
 
   JS::RootedObject customA(cx, JS_NewObject(cx, &CustomClass));
   CHECK(customA);
   JS_SetReservedSlot(customA, CUSTOM_SLOT, Int32Value(17));
 
   JS::RootedFunction customMethodA(cx, JS_NewFunction(cx, CustomMethod, 0, 0,
-                                                      customA, "customMethodA"));
+                                                      "customMethodA"));
   CHECK(customMethodA);
 
   JS::RootedValue rval(cx);
   CHECK(JS_CallFunction(cx, customA, customMethodA, JS::HandleValueArray::empty(),
                         &rval));
   CHECK_SAME(rval, Int32Value(17));
 
   // Now create the second global object and compartment...
@@ -59,17 +59,18 @@ BEGIN_TEST(test_CallNonGenericMethodOnPr
     CHECK(globalB);
 
     // ...and enter it.
     JSAutoCompartment enter(cx, globalB);
     JS::RootedObject customB(cx, JS_NewObject(cx, &CustomClass));
     CHECK(customB);
     JS_SetReservedSlot(customB, CUSTOM_SLOT, Int32Value(42));
 
-    JS::RootedFunction customMethodB(cx, JS_NewFunction(cx, CustomMethod, 0, 0, customB, "customMethodB"));
+    JS::RootedFunction customMethodB(cx, JS_NewFunction(cx, CustomMethod, 0, 0,
+							"customMethodB"));
     CHECK(customMethodB);
 
     JS::RootedValue rval(cx);
     CHECK(JS_CallFunction(cx, customB, customMethodB, JS::HandleValueArray::empty(),
                           &rval));
     CHECK_SAME(rval, Int32Value(42));
 
     JS::RootedObject wrappedCustomA(cx, customA);
--- a/js/src/jsapi-tests/testChromeBuffer.cpp
+++ b/js/src/jsapi-tests/testChromeBuffer.cpp
@@ -162,17 +162,17 @@ BEGIN_TEST(testChromeBuffer)
             options.setFileAndLine("", 0);
             JS::AutoObjectVector emptyScopeChain(cx);
             CHECK(JS::CompileFunction(cx, emptyScopeChain, options, "trusted",
                                       0, nullptr, bytes, strlen(bytes), &fun));
             CHECK(JS_DefineProperty(cx, trusted_glob, "trusted", fun, JSPROP_ENUMERATE));
             trusted_fun = JS_GetFunctionObject(fun);
         }
 
-        JS::RootedFunction fun(cx, JS_NewFunction(cx, CallTrusted, 0, 0, global, "callTrusted"));
+        JS::RootedFunction fun(cx, JS_NewFunction(cx, CallTrusted, 0, 0, "callTrusted"));
         JS::RootedObject callTrusted(cx, JS_GetFunctionObject(fun));
 
         const char *paramName = "f";
         const char *bytes = "try {                                      "
                             "  return untrusted(trusted);               "
                             "} catch (e) {                              "
                             "  return f();                              "
                             "}                                          ";
--- a/js/src/jsapi-tests/testDefineGetterSetterNonEnumerable.cpp
+++ b/js/src/jsapi-tests/testDefineGetterSetterNonEnumerable.cpp
@@ -17,22 +17,22 @@ BEGIN_TEST(testDefineGetterSetterNonEnum
 {
     static const char PROPERTY_NAME[] = "foo";
 
     JS::RootedValue vobj(cx);
     JS::RootedObject obj(cx, JS_NewPlainObject(cx));
     CHECK(obj);
     vobj = OBJECT_TO_JSVAL(obj);
 
-    JSFunction *funGet = JS_NewFunction(cx, NativeGetterSetter, 0, 0, JS::NullPtr(), "get");
+    JSFunction *funGet = JS_NewFunction(cx, NativeGetterSetter, 0, 0, "get");
     CHECK(funGet);
     JS::RootedObject funGetObj(cx, JS_GetFunctionObject(funGet));
     JS::RootedValue vget(cx, OBJECT_TO_JSVAL(funGetObj));
 
-    JSFunction *funSet = JS_NewFunction(cx, NativeGetterSetter, 1, 0, JS::NullPtr(), "set");
+    JSFunction *funSet = JS_NewFunction(cx, NativeGetterSetter, 1, 0, "set");
     CHECK(funSet);
     JS::RootedObject funSetObj(cx, JS_GetFunctionObject(funSet));
     JS::RootedValue vset(cx, OBJECT_TO_JSVAL(funSetObj));
 
     JS::RootedObject vObject(cx, vobj.toObjectOrNull());
     CHECK(JS_DefineProperty(cx, vObject, PROPERTY_NAME,
                             JS::UndefinedHandleValue,
                             JSPROP_GETTER | JSPROP_SETTER | JSPROP_SHARED | JSPROP_ENUMERATE,
--- a/js/src/jsapi-tests/testParseJSON.cpp
+++ b/js/src/jsapi-tests/testParseJSON.cpp
@@ -333,17 +333,17 @@ Censor(JSContext *cx, unsigned argc, jsv
     MOZ_RELEASE_ASSERT(args.length() == 2);
     MOZ_RELEASE_ASSERT(args[0].isString());
     args.rval().setNull();
     return true;
 }
 
 BEGIN_TEST(testParseJSON_reviver)
 {
-    JSFunction *fun = JS_NewFunction(cx, Censor, 0, 0, global, "censor");
+    JSFunction *fun = JS_NewFunction(cx, Censor, 0, 0, "censor");
     CHECK(fun);
 
     JS::RootedValue filter(cx, OBJECT_TO_JSVAL(JS_GetFunctionObject(fun)));
 
     CHECK(TryParse(cx, "true", filter));
     CHECK(TryParse(cx, "false", filter));
     CHECK(TryParse(cx, "null", filter));
     CHECK(TryParse(cx, "1", filter));
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -3131,33 +3131,32 @@ JS_InitDestroyPrincipalsCallback(JSRunti
 {
     MOZ_ASSERT(destroyPrincipals);
     MOZ_ASSERT(!rt->destroyPrincipals);
     rt->destroyPrincipals = destroyPrincipals;
 }
 
 JS_PUBLIC_API(JSFunction *)
 JS_NewFunction(JSContext *cx, JSNative native, unsigned nargs, unsigned flags,
-               HandleObject parent, const char *name)
+               const char *name)
 {
     MOZ_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
 
     AssertHeapIsIdle(cx);
     CHECK_REQUEST(cx);
-    assertSameCompartment(cx, parent);
 
     RootedAtom atom(cx);
     if (name) {
         atom = Atomize(cx, name, strlen(name));
         if (!atom)
             return nullptr;
     }
 
     JSFunction::Flags funFlags = JSAPIToJSFunctionFlags(flags);
-    return NewFunction(cx, NullPtr(), native, nargs, funFlags, parent, atom);
+    return NewFunction(cx, NullPtr(), native, nargs, funFlags, NullPtr(), atom);
 }
 
 JS_PUBLIC_API(JSFunction *)
 JS_NewFunctionById(JSContext *cx, JSNative native, unsigned nargs, unsigned flags,
                    HandleObject parent, HandleId id)
 {
     MOZ_ASSERT(JSID_IS_STRING(id));
     MOZ_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -3062,17 +3062,17 @@ JS_SetReservedSlot(JSObject *obj, uint32
 
 /************************************************************************/
 
 /*
  * Functions and scripts.
  */
 extern JS_PUBLIC_API(JSFunction *)
 JS_NewFunction(JSContext *cx, JSNative call, unsigned nargs, unsigned flags,
-               JS::Handle<JSObject*> parent, const char *name);
+               const char *name);
 
 /*
  * Create the function with the name given by the id. JSID_IS_STRING(id) must
  * be true.
  */
 extern JS_PUBLIC_API(JSFunction *)
 JS_NewFunctionById(JSContext *cx, JSNative call, unsigned nargs, unsigned flags,
                    JS::Handle<JSObject*> parent, JS::Handle<jsid> id);
--- a/js/xpconnect/src/XPCWrappedNativeJSOps.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeJSOps.cpp
@@ -237,17 +237,17 @@ DefinePropertyIfFound(XPCCallContext& cc
                 name = rt->GetStringName(XPCJSRuntime::IDX_TO_SOURCE);
                 id   = rt->GetStringID(XPCJSRuntime::IDX_TO_SOURCE);
             }
 
             else
                 call = nullptr;
 
             if (call) {
-                RootedFunction fun(ccx, JS_NewFunction(ccx, call, 0, 0, obj, name));
+                RootedFunction fun(ccx, JS_NewFunction(ccx, call, 0, 0, name));
                 if (!fun) {
                     JS_ReportOutOfMemory(ccx);
                     return false;
                 }
 
                 AutoResolveName arn(ccx, id);
                 if (resolved)
                     *resolved = true;
@@ -294,17 +294,17 @@ DefinePropertyIfFound(XPCCallContext& cc
             // A security check is done on a per-get basis.
 
             JSFunction* fun;
 
             id = rt->GetStringID(XPCJSRuntime::IDX_WRAPPED_JSOBJECT);
             name = rt->GetStringName(XPCJSRuntime::IDX_WRAPPED_JSOBJECT);
 
             fun = JS_NewFunction(ccx, XPC_WN_DoubleWrappedGetter,
-                                 0, 0, obj, name);
+                                 0, 0, name);
 
             if (!fun)
                 return false;
 
             RootedObject funobj(ccx, JS_GetFunctionObject(fun));
             if (!funobj)
                 return false;
 
--- a/js/xpconnect/wrappers/XrayWrapper.cpp
+++ b/js/xpconnect/wrappers/XrayWrapper.cpp
@@ -1200,17 +1200,17 @@ XPCWrappedNativeXrayTraits::resolveNativ
     if (ccx.GetWrapper() != wn || !wn->IsValid()) {
         return true;
     }
 
     if (!(iface = ccx.GetInterface()) || !(member = ccx.GetMember())) {
         if (id != nsXPConnect::GetRuntimeInstance()->GetStringID(XPCJSRuntime::IDX_TO_STRING))
             return true;
 
-        JSFunction *toString = JS_NewFunction(cx, XrayToString, 0, 0, holder, "toString");
+        JSFunction *toString = JS_NewFunction(cx, XrayToString, 0, 0, "toString");
         if (!toString)
             return false;
 
         FillPropertyDescriptor(desc, wrapper, 0,
                                ObjectValue(*JS_GetFunctionObject(toString)));
 
         return JS_DefinePropertyById(cx, holder, id, desc) &&
                JS_GetPropertyDescriptorById(cx, holder, id, desc);