Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1766)

Unified Diff: src/objects.h

Issue 101413006: Implement in-heap backing store for typed arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: GC fixes Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ic.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 94acf5056d6fc7952901cd38af8343ea3a77bc0a..7d036eb37e4de9231b4ca7592199ed1f7ef153e8 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,
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).
@@ -989,6 +1014,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) \
@@ -2109,6 +2144,7 @@ class JSObject: public JSReceiver {
inline bool HasFastHoleyElements();
inline bool HasNonStrictArgumentsElements();
inline bool HasDictionaryElements();
+
inline bool HasExternalPixelElements();
inline bool HasExternalArrayElements();
inline bool HasExternalByteElements();
@@ -2119,6 +2155,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.
@@ -4828,6 +4867,76 @@ 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);
+};
+
+#define FIXED_TYPED_ARRAY_TRAITS(Type, type, TYPE, elementType) \
+ class Type##ArrayTraits { \
+ public: \
+ typedef elementType ElementType; \
+ static const InstanceType kInstanceType = FIXED_##TYPE##_ARRAY_TYPE; \
+ static const char* Designator() { return #type " array"; } \
+ static inline MaybeObject* ToObject(Heap* heap, elementType scalar); \
+ static elementType defaultValue() { return 0; } \
+ }; \
+ \
+ typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array;
+
+FIXED_TYPED_ARRAY_TRAITS(Uint8, uint8, UINT8, uint8_t)
+FIXED_TYPED_ARRAY_TRAITS(Int8, int8, INT8, int8_t)
+FIXED_TYPED_ARRAY_TRAITS(Uint16, uint16, UINT16, uint16_t)
+FIXED_TYPED_ARRAY_TRAITS(Int16, int16, INT16, int16_t)
+FIXED_TYPED_ARRAY_TRAITS(Uint32, uint32, UINT32, uint32_t)
+FIXED_TYPED_ARRAY_TRAITS(Int32, int32, INT32, int32_t)
+FIXED_TYPED_ARRAY_TRAITS(Float32, float32, FLOAT32, float)
+FIXED_TYPED_ARRAY_TRAITS(Float64, float64, FLOAT64, double)
+FIXED_TYPED_ARRAY_TRAITS(Uint8Clamped, uint8_clamped, UINT8_CLAMPED, uint8_t)
+
+#undef FIXED_TYPED_ARRAY_TRAITS
+
// 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
@@ -5837,6 +5946,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());
}
« no previous file with comments | « src/ic.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698