зеркало из https://github.com/mozilla/pjs.git
Bug 585786. Do fast-unwrapping even for non-slim wrappers as long as they're cached. r=peterv
This commit is contained in:
Родитель
5621d0acac
Коммит
79b392b950
|
@ -5504,7 +5504,7 @@ nsContentUtils::WrapNative(JSContext *cx, JSObject *scope, nsISupports *native,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
JSObject *wrapper = xpc_GetCachedSlimWrapper(cache, scope, vp);
|
||||
JSObject *wrapper = xpc_FastGetCachedWrapper(cache, scope, vp);
|
||||
if (wrapper) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -4265,7 +4265,7 @@ nsDOMClassInfo::WrapNative(JSContext *cx, JSObject *scope,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
JSObject *wrapper = xpc_GetCachedSlimWrapper(cache, scope, vp);
|
||||
JSObject *wrapper = xpc_FastGetCachedWrapper(cache, scope, vp);
|
||||
if (wrapper) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -722,7 +722,7 @@ def writeResultConv(f, type, jsvalPtr, jsvalRef):
|
|||
return
|
||||
else:
|
||||
f.write(" nsWrapperCache* cache = xpc_qsGetWrapperCache(result);\n"
|
||||
" if (xpc_GetCachedSlimWrapper(cache, obj, %s)) {\n"
|
||||
" if (xpc_FastGetCachedWrapper(cache, obj, %s)) {\n"
|
||||
" return JS_TRUE;\n"
|
||||
" }\n"
|
||||
" // After this point do not use 'result'!\n"
|
||||
|
@ -1285,7 +1285,7 @@ def writeTraceableResultConv(f, type):
|
|||
else:
|
||||
f.write(" nsWrapperCache* cache = xpc_qsGetWrapperCache(result);\n"
|
||||
" JSObject* wrapper =\n"
|
||||
" xpc_GetCachedSlimWrapper(cache, obj);\n"
|
||||
" xpc_FastGetCachedWrapper(cache, obj);\n"
|
||||
" if (wrapper) {\n"
|
||||
" return wrapper;\n"
|
||||
" }\n"
|
||||
|
|
|
@ -113,18 +113,23 @@ xpc_GetGlobalForObject(JSObject *obj)
|
|||
return obj;
|
||||
}
|
||||
|
||||
extern bool
|
||||
xpc_OkToHandOutWrapper(nsWrapperCache *cache);
|
||||
|
||||
inline JSObject*
|
||||
xpc_GetCachedSlimWrapper(nsWrapperCache *cache, JSObject *scope, jsval *vp)
|
||||
xpc_FastGetCachedWrapper(nsWrapperCache *cache, JSObject *scope, jsval *vp)
|
||||
{
|
||||
if (cache) {
|
||||
JSObject* wrapper = cache->GetWrapper();
|
||||
// FIXME: Bug 585786, the check for IS_SLIM_WRAPPER_OBJECT should go
|
||||
// away
|
||||
NS_ASSERTION(!wrapper ||
|
||||
!cache->IsProxy() ||
|
||||
!IS_SLIM_WRAPPER_OBJECT(wrapper),
|
||||
"Should never have a slim wrapper when IsProxy()");
|
||||
if (wrapper &&
|
||||
IS_SLIM_WRAPPER_OBJECT(wrapper) &&
|
||||
wrapper->compartment() == scope->getCompartment()) {
|
||||
wrapper->compartment() == scope->getCompartment() &&
|
||||
(IS_SLIM_WRAPPER_OBJECT(wrapper) ||
|
||||
xpc_OkToHandOutWrapper(cache))) {
|
||||
*vp = OBJECT_TO_JSVAL(wrapper);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
}
|
||||
|
@ -133,10 +138,10 @@ xpc_GetCachedSlimWrapper(nsWrapperCache *cache, JSObject *scope, jsval *vp)
|
|||
}
|
||||
|
||||
inline JSObject*
|
||||
xpc_GetCachedSlimWrapper(nsWrapperCache *cache, JSObject *scope)
|
||||
xpc_FastGetCachedWrapper(nsWrapperCache *cache, JSObject *scope)
|
||||
{
|
||||
jsval dummy;
|
||||
return xpc_GetCachedSlimWrapper(cache, scope, &dummy);
|
||||
return xpc_FastGetCachedWrapper(cache, scope, &dummy);
|
||||
}
|
||||
|
||||
// The JS GC marks objects gray that are held alive directly or indirectly
|
||||
|
|
|
@ -53,6 +53,18 @@
|
|||
#include "AccessCheck.h"
|
||||
#include "WrapperFactory.h"
|
||||
|
||||
bool
|
||||
xpc_OkToHandOutWrapper(nsWrapperCache *cache)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(cache->GetWrapper(), "Must have wrapper");
|
||||
NS_ABORT_IF_FALSE(cache->IsProxy() || IS_WN_WRAPPER(cache->GetWrapper()),
|
||||
"Must have proxy or XPCWrappedNative wrapper");
|
||||
return
|
||||
!cache->IsProxy() &&
|
||||
!static_cast<XPCWrappedNative*>(xpc_GetJSPrivate(cache->GetWrapper()))->
|
||||
NeedsSOW();
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(XPCWrappedNative)
|
||||
|
|
Загрузка…
Ссылка в новой задаче