Bug 864046 - GC: Almost the last rooting fixes in XPConnect - part 2 r=bholley
authorJon Coppeard <jcoppeard@mozilla.com>
Sat, 20 Apr 2013 13:08:16 +0100
changeset 140534 7712c68becc6bd4abdcd0a87460dad3c97ed458c
parent 140533 5b9533763879f4ed20932573e1ba24beb18d39a0
child 140535 ed5ef73d646e904216dcdff8bd25b378c828669b
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs864046
milestone23.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 864046 - GC: Almost the last rooting fixes in XPConnect - part 2 r=bholley
js/xpconnect/src/XPCComponents.cpp
js/xpconnect/src/XPCInlines.h
js/xpconnect/src/XPCMaps.h
js/xpconnect/src/XPCQuickStubs.h
js/xpconnect/src/xpcprivate.h
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -3185,17 +3185,18 @@ bool BindPropertyOp(JSContext *cx, Op &o
     RootedObject func(cx);
     if (desc->attrs & attrFlag) {
         // Already an object
         func = JS_FUNC_TO_DATA_PTR(JSObject *, op);
     } else {
         // We have an actual property op.  For getters, we use 0
         // args, for setters we use 1 arg.
         uint32_t args = (attrFlag == JSPROP_GETTER) ? 0 : 1;
-        func = GeneratePropertyOp(cx, desc->obj, id, args, op);
+        RootedObject obj(cx, desc->obj);
+        func = GeneratePropertyOp(cx, obj, id, args, op);
         if (!func)
             return false;
     }
     func = WrapCallable(cx, func, sandboxProtoProxy);
     if (!func)
         return false;
     op = JS_DATA_TO_FUNC_PTR(Op, func.get());
     desc->attrs |= attrFlag;
--- a/js/xpconnect/src/XPCInlines.h
+++ b/js/xpconnect/src/XPCInlines.h
@@ -254,17 +254,17 @@ XPCCallContext::SetRetVal(jsval val)
 inline jsid
 XPCCallContext::GetResolveName() const
 {
     CHECK_STATE(HAVE_CONTEXT);
     return XPCJSRuntime::Get()->GetResolveName();
 }
 
 inline jsid
-XPCCallContext::SetResolveName(jsid name)
+XPCCallContext::SetResolveName(JS::HandleId name)
 {
     CHECK_STATE(HAVE_CONTEXT);
     return XPCJSRuntime::Get()->SetResolveName(name);
 }
 
 inline XPCWrappedNative*
 XPCCallContext::GetResolvingWrapper() const
 {
--- a/js/xpconnect/src/XPCMaps.h
+++ b/js/xpconnect/src/XPCMaps.h
@@ -645,24 +645,25 @@ public:
             JSObject *updated = e.front().key;
             if (JS_IsAboutToBeFinalized(&updated) || JS_IsAboutToBeFinalized(&e.front().value))
                 e.removeFront();
             else if (updated != e.front().key)
                 e.rekeyFront(updated);
         }
     }
 
-    void Reparent(JSContext *aCx, JSObject *aNewInner) {
+    void Reparent(JSContext *aCx, JSObject *aNewInnerArg) {
+        JS::RootedObject aNewInner(aCx, aNewInnerArg);
         for (Map::Enum e(mTable); !e.empty(); e.popFront()) {
             /*
              * We reparent wrappers that have as their parent an inner window
              * whose outer has the new inner window as its current inner.
              */
-            JSObject *parent = JS_GetParent(e.front().value);
-            JSObject *outer = JS_ObjectToOuterObject(aCx, parent);
+            JS::RootedObject parent(aCx, JS_GetParent(e.front().value));
+            JS::RootedObject outer(aCx, JS_ObjectToOuterObject(aCx, parent));
             if (outer) {
                 JSObject *inner = JS_ObjectToInnerObject(aCx, outer);
                 if (inner == aNewInner && inner != parent)
                     JS_SetParent(aCx, e.front().value, aNewInner);
             } else {
                 JS_ClearPendingException(aCx);
             }
         }
--- a/js/xpconnect/src/XPCQuickStubs.h
+++ b/js/xpconnect/src/XPCQuickStubs.h
@@ -660,52 +660,50 @@ PropertyOpForwarder(JSContext *cx, unsig
 {
     // Layout:
     //   this = our this
     //   property op to call = callee reserved slot 0
     //   name of the property = callee reserved slot 1
 
     JS::CallArgs args = CallArgsFromVp(argc, vp);
 
-    JSObject *callee = &args.callee();
+    JS::RootedObject callee(cx, &args.callee());
     JS::RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
     if (!obj)
         return false;
 
     jsval v = js::GetFunctionNativeReserved(callee, 0);
 
     JSObject *ptrobj = JSVAL_TO_OBJECT(v);
     Op *popp = static_cast<Op *>(JS_GetPrivate(ptrobj));
 
     v = js::GetFunctionNativeReserved(callee, 1);
 
-    jsval argval = (argc > 0) ? args[0] : JSVAL_VOID;
+    JS::RootedValue argval(cx, (argc > 0) ? args.get(0) : JSVAL_VOID);
     JS::RootedId id(cx);
     if (!JS_ValueToId(cx, v, id.address()))
         return false;
     args.rval().set(argval);
     return ApplyPropertyOp<Op>(cx, *popp, obj, id, args.rval());
 }
 
 extern JSClass PointerHolderClass;
 
 template<typename Op>
 JSObject *
-GeneratePropertyOp(JSContext *cx, JSObject *obj, jsid id, unsigned argc, Op pop)
+GeneratePropertyOp(JSContext *cx, JS::HandleObject obj, JS::HandleId id, unsigned argc, Op pop)
 {
     // The JS engine provides two reserved slots on function objects for
     // XPConnect to use. Use them to stick the necessary info here.
     JSFunction *fun =
         js::NewFunctionByIdWithReserved(cx, PropertyOpForwarder<Op>, argc, 0, obj, id);
     if (!fun)
         return nullptr;
 
-    JSObject *funobj = JS_GetFunctionObject(fun);
-
-    JS::AutoObjectRooter tvr(cx, funobj);
+    JS::RootedObject funobj(cx, JS_GetFunctionObject(fun));
 
     // Unfortunately, we cannot guarantee that Op is aligned. Use a
     // second object to work around this.
     JSObject *ptrobj = JS_NewObject(cx, &PointerHolderClass, nullptr, funobj);
     if (!ptrobj)
         return nullptr;
     Op *popp = new Op;
     if (!popp)
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -1197,17 +1197,17 @@ public:
 
     inline uint16_t                     GetMethodIndex() const ;
     inline void                         SetMethodIndex(uint16_t index) ;
 
     inline JSBool   GetDestroyJSContextInDestructor() const;
     inline void     SetDestroyJSContextInDestructor(JSBool b);
 
     inline jsid GetResolveName() const;
-    inline jsid SetResolveName(jsid name);
+    inline jsid SetResolveName(JS::HandleId name);
 
     inline XPCWrappedNative* GetResolvingWrapper() const;
     inline XPCWrappedNative* SetResolvingWrapper(XPCWrappedNative* w);
 
     inline void SetRetVal(jsval val);
 
     void SetName(jsid name);
     void SetArgsAndResultPtr(unsigned argc, jsval *argv, jsval *rval);
@@ -3831,17 +3831,17 @@ private:
     AutoScriptEvaluate(const AutoScriptEvaluate &) MOZ_DELETE;
     AutoScriptEvaluate & operator =(const AutoScriptEvaluate &) MOZ_DELETE;
 };
 
 /***************************************************************************/
 class MOZ_STACK_CLASS AutoResolveName
 {
 public:
-    AutoResolveName(XPCCallContext& ccx, jsid name
+    AutoResolveName(XPCCallContext& ccx, JS::HandleId name
                     MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
           mOld(ccx, XPCJSRuntime::Get()->SetResolveName(name))
 #ifdef DEBUG
           ,mCheck(ccx, name)
 #endif
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     }