mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 924720 - Part 1: Implement IsProxy() using new JSClass flag. (r=jwalden)
This commit is contained in:
parent
9a2a33e448
commit
f139382c7a
@ -541,7 +541,9 @@ struct JSClass {
|
||||
#define JSCLASS_INTERNAL_FLAG2 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+2))
|
||||
#define JSCLASS_INTERNAL_FLAG3 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+3))
|
||||
|
||||
// Bits 21 and 22 unused.
|
||||
#define JSCLASS_IS_PROXY (1<<(JSCLASS_HIGH_FLAGS_SHIFT+4))
|
||||
|
||||
// Bit 22 unused.
|
||||
|
||||
// Reserved for embeddings.
|
||||
#define JSCLASS_USERBIT2 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+6))
|
||||
@ -614,6 +616,10 @@ struct Class
|
||||
return this == js::FunctionClassPtr || call;
|
||||
}
|
||||
|
||||
bool isProxy() const {
|
||||
return flags & JSCLASS_IS_PROXY;
|
||||
}
|
||||
|
||||
static size_t offsetOfFlags() { return offsetof(Class, flags); }
|
||||
};
|
||||
|
||||
|
@ -1528,17 +1528,10 @@ static void
|
||||
GenerateProxyClassGuards(MacroAssembler &masm, Register object, Register scratchReg,
|
||||
Label *failures)
|
||||
{
|
||||
Label success;
|
||||
// Ensure that the incoming object has one of the magic class pointers, i.e,
|
||||
// that it is one of an ObjectProxy, FunctionProxy, or OuterWindowProxy.
|
||||
// This is equivalent to obj->is<ProxyObject>().
|
||||
masm.branchTestObjClass(Assembler::Equal, object, scratchReg,
|
||||
CallableProxyClassPtr, &success);
|
||||
masm.branchTestObjClass(Assembler::Equal, object, scratchReg,
|
||||
UncallableProxyClassPtr, &success);
|
||||
masm.branchTestObjClass(Assembler::NotEqual, object, scratchReg,
|
||||
OuterWindowProxyClassPtr, failures);
|
||||
masm.bind(&success);
|
||||
masm.loadObjClass(object, scratchReg);
|
||||
masm.branchTest32(Assembler::Zero,
|
||||
Address(scratchReg, Class::offsetOfFlags()),
|
||||
Imm32(JSCLASS_IS_PROXY), failures);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -912,11 +912,11 @@ class MacroAssembler : public MacroAssemblerSpecific
|
||||
// of the JSObject::isWrapper test performed in EmulatesUndefined. If none
|
||||
// of the branches are taken, we can check class flags directly.
|
||||
loadObjClass(objReg, scratch);
|
||||
branchPtr(Assembler::Equal, scratch, ImmPtr(&ProxyObject::callableClass_), slowCheck);
|
||||
branchPtr(Assembler::Equal, scratch, ImmPtr(&ProxyObject::uncallableClass_), slowCheck);
|
||||
branchPtr(Assembler::Equal, scratch, ImmPtr(&OuterWindowProxyObject::class_), slowCheck);
|
||||
Address flags(scratch, Class::offsetOfFlags());
|
||||
|
||||
test32(Address(scratch, Class::offsetOfFlags()), Imm32(JSCLASS_EMULATES_UNDEFINED));
|
||||
branchTest32(Assembler::NonZero, flags, Imm32(JSCLASS_IS_PROXY), slowCheck);
|
||||
|
||||
test32(flags, Imm32(JSCLASS_EMULATES_UNDEFINED));
|
||||
return truthy ? Assembler::Zero : Assembler::NonZero;
|
||||
}
|
||||
|
||||
|
@ -3104,6 +3104,7 @@ proxy_Slice(JSContext *cx, HandleObject proxy, uint32_t begin, uint32_t end,
|
||||
#define PROXY_CLASS(callOp, constructOp) { \
|
||||
"Proxy", \
|
||||
Class::NON_NATIVE | \
|
||||
JSCLASS_IS_PROXY | \
|
||||
JSCLASS_IMPLEMENTS_BARRIERS | \
|
||||
JSCLASS_HAS_RESERVED_SLOTS(4) | \
|
||||
JSCLASS_HAS_CACHED_PROTO(JSProto_Proxy), \
|
||||
@ -3157,7 +3158,7 @@ const Class* const js::UncallableProxyClassPtr = &ProxyObject::uncallableClass_;
|
||||
|
||||
const Class js::OuterWindowProxyObject::class_ = {
|
||||
"Proxy",
|
||||
Class::NON_NATIVE | JSCLASS_IMPLEMENTS_BARRIERS | JSCLASS_HAS_RESERVED_SLOTS(4),
|
||||
Class::NON_NATIVE | JSCLASS_IS_PROXY | JSCLASS_IMPLEMENTS_BARRIERS | JSCLASS_HAS_RESERVED_SLOTS(4),
|
||||
JS_PropertyStub, /* addProperty */
|
||||
JS_DeletePropertyStub, /* delProperty */
|
||||
JS_PropertyStub, /* getProperty */
|
||||
|
@ -341,9 +341,7 @@ extern JS_FRIEND_DATA(const js::Class* const) OuterWindowProxyClassPtr;
|
||||
|
||||
inline bool IsProxyClass(const Class *clasp)
|
||||
{
|
||||
return clasp == CallableProxyClassPtr ||
|
||||
clasp == UncallableProxyClassPtr ||
|
||||
clasp == OuterWindowProxyClassPtr;
|
||||
return clasp->isProxy();
|
||||
}
|
||||
|
||||
inline bool IsProxy(JSObject *obj)
|
||||
|
Loading…
Reference in New Issue
Block a user