#define IndexingHeader_h
#include "PropertyStorage.h"
-#include <wtf/Platform.h>
namespace JSC {
+class ArrayBuffer;
class Butterfly;
class LLIntOffsetsExtractor;
class Structure;
static ptrdiff_t offsetOfIndexingHeader() { return -static_cast<ptrdiff_t>(sizeof(IndexingHeader)); }
- static ptrdiff_t offsetOfPublicLength() { return OBJECT_OFFSETOF(IndexingHeader, m_publicLength); }
- static ptrdiff_t offsetOfVectorLength() { return OBJECT_OFFSETOF(IndexingHeader, m_vectorLength); }
+ static ptrdiff_t offsetOfArrayBuffer() { return OBJECT_OFFSETOF(IndexingHeader, u.typedArray.buffer); }
+ static ptrdiff_t offsetOfPublicLength() { return OBJECT_OFFSETOF(IndexingHeader, u.lengths.publicLength); }
+ static ptrdiff_t offsetOfVectorLength() { return OBJECT_OFFSETOF(IndexingHeader, u.lengths.vectorLength); }
IndexingHeader()
- : m_publicLength(0)
- , m_vectorLength(0)
{
+ u.lengths.publicLength = 0;
+ u.lengths.vectorLength = 0;
}
- uint32_t vectorLength() const { return m_vectorLength; }
+ uint32_t vectorLength() const { return u.lengths.vectorLength; }
void setVectorLength(uint32_t length)
{
RELEASE_ASSERT(length <= maximumLength);
- m_vectorLength = length;
+ u.lengths.vectorLength = length;
}
- uint32_t publicLength() { return m_publicLength; }
- void setPublicLength(uint32_t auxWord) { m_publicLength = auxWord; }
+ uint32_t publicLength() const { return u.lengths.publicLength; }
+ void setPublicLength(uint32_t auxWord) { u.lengths.publicLength = auxWord; }
+
+ ArrayBuffer* arrayBuffer() { return u.typedArray.buffer; }
+ void setArrayBuffer(ArrayBuffer* buffer) { u.typedArray.buffer = buffer; }
static IndexingHeader* from(Butterfly* butterfly)
{
static IndexingHeader* from(ArrayStorage* arrayStorage)
{
- return reinterpret_cast<IndexingHeader*>(arrayStorage) - 1;
+ return const_cast<IndexingHeader*>(from(const_cast<const ArrayStorage*>(arrayStorage)));
+ }
+
+ static const IndexingHeader* from(const ArrayStorage* arrayStorage)
+ {
+ return reinterpret_cast<const IndexingHeader*>(arrayStorage) - 1;
}
static IndexingHeader* fromEndOf(PropertyStorage propertyStorage)
private:
friend class LLIntOffsetsExtractor;
-
- uint32_t m_publicLength; // The meaning of this field depends on the array type, but for all JSArrays we rely on this being the publicly visible length (array.length).
- uint32_t m_vectorLength; // The length of the indexed property storage. The actual size of the storage depends on this, and the type.
+
+ union {
+ struct {
+ uint32_t publicLength; // The meaning of this field depends on the array type, but for all JSArrays we rely on this being the publicly visible length (array.length).
+ uint32_t vectorLength; // The length of the indexed property storage. The actual size of the storage depends on this, and the type.
+ } lengths;
+
+ struct {
+ ArrayBuffer* buffer;
+ } typedArray;
+ } u;
};
} // namespace JSC