OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 4624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4635 DECL_ACCESSORS(external_pointer, void) // Pointer to the data store. | 4635 DECL_ACCESSORS(external_pointer, void) // Pointer to the data store. |
4636 | 4636 |
4637 DECLARE_CAST(ExternalArray) | 4637 DECLARE_CAST(ExternalArray) |
4638 | 4638 |
4639 // Maximal acceptable length for an external array. | 4639 // Maximal acceptable length for an external array. |
4640 static const int kMaxLength = 0x3fffffff; | 4640 static const int kMaxLength = 0x3fffffff; |
4641 | 4641 |
4642 // ExternalArray headers are not quadword aligned. | 4642 // ExternalArray headers are not quadword aligned. |
4643 static const int kExternalPointerOffset = | 4643 static const int kExternalPointerOffset = |
4644 POINTER_SIZE_ALIGN(FixedArrayBase::kLengthOffset + kPointerSize); | 4644 POINTER_SIZE_ALIGN(FixedArrayBase::kLengthOffset + kPointerSize); |
4645 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; | 4645 static const int kSize = kExternalPointerOffset + kPointerSize; |
4646 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); | |
4647 | 4646 |
4648 private: | 4647 private: |
4649 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); | 4648 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); |
4650 }; | 4649 }; |
4651 | 4650 |
4652 | 4651 |
4653 // A ExternalUint8ClampedArray represents a fixed-size byte array with special | 4652 // A ExternalUint8ClampedArray represents a fixed-size byte array with special |
4654 // semantics used for implementing the CanvasPixelArray object. Please see the | 4653 // semantics used for implementing the CanvasPixelArray object. Please see the |
4655 // specification at: | 4654 // specification at: |
4656 | 4655 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4878 | 4877 |
4879 private: | 4878 private: |
4880 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloat64Array); | 4879 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloat64Array); |
4881 }; | 4880 }; |
4882 | 4881 |
4883 | 4882 |
4884 class FixedTypedArrayBase: public FixedArrayBase { | 4883 class FixedTypedArrayBase: public FixedArrayBase { |
4885 public: | 4884 public: |
4886 DECLARE_CAST(FixedTypedArrayBase) | 4885 DECLARE_CAST(FixedTypedArrayBase) |
4887 | 4886 |
4888 static const int kDataOffset = kHeaderSize; | 4887 static const int kDataOffset = DOUBLE_POINTER_ALIGN(kHeaderSize); |
4889 | 4888 |
4890 inline int size(); | 4889 inline int size(); |
4891 | 4890 |
4892 static inline int TypedArraySize(InstanceType type, int length); | 4891 static inline int TypedArraySize(InstanceType type, int length); |
4893 inline int TypedArraySize(InstanceType type); | 4892 inline int TypedArraySize(InstanceType type); |
4894 | 4893 |
4895 // Use with care: returns raw pointer into heap. | 4894 // Use with care: returns raw pointer into heap. |
4896 inline void* DataPtr(); | 4895 inline void* DataPtr(); |
4897 | 4896 |
4898 inline int DataSize(); | 4897 inline int DataSize(); |
4899 | 4898 |
4900 private: | 4899 private: |
4901 static inline int ElementSize(InstanceType type); | 4900 static inline int ElementSize(InstanceType type); |
4902 | 4901 |
4903 inline int DataSize(InstanceType type); | 4902 inline int DataSize(InstanceType type); |
4904 | 4903 |
4905 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArrayBase); | 4904 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArrayBase); |
4906 }; | 4905 }; |
4907 | 4906 |
4908 | 4907 |
4909 template <class Traits> | 4908 template <class Traits> |
4910 class FixedTypedArray: public FixedTypedArrayBase { | 4909 class FixedTypedArray: public FixedTypedArrayBase { |
4911 public: | 4910 public: |
4912 typedef typename Traits::ElementType ElementType; | 4911 typedef typename Traits::ElementType ElementType; |
4913 static const InstanceType kInstanceType = Traits::kInstanceType; | 4912 static const InstanceType kInstanceType = Traits::kInstanceType; |
4914 | 4913 |
4915 DECLARE_CAST(FixedTypedArray<Traits>) | 4914 DECLARE_CAST(FixedTypedArray<Traits>) |
4916 | 4915 |
4917 static inline int ElementOffset(int index) { | |
4918 return kDataOffset + index * sizeof(ElementType); | |
4919 } | |
4920 | |
4921 static inline int SizeFor(int length) { | |
4922 return ElementOffset(length); | |
4923 } | |
4924 | |
4925 inline ElementType get_scalar(int index); | 4916 inline ElementType get_scalar(int index); |
4926 static inline Handle<Object> get(Handle<FixedTypedArray> array, int index); | 4917 static inline Handle<Object> get(Handle<FixedTypedArray> array, int index); |
4927 inline void set(int index, ElementType value); | 4918 inline void set(int index, ElementType value); |
4928 | 4919 |
4929 static inline ElementType from_int(int value); | 4920 static inline ElementType from_int(int value); |
4930 static inline ElementType from_double(double value); | 4921 static inline ElementType from_double(double value); |
4931 | 4922 |
4932 // This accessor applies the correct conversion from Smi, HeapNumber | 4923 // This accessor applies the correct conversion from Smi, HeapNumber |
4933 // and undefined. | 4924 // and undefined. |
4934 static Handle<Object> SetValue(Handle<JSObject> holder, | 4925 static Handle<Object> SetValue(Handle<JSObject> holder, |
(...skipping 6171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11106 } else { | 11097 } else { |
11107 value &= ~(1 << bit_position); | 11098 value &= ~(1 << bit_position); |
11108 } | 11099 } |
11109 return value; | 11100 return value; |
11110 } | 11101 } |
11111 }; | 11102 }; |
11112 | 11103 |
11113 } } // namespace v8::internal | 11104 } } // namespace v8::internal |
11114 | 11105 |
11115 #endif // V8_OBJECTS_H_ | 11106 #endif // V8_OBJECTS_H_ |
OLD | NEW |