Bug 1131805 part 2. Remove remaining js::GetObjectParent and JS_GetParent uses in SpiderMonkey. r=waldo
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 06 Mar 2015 16:33:31 -0500
changeset 232359 41846743ab88b9ca108c2accb2d646cf6a9387e3
parent 232358 fdb146bc4052d731374a19a496b21640507ddb73
child 232360 62fecc6ab96e72c0958e8ebda798700ff431a8ae
push id56525
push userbzbarsky@mozilla.com
push dateSat, 07 Mar 2015 02:16:16 +0000
treeherdermozilla-inbound@41846743ab88 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswaldo
bugs1131805
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 1131805 part 2. Remove remaining js::GetObjectParent and JS_GetParent uses in SpiderMonkey. r=waldo
js/src/jsapi-tests/selfTest.cpp
js/src/jsapi-tests/testTypedArrays.cpp
js/src/jsapi.cpp
js/src/jsapi.h
js/src/jsfriendapi.h
js/src/shell/js.cpp
--- a/js/src/jsapi-tests/selfTest.cpp
+++ b/js/src/jsapi-tests/selfTest.cpp
@@ -13,15 +13,8 @@ BEGIN_TEST(selfTest_NaNsAreSame)
     EVAL("0/0", &v1);  // NaN
     CHECK_SAME(v1, v1);
 
     EVAL("Math.sin('no')", &v2);  // also NaN
     CHECK_SAME(v1, v2);
     return true;
 }
 END_TEST(selfTest_NaNsAreSame)
-
-BEGIN_TEST(selfTest_globalHasNoParent)
-{
-    CHECK(JS_GetParent(global) == nullptr);
-    return true;
-}
-END_TEST(selfTest_globalHasNoParent)
--- a/js/src/jsapi-tests/testTypedArrays.cpp
+++ b/js/src/jsapi-tests/testTypedArrays.cpp
@@ -28,18 +28,16 @@ BEGIN_TEST(testTypedArrays)
 
     size_t nbytes = sizeof(double) * 8;
     RootedObject buffer(cx, JS_NewArrayBuffer(cx, nbytes));
     CHECK(JS_IsArrayBufferObject(buffer));
 
     RootedObject proto(cx);
     JS_GetPrototype(cx, buffer, &proto);
     CHECK(!JS_IsArrayBufferObject(proto));
-    RootedObject dummy(cx, JS_GetParent(proto));
-    CHECK(!JS_IsArrayBufferObject(dummy));
 
     {
         JS::AutoCheckCannotGC nogc;
         CHECK_EQUAL(JS_GetArrayBufferByteLength(buffer), nbytes);
         memset(JS_GetArrayBufferData(buffer, nogc), 1, nbytes);
     }
 
     ok = ok &&
@@ -67,18 +65,16 @@ TestPlainTypedArray(JSContext *cx)
         CHECK(!notArray);
     }
 
     RootedObject array(cx, Create(cx, 7));
     CHECK(JS_IsTypedArrayObject(array));
     RootedObject proto(cx);
     JS_GetPrototype(cx, array, &proto);
     CHECK(!JS_IsTypedArrayObject(proto));
-    RootedObject dummy(cx, JS_GetParent(proto));
-    CHECK(!JS_IsTypedArrayObject(dummy));
 
     CHECK_EQUAL(JS_GetTypedArrayLength(array), 7u);
     CHECK_EQUAL(JS_GetTypedArrayByteOffset(array), 0u);
     CHECK_EQUAL(JS_GetTypedArrayByteLength(array), sizeof(Element) * 7);
 
     {
         JS::AutoCheckCannotGC nogc;
         Element *data;
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1803,23 +1803,16 @@ JS_IsExtensible(JSContext *cx, HandleObj
 
 JS_PUBLIC_API(bool)
 JS_PreventExtensions(JSContext *cx, JS::HandleObject obj, ObjectOpResult &result)
 {
     return PreventExtensions(cx, obj, result);
 }
 
 JS_PUBLIC_API(JSObject *)
-JS_GetParent(JSObject *obj)
-{
-    MOZ_ASSERT(!obj->is<ScopeObject>());
-    return obj->getParent();
-}
-
-JS_PUBLIC_API(JSObject *)
 JS_GetConstructor(JSContext *cx, HandleObject proto)
 {
     AssertHeapIsIdle(cx);
     CHECK_REQUEST(cx);
     assertSameCompartment(cx, proto);
 
     RootedValue cval(cx);
     if (!GetProperty(cx, proto, proto, cx->names().constructor, &cval))
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -2238,19 +2238,16 @@ JS_GetInstancePrivate(JSContext *cx, JS:
 
 extern JS_PUBLIC_API(bool)
 JS_GetPrototype(JSContext *cx, JS::HandleObject obj, JS::MutableHandleObject protop);
 
 extern JS_PUBLIC_API(bool)
 JS_SetPrototype(JSContext *cx, JS::HandleObject obj, JS::HandleObject proto);
 
 extern JS_PUBLIC_API(JSObject *)
-JS_GetParent(JSObject *obj);
-
-extern JS_PUBLIC_API(JSObject *)
 JS_GetConstructor(JSContext *cx, JS::Handle<JSObject*> proto);
 
 namespace JS {
 
 enum ZoneSpecifier {
     FreshZone = 0,
     SystemZone = 1
 };
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -684,24 +684,16 @@ JS_FRIEND_API(bool)
 IsScopeObject(JSObject *obj);
 
 JS_FRIEND_API(bool)
 IsCallObject(JSObject *obj);
 
 JS_FRIEND_API(bool)
 CanAccessObjectShape(JSObject *obj);
 
-inline JSObject *
-GetObjectParent(JSObject *obj)
-{
-    MOZ_ASSERT(!IsScopeObject(obj));
-    MOZ_ASSERT(CanAccessObjectShape(obj));
-    return reinterpret_cast<shadow::Object*>(obj)->shape->base->parent;
-}
-
 static MOZ_ALWAYS_INLINE JSCompartment *
 GetObjectCompartment(JSObject *obj)
 {
     return reinterpret_cast<shadow::Object*>(obj)->group->compartment;
 }
 
 JS_FRIEND_API(JSObject *)
 GetGlobalForObjectCrossCompartment(JSObject *obj);
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -2579,17 +2579,17 @@ Clone(JSContext *cx, unsigned argc, jsva
             return false;
         }
     }
 
     if (args.length() > 1) {
         if (!JS_ValueToObject(cx, args[1], &parent))
             return false;
     } else {
-        parent = JS_GetParent(&args.callee());
+        parent = js::GetGlobalForObjectCrossCompartment(&args.callee());
     }
 
     // Should it worry us that we might be getting with wrappers
     // around with wrappers here?
     JS::AutoObjectVector scopeChain(cx);
     if (!parent->is<GlobalObject>() && !scopeChain.append(parent))
         return false;
     JSObject *clone = JS::CloneFunctionObject(cx, funobj, scopeChain);
@@ -3233,44 +3233,16 @@ Elapsed(JSContext *cx, unsigned argc, js
         args.rval().setDouble(d);
         return true;
     }
     JS_ReportError(cx, "Wrong number of arguments");
     return false;
 }
 
 static bool
-Parent(JSContext *cx, unsigned argc, jsval *vp)
-{
-    CallArgs args = CallArgsFromVp(argc, vp);
-    if (args.length() != 1) {
-        JS_ReportError(cx, "Wrong number of arguments");
-        return false;
-    }
-
-    Value v = args[0];
-    if (v.isPrimitive()) {
-        JS_ReportError(cx, "Only objects have parents!");
-        return false;
-    }
-
-    Rooted<JSObject*> parent(cx, JS_GetParent(&v.toObject()));
-
-    /* Outerize if necessary. */
-    if (parent) {
-        parent = GetOuterObject(cx, parent);
-        if (!parent)
-            return false;
-    }
-
-    args.rval().setObjectOrNull(parent);
-    return true;
-}
-
-static bool
 Compile(JSContext *cx, unsigned argc, jsval *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     if (args.length() < 1) {
         JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED,
                              "compile", "0", "s");
         return false;
     }
@@ -4927,20 +4899,16 @@ static const JSFunctionSpecWithHelp fuzz
 "clone(fun[, scope])",
 "  Clone function object."),
 
     JS_FN_HELP("getSelfHostedValue", GetSelfHostedValue, 1, 0,
 "getSelfHostedValue()",
 "  Get a self-hosted value by its name. Note that these values don't get \n"
 "  cached, so repeatedly getting the same value creates multiple distinct clones."),
 
-    JS_FN_HELP("parent", Parent, 1, 0,
-"parent(obj)",
-"  Returns the parent of obj."),
-
     JS_FN_HELP("line2pc", LineToPC, 0, 0,
 "line2pc([fun,] line)",
 "  Map line number to PC."),
 
     JS_FN_HELP("pc2line", PCToLine, 0, 0,
 "pc2line(fun[, pc])",
 "  Map PC to line number."),