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::DataSize(InstanceType type) { |
3677 InstanceType instance_type = map()->instance_type(); | |
3678 int element_size; | 3677 int element_size; |
3679 switch (instance_type) { | 3678 switch (type) { |
3680 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 3679 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
3681 case FIXED_##TYPE##_ARRAY_TYPE: \ | 3680 case FIXED_##TYPE##_ARRAY_TYPE: \ |
3682 element_size = size; \ | 3681 element_size = size; \ |
3683 break; | 3682 break; |
3684 | 3683 |
3685 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 3684 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
3686 #undef TYPED_ARRAY_CASE | 3685 #undef TYPED_ARRAY_CASE |
3687 default: | 3686 default: |
3688 UNREACHABLE(); | 3687 UNREACHABLE(); |
3689 return 0; | 3688 return 0; |
3690 } | 3689 } |
3691 return length() * element_size; | 3690 return length() * element_size; |
3692 } | 3691 } |
3693 | 3692 |
3694 | 3693 |
| 3694 int FixedTypedArrayBase::DataSize() { |
| 3695 return DataSize(map()->instance_type()); |
| 3696 } |
| 3697 |
| 3698 |
3695 int FixedTypedArrayBase::size() { | 3699 int FixedTypedArrayBase::size() { |
3696 return OBJECT_POINTER_ALIGN(kDataOffset + DataSize()); | 3700 return OBJECT_POINTER_ALIGN(kDataOffset + DataSize()); |
3697 } | 3701 } |
3698 | 3702 |
3699 | 3703 |
| 3704 int FixedTypedArrayBase::TypedArraySize(InstanceType type) { |
| 3705 return OBJECT_POINTER_ALIGN(kDataOffset + DataSize(type)); |
| 3706 } |
| 3707 |
| 3708 |
3700 uint8_t Uint8ArrayTraits::defaultValue() { return 0; } | 3709 uint8_t Uint8ArrayTraits::defaultValue() { return 0; } |
3701 | 3710 |
3702 | 3711 |
3703 uint8_t Uint8ClampedArrayTraits::defaultValue() { return 0; } | 3712 uint8_t Uint8ClampedArrayTraits::defaultValue() { return 0; } |
3704 | 3713 |
3705 | 3714 |
3706 int8_t Int8ArrayTraits::defaultValue() { return 0; } | 3715 int8_t Int8ArrayTraits::defaultValue() { return 0; } |
3707 | 3716 |
3708 | 3717 |
3709 uint16_t Uint16ArrayTraits::defaultValue() { return 0; } | 3718 uint16_t Uint16ArrayTraits::defaultValue() { return 0; } |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3911 index -= inobject_properties(); | 3920 index -= inobject_properties(); |
3912 ASSERT(index < 0); | 3921 ASSERT(index < 0); |
3913 return instance_size() + (index * kPointerSize); | 3922 return instance_size() + (index * kPointerSize); |
3914 } | 3923 } |
3915 | 3924 |
3916 | 3925 |
3917 int HeapObject::SizeFromMap(Map* map) { | 3926 int HeapObject::SizeFromMap(Map* map) { |
3918 int instance_size = map->instance_size(); | 3927 int instance_size = map->instance_size(); |
3919 if (instance_size != kVariableSizeSentinel) return instance_size; | 3928 if (instance_size != kVariableSizeSentinel) return instance_size; |
3920 // Only inline the most frequent cases. | 3929 // Only inline the most frequent cases. |
3921 int instance_type = static_cast<int>(map->instance_type()); | 3930 InstanceType instance_type = map->instance_type(); |
3922 if (instance_type == FIXED_ARRAY_TYPE) { | 3931 if (instance_type == FIXED_ARRAY_TYPE) { |
3923 return FixedArray::BodyDescriptor::SizeOf(map, this); | 3932 return FixedArray::BodyDescriptor::SizeOf(map, this); |
3924 } | 3933 } |
3925 if (instance_type == ASCII_STRING_TYPE || | 3934 if (instance_type == ASCII_STRING_TYPE || |
3926 instance_type == ASCII_INTERNALIZED_STRING_TYPE) { | 3935 instance_type == ASCII_INTERNALIZED_STRING_TYPE) { |
3927 return SeqOneByteString::SizeFor( | 3936 return SeqOneByteString::SizeFor( |
3928 reinterpret_cast<SeqOneByteString*>(this)->length()); | 3937 reinterpret_cast<SeqOneByteString*>(this)->length()); |
3929 } | 3938 } |
3930 if (instance_type == BYTE_ARRAY_TYPE) { | 3939 if (instance_type == BYTE_ARRAY_TYPE) { |
3931 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); | 3940 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); |
(...skipping 12 matching lines...) Expand all Loading... |
3944 } | 3953 } |
3945 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { | 3954 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { |
3946 return ConstantPoolArray::SizeFor( | 3955 return ConstantPoolArray::SizeFor( |
3947 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int64_entries(), | 3956 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int64_entries(), |
3948 reinterpret_cast<ConstantPoolArray*>(this)->count_of_code_ptr_entries(), | 3957 reinterpret_cast<ConstantPoolArray*>(this)->count_of_code_ptr_entries(), |
3949 reinterpret_cast<ConstantPoolArray*>(this)->count_of_heap_ptr_entries(), | 3958 reinterpret_cast<ConstantPoolArray*>(this)->count_of_heap_ptr_entries(), |
3950 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int32_entries()); | 3959 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int32_entries()); |
3951 } | 3960 } |
3952 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && | 3961 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && |
3953 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { | 3962 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { |
3954 return reinterpret_cast<FixedTypedArrayBase*>(this)->size(); | 3963 return reinterpret_cast<FixedTypedArrayBase*>( |
| 3964 this)->TypedArraySize(instance_type); |
3955 } | 3965 } |
3956 ASSERT(instance_type == CODE_TYPE); | 3966 ASSERT(instance_type == CODE_TYPE); |
3957 return reinterpret_cast<Code*>(this)->CodeSize(); | 3967 return reinterpret_cast<Code*>(this)->CodeSize(); |
3958 } | 3968 } |
3959 | 3969 |
3960 | 3970 |
3961 void Map::set_instance_size(int value) { | 3971 void Map::set_instance_size(int value) { |
3962 ASSERT_EQ(0, value & (kPointerSize - 1)); | 3972 ASSERT_EQ(0, value & (kPointerSize - 1)); |
3963 value >>= kPointerSizeLog2; | 3973 value >>= kPointerSizeLog2; |
3964 ASSERT(0 <= value && value < 256); | 3974 ASSERT(0 <= value && value < 256); |
(...skipping 2880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6845 #undef READ_SHORT_FIELD | 6855 #undef READ_SHORT_FIELD |
6846 #undef WRITE_SHORT_FIELD | 6856 #undef WRITE_SHORT_FIELD |
6847 #undef READ_BYTE_FIELD | 6857 #undef READ_BYTE_FIELD |
6848 #undef WRITE_BYTE_FIELD | 6858 #undef WRITE_BYTE_FIELD |
6849 #undef NOBARRIER_READ_BYTE_FIELD | 6859 #undef NOBARRIER_READ_BYTE_FIELD |
6850 #undef NOBARRIER_WRITE_BYTE_FIELD | 6860 #undef NOBARRIER_WRITE_BYTE_FIELD |
6851 | 6861 |
6852 } } // namespace v8::internal | 6862 } } // namespace v8::internal |
6853 | 6863 |
6854 #endif // V8_OBJECTS_INL_H_ | 6864 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |