| 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 // Review notes: | 5 // Review notes: |
| 6 // | 6 // |
| 7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
| 8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
| 9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
| 10 // | 10 // |
| (...skipping 3815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3826 void ExternalFloat64Array::set(int index, double value) { | 3826 void ExternalFloat64Array::set(int index, double value) { |
| 3827 DCHECK((index >= 0) && (index < this->length())); | 3827 DCHECK((index >= 0) && (index < this->length())); |
| 3828 double* ptr = static_cast<double*>(external_pointer()); | 3828 double* ptr = static_cast<double*>(external_pointer()); |
| 3829 ptr[index] = value; | 3829 ptr[index] = value; |
| 3830 } | 3830 } |
| 3831 | 3831 |
| 3832 | 3832 |
| 3833 ACCESSORS(FixedTypedArrayBase, base_pointer, Object, kBasePointerOffset) | 3833 ACCESSORS(FixedTypedArrayBase, base_pointer, Object, kBasePointerOffset) |
| 3834 | 3834 |
| 3835 | 3835 |
| 3836 void* FixedTypedArrayBase::DataPtr() { | 3836 void* FixedTypedArrayBase::external_pointer() const { |
| 3837 return FIELD_ADDR(this, kDataOffset); | 3837 intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset); |
| 3838 return reinterpret_cast<void*>(ptr); |
| 3838 } | 3839 } |
| 3839 | 3840 |
| 3840 | 3841 |
| 3842 void FixedTypedArrayBase::set_external_pointer(void* value, |
| 3843 WriteBarrierMode mode) { |
| 3844 intptr_t ptr = reinterpret_cast<intptr_t>(value); |
| 3845 WRITE_INTPTR_FIELD(this, kExternalPointerOffset, ptr); |
| 3846 } |
| 3847 |
| 3848 |
| 3849 void* FixedTypedArrayBase::DataPtr() { |
| 3850 return reinterpret_cast<void*>( |
| 3851 reinterpret_cast<intptr_t>(base_pointer()) + |
| 3852 reinterpret_cast<intptr_t>(external_pointer())); |
| 3853 } |
| 3854 |
| 3855 |
| 3841 int FixedTypedArrayBase::ElementSize(InstanceType type) { | 3856 int FixedTypedArrayBase::ElementSize(InstanceType type) { |
| 3842 int element_size; | 3857 int element_size; |
| 3843 switch (type) { | 3858 switch (type) { |
| 3844 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 3859 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
| 3845 case FIXED_##TYPE##_ARRAY_TYPE: \ | 3860 case FIXED_##TYPE##_ARRAY_TYPE: \ |
| 3846 element_size = size; \ | 3861 element_size = size; \ |
| 3847 break; | 3862 break; |
| 3848 | 3863 |
| 3849 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 3864 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 3850 #undef TYPED_ARRAY_CASE | 3865 #undef TYPED_ARRAY_CASE |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3908 | 3923 |
| 3909 | 3924 |
| 3910 double Float64ArrayTraits::defaultValue() { | 3925 double Float64ArrayTraits::defaultValue() { |
| 3911 return std::numeric_limits<double>::quiet_NaN(); | 3926 return std::numeric_limits<double>::quiet_NaN(); |
| 3912 } | 3927 } |
| 3913 | 3928 |
| 3914 | 3929 |
| 3915 template <class Traits> | 3930 template <class Traits> |
| 3916 typename Traits::ElementType FixedTypedArray<Traits>::get_scalar(int index) { | 3931 typename Traits::ElementType FixedTypedArray<Traits>::get_scalar(int index) { |
| 3917 DCHECK((index >= 0) && (index < this->length())); | 3932 DCHECK((index >= 0) && (index < this->length())); |
| 3918 ElementType* ptr = reinterpret_cast<ElementType*>( | 3933 ElementType* ptr = reinterpret_cast<ElementType*>(DataPtr()); |
| 3919 FIELD_ADDR(this, kDataOffset)); | |
| 3920 return ptr[index]; | 3934 return ptr[index]; |
| 3921 } | 3935 } |
| 3922 | 3936 |
| 3923 | 3937 |
| 3924 template <class Traits> | 3938 template <class Traits> |
| 3925 void FixedTypedArray<Traits>::set(int index, ElementType value) { | 3939 void FixedTypedArray<Traits>::set(int index, ElementType value) { |
| 3926 DCHECK((index >= 0) && (index < this->length())); | 3940 DCHECK((index >= 0) && (index < this->length())); |
| 3927 ElementType* ptr = reinterpret_cast<ElementType*>( | 3941 ElementType* ptr = reinterpret_cast<ElementType*>(DataPtr()); |
| 3928 FIELD_ADDR(this, kDataOffset)); | |
| 3929 ptr[index] = value; | 3942 ptr[index] = value; |
| 3930 } | 3943 } |
| 3931 | 3944 |
| 3932 | 3945 |
| 3933 template <class Traits> | 3946 template <class Traits> |
| 3934 typename Traits::ElementType FixedTypedArray<Traits>::from_int(int value) { | 3947 typename Traits::ElementType FixedTypedArray<Traits>::from_int(int value) { |
| 3935 return static_cast<ElementType>(value); | 3948 return static_cast<ElementType>(value); |
| 3936 } | 3949 } |
| 3937 | 3950 |
| 3938 | 3951 |
| (...skipping 3361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7300 #undef READ_SHORT_FIELD | 7313 #undef READ_SHORT_FIELD |
| 7301 #undef WRITE_SHORT_FIELD | 7314 #undef WRITE_SHORT_FIELD |
| 7302 #undef READ_BYTE_FIELD | 7315 #undef READ_BYTE_FIELD |
| 7303 #undef WRITE_BYTE_FIELD | 7316 #undef WRITE_BYTE_FIELD |
| 7304 #undef NOBARRIER_READ_BYTE_FIELD | 7317 #undef NOBARRIER_READ_BYTE_FIELD |
| 7305 #undef NOBARRIER_WRITE_BYTE_FIELD | 7318 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 7306 | 7319 |
| 7307 } } // namespace v8::internal | 7320 } } // namespace v8::internal |
| 7308 | 7321 |
| 7309 #endif // V8_OBJECTS_INL_H_ | 7322 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |