| 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 3655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3666 double* ptr = static_cast<double*>(external_pointer()); | 3666 double* ptr = static_cast<double*>(external_pointer()); |
| 3667 ptr[index] = value; | 3667 ptr[index] = value; |
| 3668 } | 3668 } |
| 3669 | 3669 |
| 3670 | 3670 |
| 3671 void* FixedTypedArrayBase::DataPtr() { | 3671 void* FixedTypedArrayBase::DataPtr() { |
| 3672 return FIELD_ADDR(this, kDataOffset); | 3672 return FIELD_ADDR(this, kDataOffset); |
| 3673 } | 3673 } |
| 3674 | 3674 |
| 3675 | 3675 |
| 3676 int FixedTypedArrayBase::DataSize() { | 3676 int FixedTypedArrayBase::DataSizeFromMap(Map* map) { |
| 3677 InstanceType instance_type = map()->instance_type(); | 3677 InstanceType instance_type = map->instance_type(); |
| 3678 int element_size; | 3678 int element_size; |
| 3679 switch (instance_type) { | 3679 switch (instance_type) { |
| 3680 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 3680 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
| 3681 case FIXED_##TYPE##_ARRAY_TYPE: \ | 3681 case FIXED_##TYPE##_ARRAY_TYPE: \ |
| 3682 element_size = size; \ | 3682 element_size = size; \ |
| 3683 break; | 3683 break; |
| 3684 | 3684 |
| 3685 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 3685 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 3686 #undef TYPED_ARRAY_CASE | 3686 #undef TYPED_ARRAY_CASE |
| 3687 default: | 3687 default: |
| 3688 UNREACHABLE(); | 3688 UNREACHABLE(); |
| 3689 return 0; | 3689 return 0; |
| 3690 } | 3690 } |
| 3691 return length() * element_size; | 3691 return length() * element_size; |
| 3692 } | 3692 } |
| 3693 | 3693 |
| 3694 | 3694 |
| 3695 int FixedTypedArrayBase::size() { | 3695 int FixedTypedArrayBase::size() { |
| 3696 return OBJECT_POINTER_ALIGN(kDataOffset + DataSize()); | 3696 return OBJECT_POINTER_ALIGN(kDataOffset + DataSizeFromMap(map())); |
| 3697 } | 3697 } |
| 3698 | 3698 |
| 3699 | 3699 |
| 3700 int FixedTypedArrayBase::SizeFromMap(Map* map) { |
| 3701 return OBJECT_POINTER_ALIGN(kDataOffset + DataSizeFromMap(map)); |
| 3702 } |
| 3703 |
| 3704 |
| 3700 uint8_t Uint8ArrayTraits::defaultValue() { return 0; } | 3705 uint8_t Uint8ArrayTraits::defaultValue() { return 0; } |
| 3701 | 3706 |
| 3702 | 3707 |
| 3703 uint8_t Uint8ClampedArrayTraits::defaultValue() { return 0; } | 3708 uint8_t Uint8ClampedArrayTraits::defaultValue() { return 0; } |
| 3704 | 3709 |
| 3705 | 3710 |
| 3706 int8_t Int8ArrayTraits::defaultValue() { return 0; } | 3711 int8_t Int8ArrayTraits::defaultValue() { return 0; } |
| 3707 | 3712 |
| 3708 | 3713 |
| 3709 uint16_t Uint16ArrayTraits::defaultValue() { return 0; } | 3714 uint16_t Uint16ArrayTraits::defaultValue() { return 0; } |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3944 } | 3949 } |
| 3945 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { | 3950 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { |
| 3946 return ConstantPoolArray::SizeFor( | 3951 return ConstantPoolArray::SizeFor( |
| 3947 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int64_entries(), | 3952 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int64_entries(), |
| 3948 reinterpret_cast<ConstantPoolArray*>(this)->count_of_code_ptr_entries(), | 3953 reinterpret_cast<ConstantPoolArray*>(this)->count_of_code_ptr_entries(), |
| 3949 reinterpret_cast<ConstantPoolArray*>(this)->count_of_heap_ptr_entries(), | 3954 reinterpret_cast<ConstantPoolArray*>(this)->count_of_heap_ptr_entries(), |
| 3950 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int32_entries()); | 3955 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int32_entries()); |
| 3951 } | 3956 } |
| 3952 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && | 3957 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && |
| 3953 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { | 3958 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { |
| 3954 return reinterpret_cast<FixedTypedArrayBase*>(this)->size(); | 3959 return reinterpret_cast<FixedTypedArrayBase*>(this)->SizeFromMap(map); |
| 3955 } | 3960 } |
| 3956 ASSERT(instance_type == CODE_TYPE); | 3961 ASSERT(instance_type == CODE_TYPE); |
| 3957 return reinterpret_cast<Code*>(this)->CodeSize(); | 3962 return reinterpret_cast<Code*>(this)->CodeSize(); |
| 3958 } | 3963 } |
| 3959 | 3964 |
| 3960 | 3965 |
| 3961 void Map::set_instance_size(int value) { | 3966 void Map::set_instance_size(int value) { |
| 3962 ASSERT_EQ(0, value & (kPointerSize - 1)); | 3967 ASSERT_EQ(0, value & (kPointerSize - 1)); |
| 3963 value >>= kPointerSizeLog2; | 3968 value >>= kPointerSizeLog2; |
| 3964 ASSERT(0 <= value && value < 256); | 3969 ASSERT(0 <= value && value < 256); |
| (...skipping 2880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6845 #undef READ_SHORT_FIELD | 6850 #undef READ_SHORT_FIELD |
| 6846 #undef WRITE_SHORT_FIELD | 6851 #undef WRITE_SHORT_FIELD |
| 6847 #undef READ_BYTE_FIELD | 6852 #undef READ_BYTE_FIELD |
| 6848 #undef WRITE_BYTE_FIELD | 6853 #undef WRITE_BYTE_FIELD |
| 6849 #undef NOBARRIER_READ_BYTE_FIELD | 6854 #undef NOBARRIER_READ_BYTE_FIELD |
| 6850 #undef NOBARRIER_WRITE_BYTE_FIELD | 6855 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 6851 | 6856 |
| 6852 } } // namespace v8::internal | 6857 } } // namespace v8::internal |
| 6853 | 6858 |
| 6854 #endif // V8_OBJECTS_INL_H_ | 6859 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |