mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 737245 - Typed Arrays should handle cross-compartment wrappers; part2. r=luke
This commit is contained in:
parent
239bf91898
commit
c26ed100c4
@ -1057,6 +1057,7 @@ struct JSObject : public js::ObjectImpl
|
||||
inline bool isScope() const;
|
||||
inline bool isScript() const;
|
||||
inline bool isStopIteration() const;
|
||||
inline bool isTypedArray() const;
|
||||
inline bool isWeakMap() const;
|
||||
inline bool isXML() const;
|
||||
inline bool isXMLId() const;
|
||||
|
@ -803,6 +803,7 @@ inline bool JSObject::isStaticBlock() const { return isBlock() && !getProto(); }
|
||||
inline bool JSObject::isStopIteration() const { return hasClass(&js::StopIterationClass); }
|
||||
inline bool JSObject::isStrictArguments() const { return hasClass(&js::StrictArgumentsObjectClass); }
|
||||
inline bool JSObject::isString() const { return hasClass(&js::StringClass); }
|
||||
inline bool JSObject::isTypedArray() const { return IsFastTypedArrayClass(getClass()); };
|
||||
inline bool JSObject::isWeakMap() const { return hasClass(&js::WeakMapClass); }
|
||||
inline bool JSObject::isWith() const { return hasClass(&js::WithClass); }
|
||||
inline bool JSObject::isXML() const { return hasClass(&js::XMLClass); }
|
||||
|
@ -2513,17 +2513,32 @@ IsFastTypedArrayClass(const Class *clasp)
|
||||
clasp < &TypedArray::fastClasses[TypedArray::TYPE_MAX];
|
||||
}
|
||||
|
||||
bool
|
||||
IsSlowTypedArrayClass(const Class *clasp)
|
||||
{
|
||||
return &TypedArray::slowClasses[0] <= clasp &&
|
||||
clasp < &TypedArray::slowClasses[TypedArray::TYPE_MAX];
|
||||
}
|
||||
|
||||
bool IsFastOrSlowTypedArray(JSObject *obj)
|
||||
{
|
||||
Class *clasp = obj->getClass();
|
||||
return IsFastTypedArrayClass(clasp) || IsSlowTypedArrayClass(clasp);
|
||||
}
|
||||
|
||||
} // namespace js
|
||||
|
||||
uint32_t
|
||||
JS_GetArrayBufferByteLength(JSObject *obj)
|
||||
{
|
||||
JS_ASSERT(obj->isArrayBuffer());
|
||||
return obj->arrayBufferByteLength();
|
||||
}
|
||||
|
||||
uint8_t *
|
||||
JS_GetArrayBufferData(JSObject *obj)
|
||||
{
|
||||
JS_ASSERT(obj->isArrayBuffer());
|
||||
return obj->arrayBufferDataOffset();
|
||||
}
|
||||
|
||||
@ -2632,29 +2647,34 @@ js_CreateTypedArrayWithBuffer(JSContext *cx, int atype, JSObject *bufArg,
|
||||
uint32_t
|
||||
JS_GetTypedArrayLength(JSObject *obj)
|
||||
{
|
||||
JS_ASSERT(obj->isTypedArray());
|
||||
return obj->getSlot(TypedArray::FIELD_LENGTH).toInt32();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
JS_GetTypedArrayByteOffset(JSObject *obj)
|
||||
{
|
||||
JS_ASSERT(obj->isTypedArray());
|
||||
return obj->getSlot(TypedArray::FIELD_BYTEOFFSET).toInt32();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
JS_GetTypedArrayByteLength(JSObject *obj)
|
||||
{
|
||||
JS_ASSERT(obj->isTypedArray());
|
||||
return obj->getSlot(TypedArray::FIELD_BYTELENGTH).toInt32();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
JS_GetTypedArrayType(JSObject *obj)
|
||||
{
|
||||
JS_ASSERT(obj->isTypedArray());
|
||||
return obj->getSlot(TypedArray::FIELD_TYPE).toInt32();
|
||||
}
|
||||
|
||||
void *
|
||||
JS_GetTypedArrayData(JSObject *obj)
|
||||
{
|
||||
JS_ASSERT(obj->isTypedArray());
|
||||
return TypedArray::getDataOffset(obj);
|
||||
}
|
||||
|
@ -286,6 +286,12 @@ struct JS_FRIEND_API(TypedArray) {
|
||||
extern bool
|
||||
IsFastTypedArrayClass(const Class *clasp);
|
||||
|
||||
extern bool
|
||||
IsSlowTypedArrayClass(const Class *clasp);
|
||||
|
||||
extern bool
|
||||
IsFastOrSlowTypedArray(JSObject *obj);
|
||||
|
||||
} // namespace js
|
||||
|
||||
/* Friend API methods */
|
||||
|
@ -70,31 +70,37 @@ ClampIntForUint8Array(int32_t x)
|
||||
|
||||
inline uint32_t
|
||||
TypedArray::getLength(JSObject *obj) {
|
||||
JS_ASSERT(IsFastOrSlowTypedArray(obj));
|
||||
return obj->getFixedSlot(FIELD_LENGTH).toInt32();
|
||||
}
|
||||
|
||||
inline uint32_t
|
||||
TypedArray::getByteOffset(JSObject *obj) {
|
||||
JS_ASSERT(IsFastOrSlowTypedArray(obj));
|
||||
return obj->getFixedSlot(FIELD_BYTEOFFSET).toInt32();
|
||||
}
|
||||
|
||||
inline uint32_t
|
||||
TypedArray::getByteLength(JSObject *obj) {
|
||||
JS_ASSERT(IsFastOrSlowTypedArray(obj));
|
||||
return obj->getFixedSlot(FIELD_BYTELENGTH).toInt32();
|
||||
}
|
||||
|
||||
inline uint32_t
|
||||
TypedArray::getType(JSObject *obj) {
|
||||
JS_ASSERT(IsFastOrSlowTypedArray(obj));
|
||||
return obj->getFixedSlot(FIELD_TYPE).toInt32();
|
||||
}
|
||||
|
||||
inline JSObject *
|
||||
TypedArray::getBuffer(JSObject *obj) {
|
||||
JS_ASSERT(IsFastOrSlowTypedArray(obj));
|
||||
return &obj->getFixedSlot(FIELD_BUFFER).toObject();
|
||||
}
|
||||
|
||||
inline void *
|
||||
TypedArray::getDataOffset(JSObject *obj) {
|
||||
JS_ASSERT(IsFastOrSlowTypedArray(obj));
|
||||
return (void *)obj->getPrivate(NUM_FIXED_SLOTS);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user