author | David Zbarsky <dzbarsky@gmail.com> |
Tue, 14 May 2013 16:25:32 -0700 | |
changeset 143437 | c4f374baea0ab471d360493da85051f3920e5696 |
parent 143436 | 5f45f5f6cc29783bee64fba02bf5e45f025fa00a |
child 143438 | 1be2d9024641e4272e6c155e115f0636139c6e9b |
push id | 2697 |
push user | bbajaj@mozilla.com |
push date | Mon, 05 Aug 2013 18:49:53 +0000 |
treeherder | mozilla-beta@dfec938c7b63 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bz |
bugs | 868312 |
milestone | 24.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
|
--- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -7420,19 +7420,20 @@ nsGlobalWindow::NotifyDOMWindowThawed(ns DOM_WINDOW_THAWED_TOPIC, nullptr); } } } JSObject* nsGlobalWindow::GetCachedXBLPrototypeHandler(nsXBLPrototypeHandler* aKey) { - JSObject* handler = nullptr; + AutoSafeJSContext cx; + JS::Rooted<JSObject*> handler(cx); if (mCachedXBLPrototypeHandlers.IsInitialized()) { - mCachedXBLPrototypeHandlers.Get(aKey, &handler); + mCachedXBLPrototypeHandlers.Get(aKey, handler.address()); } return handler; } void nsGlobalWindow::CacheXBLPrototypeHandler(nsXBLPrototypeHandler* aKey, JS::Handle<JSObject*> aHandler) {
--- a/dom/plugins/base/nsJSNPRuntime.cpp +++ b/dom/plugins/base/nsJSNPRuntime.cpp @@ -137,17 +137,17 @@ NPObjWrapper_Finalize(JSFreeOp *fop, JSO static JSBool NPObjWrapper_Call(JSContext *cx, unsigned argc, JS::Value *vp); static JSBool NPObjWrapper_Construct(JSContext *cx, unsigned argc, JS::Value *vp); static JSBool CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject *npobj, - jsid id, NPVariant* getPropertyResult, JS::Value *vp); + JS::Handle<jsid> id, NPVariant* getPropertyResult, JS::Value *vp); JSClass sNPObjectJSWrapperClass = { NPRUNTIME_JSCLASS_NAME, JSCLASS_HAS_PRIVATE | JSCLASS_IMPLEMENTS_BARRIERS | JSCLASS_NEW_RESOLVE | JSCLASS_NEW_ENUMERATE, NPObjWrapper_AddProperty, NPObjWrapper_DelProperty, NPObjWrapper_GetProperty, @@ -955,17 +955,17 @@ JSObjWrapperHashMatchEntry(PLDHashTable e->mJSObjWrapper->mNpp == objWrapperKey->mNpp); } // Look up or create an NPObject that wraps the JSObject obj. // static NPObject * -nsJSObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, JSObject *obj) +nsJSObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, JS::Handle<JSObject*> obj) { if (!npp) { NS_ERROR("Null NPP passed to nsJSObjWrapper::GetNewOrUsed()!"); return nullptr; } if (!cx) { @@ -1079,26 +1079,27 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JS // Climb the prototype chain, unwrapping as necessary until we find an NP object // wrapper. // // Because this function unwraps, its return value must be wrapped for the cx // compartment for callers that plan to hold onto the result or do anything // substantial with it. static JSObject * -GetNPObjectWrapper(JSContext *cx, JSObject *obj, bool wrapResult = true) +GetNPObjectWrapper(JSContext *cx, JSObject *aObj, bool wrapResult = true) { + JS::Rooted<JSObject*> obj(cx, aObj); while (obj && (obj = js::CheckedUnwrap(obj))) { if (JS_GetClass(obj) == &sNPObjectJSWrapperClass) { - if (wrapResult && !JS_WrapObject(cx, &obj)) { + if (wrapResult && !JS_WrapObject(cx, obj.address())) { return NULL; } return obj; } - if (!::JS_GetPrototype(cx, obj, &obj)) { + if (!::JS_GetPrototype(cx, obj, obj.address())) { return NULL; } } return NULL; } static NPObject * GetNPObject(JSContext *cx, JSObject *obj) @@ -1331,17 +1332,17 @@ NPObjWrapper_GetProperty(JSContext *cx, if (!ReportExceptionIfPending(cx)) return JS_FALSE; } return JS_TRUE; } static JSBool -CallNPMethodInternal(JSContext *cx, JSObject *obj, unsigned argc, +CallNPMethodInternal(JSContext *cx, JS::Handle<JSObject*> obj, unsigned argc, JS::Value *argv, JS::Value *rval, bool ctorCall) { NPObject *npobj = GetNPObject(cx, obj); if (!npobj || !npobj->_class) { ThrowJSException(cx, "Bad NPObject as private data!"); return JS_FALSE; @@ -1460,17 +1461,17 @@ CallNPMethodInternal(JSContext *cx, JSOb _releasevariantvalue(&v); return ReportExceptionIfPending(cx); } static JSBool CallNPMethod(JSContext *cx, unsigned argc, JS::Value *vp) { - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::Rooted<JSObject*> obj(cx, JS_THIS_OBJECT(cx, vp)); if (!obj) return JS_FALSE; return CallNPMethodInternal(cx, obj, argc, JS_ARGV(cx, vp), vp, false); } struct NPObjectEnumerateState { uint32_t index; @@ -1661,24 +1662,26 @@ NPObjWrapper_Finalize(JSFreeOp *fop, JSO if (!sDelayedReleases) sDelayedReleases = new nsTArray<NPObject*>; sDelayedReleases->AppendElement(npobj); } static JSBool NPObjWrapper_Call(JSContext *cx, unsigned argc, JS::Value *vp) { - return CallNPMethodInternal(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)), argc, + JS::Rooted<JSObject*> obj(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp))); + return CallNPMethodInternal(cx, obj, argc, JS_ARGV(cx, vp), vp, false); } static JSBool NPObjWrapper_Construct(JSContext *cx, unsigned argc, JS::Value *vp) { - return CallNPMethodInternal(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)), argc, + JS::Rooted<JSObject*> obj(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp))); + return CallNPMethodInternal(cx, obj, argc, JS_ARGV(cx, vp), vp, true); } class NPObjWrapperHashEntry : public PLDHashEntryHdr { public: NPObject *mNPObj; // Must be the first member for the PLDHash stubs to work JSObject *mJSObj; @@ -1955,17 +1958,17 @@ LookupNPP(NPObject *npobj) NS_ASSERTION(entry->mNpp, "Live NPObject entry w/o an NPP!"); return entry->mNpp; } JSBool CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject* npobj, - jsid id, NPVariant* getPropertyResult, JS::Value *vp) + JS::Handle<jsid> id, NPVariant* getPropertyResult, JS::Value *vp) { NS_ENSURE_TRUE(vp, JS_FALSE); if (!npobj || !npobj->_class || !npobj->_class->getProperty || !npobj->_class->invoke) { ThrowJSException(cx, "Bad NPObject"); return JS_FALSE;
--- a/dom/plugins/base/nsJSNPRuntime.h +++ b/dom/plugins/base/nsJSNPRuntime.h @@ -32,17 +32,18 @@ public: }; extern JSClass sNPObjectJSWrapperClass; class nsJSObjWrapper : public NPObject, public nsJSObjWrapperKey { public: - static NPObject *GetNewOrUsed(NPP npp, JSContext *cx, JSObject *obj); + static NPObject *GetNewOrUsed(NPP npp, JSContext *cx, + JS::Handle<JSObject*> obj); protected: nsJSObjWrapper(NPP npp); ~nsJSObjWrapper(); static NPObject * NP_Allocate(NPP npp, NPClass *aClass); static void NP_Deallocate(NPObject *obj); static void NP_Invalidate(NPObject *obj);
--- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -1206,17 +1206,18 @@ NPObject* NP_CALLBACK return nullptr; } AutoPushJSContext cx(GetJSContextFromNPP(npp)); NS_ENSURE_TRUE(cx, nullptr); // Using ::JS_GetGlobalObject(cx) is ok here since the window we // want to return here is the outer window, *not* the inner (since // we don't know what the plugin will do with it). - return nsJSObjWrapper::GetNewOrUsed(npp, cx, ::JS_GetGlobalObject(cx)); + JS::Rooted<JSObject*> global(cx, ::JS_GetGlobalObject(cx)); + return nsJSObjWrapper::GetNewOrUsed(npp, cx, global); } NPObject* NP_CALLBACK _getpluginelement(NPP npp) { if (!NS_IsMainThread()) { NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getpluginelement called from the wrong thread\n")); return nullptr;