X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/93a3786624b2768d89bfa27e46598dc64e2fb70a..40a37d088818fc2fbeba2ef850dbcaaf294befbf:/runtime/IndexingHeader.h?ds=sidebyside diff --git a/runtime/IndexingHeader.h b/runtime/IndexingHeader.h index cee0762..aadd829 100644 --- a/runtime/IndexingHeader.h +++ b/runtime/IndexingHeader.h @@ -27,10 +27,10 @@ #define IndexingHeader_h #include "PropertyStorage.h" -#include namespace JSC { +class ArrayBuffer; class Butterfly; class LLIntOffsetsExtractor; class Structure; @@ -44,25 +44,29 @@ public: static ptrdiff_t offsetOfIndexingHeader() { return -static_cast(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) { @@ -76,7 +80,12 @@ public: static IndexingHeader* from(ArrayStorage* arrayStorage) { - return reinterpret_cast(arrayStorage) - 1; + return const_cast(from(const_cast(arrayStorage))); + } + + static const IndexingHeader* from(const ArrayStorage* arrayStorage) + { + return reinterpret_cast(arrayStorage) - 1; } static IndexingHeader* fromEndOf(PropertyStorage propertyStorage) @@ -111,9 +120,17 @@ public: 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