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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 #define BOOL_ACCESSORS(holder, field, name, offset) \ | 134 #define BOOL_ACCESSORS(holder, field, name, offset) \ |
135 bool holder::name() const { \ | 135 bool holder::name() const { \ |
136 return BooleanBit::get(field(), offset); \ | 136 return BooleanBit::get(field(), offset); \ |
137 } \ | 137 } \ |
138 void holder::set_##name(bool value) { \ | 138 void holder::set_##name(bool value) { \ |
139 set_##field(BooleanBit::set(field(), offset, value)); \ | 139 set_##field(BooleanBit::set(field(), offset, value)); \ |
140 } | 140 } |
141 | 141 |
142 | 142 |
143 bool Object::IsFixedArrayBase() const { | 143 bool Object::IsFixedArrayBase() const { |
144 return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase() || | 144 return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase(); |
145 IsExternalArray(); | |
146 } | 145 } |
147 | 146 |
148 | 147 |
149 // External objects are not extensible, so the map check is enough. | 148 // External objects are not extensible, so the map check is enough. |
150 bool Object::IsExternal() const { | 149 bool Object::IsExternal() const { |
151 return Object::IsHeapObject() && | 150 return Object::IsHeapObject() && |
152 HeapObject::cast(this)->map() == | 151 HeapObject::cast(this)->map() == |
153 HeapObject::cast(this)->GetHeap()->external_map(); | 152 HeapObject::cast(this)->GetHeap()->external_map(); |
154 } | 153 } |
155 | 154 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 262 |
264 bool Object::IsExternalTwoByteString() const { | 263 bool Object::IsExternalTwoByteString() const { |
265 if (!IsString()) return false; | 264 if (!IsString()) return false; |
266 return StringShape(String::cast(this)).IsExternal() && | 265 return StringShape(String::cast(this)).IsExternal() && |
267 String::cast(this)->IsTwoByteRepresentation(); | 266 String::cast(this)->IsTwoByteRepresentation(); |
268 } | 267 } |
269 | 268 |
270 | 269 |
271 bool Object::HasValidElements() { | 270 bool Object::HasValidElements() { |
272 // Dictionary is covered under FixedArray. | 271 // Dictionary is covered under FixedArray. |
273 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray() || | 272 return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase(); |
274 IsFixedTypedArrayBase(); | |
275 } | 273 } |
276 | 274 |
277 | 275 |
278 bool Object::KeyEquals(Object* second) { | 276 bool Object::KeyEquals(Object* second) { |
279 Object* first = this; | 277 Object* first = this; |
280 if (second->IsNumber()) { | 278 if (second->IsNumber()) { |
281 if (first->IsNumber()) return first->Number() == second->Number(); | 279 if (first->IsNumber()) return first->Number() == second->Number(); |
282 Object* temp = first; | 280 Object* temp = first; |
283 first = second; | 281 first = second; |
284 second = temp; | 282 second = temp; |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE) | 650 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE) |
653 | 651 |
654 | 652 |
655 bool Object::IsFiller() const { | 653 bool Object::IsFiller() const { |
656 if (!Object::IsHeapObject()) return false; | 654 if (!Object::IsHeapObject()) return false; |
657 InstanceType instance_type = HeapObject::cast(this)->map()->instance_type(); | 655 InstanceType instance_type = HeapObject::cast(this)->map()->instance_type(); |
658 return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE; | 656 return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE; |
659 } | 657 } |
660 | 658 |
661 | 659 |
662 bool Object::IsExternalArray() const { | |
663 if (!Object::IsHeapObject()) | |
664 return false; | |
665 InstanceType instance_type = | |
666 HeapObject::cast(this)->map()->instance_type(); | |
667 return (instance_type >= FIRST_EXTERNAL_ARRAY_TYPE && | |
668 instance_type <= LAST_EXTERNAL_ARRAY_TYPE); | |
669 } | |
670 | |
671 | 660 |
672 #define TYPED_ARRAY_TYPE_CHECKER(Type, type, TYPE, ctype, size) \ | 661 #define TYPED_ARRAY_TYPE_CHECKER(Type, type, TYPE, ctype, size) \ |
673 TYPE_CHECKER(External##Type##Array, EXTERNAL_##TYPE##_ARRAY_TYPE) \ | |
674 TYPE_CHECKER(Fixed##Type##Array, FIXED_##TYPE##_ARRAY_TYPE) | 662 TYPE_CHECKER(Fixed##Type##Array, FIXED_##TYPE##_ARRAY_TYPE) |
675 | 663 |
676 TYPED_ARRAYS(TYPED_ARRAY_TYPE_CHECKER) | 664 TYPED_ARRAYS(TYPED_ARRAY_TYPE_CHECKER) |
677 #undef TYPED_ARRAY_TYPE_CHECKER | 665 #undef TYPED_ARRAY_TYPE_CHECKER |
678 | 666 |
679 | 667 |
680 bool Object::IsFixedTypedArrayBase() const { | 668 bool Object::IsFixedTypedArrayBase() const { |
681 if (!Object::IsHeapObject()) return false; | 669 if (!Object::IsHeapObject()) return false; |
682 | 670 |
683 InstanceType instance_type = | 671 InstanceType instance_type = |
(...skipping 1952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2636 PropertyDetails Map::GetLastDescriptorDetails() { | 2624 PropertyDetails Map::GetLastDescriptorDetails() { |
2637 return instance_descriptors()->GetDetails(LastAdded()); | 2625 return instance_descriptors()->GetDetails(LastAdded()); |
2638 } | 2626 } |
2639 | 2627 |
2640 | 2628 |
2641 FixedArrayBase* Map::GetInitialElements() { | 2629 FixedArrayBase* Map::GetInitialElements() { |
2642 if (has_fast_smi_or_object_elements() || | 2630 if (has_fast_smi_or_object_elements() || |
2643 has_fast_double_elements()) { | 2631 has_fast_double_elements()) { |
2644 DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); | 2632 DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); |
2645 return GetHeap()->empty_fixed_array(); | 2633 return GetHeap()->empty_fixed_array(); |
2646 } else if (has_external_array_elements()) { | |
2647 ExternalArray* empty_array = GetHeap()->EmptyExternalArrayForMap(this); | |
2648 DCHECK(!GetHeap()->InNewSpace(empty_array)); | |
2649 return empty_array; | |
2650 } else if (has_fixed_typed_array_elements()) { | 2634 } else if (has_fixed_typed_array_elements()) { |
2651 FixedTypedArrayBase* empty_array = | 2635 FixedTypedArrayBase* empty_array = |
2652 GetHeap()->EmptyFixedTypedArrayForMap(this); | 2636 GetHeap()->EmptyFixedTypedArrayForMap(this); |
2653 DCHECK(!GetHeap()->InNewSpace(empty_array)); | 2637 DCHECK(!GetHeap()->InNewSpace(empty_array)); |
2654 return empty_array; | 2638 return empty_array; |
2655 } else { | 2639 } else { |
2656 UNREACHABLE(); | 2640 UNREACHABLE(); |
2657 } | 2641 } |
2658 return NULL; | 2642 return NULL; |
2659 } | 2643 } |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2928 CAST_ACCESSOR(BytecodeArray) | 2912 CAST_ACCESSOR(BytecodeArray) |
2929 CAST_ACCESSOR(Cell) | 2913 CAST_ACCESSOR(Cell) |
2930 CAST_ACCESSOR(Code) | 2914 CAST_ACCESSOR(Code) |
2931 CAST_ACCESSOR(CodeCacheHashTable) | 2915 CAST_ACCESSOR(CodeCacheHashTable) |
2932 CAST_ACCESSOR(CompilationCacheTable) | 2916 CAST_ACCESSOR(CompilationCacheTable) |
2933 CAST_ACCESSOR(ConsString) | 2917 CAST_ACCESSOR(ConsString) |
2934 CAST_ACCESSOR(DeoptimizationInputData) | 2918 CAST_ACCESSOR(DeoptimizationInputData) |
2935 CAST_ACCESSOR(DeoptimizationOutputData) | 2919 CAST_ACCESSOR(DeoptimizationOutputData) |
2936 CAST_ACCESSOR(DependentCode) | 2920 CAST_ACCESSOR(DependentCode) |
2937 CAST_ACCESSOR(DescriptorArray) | 2921 CAST_ACCESSOR(DescriptorArray) |
2938 CAST_ACCESSOR(ExternalArray) | |
2939 CAST_ACCESSOR(ExternalOneByteString) | 2922 CAST_ACCESSOR(ExternalOneByteString) |
2940 CAST_ACCESSOR(ExternalFloat32Array) | |
2941 CAST_ACCESSOR(ExternalFloat64Array) | |
2942 CAST_ACCESSOR(ExternalInt16Array) | |
2943 CAST_ACCESSOR(ExternalInt32Array) | |
2944 CAST_ACCESSOR(ExternalInt8Array) | |
2945 CAST_ACCESSOR(ExternalString) | 2923 CAST_ACCESSOR(ExternalString) |
2946 CAST_ACCESSOR(ExternalTwoByteString) | 2924 CAST_ACCESSOR(ExternalTwoByteString) |
2947 CAST_ACCESSOR(ExternalUint16Array) | |
2948 CAST_ACCESSOR(ExternalUint32Array) | |
2949 CAST_ACCESSOR(ExternalUint8Array) | |
2950 CAST_ACCESSOR(ExternalUint8ClampedArray) | |
2951 CAST_ACCESSOR(FixedArray) | 2925 CAST_ACCESSOR(FixedArray) |
2952 CAST_ACCESSOR(FixedArrayBase) | 2926 CAST_ACCESSOR(FixedArrayBase) |
2953 CAST_ACCESSOR(FixedDoubleArray) | 2927 CAST_ACCESSOR(FixedDoubleArray) |
2954 CAST_ACCESSOR(FixedTypedArrayBase) | 2928 CAST_ACCESSOR(FixedTypedArrayBase) |
2955 CAST_ACCESSOR(Float32x4) | 2929 CAST_ACCESSOR(Float32x4) |
2956 CAST_ACCESSOR(Foreign) | 2930 CAST_ACCESSOR(Foreign) |
2957 CAST_ACCESSOR(GlobalDictionary) | 2931 CAST_ACCESSOR(GlobalDictionary) |
2958 CAST_ACCESSOR(GlobalObject) | 2932 CAST_ACCESSOR(GlobalObject) |
2959 CAST_ACCESSOR(HandlerTable) | 2933 CAST_ACCESSOR(HandlerTable) |
2960 CAST_ACCESSOR(HeapObject) | 2934 CAST_ACCESSOR(HeapObject) |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3650 int BytecodeArray::frame_size() const { | 3624 int BytecodeArray::frame_size() const { |
3651 return READ_INT_FIELD(this, kFrameSizeOffset); | 3625 return READ_INT_FIELD(this, kFrameSizeOffset); |
3652 } | 3626 } |
3653 | 3627 |
3654 | 3628 |
3655 Address BytecodeArray::GetFirstBytecodeAddress() { | 3629 Address BytecodeArray::GetFirstBytecodeAddress() { |
3656 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize; | 3630 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize; |
3657 } | 3631 } |
3658 | 3632 |
3659 | 3633 |
3660 uint8_t* ExternalUint8ClampedArray::external_uint8_clamped_pointer() { | |
3661 return reinterpret_cast<uint8_t*>(external_pointer()); | |
3662 } | |
3663 | |
3664 | |
3665 uint8_t ExternalUint8ClampedArray::get_scalar(int index) { | |
3666 DCHECK((index >= 0) && (index < this->length())); | |
3667 uint8_t* ptr = external_uint8_clamped_pointer(); | |
3668 return ptr[index]; | |
3669 } | |
3670 | |
3671 | |
3672 Handle<Object> ExternalUint8ClampedArray::get( | |
3673 Handle<ExternalUint8ClampedArray> array, | |
3674 int index) { | |
3675 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), | |
3676 array->GetIsolate()); | |
3677 } | |
3678 | |
3679 | |
3680 void ExternalUint8ClampedArray::set(int index, uint8_t value) { | |
3681 DCHECK((index >= 0) && (index < this->length())); | |
3682 uint8_t* ptr = external_uint8_clamped_pointer(); | |
3683 ptr[index] = value; | |
3684 } | |
3685 | |
3686 | |
3687 void* ExternalArray::external_pointer() const { | |
3688 intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset); | |
3689 return reinterpret_cast<void*>(ptr); | |
3690 } | |
3691 | |
3692 | |
3693 void ExternalArray::set_external_pointer(void* value, WriteBarrierMode mode) { | |
3694 intptr_t ptr = reinterpret_cast<intptr_t>(value); | |
3695 WRITE_INTPTR_FIELD(this, kExternalPointerOffset, ptr); | |
3696 } | |
3697 | |
3698 | |
3699 int8_t ExternalInt8Array::get_scalar(int index) { | |
3700 DCHECK((index >= 0) && (index < this->length())); | |
3701 int8_t* ptr = static_cast<int8_t*>(external_pointer()); | |
3702 return ptr[index]; | |
3703 } | |
3704 | |
3705 | |
3706 Handle<Object> ExternalInt8Array::get(Handle<ExternalInt8Array> array, | |
3707 int index) { | |
3708 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), | |
3709 array->GetIsolate()); | |
3710 } | |
3711 | |
3712 | |
3713 void ExternalInt8Array::set(int index, int8_t value) { | |
3714 DCHECK((index >= 0) && (index < this->length())); | |
3715 int8_t* ptr = static_cast<int8_t*>(external_pointer()); | |
3716 ptr[index] = value; | |
3717 } | |
3718 | |
3719 | |
3720 uint8_t ExternalUint8Array::get_scalar(int index) { | |
3721 DCHECK((index >= 0) && (index < this->length())); | |
3722 uint8_t* ptr = static_cast<uint8_t*>(external_pointer()); | |
3723 return ptr[index]; | |
3724 } | |
3725 | |
3726 | |
3727 Handle<Object> ExternalUint8Array::get(Handle<ExternalUint8Array> array, | |
3728 int index) { | |
3729 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), | |
3730 array->GetIsolate()); | |
3731 } | |
3732 | |
3733 | |
3734 void ExternalUint8Array::set(int index, uint8_t value) { | |
3735 DCHECK((index >= 0) && (index < this->length())); | |
3736 uint8_t* ptr = static_cast<uint8_t*>(external_pointer()); | |
3737 ptr[index] = value; | |
3738 } | |
3739 | |
3740 | |
3741 int16_t ExternalInt16Array::get_scalar(int index) { | |
3742 DCHECK((index >= 0) && (index < this->length())); | |
3743 int16_t* ptr = static_cast<int16_t*>(external_pointer()); | |
3744 return ptr[index]; | |
3745 } | |
3746 | |
3747 | |
3748 Handle<Object> ExternalInt16Array::get(Handle<ExternalInt16Array> array, | |
3749 int index) { | |
3750 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), | |
3751 array->GetIsolate()); | |
3752 } | |
3753 | |
3754 | |
3755 void ExternalInt16Array::set(int index, int16_t value) { | |
3756 DCHECK((index >= 0) && (index < this->length())); | |
3757 int16_t* ptr = static_cast<int16_t*>(external_pointer()); | |
3758 ptr[index] = value; | |
3759 } | |
3760 | |
3761 | |
3762 uint16_t ExternalUint16Array::get_scalar(int index) { | |
3763 DCHECK((index >= 0) && (index < this->length())); | |
3764 uint16_t* ptr = static_cast<uint16_t*>(external_pointer()); | |
3765 return ptr[index]; | |
3766 } | |
3767 | |
3768 | |
3769 Handle<Object> ExternalUint16Array::get(Handle<ExternalUint16Array> array, | |
3770 int index) { | |
3771 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), | |
3772 array->GetIsolate()); | |
3773 } | |
3774 | |
3775 | |
3776 void ExternalUint16Array::set(int index, uint16_t value) { | |
3777 DCHECK((index >= 0) && (index < this->length())); | |
3778 uint16_t* ptr = static_cast<uint16_t*>(external_pointer()); | |
3779 ptr[index] = value; | |
3780 } | |
3781 | |
3782 | |
3783 int32_t ExternalInt32Array::get_scalar(int index) { | |
3784 DCHECK((index >= 0) && (index < this->length())); | |
3785 int32_t* ptr = static_cast<int32_t*>(external_pointer()); | |
3786 return ptr[index]; | |
3787 } | |
3788 | |
3789 | |
3790 Handle<Object> ExternalInt32Array::get(Handle<ExternalInt32Array> array, | |
3791 int index) { | |
3792 return array->GetIsolate()->factory()-> | |
3793 NewNumberFromInt(array->get_scalar(index)); | |
3794 } | |
3795 | |
3796 | |
3797 void ExternalInt32Array::set(int index, int32_t value) { | |
3798 DCHECK((index >= 0) && (index < this->length())); | |
3799 int32_t* ptr = static_cast<int32_t*>(external_pointer()); | |
3800 ptr[index] = value; | |
3801 } | |
3802 | |
3803 | |
3804 uint32_t ExternalUint32Array::get_scalar(int index) { | |
3805 DCHECK((index >= 0) && (index < this->length())); | |
3806 uint32_t* ptr = static_cast<uint32_t*>(external_pointer()); | |
3807 return ptr[index]; | |
3808 } | |
3809 | |
3810 | |
3811 Handle<Object> ExternalUint32Array::get(Handle<ExternalUint32Array> array, | |
3812 int index) { | |
3813 return array->GetIsolate()->factory()-> | |
3814 NewNumberFromUint(array->get_scalar(index)); | |
3815 } | |
3816 | |
3817 | |
3818 void ExternalUint32Array::set(int index, uint32_t value) { | |
3819 DCHECK((index >= 0) && (index < this->length())); | |
3820 uint32_t* ptr = static_cast<uint32_t*>(external_pointer()); | |
3821 ptr[index] = value; | |
3822 } | |
3823 | |
3824 | |
3825 float ExternalFloat32Array::get_scalar(int index) { | |
3826 DCHECK((index >= 0) && (index < this->length())); | |
3827 float* ptr = static_cast<float*>(external_pointer()); | |
3828 return ptr[index]; | |
3829 } | |
3830 | |
3831 | |
3832 Handle<Object> ExternalFloat32Array::get(Handle<ExternalFloat32Array> array, | |
3833 int index) { | |
3834 return array->GetIsolate()->factory()->NewNumber(array->get_scalar(index)); | |
3835 } | |
3836 | |
3837 | |
3838 void ExternalFloat32Array::set(int index, float value) { | |
3839 DCHECK((index >= 0) && (index < this->length())); | |
3840 float* ptr = static_cast<float*>(external_pointer()); | |
3841 ptr[index] = value; | |
3842 } | |
3843 | |
3844 | |
3845 double ExternalFloat64Array::get_scalar(int index) { | |
3846 DCHECK((index >= 0) && (index < this->length())); | |
3847 double* ptr = static_cast<double*>(external_pointer()); | |
3848 return ptr[index]; | |
3849 } | |
3850 | |
3851 | |
3852 Handle<Object> ExternalFloat64Array::get(Handle<ExternalFloat64Array> array, | |
3853 int index) { | |
3854 return array->GetIsolate()->factory()->NewNumber(array->get_scalar(index)); | |
3855 } | |
3856 | |
3857 | |
3858 void ExternalFloat64Array::set(int index, double value) { | |
3859 DCHECK((index >= 0) && (index < this->length())); | |
3860 double* ptr = static_cast<double*>(external_pointer()); | |
3861 ptr[index] = value; | |
3862 } | |
3863 | |
3864 | |
3865 ACCESSORS(FixedTypedArrayBase, base_pointer, Object, kBasePointerOffset) | 3634 ACCESSORS(FixedTypedArrayBase, base_pointer, Object, kBasePointerOffset) |
3866 | 3635 |
3867 | 3636 |
3868 void* FixedTypedArrayBase::external_pointer() const { | 3637 void* FixedTypedArrayBase::external_pointer() const { |
3869 intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset); | 3638 intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset); |
3870 return reinterpret_cast<void*>(ptr); | 3639 return reinterpret_cast<void*>(ptr); |
3871 } | 3640 } |
3872 | 3641 |
3873 | 3642 |
3874 void FixedTypedArrayBase::set_external_pointer(void* value, | 3643 void FixedTypedArrayBase::set_external_pointer(void* value, |
(...skipping 22 matching lines...) Expand all Loading... |
3897 #undef TYPED_ARRAY_CASE | 3666 #undef TYPED_ARRAY_CASE |
3898 default: | 3667 default: |
3899 UNREACHABLE(); | 3668 UNREACHABLE(); |
3900 return 0; | 3669 return 0; |
3901 } | 3670 } |
3902 return element_size; | 3671 return element_size; |
3903 } | 3672 } |
3904 | 3673 |
3905 | 3674 |
3906 int FixedTypedArrayBase::DataSize(InstanceType type) { | 3675 int FixedTypedArrayBase::DataSize(InstanceType type) { |
| 3676 if (base_pointer() == Smi::FromInt(0)) return 0; |
3907 return length() * ElementSize(type); | 3677 return length() * ElementSize(type); |
3908 } | 3678 } |
3909 | 3679 |
3910 | 3680 |
3911 int FixedTypedArrayBase::DataSize() { | 3681 int FixedTypedArrayBase::DataSize() { |
3912 return DataSize(map()->instance_type()); | 3682 return DataSize(map()->instance_type()); |
3913 } | 3683 } |
3914 | 3684 |
3915 | 3685 |
3916 int FixedTypedArrayBase::size() { | 3686 int FixedTypedArrayBase::size() { |
(...skipping 2387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6304 bool JSObject::HasSlowArgumentsElements() { | 6074 bool JSObject::HasSlowArgumentsElements() { |
6305 return GetElementsKind() == SLOW_SLOPPY_ARGUMENTS_ELEMENTS; | 6075 return GetElementsKind() == SLOW_SLOPPY_ARGUMENTS_ELEMENTS; |
6306 } | 6076 } |
6307 | 6077 |
6308 | 6078 |
6309 bool JSObject::HasSloppyArgumentsElements() { | 6079 bool JSObject::HasSloppyArgumentsElements() { |
6310 return IsSloppyArgumentsElements(GetElementsKind()); | 6080 return IsSloppyArgumentsElements(GetElementsKind()); |
6311 } | 6081 } |
6312 | 6082 |
6313 | 6083 |
6314 bool JSObject::HasExternalArrayElements() { | |
6315 HeapObject* array = elements(); | |
6316 DCHECK(array != NULL); | |
6317 return array->IsExternalArray(); | |
6318 } | |
6319 | |
6320 | |
6321 #define EXTERNAL_ELEMENTS_CHECK(Type, type, TYPE, ctype, size) \ | |
6322 bool JSObject::HasExternal##Type##Elements() { \ | |
6323 HeapObject* array = elements(); \ | |
6324 DCHECK(array != NULL); \ | |
6325 if (!array->IsHeapObject()) \ | |
6326 return false; \ | |
6327 return array->map()->instance_type() == EXTERNAL_##TYPE##_ARRAY_TYPE; \ | |
6328 } | |
6329 | |
6330 TYPED_ARRAYS(EXTERNAL_ELEMENTS_CHECK) | |
6331 | |
6332 #undef EXTERNAL_ELEMENTS_CHECK | |
6333 | |
6334 | |
6335 bool JSObject::HasFixedTypedArrayElements() { | 6084 bool JSObject::HasFixedTypedArrayElements() { |
6336 HeapObject* array = elements(); | 6085 HeapObject* array = elements(); |
6337 DCHECK(array != NULL); | 6086 DCHECK(array != NULL); |
6338 return array->IsFixedTypedArrayBase(); | 6087 return array->IsFixedTypedArrayBase(); |
6339 } | 6088 } |
6340 | 6089 |
6341 | 6090 |
6342 #define FIXED_TYPED_ELEMENTS_CHECK(Type, type, TYPE, ctype, size) \ | 6091 #define FIXED_TYPED_ELEMENTS_CHECK(Type, type, TYPE, ctype, size) \ |
6343 bool JSObject::HasFixed##Type##Elements() { \ | 6092 bool JSObject::HasFixed##Type##Elements() { \ |
6344 HeapObject* array = elements(); \ | 6093 HeapObject* array = elements(); \ |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6996 // If the new array won't fit in a some non-trivial fraction of the max old | 6745 // If the new array won't fit in a some non-trivial fraction of the max old |
6997 // space size, then force it to go dictionary mode. | 6746 // space size, then force it to go dictionary mode. |
6998 uint32_t max_fast_array_size = | 6747 uint32_t max_fast_array_size = |
6999 static_cast<uint32_t>((heap->MaxOldGenerationSize() / kDoubleSize) / 4); | 6748 static_cast<uint32_t>((heap->MaxOldGenerationSize() / kDoubleSize) / 4); |
7000 return new_length >= max_fast_array_size; | 6749 return new_length >= max_fast_array_size; |
7001 } | 6750 } |
7002 | 6751 |
7003 | 6752 |
7004 bool JSArray::AllowsSetLength() { | 6753 bool JSArray::AllowsSetLength() { |
7005 bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray(); | 6754 bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray(); |
7006 DCHECK(result == !HasExternalArrayElements()); | 6755 DCHECK(result == !HasFixedTypedArrayElements()); |
7007 return result; | 6756 return result; |
7008 } | 6757 } |
7009 | 6758 |
7010 | 6759 |
7011 void JSArray::SetContent(Handle<JSArray> array, | 6760 void JSArray::SetContent(Handle<JSArray> array, |
7012 Handle<FixedArrayBase> storage) { | 6761 Handle<FixedArrayBase> storage) { |
7013 EnsureCanContainElements(array, storage, storage->length(), | 6762 EnsureCanContainElements(array, storage, storage->length(), |
7014 ALLOW_COPIED_DOUBLE_ELEMENTS); | 6763 ALLOW_COPIED_DOUBLE_ELEMENTS); |
7015 | 6764 |
7016 DCHECK((storage->map() == array->GetHeap()->fixed_double_array_map() && | 6765 DCHECK((storage->map() == array->GetHeap()->fixed_double_array_map() && |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7344 #undef READ_SHORT_FIELD | 7093 #undef READ_SHORT_FIELD |
7345 #undef WRITE_SHORT_FIELD | 7094 #undef WRITE_SHORT_FIELD |
7346 #undef READ_BYTE_FIELD | 7095 #undef READ_BYTE_FIELD |
7347 #undef WRITE_BYTE_FIELD | 7096 #undef WRITE_BYTE_FIELD |
7348 #undef NOBARRIER_READ_BYTE_FIELD | 7097 #undef NOBARRIER_READ_BYTE_FIELD |
7349 #undef NOBARRIER_WRITE_BYTE_FIELD | 7098 #undef NOBARRIER_WRITE_BYTE_FIELD |
7350 | 7099 |
7351 } } // namespace v8::internal | 7100 } } // namespace v8::internal |
7352 | 7101 |
7353 #endif // V8_OBJECTS_INL_H_ | 7102 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |