#ifndef IndexingHeader_h
#define IndexingHeader_h
#include "PropertyStorage.h"
#include <wtf/Platform.h>
namespace JSC {
class Butterfly;
class LLIntOffsetsExtractor;
class Structure;
struct ArrayStorage;
class IndexingHeader {
public:
enum { maximumLength = 0x10000000 };
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); }
IndexingHeader()
: m_publicLength(0)
, m_vectorLength(0)
{
}
uint32_t vectorLength() const { return m_vectorLength; }
void setVectorLength(uint32_t length)
{
RELEASE_ASSERT(length <= maximumLength);
m_vectorLength = length;
}
uint32_t publicLength() { return m_publicLength; }
void setPublicLength(uint32_t auxWord) { m_publicLength = auxWord; }
static IndexingHeader* from(Butterfly* butterfly)
{
return reinterpret_cast<IndexingHeader*>(butterfly) - 1;
}
static const IndexingHeader* from(const Butterfly* butterfly)
{
return reinterpret_cast<const IndexingHeader*>(butterfly) - 1;
}
static IndexingHeader* from(ArrayStorage* arrayStorage)
{
return reinterpret_cast<IndexingHeader*>(arrayStorage) - 1;
}
static IndexingHeader* fromEndOf(PropertyStorage propertyStorage)
{
return reinterpret_cast<IndexingHeader*>(propertyStorage);
}
PropertyStorage propertyStorage()
{
return reinterpret_cast_ptr<PropertyStorage>(this);
}
ConstPropertyStorage propertyStorage() const
{
return reinterpret_cast_ptr<ConstPropertyStorage>(this);
}
ArrayStorage* arrayStorage()
{
return reinterpret_cast<ArrayStorage*>(this + 1);
}
Butterfly* butterfly()
{
return reinterpret_cast<Butterfly*>(this + 1);
}
size_t preCapacity(Structure*);
size_t indexingPayloadSizeInBytes(Structure*);
private:
friend class LLIntOffsetsExtractor;
uint32_t m_publicLength; uint32_t m_vectorLength; };
}
#endif // IndexingHeader_h