mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1261720 (part 2) - Move ClassExtension::isWrappedNative into js::Class::flags. r=jorendorff.
This saves 10 KiB of static data on 64-bit, and half that on 32-bit. --HG-- extra : rebase_source : f0e9c5cdba7f5a71cda046152691de6a5184a223
This commit is contained in:
parent
f7dab46ae8
commit
0faa7a06ba
@ -759,7 +759,6 @@ protected:
|
||||
};
|
||||
|
||||
static const js::ClassExtension OuterWindowProxyClassExtension = PROXY_MAKE_EXT(
|
||||
false, /* isWrappedNative */
|
||||
nsOuterWindowProxy::ObjectMoved
|
||||
);
|
||||
|
||||
|
@ -441,7 +441,6 @@ class CGDOMJSClass(CGThing):
|
||||
return fill(
|
||||
"""
|
||||
static const js::ClassExtension sClassExtension = {
|
||||
false, /* isWrappedNative */
|
||||
nullptr, /* weakmapKeyDelegateOp */
|
||||
${objectMoved} /* objectMovedOp */
|
||||
};
|
||||
@ -510,7 +509,6 @@ class CGDOMProxyJSClass(CGThing):
|
||||
return fill(
|
||||
"""
|
||||
static const js::ClassExtension sClassExtension = PROXY_MAKE_EXT(
|
||||
false, /* isWrappedNative */
|
||||
${objectMoved}
|
||||
);
|
||||
|
||||
|
@ -71,7 +71,6 @@ SimpleGlobal_moved(JSObject *obj, const JSObject *old)
|
||||
}
|
||||
|
||||
static const js::ClassExtension SimpleGlobalClassExtension = {
|
||||
false,
|
||||
nullptr,
|
||||
SimpleGlobal_moved
|
||||
};
|
||||
|
@ -219,7 +219,6 @@ CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject* npobj,
|
||||
JS::MutableHandle<JS::Value> vp);
|
||||
|
||||
const static js::ClassExtension sNPObjectJSWrapperClassExtension = {
|
||||
false, /* isWrappedNative */
|
||||
nullptr, /* weakmapKeyDelegateOp */
|
||||
NPObjWrapper_ObjectMoved
|
||||
};
|
||||
|
@ -587,12 +587,6 @@ struct ClassSpec
|
||||
|
||||
struct ClassExtension
|
||||
{
|
||||
/**
|
||||
* isWrappedNative is true only if the class is an XPCWrappedNative.
|
||||
* WeakMaps use this to override the wrapper disposal optimization.
|
||||
*/
|
||||
bool isWrappedNative;
|
||||
|
||||
/**
|
||||
* If an object is used as a key in a weakmap, it may be desirable for the
|
||||
* garbage collector to keep that object around longer than it otherwise
|
||||
@ -661,6 +655,10 @@ struct JSClass {
|
||||
#define JSCLASS_DELAY_METADATA_BUILDER (1<<1) // class's initialization code
|
||||
// will call
|
||||
// SetNewObjectMetadata itself
|
||||
#define JSCLASS_IS_WRAPPED_NATIVE (1<<2) // class is an XPCWrappedNative.
|
||||
// WeakMaps use this to override
|
||||
// the wrapper disposal
|
||||
// mechanism.
|
||||
#define JSCLASS_PRIVATE_IS_NSISUPPORTS (1<<3) // private is (nsISupports*)
|
||||
#define JSCLASS_IS_DOMJSCLASS (1<<4) // objects are DOM
|
||||
#define JSCLASS_HAS_XRAYED_CONSTRUCTOR (1<<5) // if wrapped by an xray
|
||||
@ -802,6 +800,10 @@ struct Class
|
||||
return flags & JSCLASS_DELAY_METADATA_BUILDER;
|
||||
}
|
||||
|
||||
bool isWrappedNative() const {
|
||||
return flags & JSCLASS_IS_WRAPPED_NATIVE;
|
||||
}
|
||||
|
||||
static size_t offsetOfFlags() { return offsetof(Class, flags); }
|
||||
|
||||
bool specDefined() const { return spec ? spec->defined() : false; }
|
||||
@ -824,7 +826,6 @@ struct Class
|
||||
FinishClassInitOp specFinishInitHook()
|
||||
const { return spec ? spec->finishInitHook() : nullptr; }
|
||||
|
||||
bool extIsWrappedNative() const { return ext ? ext->isWrappedNative : false; }
|
||||
JSWeakmapKeyDelegateOp extWeakmapKeyDelegateOp()
|
||||
const { return ext ? ext->weakmapKeyDelegateOp : nullptr; }
|
||||
JSObjectMovedOp extObjectMovedOp()
|
||||
|
@ -111,8 +111,8 @@ js::WeakMap_delete(JSContext* cx, unsigned argc, Value* vp)
|
||||
static bool
|
||||
TryPreserveReflector(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
if (obj->getClass()->extIsWrappedNative() ||
|
||||
(obj->getClass()->flags & JSCLASS_IS_DOMJSCLASS) ||
|
||||
if (obj->getClass()->isWrappedNative() ||
|
||||
obj->getClass()->isDOMClass() ||
|
||||
(obj->is<ProxyObject>() &&
|
||||
obj->as<ProxyObject>().handler()->family() == GetDOMProxyHandlerFamily()))
|
||||
{
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "vm/ProxyObject.h"
|
||||
|
||||
static const js::ClassExtension OuterWrapperClassExtension = PROXY_MAKE_EXT(
|
||||
false, /* isWrappedNative */
|
||||
nullptr /* objectMoved */
|
||||
);
|
||||
|
||||
|
@ -153,7 +153,6 @@ static JSObject* GetKeyDelegate(JSObject* obj)
|
||||
JSObject* newKey()
|
||||
{
|
||||
static const js::ClassExtension keyClassExtension = {
|
||||
false,
|
||||
GetKeyDelegate
|
||||
};
|
||||
|
||||
@ -209,7 +208,6 @@ JSObject* newCCW(JS::HandleObject sourceZone, JS::HandleObject destZone)
|
||||
JSObject* newDelegate()
|
||||
{
|
||||
static const js::ClassExtension delegateClassExtension = {
|
||||
false,
|
||||
nullptr,
|
||||
DelegateObjectMoved
|
||||
};
|
||||
|
@ -323,9 +323,8 @@ extern JS_FRIEND_DATA(const js::ObjectOps) ProxyObjectOps;
|
||||
* NB: The macro invocation must be surrounded by braces, so as to
|
||||
* allow for potential JSClass extensions.
|
||||
*/
|
||||
#define PROXY_MAKE_EXT(isWrappedNative, objectMoved) \
|
||||
#define PROXY_MAKE_EXT(objectMoved) \
|
||||
{ \
|
||||
isWrappedNative, \
|
||||
js::proxy_WeakmapKeyDelegate, \
|
||||
objectMoved \
|
||||
}
|
||||
|
@ -717,7 +717,6 @@ js::proxy_FunToString(JSContext* cx, HandleObject proxy, unsigned indent)
|
||||
}
|
||||
|
||||
const ClassExtension js::ProxyClassExtension = PROXY_MAKE_EXT(
|
||||
false, /* isWrappedNative */
|
||||
js::proxy_ObjectMoved
|
||||
);
|
||||
|
||||
|
@ -97,7 +97,6 @@ const Class ArrayBufferObject::protoClass = {
|
||||
};
|
||||
|
||||
static const ClassExtension ArrayBufferObjectClassExtension = {
|
||||
false, /* isWrappedNative */
|
||||
nullptr, /* weakmapKeyDelegateOp */
|
||||
ArrayBufferObject::objectMoved
|
||||
};
|
||||
|
@ -1592,7 +1592,6 @@ UnboxedArrayObject::obj_enumerate(JSContext* cx, HandleObject obj, AutoIdVector&
|
||||
}
|
||||
|
||||
static const ClassExtension UnboxedArrayObjectClassExtension = {
|
||||
false, /* isWrappedNative */
|
||||
nullptr, /* weakmapKeyDelegateOp */
|
||||
UnboxedArrayObject::objectMoved
|
||||
};
|
||||
|
@ -551,7 +551,6 @@ sandbox_addProperty(JSContext* cx, HandleObject obj, HandleId id, HandleValue v)
|
||||
#define XPCONNECT_SANDBOX_CLASS_METADATA_SLOT (XPCONNECT_GLOBAL_EXTRA_SLOT_OFFSET)
|
||||
|
||||
static const js::ClassExtension SandboxClassExtension = {
|
||||
false, /* isWrappedNative */
|
||||
nullptr, /* weakmapKeyDelegateOp */
|
||||
sandbox_moved /* objectMovedOp */
|
||||
};
|
||||
|
@ -621,7 +621,6 @@ XPC_WN_NoHelper_Resolve(JSContext* cx, HandleObject obj, HandleId id, bool* reso
|
||||
}
|
||||
|
||||
static const js::ClassExtension XPC_WN_JSClassExtension = {
|
||||
true, // isWrappedNative
|
||||
nullptr, // weakmapKeyDelegateOp
|
||||
WrappedNativeObjectMoved
|
||||
};
|
||||
@ -629,6 +628,7 @@ static const js::ClassExtension XPC_WN_JSClassExtension = {
|
||||
const js::Class XPC_WN_NoHelper_JSClass = {
|
||||
"XPCWrappedNative_NoHelper", // name;
|
||||
WRAPPER_FLAGS |
|
||||
JSCLASS_IS_WRAPPED_NATIVE |
|
||||
JSCLASS_PRIVATE_IS_NSISUPPORTS, // flags
|
||||
|
||||
/* Mandatory non-null function pointer members. */
|
||||
@ -977,7 +977,9 @@ XPCNativeScriptableShared::XPCNativeScriptableShared(uint32_t aFlags,
|
||||
if (!aPopulate)
|
||||
return;
|
||||
|
||||
mJSClass.flags = WRAPPER_FLAGS | JSCLASS_PRIVATE_IS_NSISUPPORTS;
|
||||
mJSClass.flags = WRAPPER_FLAGS |
|
||||
JSCLASS_PRIVATE_IS_NSISUPPORTS |
|
||||
JSCLASS_IS_WRAPPED_NATIVE;
|
||||
|
||||
if (mFlags.IsGlobalObject())
|
||||
mJSClass.flags |= XPCONNECT_GLOBAL_FLAGS;
|
||||
@ -1258,7 +1260,6 @@ XPC_WN_ModsAllowed_Proto_Resolve(JSContext* cx, HandleObject obj, HandleId id, b
|
||||
}
|
||||
|
||||
static const js::ClassExtension XPC_WN_Shared_Proto_ClassExtension = {
|
||||
false, /* isWrappedNative */
|
||||
nullptr, /* weakmapKeyDelegateOp */
|
||||
XPC_WN_Shared_Proto_ObjectMoved
|
||||
};
|
||||
@ -1488,7 +1489,6 @@ static_assert(((WRAPPER_FLAGS >> JSCLASS_RESERVED_SLOTS_SHIFT) &
|
||||
"WRAPPER_FLAGS should not include any reserved slots");
|
||||
|
||||
static const js::ClassExtension XPC_WN_Tearoff_JSClassExtension = {
|
||||
false, // isWrappedNative
|
||||
nullptr, // weakmapKeyDelegateOp
|
||||
XPC_WN_TearOff_ObjectMoved
|
||||
};
|
||||
|
@ -385,7 +385,7 @@ CreateGlobalObject(JSContext* cx, const JSClass* clasp, nsIPrincipal* principal,
|
||||
// Verify that the right trace hook is called. Note that this doesn't
|
||||
// work right for wrapped globals, since the tracing situation there is
|
||||
// more complicated. Manual inspection shows that they do the right thing.
|
||||
if (!((const js::Class*)clasp)->extIsWrappedNative())
|
||||
if (!((const js::Class*)clasp)->isWrappedNative())
|
||||
{
|
||||
VerifyTraceProtoAndIfaceCacheCalledTracer trc(JS_GetRuntime(cx));
|
||||
TraceChildren(&trc, GCCellPtr(global.get()));
|
||||
|
@ -219,7 +219,7 @@ extern const char XPC_XPCONNECT_CONTRACTID[];
|
||||
// wrappednative wrapper, holding the XPCWrappedNative in its private slot.
|
||||
static inline bool IS_WN_CLASS(const js::Class* clazz)
|
||||
{
|
||||
return clazz->extIsWrappedNative();
|
||||
return clazz->isWrappedNative();
|
||||
}
|
||||
|
||||
static inline bool IS_WN_REFLECTOR(JSObject* obj)
|
||||
|
Loading…
Reference in New Issue
Block a user