Bug 1348095 part 2. Give all the Xray holders a JSClass that has a slot for caching a prototype. r=bholley

MozReview-Commit-ID: ID9vMG3iJfZ
This commit is contained in:
Boris Zbarsky 2017-03-23 03:06:25 -04:00
Родитель ab35f8679e
Коммит e2c99615af
2 изменённых файлов: 15 добавлений и 4 удалений

Просмотреть файл

@ -201,9 +201,12 @@ XPCWrappedNativeXrayTraits::getWN(JSObject* wrapper)
} }
const JSClass XPCWrappedNativeXrayTraits::HolderClass = { const JSClass XPCWrappedNativeXrayTraits::HolderClass = {
"NativePropertyHolder" "NativePropertyHolder", JSCLASS_HAS_RESERVED_SLOTS(HOLDER_SHARED_SLOT_COUNT)
}; };
const JSClass XrayTraits::HolderClass = {
"XrayHolder", JSCLASS_HAS_RESERVED_SLOTS(HOLDER_SHARED_SLOT_COUNT)
};
const JSClass JSXrayTraits::HolderClass = { const JSClass JSXrayTraits::HolderClass = {
"JSXrayHolder", JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT) "JSXrayHolder", JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT)
@ -1854,7 +1857,7 @@ DOMXrayTraits::preserveWrapper(JSObject* target)
JSObject* JSObject*
DOMXrayTraits::createHolder(JSContext* cx, JSObject* wrapper) DOMXrayTraits::createHolder(JSContext* cx, JSObject* wrapper)
{ {
return JS_NewObjectWithGivenProto(cx, nullptr, nullptr); return JS_NewObjectWithGivenProto(cx, &HolderClass, nullptr);
} }
const JSClass* const JSClass*

Просмотреть файл

@ -99,6 +99,12 @@ public:
JSObject* ensureExpandoObject(JSContext* cx, JS::HandleObject wrapper, JSObject* ensureExpandoObject(JSContext* cx, JS::HandleObject wrapper,
JS::HandleObject target); JS::HandleObject target);
// Slots for holder objects.
enum {
HOLDER_SLOT_CACHED_PROTO = 0,
HOLDER_SHARED_SLOT_COUNT
};
JSObject* getHolder(JSObject* wrapper); JSObject* getHolder(JSObject* wrapper);
JSObject* ensureHolder(JSContext* cx, JS::HandleObject wrapper); JSObject* ensureHolder(JSContext* cx, JS::HandleObject wrapper);
virtual JSObject* createHolder(JSContext* cx, JSObject* wrapper) = 0; virtual JSObject* createHolder(JSContext* cx, JSObject* wrapper) = 0;
@ -108,6 +114,8 @@ public:
bool cloneExpandoChain(JSContext* cx, JS::HandleObject dst, JS::HandleObject src); bool cloneExpandoChain(JSContext* cx, JS::HandleObject dst, JS::HandleObject src);
protected: protected:
static const JSClass HolderClass;
// Get the JSClass we should use for our expando object. // Get the JSClass we should use for our expando object.
virtual const JSClass* getExpandoClass(JSContext* cx, virtual const JSClass* getExpandoClass(JSContext* cx,
JS::HandleObject target) const; JS::HandleObject target) const;
@ -301,7 +309,7 @@ public:
} }
enum { enum {
SLOT_PROTOKEY = 0, SLOT_PROTOKEY = HOLDER_SHARED_SLOT_COUNT,
SLOT_ISPROTOTYPE, SLOT_ISPROTOTYPE,
SLOT_CONSTRUCTOR_FOR, SLOT_CONSTRUCTOR_FOR,
SLOT_COUNT SLOT_COUNT
@ -421,7 +429,7 @@ public:
virtual JSObject* createHolder(JSContext* cx, JSObject* wrapper) override virtual JSObject* createHolder(JSContext* cx, JSObject* wrapper) override
{ {
return JS_NewObjectWithGivenProto(cx, nullptr, nullptr); return JS_NewObjectWithGivenProto(cx, &HolderClass, nullptr);
} }
static OpaqueXrayTraits singleton; static OpaqueXrayTraits singleton;