OLD | NEW |
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 2182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2193 inline bool HasExternalUint8Elements(); | 2193 inline bool HasExternalUint8Elements(); |
2194 inline bool HasExternalInt16Elements(); | 2194 inline bool HasExternalInt16Elements(); |
2195 inline bool HasExternalUint16Elements(); | 2195 inline bool HasExternalUint16Elements(); |
2196 inline bool HasExternalInt32Elements(); | 2196 inline bool HasExternalInt32Elements(); |
2197 inline bool HasExternalUint32Elements(); | 2197 inline bool HasExternalUint32Elements(); |
2198 inline bool HasExternalFloat32Elements(); | 2198 inline bool HasExternalFloat32Elements(); |
2199 inline bool HasExternalFloat64Elements(); | 2199 inline bool HasExternalFloat64Elements(); |
2200 | 2200 |
2201 inline bool HasFixedTypedArrayElements(); | 2201 inline bool HasFixedTypedArrayElements(); |
2202 | 2202 |
| 2203 inline bool HasFixedUint8ClampedElements(); |
| 2204 inline bool HasFixedArrayElements(); |
| 2205 inline bool HasFixedInt8Elements(); |
| 2206 inline bool HasFixedUint8Elements(); |
| 2207 inline bool HasFixedInt16Elements(); |
| 2208 inline bool HasFixedUint16Elements(); |
| 2209 inline bool HasFixedInt32Elements(); |
| 2210 inline bool HasFixedUint32Elements(); |
| 2211 inline bool HasFixedFloat32Elements(); |
| 2212 inline bool HasFixedFloat64Elements(); |
| 2213 |
2203 bool HasFastArgumentsElements(); | 2214 bool HasFastArgumentsElements(); |
2204 bool HasDictionaryArgumentsElements(); | 2215 bool HasDictionaryArgumentsElements(); |
2205 inline SeededNumberDictionary* element_dictionary(); // Gets slow elements. | 2216 inline SeededNumberDictionary* element_dictionary(); // Gets slow elements. |
2206 | 2217 |
2207 inline void set_map_and_elements( | 2218 inline void set_map_and_elements( |
2208 Map* map, | 2219 Map* map, |
2209 FixedArrayBase* value, | 2220 FixedArrayBase* value, |
2210 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 2221 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
2211 | 2222 |
2212 // Requires: HasFastElements(). | 2223 // Requires: HasFastElements(). |
(...skipping 2707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4920 | 4931 |
4921 class FixedTypedArrayBase: public FixedArrayBase { | 4932 class FixedTypedArrayBase: public FixedArrayBase { |
4922 public: | 4933 public: |
4923 // Casting: | 4934 // Casting: |
4924 static inline FixedTypedArrayBase* cast(Object* obj); | 4935 static inline FixedTypedArrayBase* cast(Object* obj); |
4925 | 4936 |
4926 static const int kDataOffset = kHeaderSize; | 4937 static const int kDataOffset = kHeaderSize; |
4927 | 4938 |
4928 inline int size(); | 4939 inline int size(); |
4929 | 4940 |
| 4941 // Use with care: returns raw pointer into heap. |
| 4942 inline void* DataPtr(); |
| 4943 |
| 4944 inline int DataSize(); |
| 4945 |
4930 private: | 4946 private: |
4931 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArrayBase); | 4947 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArrayBase); |
4932 }; | 4948 }; |
4933 | 4949 |
4934 | 4950 |
4935 template <class Traits> | 4951 template <class Traits> |
4936 class FixedTypedArray: public FixedTypedArrayBase { | 4952 class FixedTypedArray: public FixedTypedArrayBase { |
4937 public: | 4953 public: |
4938 typedef typename Traits::ElementType ElementType; | 4954 typedef typename Traits::ElementType ElementType; |
4939 static const InstanceType kInstanceType = Traits::kInstanceType; | 4955 static const InstanceType kInstanceType = Traits::kInstanceType; |
4940 | 4956 |
4941 // Casting: | 4957 // Casting: |
4942 static inline FixedTypedArray<Traits>* cast(Object* obj); | 4958 static inline FixedTypedArray<Traits>* cast(Object* obj); |
4943 | 4959 |
4944 static inline int ElementOffset(int index) { | 4960 static inline int ElementOffset(int index) { |
4945 return kDataOffset + index * sizeof(ElementType); | 4961 return kDataOffset + index * sizeof(ElementType); |
4946 } | 4962 } |
4947 | 4963 |
4948 static inline int SizeFor(int length) { | 4964 static inline int SizeFor(int length) { |
4949 return ElementOffset(length); | 4965 return ElementOffset(length); |
4950 } | 4966 } |
4951 | 4967 |
4952 inline ElementType get_scalar(int index); | 4968 inline ElementType get_scalar(int index); |
4953 MUST_USE_RESULT inline MaybeObject* get(int index); | 4969 MUST_USE_RESULT inline MaybeObject* get(int index); |
4954 inline void set(int index, ElementType value); | 4970 inline void set(int index, ElementType value); |
4955 | 4971 |
| 4972 static inline ElementType from_int(int value); |
| 4973 static inline ElementType from_double(double value); |
| 4974 |
4956 // This accessor applies the correct conversion from Smi, HeapNumber | 4975 // This accessor applies the correct conversion from Smi, HeapNumber |
4957 // and undefined. | 4976 // and undefined. |
4958 MUST_USE_RESULT MaybeObject* SetValue(uint32_t index, Object* value); | 4977 MUST_USE_RESULT MaybeObject* SetValue(uint32_t index, Object* value); |
4959 | 4978 |
4960 static Handle<Object> SetValue(Handle<FixedTypedArray<Traits> > array, | 4979 static Handle<Object> SetValue(Handle<FixedTypedArray<Traits> > array, |
4961 uint32_t index, | 4980 uint32_t index, |
4962 Handle<Object> value); | 4981 Handle<Object> value); |
4963 | 4982 |
4964 DECLARE_PRINTER(FixedTypedArray) | 4983 DECLARE_PRINTER(FixedTypedArray) |
4965 DECLARE_VERIFIER(FixedTypedArray) | 4984 DECLARE_VERIFIER(FixedTypedArray) |
4966 | 4985 |
4967 private: | 4986 private: |
4968 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArray); | 4987 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArray); |
4969 }; | 4988 }; |
4970 | 4989 |
4971 #define FIXED_TYPED_ARRAY_TRAITS(Type, type, TYPE, elementType, size) \ | 4990 #define FIXED_TYPED_ARRAY_TRAITS(Type, type, TYPE, elementType, size) \ |
4972 class Type##ArrayTraits { \ | 4991 class Type##ArrayTraits { \ |
4973 public: \ | 4992 public: \ |
4974 typedef elementType ElementType; \ | 4993 typedef elementType ElementType; \ |
4975 static const InstanceType kInstanceType = FIXED_##TYPE##_ARRAY_TYPE; \ | 4994 static const InstanceType kInstanceType = FIXED_##TYPE##_ARRAY_TYPE; \ |
4976 static const char* Designator() { return #type " array"; } \ | 4995 static const char* Designator() { return #type " array"; } \ |
4977 static inline MaybeObject* ToObject(Heap* heap, elementType scalar); \ | 4996 static inline MaybeObject* ToObject(Heap* heap, elementType scalar); \ |
4978 static elementType defaultValue() { return 0; } \ | 4997 static inline elementType defaultValue(); \ |
4979 }; \ | 4998 }; \ |
4980 \ | 4999 \ |
4981 typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array; | 5000 typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array; |
4982 | 5001 |
4983 TYPED_ARRAYS(FIXED_TYPED_ARRAY_TRAITS) | 5002 TYPED_ARRAYS(FIXED_TYPED_ARRAY_TRAITS) |
4984 | 5003 |
4985 #undef FIXED_TYPED_ARRAY_TRAITS | 5004 #undef FIXED_TYPED_ARRAY_TRAITS |
4986 | 5005 |
4987 // DeoptimizationInputData is a fixed array used to hold the deoptimization | 5006 // DeoptimizationInputData is a fixed array used to hold the deoptimization |
4988 // data for code generated by the Hydrogen/Lithium compiler. It also | 5007 // data for code generated by the Hydrogen/Lithium compiler. It also |
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6185 TransitionFlag flag); | 6204 TransitionFlag flag); |
6186 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor, | 6205 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor, |
6187 TransitionFlag flag); | 6206 TransitionFlag flag); |
6188 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor( | 6207 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor( |
6189 DescriptorArray* descriptors, | 6208 DescriptorArray* descriptors, |
6190 Descriptor* descriptor, | 6209 Descriptor* descriptor, |
6191 int index, | 6210 int index, |
6192 TransitionFlag flag); | 6211 TransitionFlag flag); |
6193 MUST_USE_RESULT MaybeObject* AsElementsKind(ElementsKind kind); | 6212 MUST_USE_RESULT MaybeObject* AsElementsKind(ElementsKind kind); |
6194 | 6213 |
| 6214 static Handle<Map> AsElementsKind(Handle<Map> map, ElementsKind kind); |
| 6215 |
6195 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind, | 6216 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind, |
6196 TransitionFlag flag); | 6217 TransitionFlag flag); |
6197 | 6218 |
6198 static Handle<Map> CopyForObserved(Handle<Map> map); | 6219 static Handle<Map> CopyForObserved(Handle<Map> map); |
6199 | 6220 |
6200 static Handle<Map> CopyNormalized(Handle<Map> map, | 6221 static Handle<Map> CopyNormalized(Handle<Map> map, |
6201 PropertyNormalizationMode mode, | 6222 PropertyNormalizationMode mode, |
6202 NormalizedMapSharingMode sharing); | 6223 NormalizedMapSharingMode sharing); |
6203 | 6224 |
6204 inline void AppendDescriptor(Descriptor* desc, | 6225 inline void AppendDescriptor(Descriptor* desc, |
(...skipping 3700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9905 | 9926 |
9906 // Neutering. Only neuters this typed array. | 9927 // Neutering. Only neuters this typed array. |
9907 void Neuter(); | 9928 void Neuter(); |
9908 | 9929 |
9909 // Casting. | 9930 // Casting. |
9910 static inline JSTypedArray* cast(Object* obj); | 9931 static inline JSTypedArray* cast(Object* obj); |
9911 | 9932 |
9912 ExternalArrayType type(); | 9933 ExternalArrayType type(); |
9913 size_t element_size(); | 9934 size_t element_size(); |
9914 | 9935 |
| 9936 Handle<JSArrayBuffer> GetBuffer(); |
| 9937 |
9915 // Dispatched behavior. | 9938 // Dispatched behavior. |
9916 DECLARE_PRINTER(JSTypedArray) | 9939 DECLARE_PRINTER(JSTypedArray) |
9917 DECLARE_VERIFIER(JSTypedArray) | 9940 DECLARE_VERIFIER(JSTypedArray) |
9918 | 9941 |
9919 static const int kLengthOffset = kViewSize + kPointerSize; | 9942 static const int kLengthOffset = kViewSize + kPointerSize; |
9920 static const int kSize = kLengthOffset + kPointerSize; | 9943 static const int kSize = kLengthOffset + kPointerSize; |
9921 | 9944 |
9922 static const int kSizeWithInternalFields = | 9945 static const int kSizeWithInternalFields = |
9923 kSize + v8::ArrayBufferView::kInternalFieldCount * kPointerSize; | 9946 kSize + v8::ArrayBufferView::kInternalFieldCount * kPointerSize; |
9924 | 9947 |
9925 private: | 9948 private: |
| 9949 static Handle<JSArrayBuffer> MaterializeArrayBuffer( |
| 9950 Handle<JSTypedArray> typed_array); |
| 9951 |
9926 DISALLOW_IMPLICIT_CONSTRUCTORS(JSTypedArray); | 9952 DISALLOW_IMPLICIT_CONSTRUCTORS(JSTypedArray); |
9927 }; | 9953 }; |
9928 | 9954 |
9929 | 9955 |
9930 class JSDataView: public JSArrayBufferView { | 9956 class JSDataView: public JSArrayBufferView { |
9931 public: | 9957 public: |
9932 // Only neuters this DataView | 9958 // Only neuters this DataView |
9933 void Neuter(); | 9959 void Neuter(); |
9934 | 9960 |
9935 // Casting. | 9961 // Casting. |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10778 } else { | 10804 } else { |
10779 value &= ~(1 << bit_position); | 10805 value &= ~(1 << bit_position); |
10780 } | 10806 } |
10781 return value; | 10807 return value; |
10782 } | 10808 } |
10783 }; | 10809 }; |
10784 | 10810 |
10785 } } // namespace v8::internal | 10811 } } // namespace v8::internal |
10786 | 10812 |
10787 #endif // V8_OBJECTS_H_ | 10813 #endif // V8_OBJECTS_H_ |
OLD | NEW |