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

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: Patch for landing Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2199 matching lines...) Expand 10 before | Expand all | Expand 10 after
2210 inline bool HasExternalUint8Elements(); 2210 inline bool HasExternalUint8Elements();
2211 inline bool HasExternalInt16Elements(); 2211 inline bool HasExternalInt16Elements();
2212 inline bool HasExternalUint16Elements(); 2212 inline bool HasExternalUint16Elements();
2213 inline bool HasExternalInt32Elements(); 2213 inline bool HasExternalInt32Elements();
2214 inline bool HasExternalUint32Elements(); 2214 inline bool HasExternalUint32Elements();
2215 inline bool HasExternalFloat32Elements(); 2215 inline bool HasExternalFloat32Elements();
2216 inline bool HasExternalFloat64Elements(); 2216 inline bool HasExternalFloat64Elements();
2217 2217
2218 inline bool HasFixedTypedArrayElements(); 2218 inline bool HasFixedTypedArrayElements();
2219 2219
2220 inline bool HasFixedUint8ClampedElements();
2221 inline bool HasFixedArrayElements();
2222 inline bool HasFixedInt8Elements();
2223 inline bool HasFixedUint8Elements();
2224 inline bool HasFixedInt16Elements();
2225 inline bool HasFixedUint16Elements();
2226 inline bool HasFixedInt32Elements();
2227 inline bool HasFixedUint32Elements();
2228 inline bool HasFixedFloat32Elements();
2229 inline bool HasFixedFloat64Elements();
2230
2220 bool HasFastArgumentsElements(); 2231 bool HasFastArgumentsElements();
2221 bool HasDictionaryArgumentsElements(); 2232 bool HasDictionaryArgumentsElements();
2222 inline SeededNumberDictionary* element_dictionary(); // Gets slow elements. 2233 inline SeededNumberDictionary* element_dictionary(); // Gets slow elements.
2223 2234
2224 inline void set_map_and_elements( 2235 inline void set_map_and_elements(
2225 Map* map, 2236 Map* map,
2226 FixedArrayBase* value, 2237 FixedArrayBase* value,
2227 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 2238 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
2228 2239
2229 // Requires: HasFastElements(). 2240 // Requires: HasFastElements().
(...skipping 2719 matching lines...) Expand 10 before | Expand all | Expand 10 after
4949 4960
4950 class FixedTypedArrayBase: public FixedArrayBase { 4961 class FixedTypedArrayBase: public FixedArrayBase {
4951 public: 4962 public:
4952 // Casting: 4963 // Casting:
4953 static inline FixedTypedArrayBase* cast(Object* obj); 4964 static inline FixedTypedArrayBase* cast(Object* obj);
4954 4965
4955 static const int kDataOffset = kHeaderSize; 4966 static const int kDataOffset = kHeaderSize;
4956 4967
4957 inline int size(); 4968 inline int size();
4958 4969
4970 // Use with care: returns raw pointer into heap.
4971 inline void* DataPtr();
4972
4973 inline int DataSize();
4974
4959 private: 4975 private:
4960 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArrayBase); 4976 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArrayBase);
4961 }; 4977 };
4962 4978
4963 4979
4964 template <class Traits> 4980 template <class Traits>
4965 class FixedTypedArray: public FixedTypedArrayBase { 4981 class FixedTypedArray: public FixedTypedArrayBase {
4966 public: 4982 public:
4967 typedef typename Traits::ElementType ElementType; 4983 typedef typename Traits::ElementType ElementType;
4968 static const InstanceType kInstanceType = Traits::kInstanceType; 4984 static const InstanceType kInstanceType = Traits::kInstanceType;
4969 4985
4970 // Casting: 4986 // Casting:
4971 static inline FixedTypedArray<Traits>* cast(Object* obj); 4987 static inline FixedTypedArray<Traits>* cast(Object* obj);
4972 4988
4973 static inline int ElementOffset(int index) { 4989 static inline int ElementOffset(int index) {
4974 return kDataOffset + index * sizeof(ElementType); 4990 return kDataOffset + index * sizeof(ElementType);
4975 } 4991 }
4976 4992
4977 static inline int SizeFor(int length) { 4993 static inline int SizeFor(int length) {
4978 return ElementOffset(length); 4994 return ElementOffset(length);
4979 } 4995 }
4980 4996
4981 inline ElementType get_scalar(int index); 4997 inline ElementType get_scalar(int index);
4982 MUST_USE_RESULT inline MaybeObject* get(int index); 4998 MUST_USE_RESULT inline MaybeObject* get(int index);
4983 inline void set(int index, ElementType value); 4999 inline void set(int index, ElementType value);
4984 5000
5001 static inline ElementType from_int(int value);
5002 static inline ElementType from_double(double value);
5003
4985 // This accessor applies the correct conversion from Smi, HeapNumber 5004 // This accessor applies the correct conversion from Smi, HeapNumber
4986 // and undefined. 5005 // and undefined.
4987 MUST_USE_RESULT MaybeObject* SetValue(uint32_t index, Object* value); 5006 MUST_USE_RESULT MaybeObject* SetValue(uint32_t index, Object* value);
4988 5007
4989 static Handle<Object> SetValue(Handle<FixedTypedArray<Traits> > array, 5008 static Handle<Object> SetValue(Handle<FixedTypedArray<Traits> > array,
4990 uint32_t index, 5009 uint32_t index,
4991 Handle<Object> value); 5010 Handle<Object> value);
4992 5011
4993 DECLARE_PRINTER(FixedTypedArray) 5012 DECLARE_PRINTER(FixedTypedArray)
4994 DECLARE_VERIFIER(FixedTypedArray) 5013 DECLARE_VERIFIER(FixedTypedArray)
4995 5014
4996 private: 5015 private:
4997 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArray); 5016 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArray);
4998 }; 5017 };
4999 5018
5000 #define FIXED_TYPED_ARRAY_TRAITS(Type, type, TYPE, elementType, size) \ 5019 #define FIXED_TYPED_ARRAY_TRAITS(Type, type, TYPE, elementType, size) \
5001 class Type##ArrayTraits { \ 5020 class Type##ArrayTraits { \
5002 public: \ 5021 public: \
5003 typedef elementType ElementType; \ 5022 typedef elementType ElementType; \
5004 static const InstanceType kInstanceType = FIXED_##TYPE##_ARRAY_TYPE; \ 5023 static const InstanceType kInstanceType = FIXED_##TYPE##_ARRAY_TYPE; \
5005 static const char* Designator() { return #type " array"; } \ 5024 static const char* Designator() { return #type " array"; } \
5006 static inline MaybeObject* ToObject(Heap* heap, elementType scalar); \ 5025 static inline MaybeObject* ToObject(Heap* heap, elementType scalar); \
5007 static elementType defaultValue() { return 0; } \ 5026 static inline elementType defaultValue(); \
5008 }; \ 5027 }; \
5009 \ 5028 \
5010 typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array; 5029 typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array;
5011 5030
5012 TYPED_ARRAYS(FIXED_TYPED_ARRAY_TRAITS) 5031 TYPED_ARRAYS(FIXED_TYPED_ARRAY_TRAITS)
5013 5032
5014 #undef FIXED_TYPED_ARRAY_TRAITS 5033 #undef FIXED_TYPED_ARRAY_TRAITS
5015 5034
5016 // DeoptimizationInputData is a fixed array used to hold the deoptimization 5035 // DeoptimizationInputData is a fixed array used to hold the deoptimization
5017 // data for code generated by the Hydrogen/Lithium compiler. It also 5036 // data for code generated by the Hydrogen/Lithium compiler. It also
(...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after
6217 Descriptor* descriptor); 6236 Descriptor* descriptor);
6218 MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor, 6237 MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor,
6219 TransitionFlag flag); 6238 TransitionFlag flag);
6220 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor, 6239 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor,
6221 TransitionFlag flag); 6240 TransitionFlag flag);
6222 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor( 6241 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor(
6223 DescriptorArray* descriptors, 6242 DescriptorArray* descriptors,
6224 Descriptor* descriptor, 6243 Descriptor* descriptor,
6225 int index, 6244 int index,
6226 TransitionFlag flag); 6245 TransitionFlag flag);
6246
6247 MUST_USE_RESULT MaybeObject* AsElementsKind(ElementsKind kind);
6248
6227 static Handle<Map> AsElementsKind(Handle<Map> map, ElementsKind kind); 6249 static Handle<Map> AsElementsKind(Handle<Map> map, ElementsKind kind);
6228 MUST_USE_RESULT MaybeObject* AsElementsKind(ElementsKind kind);
6229 6250
6230 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind, 6251 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind,
6231 TransitionFlag flag); 6252 TransitionFlag flag);
6232 6253
6233 static Handle<Map> CopyForObserved(Handle<Map> map); 6254 static Handle<Map> CopyForObserved(Handle<Map> map);
6234 6255
6235 static Handle<Map> CopyNormalized(Handle<Map> map, 6256 static Handle<Map> CopyNormalized(Handle<Map> map,
6236 PropertyNormalizationMode mode, 6257 PropertyNormalizationMode mode,
6237 NormalizedMapSharingMode sharing); 6258 NormalizedMapSharingMode sharing);
6238 6259
(...skipping 3670 matching lines...) Expand 10 before | Expand all | Expand 10 after
9909 9930
9910 // Neutering. Only neuters this typed array. 9931 // Neutering. Only neuters this typed array.
9911 void Neuter(); 9932 void Neuter();
9912 9933
9913 // Casting. 9934 // Casting.
9914 static inline JSTypedArray* cast(Object* obj); 9935 static inline JSTypedArray* cast(Object* obj);
9915 9936
9916 ExternalArrayType type(); 9937 ExternalArrayType type();
9917 size_t element_size(); 9938 size_t element_size();
9918 9939
9940 Handle<JSArrayBuffer> GetBuffer();
9941
9919 // Dispatched behavior. 9942 // Dispatched behavior.
9920 DECLARE_PRINTER(JSTypedArray) 9943 DECLARE_PRINTER(JSTypedArray)
9921 DECLARE_VERIFIER(JSTypedArray) 9944 DECLARE_VERIFIER(JSTypedArray)
9922 9945
9923 static const int kLengthOffset = kViewSize + kPointerSize; 9946 static const int kLengthOffset = kViewSize + kPointerSize;
9924 static const int kSize = kLengthOffset + kPointerSize; 9947 static const int kSize = kLengthOffset + kPointerSize;
9925 9948
9926 static const int kSizeWithInternalFields = 9949 static const int kSizeWithInternalFields =
9927 kSize + v8::ArrayBufferView::kInternalFieldCount * kPointerSize; 9950 kSize + v8::ArrayBufferView::kInternalFieldCount * kPointerSize;
9928 9951
9929 private: 9952 private:
9953 static Handle<JSArrayBuffer> MaterializeArrayBuffer(
9954 Handle<JSTypedArray> typed_array);
9955
9930 DISALLOW_IMPLICIT_CONSTRUCTORS(JSTypedArray); 9956 DISALLOW_IMPLICIT_CONSTRUCTORS(JSTypedArray);
9931 }; 9957 };
9932 9958
9933 9959
9934 class JSDataView: public JSArrayBufferView { 9960 class JSDataView: public JSArrayBufferView {
9935 public: 9961 public:
9936 // Only neuters this DataView 9962 // Only neuters this DataView
9937 void Neuter(); 9963 void Neuter();
9938 9964
9939 // Casting. 9965 // Casting.
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
10786 } else { 10812 } else {
10787 value &= ~(1 << bit_position); 10813 value &= ~(1 << bit_position);
10788 } 10814 }
10789 return value; 10815 return value;
10790 } 10816 }
10791 }; 10817 };
10792 10818
10793 } } // namespace v8::internal 10819 } } // namespace v8::internal
10794 10820
10795 #endif // V8_OBJECTS_H_ 10821 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698