Chromium Code Reviews

Side by Side Diff: src/objects.h

Issue 150813004: In-heap small typed arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2202 matching lines...)
2213 inline bool HasExternalUint8Elements(); 2213 inline bool HasExternalUint8Elements();
2214 inline bool HasExternalInt16Elements(); 2214 inline bool HasExternalInt16Elements();
2215 inline bool HasExternalUint16Elements(); 2215 inline bool HasExternalUint16Elements();
2216 inline bool HasExternalInt32Elements(); 2216 inline bool HasExternalInt32Elements();
2217 inline bool HasExternalUint32Elements(); 2217 inline bool HasExternalUint32Elements();
2218 inline bool HasExternalFloat32Elements(); 2218 inline bool HasExternalFloat32Elements();
2219 inline bool HasExternalFloat64Elements(); 2219 inline bool HasExternalFloat64Elements();
2220 2220
2221 inline bool HasFixedTypedArrayElements(); 2221 inline bool HasFixedTypedArrayElements();
2222 2222
2223 inline bool HasFixedUint8ClampedElements();
2224 inline bool HasFixedArrayElements();
2225 inline bool HasFixedInt8Elements();
2226 inline bool HasFixedUint8Elements();
2227 inline bool HasFixedInt16Elements();
2228 inline bool HasFixedUint16Elements();
2229 inline bool HasFixedInt32Elements();
2230 inline bool HasFixedUint32Elements();
2231 inline bool HasFixedFloat32Elements();
2232 inline bool HasFixedFloat64Elements();
2233
2223 bool HasFastArgumentsElements(); 2234 bool HasFastArgumentsElements();
2224 bool HasDictionaryArgumentsElements(); 2235 bool HasDictionaryArgumentsElements();
2225 inline SeededNumberDictionary* element_dictionary(); // Gets slow elements. 2236 inline SeededNumberDictionary* element_dictionary(); // Gets slow elements.
2226 2237
2227 inline void set_map_and_elements( 2238 inline void set_map_and_elements(
2228 Map* map, 2239 Map* map,
2229 FixedArrayBase* value, 2240 FixedArrayBase* value,
2230 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 2241 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
2231 2242
2232 // Requires: HasFastElements(). 2243 // Requires: HasFastElements().
(...skipping 2732 matching lines...)
4965 4976
4966 class FixedTypedArrayBase: public FixedArrayBase { 4977 class FixedTypedArrayBase: public FixedArrayBase {
4967 public: 4978 public:
4968 // Casting: 4979 // Casting:
4969 static inline FixedTypedArrayBase* cast(Object* obj); 4980 static inline FixedTypedArrayBase* cast(Object* obj);
4970 4981
4971 static const int kDataOffset = kHeaderSize; 4982 static const int kDataOffset = kHeaderSize;
4972 4983
4973 inline int size(); 4984 inline int size();
4974 4985
4986 // Use with care: returns raw pointer into heap.
4987 inline void* DataPtr();
4988
4989 inline int DataSize();
4990
4975 private: 4991 private:
4976 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArrayBase); 4992 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArrayBase);
4977 }; 4993 };
4978 4994
4979 4995
4980 template <class Traits> 4996 template <class Traits>
4981 class FixedTypedArray: public FixedTypedArrayBase { 4997 class FixedTypedArray: public FixedTypedArrayBase {
4982 public: 4998 public:
4983 typedef typename Traits::ElementType ElementType; 4999 typedef typename Traits::ElementType ElementType;
4984 static const InstanceType kInstanceType = Traits::kInstanceType; 5000 static const InstanceType kInstanceType = Traits::kInstanceType;
4985 5001
4986 // Casting: 5002 // Casting:
4987 static inline FixedTypedArray<Traits>* cast(Object* obj); 5003 static inline FixedTypedArray<Traits>* cast(Object* obj);
4988 5004
4989 static inline int ElementOffset(int index) { 5005 static inline int ElementOffset(int index) {
4990 return kDataOffset + index * sizeof(ElementType); 5006 return kDataOffset + index * sizeof(ElementType);
4991 } 5007 }
4992 5008
4993 static inline int SizeFor(int length) { 5009 static inline int SizeFor(int length) {
4994 return ElementOffset(length); 5010 return ElementOffset(length);
4995 } 5011 }
4996 5012
4997 inline ElementType get_scalar(int index); 5013 inline ElementType get_scalar(int index);
4998 MUST_USE_RESULT inline MaybeObject* get(int index); 5014 MUST_USE_RESULT inline MaybeObject* get(int index);
4999 inline void set(int index, ElementType value); 5015 inline void set(int index, ElementType value);
5000 5016
5017 static inline ElementType from_int(int value);
5018 static inline ElementType from_double(double value);
5019
5001 // This accessor applies the correct conversion from Smi, HeapNumber 5020 // This accessor applies the correct conversion from Smi, HeapNumber
5002 // and undefined. 5021 // and undefined.
5003 MUST_USE_RESULT MaybeObject* SetValue(uint32_t index, Object* value); 5022 MUST_USE_RESULT MaybeObject* SetValue(uint32_t index, Object* value);
5004 5023
5005 static Handle<Object> SetValue(Handle<FixedTypedArray<Traits> > array, 5024 static Handle<Object> SetValue(Handle<FixedTypedArray<Traits> > array,
5006 uint32_t index, 5025 uint32_t index,
5007 Handle<Object> value); 5026 Handle<Object> value);
5008 5027
5009 DECLARE_PRINTER(FixedTypedArray) 5028 DECLARE_PRINTER(FixedTypedArray)
5010 DECLARE_VERIFIER(FixedTypedArray) 5029 DECLARE_VERIFIER(FixedTypedArray)
5011 5030
5012 private: 5031 private:
5013 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArray); 5032 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArray);
5014 }; 5033 };
5015 5034
5016 #define FIXED_TYPED_ARRAY_TRAITS(Type, type, TYPE, elementType, size) \ 5035 #define FIXED_TYPED_ARRAY_TRAITS(Type, type, TYPE, elementType, size) \
5017 class Type##ArrayTraits { \ 5036 class Type##ArrayTraits { \
5018 public: \ 5037 public: \
5019 typedef elementType ElementType; \ 5038 typedef elementType ElementType; \
5020 static const InstanceType kInstanceType = FIXED_##TYPE##_ARRAY_TYPE; \ 5039 static const InstanceType kInstanceType = FIXED_##TYPE##_ARRAY_TYPE; \
5021 static const char* Designator() { return #type " array"; } \ 5040 static const char* Designator() { return #type " array"; } \
5022 static inline MaybeObject* ToObject(Heap* heap, elementType scalar); \ 5041 static inline MaybeObject* ToObject(Heap* heap, elementType scalar); \
5023 static elementType defaultValue() { return 0; } \ 5042 static inline elementType defaultValue(); \
5024 }; \ 5043 }; \
5025 \ 5044 \
5026 typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array; 5045 typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array;
5027 5046
5028 TYPED_ARRAYS(FIXED_TYPED_ARRAY_TRAITS) 5047 TYPED_ARRAYS(FIXED_TYPED_ARRAY_TRAITS)
5029 5048
5030 #undef FIXED_TYPED_ARRAY_TRAITS 5049 #undef FIXED_TYPED_ARRAY_TRAITS
5031 5050
5032 // DeoptimizationInputData is a fixed array used to hold the deoptimization 5051 // DeoptimizationInputData is a fixed array used to hold the deoptimization
5033 // data for code generated by the Hydrogen/Lithium compiler. It also 5052 // data for code generated by the Hydrogen/Lithium compiler. It also
(...skipping 1199 matching lines...)
6233 Descriptor* descriptor); 6252 Descriptor* descriptor);
6234 MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor, 6253 MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor,
6235 TransitionFlag flag); 6254 TransitionFlag flag);
6236 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor, 6255 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor,
6237 TransitionFlag flag); 6256 TransitionFlag flag);
6238 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor( 6257 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor(
6239 DescriptorArray* descriptors, 6258 DescriptorArray* descriptors,
6240 Descriptor* descriptor, 6259 Descriptor* descriptor,
6241 int index, 6260 int index,
6242 TransitionFlag flag); 6261 TransitionFlag flag);
6262
6263 MUST_USE_RESULT MaybeObject* AsElementsKind(ElementsKind kind);
6264
6243 static Handle<Map> AsElementsKind(Handle<Map> map, ElementsKind kind); 6265 static Handle<Map> AsElementsKind(Handle<Map> map, ElementsKind kind);
6244 MUST_USE_RESULT MaybeObject* AsElementsKind(ElementsKind kind);
6245 6266
6246 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind, 6267 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind,
6247 TransitionFlag flag); 6268 TransitionFlag flag);
6248 6269
6249 static Handle<Map> CopyForObserved(Handle<Map> map); 6270 static Handle<Map> CopyForObserved(Handle<Map> map);
6250 6271
6251 static Handle<Map> CopyNormalized(Handle<Map> map, 6272 static Handle<Map> CopyNormalized(Handle<Map> map,
6252 PropertyNormalizationMode mode, 6273 PropertyNormalizationMode mode,
6253 NormalizedMapSharingMode sharing); 6274 NormalizedMapSharingMode sharing);
6254 6275
(...skipping 3669 matching lines...)
9924 9945
9925 // Neutering. Only neuters this typed array. 9946 // Neutering. Only neuters this typed array.
9926 void Neuter(); 9947 void Neuter();
9927 9948
9928 // Casting. 9949 // Casting.
9929 static inline JSTypedArray* cast(Object* obj); 9950 static inline JSTypedArray* cast(Object* obj);
9930 9951
9931 ExternalArrayType type(); 9952 ExternalArrayType type();
9932 size_t element_size(); 9953 size_t element_size();
9933 9954
9955 Handle<JSArrayBuffer> GetBuffer();
9956
9934 // Dispatched behavior. 9957 // Dispatched behavior.
9935 DECLARE_PRINTER(JSTypedArray) 9958 DECLARE_PRINTER(JSTypedArray)
9936 DECLARE_VERIFIER(JSTypedArray) 9959 DECLARE_VERIFIER(JSTypedArray)
9937 9960
9938 static const int kLengthOffset = kViewSize + kPointerSize; 9961 static const int kLengthOffset = kViewSize + kPointerSize;
9939 static const int kSize = kLengthOffset + kPointerSize; 9962 static const int kSize = kLengthOffset + kPointerSize;
9940 9963
9941 static const int kSizeWithInternalFields = 9964 static const int kSizeWithInternalFields =
9942 kSize + v8::ArrayBufferView::kInternalFieldCount * kPointerSize; 9965 kSize + v8::ArrayBufferView::kInternalFieldCount * kPointerSize;
9943 9966
9944 private: 9967 private:
9968 static Handle<JSArrayBuffer> MaterializeArrayBuffer(
9969 Handle<JSTypedArray> typed_array);
9970
9945 DISALLOW_IMPLICIT_CONSTRUCTORS(JSTypedArray); 9971 DISALLOW_IMPLICIT_CONSTRUCTORS(JSTypedArray);
9946 }; 9972 };
9947 9973
9948 9974
9949 class JSDataView: public JSArrayBufferView { 9975 class JSDataView: public JSArrayBufferView {
9950 public: 9976 public:
9951 // Only neuters this DataView 9977 // Only neuters this DataView
9952 void Neuter(); 9978 void Neuter();
9953 9979
9954 // Casting. 9980 // Casting.
(...skipping 844 matching lines...)
10799 } else { 10825 } else {
10800 value &= ~(1 << bit_position); 10826 value &= ~(1 << bit_position);
10801 } 10827 }
10802 return value; 10828 return value;
10803 } 10829 }
10804 }; 10830 };
10805 10831
10806 } } // namespace v8::internal 10832 } } // namespace v8::internal
10807 10833
10808 #endif // V8_OBJECTS_H_ 10834 #endif // V8_OBJECTS_H_
OLDNEW
« src/hydrogen.cc ('K') | « src/hydrogen.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine