Chromium Code Reviews| Index: src/objects.h |
| diff --git a/src/objects.h b/src/objects.h |
| index 0fa83041c6a800153401e1051a0546abe2321c26..ad582349bda58d91b7b2508e17ec59290fed8ae0 100644 |
| --- a/src/objects.h |
| +++ b/src/objects.h |
| @@ -386,6 +386,17 @@ const int kStubMinorKeyBits = kBitsPerInt - kSmiTagSize - kStubMajorKeyBits; |
| V(EXTERNAL_FLOAT_ARRAY_TYPE) \ |
| V(EXTERNAL_DOUBLE_ARRAY_TYPE) \ |
| V(EXTERNAL_PIXEL_ARRAY_TYPE) \ |
| + \ |
| + V(FIXED_INT8_ARRAY_TYPE) \ |
| + V(FIXED_UINT8_ARRAY_TYPE) \ |
| + V(FIXED_INT16_ARRAY_TYPE) \ |
| + V(FIXED_UINT16_ARRAY_TYPE) \ |
| + V(FIXED_INT32_ARRAY_TYPE) \ |
| + V(FIXED_UINT32_ARRAY_TYPE) \ |
| + V(FIXED_FLOAT32_ARRAY_TYPE) \ |
| + V(FIXED_FLOAT64_ARRAY_TYPE) \ |
| + V(FIXED_UINT8_CLAMPED_ARRAY_TYPE) \ |
| + \ |
| V(FILLER_TYPE) \ |
| \ |
| V(DECLARED_ACCESSOR_DESCRIPTOR_TYPE) \ |
| @@ -720,6 +731,17 @@ enum InstanceType { |
| EXTERNAL_FLOAT_ARRAY_TYPE, |
| EXTERNAL_DOUBLE_ARRAY_TYPE, |
| EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE |
| + |
| + FIXED_INT8_ARRAY_TYPE, // FIRST_FIXED_TYPED_ARRAY_TYPE |
| + FIXED_UINT8_ARRAY_TYPE, |
| + FIXED_INT16_ARRAY_TYPE, |
| + FIXED_UINT16_ARRAY_TYPE, |
| + FIXED_INT32_ARRAY_TYPE, |
| + FIXED_UINT32_ARRAY_TYPE, |
| + FIXED_FLOAT32_ARRAY_TYPE, |
| + FIXED_FLOAT64_ARRAY_TYPE, |
| + FIXED_UINT8_CLAMPED_ARRAY_TYPE, // LAST_FIXED_TYPED_ARRAY_TYPE |
| + |
| FIXED_DOUBLE_ARRAY_TYPE, |
| CONSTANT_POOL_ARRAY_TYPE, |
| FILLER_TYPE, // LAST_DATA_TYPE |
| @@ -797,6 +819,9 @@ enum InstanceType { |
| // Boundaries for testing for an external array. |
| FIRST_EXTERNAL_ARRAY_TYPE = EXTERNAL_BYTE_ARRAY_TYPE, |
| LAST_EXTERNAL_ARRAY_TYPE = EXTERNAL_PIXEL_ARRAY_TYPE, |
| + // Boundaries for testing for a fixed typed array. |
| + FIRST_FIXED_TYPED_ARRAY_TYPE = FIXED_INT8_ARRAY_TYPE, |
| + LAST_FIXED_TYPED_ARRAY_TYPE = FIXED_UINT8_CLAMPED_ARRAY_TYPE, |
| // Boundary for promotion to old data space/old pointer space. |
| LAST_DATA_TYPE = FILLER_TYPE, |
| // Boundary for objects represented as JSReceiver (i.e. JSObject or JSProxy). |
| @@ -986,6 +1011,16 @@ class MaybeObject BASE_EMBEDDED { |
| V(ExternalFloatArray) \ |
| V(ExternalDoubleArray) \ |
| V(ExternalPixelArray) \ |
| + V(FixedTypedArrayBase) \ |
| + V(FixedUint8Array) \ |
| + V(FixedInt8Array) \ |
| + V(FixedUint16Array) \ |
| + V(FixedInt16Array) \ |
| + V(FixedUint32Array) \ |
| + V(FixedInt32Array) \ |
| + V(FixedFloat32Array) \ |
| + V(FixedFloat64Array) \ |
| + V(FixedUint8ClampedArray) \ |
| V(ByteArray) \ |
| V(FreeSpace) \ |
| V(JSReceiver) \ |
| @@ -2103,6 +2138,7 @@ class JSObject: public JSReceiver { |
| inline bool HasFastHoleyElements(); |
| inline bool HasNonStrictArgumentsElements(); |
| inline bool HasDictionaryElements(); |
| + |
| inline bool HasExternalPixelElements(); |
| inline bool HasExternalArrayElements(); |
| inline bool HasExternalByteElements(); |
| @@ -2113,6 +2149,9 @@ class JSObject: public JSReceiver { |
| inline bool HasExternalUnsignedIntElements(); |
| inline bool HasExternalFloatElements(); |
| inline bool HasExternalDoubleElements(); |
| + |
| + inline bool HasFixedTypedArrayElements(); |
| + |
| bool HasFastArgumentsElements(); |
| bool HasDictionaryArgumentsElements(); |
| inline SeededNumberDictionary* element_dictionary(); // Gets slow elements. |
| @@ -4817,6 +4856,152 @@ class ExternalDoubleArray: public ExternalArray { |
| }; |
| +class FixedTypedArrayBase: public FixedArrayBase { |
| + public: |
| + // Casting: |
| + static inline FixedTypedArrayBase* cast(Object* obj); |
| + |
| + static const int kDataOffset = kHeaderSize; |
| + |
| + inline int size(); |
| + |
| + private: |
| + DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArrayBase); |
| +}; |
| + |
| + |
| +template <class Traits> |
| +class FixedTypedArray: public FixedTypedArrayBase { |
| + public: |
| + typedef typename Traits::ElementType ElementType; |
| + static const InstanceType kInstanceType = Traits::kInstanceType; |
| + |
| + // Casting: |
| + static inline FixedTypedArray<Traits>* cast(Object* obj); |
| + |
| + static inline int SizeFor(int length) { |
| + return kDataOffset + length * sizeof(ElementType); |
| + } |
| + |
| + inline ElementType get_scalar(int index); |
| + MUST_USE_RESULT inline MaybeObject* get(int index); |
| + inline void set(int index, ElementType value); |
| + |
| + // This accessor applies the correct conversion from Smi, HeapNumber |
| + // and undefined. |
| + MUST_USE_RESULT MaybeObject* SetValue(uint32_t index, Object* value); |
| + |
| + static Handle<Object> SetValue(Handle<FixedTypedArray<Traits> > array, |
| + uint32_t index, |
| + Handle<Object> value); |
| + |
| + DECLARE_PRINTER(FixedTypedArray) |
| + DECLARE_VERIFIER(FixedTypedArray) |
| + |
| + private: |
| + DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArray); |
| +}; |
| + |
| + |
| +class Uint8ArrayTraits { |
| + public: |
| + typedef uint8_t ElementType; |
| + static const InstanceType kInstanceType = FIXED_UINT8_ARRAY_TYPE; |
| + static const char* Designator() { return "uint8 array"; } |
| + static inline MaybeObject* ToObject(Heap* heap, uint8_t scalar); |
| + static uint8_t defaultValue() { return 0; } |
| +}; |
| + |
|
Toon Verwaest
2013/12/23 10:40:32
Double newlines between classes.
This is a lot of
Dmitry Lomov (no reviews)
2014/01/07 15:48:43
Done.
|
| +typedef FixedTypedArray<Uint8ArrayTraits> FixedUint8Array; |
| + |
| +class Int8ArrayTraits { |
| + public: |
| + typedef int8_t ElementType; |
| + static const InstanceType kInstanceType = FIXED_INT8_ARRAY_TYPE; |
| + static const char* Designator() { return "int8 array"; } |
| + static inline MaybeObject* ToObject(Heap* heap, int8_t scalar); |
| + static int8_t defaultValue() { return 0; } |
| +}; |
| + |
| +typedef FixedTypedArray<Int8ArrayTraits> FixedInt8Array; |
| + |
| +class Uint16ArrayTraits { |
| + public: |
| + typedef uint16_t ElementType; |
| + static const InstanceType kInstanceType = FIXED_UINT16_ARRAY_TYPE; |
| + static const char* Designator() { return "uint16 array"; } |
| + static inline MaybeObject* ToObject(Heap* heap, uint16_t scalar); |
| + static uint16_t defaultValue() { return 0; } |
| +}; |
| + |
| +typedef FixedTypedArray<Uint16ArrayTraits> FixedUint16Array; |
| + |
| +class Int16ArrayTraits { |
| + public: |
| + typedef int16_t ElementType; |
| + static const InstanceType kInstanceType = FIXED_INT16_ARRAY_TYPE; |
| + static const char* Designator() { return "int16 array"; } |
| + static inline MaybeObject* ToObject(Heap* heap, int16_t scalar); |
| + static int16_t defaultValue() { return 0; } |
| +}; |
| + |
| +typedef FixedTypedArray<Int16ArrayTraits> FixedInt16Array; |
| + |
| +class Uint32ArrayTraits { |
| + public: |
| + typedef uint32_t ElementType; |
| + static const InstanceType kInstanceType = FIXED_UINT32_ARRAY_TYPE; |
| + static const char* Designator() { return "uint32 array"; } |
| + static inline MaybeObject* ToObject(Heap* heap, uint32_t scalar); |
| + static uint32_t defaultValue() { return 0; } |
| +}; |
| + |
| +typedef FixedTypedArray<Uint32ArrayTraits> FixedUint32Array; |
| + |
| +class Int32ArrayTraits { |
| + public: |
| + typedef int32_t ElementType; |
| + static const InstanceType kInstanceType = FIXED_INT32_ARRAY_TYPE; |
| + static const char* Designator() { return "int32 array"; } |
| + static inline MaybeObject* ToObject(Heap* heap, int32_t scalar); |
| + static int32_t defaultValue() { return 0; } |
| +}; |
| + |
| +typedef FixedTypedArray<Int32ArrayTraits> FixedInt32Array; |
| + |
| +class Float32ArrayTraits { |
| + public: |
| + typedef float ElementType; |
| + static const InstanceType kInstanceType = FIXED_FLOAT32_ARRAY_TYPE; |
| + static const char* Designator() { return "float32 array"; } |
| + static inline MaybeObject* ToObject(Heap* heap, float scalar); |
| + static float defaultValue() { return 0; } |
| +}; |
| + |
| +typedef FixedTypedArray<Float32ArrayTraits> FixedFloat32Array; |
| + |
| +class Float64ArrayTraits { |
| + public: |
| + typedef double ElementType; |
| + static const InstanceType kInstanceType = FIXED_FLOAT64_ARRAY_TYPE; |
| + static const char* Designator() { return "float64 array"; } |
| + static inline MaybeObject* ToObject(Heap* heap, double scalar); |
| + static double defaultValue() { return 0; } |
| +}; |
| + |
| +typedef FixedTypedArray<Float64ArrayTraits> FixedFloat64Array; |
| + |
| +class Uint8ClampedArrayTraits { |
| + public: |
| + typedef uint8_t ElementType; |
| + static const InstanceType kInstanceType = FIXED_UINT8_CLAMPED_ARRAY_TYPE; |
| + static const char* Designator() { return "uint8 array"; } |
| + static inline MaybeObject* ToObject(Heap* heap, uint8_t scalar); |
| + static uint8_t defaultValue() { return 0; } |
| +}; |
| + |
| +typedef FixedTypedArray<Uint8ClampedArrayTraits> FixedUint8ClampedArray; |
| + |
| // DeoptimizationInputData is a fixed array used to hold the deoptimization |
| // data for code generated by the Hydrogen/Lithium compiler. It also |
| // contains information about functions that were inlined. If N different |
| @@ -5813,6 +5998,10 @@ class Map: public HeapObject { |
| return IsExternalArrayElementsKind(elements_kind()); |
| } |
| + inline bool has_fixed_typed_array_elements() { |
| + return IsFixedTypedArrayElementsKind(elements_kind()); |
| + } |
| + |
| inline bool has_dictionary_elements() { |
| return IsDictionaryElementsKind(elements_kind()); |
| } |