#pragma once
#include "SpeculatedType.h"
#include <wtf/LockAlgorithm.h>
#include <wtf/StdLibExtras.h>
namespace JSC {
typedef uint8_t IndexingType;
static const IndexingType IsArray = 0x01;
static const IndexingType NoIndexingShape = 0x00;
static const IndexingType UndecidedShape = 0x02; static const IndexingType Int32Shape = 0x04;
static const IndexingType DoubleShape = 0x06;
static const IndexingType ContiguousShape = 0x08;
static const IndexingType ArrayStorageShape = 0x0A;
static const IndexingType SlowPutArrayStorageShape = 0x0C;
static const IndexingType IndexingShapeMask = 0x0E;
static const IndexingType IndexingShapeShift = 1;
static const IndexingType NumberOfIndexingShapes = 7;
static const IndexingType IndexingTypeMask = IndexingShapeMask | IsArray;
static const IndexingType CopyOnWrite = 0x10;
static const IndexingType IndexingShapeAndWritabilityMask = CopyOnWrite | IndexingShapeMask;
static const IndexingType NumberOfCopyOnWriteIndexingModes = 3; static const IndexingType NumberOfArrayIndexingModes = NumberOfIndexingShapes + NumberOfCopyOnWriteIndexingModes;
static const IndexingType MayHaveIndexedAccessors = 0x20;
static const IndexingType IndexingTypeLockIsHeld = 0x40;
static const IndexingType IndexingTypeLockHasParked = 0x80;
static const IndexingType NonArray = 0x0;
static const IndexingType NonArrayWithInt32 = Int32Shape;
static const IndexingType NonArrayWithDouble = DoubleShape;
static const IndexingType NonArrayWithContiguous = ContiguousShape;
static const IndexingType NonArrayWithArrayStorage = ArrayStorageShape;
static const IndexingType NonArrayWithSlowPutArrayStorage = SlowPutArrayStorageShape;
static const IndexingType ArrayClass = IsArray; static const IndexingType ArrayWithUndecided = IsArray | UndecidedShape;
static const IndexingType ArrayWithInt32 = IsArray | Int32Shape;
static const IndexingType ArrayWithDouble = IsArray | DoubleShape;
static const IndexingType ArrayWithContiguous = IsArray | ContiguousShape;
static const IndexingType ArrayWithArrayStorage = IsArray | ArrayStorageShape;
static const IndexingType ArrayWithSlowPutArrayStorage = IsArray | SlowPutArrayStorageShape;
static const IndexingType CopyOnWriteArrayWithInt32 = IsArray | Int32Shape | CopyOnWrite;
static const IndexingType CopyOnWriteArrayWithDouble = IsArray | DoubleShape | CopyOnWrite;
static const IndexingType CopyOnWriteArrayWithContiguous = IsArray | ContiguousShape | CopyOnWrite;
#define ALL_BLANK_INDEXING_TYPES \
NonArray: \
case ArrayClass
#define ALL_UNDECIDED_INDEXING_TYPES \
ArrayWithUndecided
#define ALL_WRITABLE_INT32_INDEXING_TYPES \
NonArrayWithInt32: \
case ArrayWithInt32
#define ALL_INT32_INDEXING_TYPES \
ALL_WRITABLE_INT32_INDEXING_TYPES: \
case CopyOnWriteArrayWithInt32
#define ALL_WRITABLE_DOUBLE_INDEXING_TYPES \
NonArrayWithDouble: \
case ArrayWithDouble \
#define ALL_DOUBLE_INDEXING_TYPES \
ALL_WRITABLE_DOUBLE_INDEXING_TYPES: \
case CopyOnWriteArrayWithDouble
#define ALL_WRITABLE_CONTIGUOUS_INDEXING_TYPES \
NonArrayWithContiguous: \
case ArrayWithContiguous \
#define ALL_CONTIGUOUS_INDEXING_TYPES \
ALL_WRITABLE_CONTIGUOUS_INDEXING_TYPES: \
case CopyOnWriteArrayWithContiguous
#define ARRAY_WITH_ARRAY_STORAGE_INDEXING_TYPES \
ArrayWithArrayStorage: \
case ArrayWithSlowPutArrayStorage
#define ALL_ARRAY_STORAGE_INDEXING_TYPES \
NonArrayWithArrayStorage: \
case NonArrayWithSlowPutArrayStorage: \
case ARRAY_WITH_ARRAY_STORAGE_INDEXING_TYPES
inline bool hasIndexedProperties(IndexingType indexingType)
{
return (indexingType & IndexingShapeMask) != NoIndexingShape;
}
inline bool hasUndecided(IndexingType indexingType)
{
return (indexingType & IndexingShapeMask) == UndecidedShape;
}
inline bool hasInt32(IndexingType indexingType)
{
return (indexingType & IndexingShapeMask) == Int32Shape;
}
inline bool hasDouble(IndexingType indexingType)
{
return (indexingType & IndexingShapeMask) == DoubleShape;
}
inline bool hasContiguous(IndexingType indexingType)
{
return (indexingType & IndexingShapeMask) == ContiguousShape;
}
inline bool hasArrayStorage(IndexingType indexingType)
{
return (indexingType & IndexingShapeMask) == ArrayStorageShape;
}
inline bool hasAnyArrayStorage(IndexingType indexingType)
{
return static_cast<uint8_t>(indexingType & IndexingShapeMask) >= ArrayStorageShape;
}
inline bool hasSlowPutArrayStorage(IndexingType indexingType)
{
return (indexingType & IndexingShapeMask) == SlowPutArrayStorageShape;
}
inline bool shouldUseSlowPut(IndexingType indexingType)
{
return hasSlowPutArrayStorage(indexingType);
}
inline constexpr bool isCopyOnWrite(IndexingType indexingMode)
{
return indexingMode & CopyOnWrite;
}
inline unsigned arrayIndexFromIndexingType(IndexingType indexingType)
{
if (isCopyOnWrite(indexingType))
return ((indexingType & IndexingShapeMask) - UndecidedShape + SlowPutArrayStorageShape) >> IndexingShapeShift;
return (indexingType & IndexingShapeMask) >> IndexingShapeShift;
}
inline IndexingType indexingTypeForValue(JSValue value)
{
if (value.isInt32())
return Int32Shape;
if (value.isNumber() && value.asNumber() == value.asNumber())
return DoubleShape;
return ContiguousShape;
}
IndexingType leastUpperBoundOfIndexingTypes(IndexingType, IndexingType);
IndexingType leastUpperBoundOfIndexingTypeAndType(IndexingType, SpeculatedType);
IndexingType leastUpperBoundOfIndexingTypeAndValue(IndexingType, JSValue);
void dumpIndexingType(PrintStream&, IndexingType);
MAKE_PRINT_ADAPTOR(IndexingTypeDump, IndexingType, dumpIndexingType);
static const IndexingType AllWritableArrayTypes = IndexingShapeMask | IsArray;
static const IndexingType AllArrayTypes = AllWritableArrayTypes | CopyOnWrite;
static const IndexingType AllWritableArrayTypesAndHistory = AllWritableArrayTypes | MayHaveIndexedAccessors;
static const IndexingType AllArrayTypesAndHistory = AllArrayTypes | MayHaveIndexedAccessors;
typedef LockAlgorithm<IndexingType, IndexingTypeLockIsHeld, IndexingTypeLockHasParked> IndexingTypeLockAlgorithm;
}