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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE) | 649 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE) |
652 | 650 |
653 | 651 |
654 bool Object::IsFiller() const { | 652 bool Object::IsFiller() const { |
655 if (!Object::IsHeapObject()) return false; | 653 if (!Object::IsHeapObject()) return false; |
656 InstanceType instance_type = HeapObject::cast(this)->map()->instance_type(); | 654 InstanceType instance_type = HeapObject::cast(this)->map()->instance_type(); |
657 return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE; | 655 return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE; |
658 } | 656 } |
659 | 657 |
660 | 658 |
661 bool Object::IsExternalArray() const { | |
662 if (!Object::IsHeapObject()) | |
663 return false; | |
664 InstanceType instance_type = | |
665 HeapObject::cast(this)->map()->instance_type(); | |
666 return (instance_type >= FIRST_EXTERNAL_ARRAY_TYPE && | |
667 instance_type <= LAST_EXTERNAL_ARRAY_TYPE); | |
668 } | |
669 | |
670 | 659 |
671 #define TYPED_ARRAY_TYPE_CHECKER(Type, type, TYPE, ctype, size) \ | 660 #define TYPED_ARRAY_TYPE_CHECKER(Type, type, TYPE, ctype, size) \ |
672 TYPE_CHECKER(External##Type##Array, EXTERNAL_##TYPE##_ARRAY_TYPE) \ | |
673 TYPE_CHECKER(Fixed##Type##Array, FIXED_##TYPE##_ARRAY_TYPE) | 661 TYPE_CHECKER(Fixed##Type##Array, FIXED_##TYPE##_ARRAY_TYPE) |
674 | 662 |
675 TYPED_ARRAYS(TYPED_ARRAY_TYPE_CHECKER) | 663 TYPED_ARRAYS(TYPED_ARRAY_TYPE_CHECKER) |
676 #undef TYPED_ARRAY_TYPE_CHECKER | 664 #undef TYPED_ARRAY_TYPE_CHECKER |
677 | 665 |
678 | 666 |
679 bool Object::IsFixedTypedArrayBase() const { | 667 bool Object::IsFixedTypedArrayBase() const { |
680 if (!Object::IsHeapObject()) return false; | 668 if (!Object::IsHeapObject()) return false; |
681 | 669 |
682 InstanceType instance_type = | 670 InstanceType instance_type = |
(...skipping 1952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2635 PropertyDetails Map::GetLastDescriptorDetails() { | 2623 PropertyDetails Map::GetLastDescriptorDetails() { |
2636 return instance_descriptors()->GetDetails(LastAdded()); | 2624 return instance_descriptors()->GetDetails(LastAdded()); |
2637 } | 2625 } |
2638 | 2626 |
2639 | 2627 |
2640 FixedArrayBase* Map::GetInitialElements() { | 2628 FixedArrayBase* Map::GetInitialElements() { |
2641 if (has_fast_smi_or_object_elements() || | 2629 if (has_fast_smi_or_object_elements() || |
2642 has_fast_double_elements()) { | 2630 has_fast_double_elements()) { |
2643 DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); | 2631 DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); |
2644 return GetHeap()->empty_fixed_array(); | 2632 return GetHeap()->empty_fixed_array(); |
2645 } else if (has_external_array_elements()) { | |
2646 ExternalArray* empty_array = GetHeap()->EmptyExternalArrayForMap(this); | |
2647 DCHECK(!GetHeap()->InNewSpace(empty_array)); | |
2648 return empty_array; | |
2649 } else if (has_fixed_typed_array_elements()) { | 2633 } else if (has_fixed_typed_array_elements()) { |
2650 FixedTypedArrayBase* empty_array = | 2634 FixedTypedArrayBase* empty_array = |
2651 GetHeap()->EmptyFixedTypedArrayForMap(this); | 2635 GetHeap()->EmptyFixedTypedArrayForMap(this); |
2652 DCHECK(!GetHeap()->InNewSpace(empty_array)); | 2636 DCHECK(!GetHeap()->InNewSpace(empty_array)); |
2653 return empty_array; | 2637 return empty_array; |
2654 } else { | 2638 } else { |
2655 UNREACHABLE(); | 2639 UNREACHABLE(); |
2656 } | 2640 } |
2657 return NULL; | 2641 return NULL; |
2658 } | 2642 } |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2926 CAST_ACCESSOR(ByteArray) | 2910 CAST_ACCESSOR(ByteArray) |
2927 CAST_ACCESSOR(Cell) | 2911 CAST_ACCESSOR(Cell) |
2928 CAST_ACCESSOR(Code) | 2912 CAST_ACCESSOR(Code) |
2929 CAST_ACCESSOR(CodeCacheHashTable) | 2913 CAST_ACCESSOR(CodeCacheHashTable) |
2930 CAST_ACCESSOR(CompilationCacheTable) | 2914 CAST_ACCESSOR(CompilationCacheTable) |
2931 CAST_ACCESSOR(ConsString) | 2915 CAST_ACCESSOR(ConsString) |
2932 CAST_ACCESSOR(DeoptimizationInputData) | 2916 CAST_ACCESSOR(DeoptimizationInputData) |
2933 CAST_ACCESSOR(DeoptimizationOutputData) | 2917 CAST_ACCESSOR(DeoptimizationOutputData) |
2934 CAST_ACCESSOR(DependentCode) | 2918 CAST_ACCESSOR(DependentCode) |
2935 CAST_ACCESSOR(DescriptorArray) | 2919 CAST_ACCESSOR(DescriptorArray) |
2936 CAST_ACCESSOR(ExternalArray) | |
2937 CAST_ACCESSOR(ExternalOneByteString) | 2920 CAST_ACCESSOR(ExternalOneByteString) |
2938 CAST_ACCESSOR(ExternalFloat32Array) | |
2939 CAST_ACCESSOR(ExternalFloat64Array) | |
2940 CAST_ACCESSOR(ExternalInt16Array) | |
2941 CAST_ACCESSOR(ExternalInt32Array) | |
2942 CAST_ACCESSOR(ExternalInt8Array) | |
2943 CAST_ACCESSOR(ExternalString) | 2921 CAST_ACCESSOR(ExternalString) |
2944 CAST_ACCESSOR(ExternalTwoByteString) | 2922 CAST_ACCESSOR(ExternalTwoByteString) |
2945 CAST_ACCESSOR(ExternalUint16Array) | |
2946 CAST_ACCESSOR(ExternalUint32Array) | |
2947 CAST_ACCESSOR(ExternalUint8Array) | |
2948 CAST_ACCESSOR(ExternalUint8ClampedArray) | |
2949 CAST_ACCESSOR(FixedArray) | 2923 CAST_ACCESSOR(FixedArray) |
2950 CAST_ACCESSOR(FixedArrayBase) | 2924 CAST_ACCESSOR(FixedArrayBase) |
2951 CAST_ACCESSOR(FixedDoubleArray) | 2925 CAST_ACCESSOR(FixedDoubleArray) |
2952 CAST_ACCESSOR(FixedTypedArrayBase) | 2926 CAST_ACCESSOR(FixedTypedArrayBase) |
2953 CAST_ACCESSOR(Float32x4) | 2927 CAST_ACCESSOR(Float32x4) |
2954 CAST_ACCESSOR(Foreign) | 2928 CAST_ACCESSOR(Foreign) |
2955 CAST_ACCESSOR(GlobalDictionary) | 2929 CAST_ACCESSOR(GlobalDictionary) |
2956 CAST_ACCESSOR(GlobalObject) | 2930 CAST_ACCESSOR(GlobalObject) |
2957 CAST_ACCESSOR(HandlerTable) | 2931 CAST_ACCESSOR(HandlerTable) |
2958 CAST_ACCESSOR(HeapObject) | 2932 CAST_ACCESSOR(HeapObject) |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3618 DCHECK_TAG_ALIGNED(address); | 3592 DCHECK_TAG_ALIGNED(address); |
3619 return reinterpret_cast<ByteArray*>(address - kHeaderSize + kHeapObjectTag); | 3593 return reinterpret_cast<ByteArray*>(address - kHeaderSize + kHeapObjectTag); |
3620 } | 3594 } |
3621 | 3595 |
3622 | 3596 |
3623 Address ByteArray::GetDataStartAddress() { | 3597 Address ByteArray::GetDataStartAddress() { |
3624 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize; | 3598 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize; |
3625 } | 3599 } |
3626 | 3600 |
3627 | 3601 |
3628 uint8_t* ExternalUint8ClampedArray::external_uint8_clamped_pointer() { | |
3629 return reinterpret_cast<uint8_t*>(external_pointer()); | |
3630 } | |
3631 | |
3632 | |
3633 uint8_t ExternalUint8ClampedArray::get_scalar(int index) { | |
3634 DCHECK((index >= 0) && (index < this->length())); | |
3635 uint8_t* ptr = external_uint8_clamped_pointer(); | |
3636 return ptr[index]; | |
3637 } | |
3638 | |
3639 | |
3640 Handle<Object> ExternalUint8ClampedArray::get( | |
3641 Handle<ExternalUint8ClampedArray> array, | |
3642 int index) { | |
3643 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), | |
3644 array->GetIsolate()); | |
3645 } | |
3646 | |
3647 | |
3648 void ExternalUint8ClampedArray::set(int index, uint8_t value) { | |
3649 DCHECK((index >= 0) && (index < this->length())); | |
3650 uint8_t* ptr = external_uint8_clamped_pointer(); | |
3651 ptr[index] = value; | |
3652 } | |
3653 | |
3654 | |
3655 void* ExternalArray::external_pointer() const { | |
3656 intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset); | |
3657 return reinterpret_cast<void*>(ptr); | |
3658 } | |
3659 | |
3660 | |
3661 void ExternalArray::set_external_pointer(void* value, WriteBarrierMode mode) { | |
3662 intptr_t ptr = reinterpret_cast<intptr_t>(value); | |
3663 WRITE_INTPTR_FIELD(this, kExternalPointerOffset, ptr); | |
3664 } | |
3665 | |
3666 | |
3667 int8_t ExternalInt8Array::get_scalar(int index) { | |
3668 DCHECK((index >= 0) && (index < this->length())); | |
3669 int8_t* ptr = static_cast<int8_t*>(external_pointer()); | |
3670 return ptr[index]; | |
3671 } | |
3672 | |
3673 | |
3674 Handle<Object> ExternalInt8Array::get(Handle<ExternalInt8Array> array, | |
3675 int index) { | |
3676 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), | |
3677 array->GetIsolate()); | |
3678 } | |
3679 | |
3680 | |
3681 void ExternalInt8Array::set(int index, int8_t value) { | |
3682 DCHECK((index >= 0) && (index < this->length())); | |
3683 int8_t* ptr = static_cast<int8_t*>(external_pointer()); | |
3684 ptr[index] = value; | |
3685 } | |
3686 | |
3687 | |
3688 uint8_t ExternalUint8Array::get_scalar(int index) { | |
3689 DCHECK((index >= 0) && (index < this->length())); | |
3690 uint8_t* ptr = static_cast<uint8_t*>(external_pointer()); | |
3691 return ptr[index]; | |
3692 } | |
3693 | |
3694 | |
3695 Handle<Object> ExternalUint8Array::get(Handle<ExternalUint8Array> array, | |
3696 int index) { | |
3697 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), | |
3698 array->GetIsolate()); | |
3699 } | |
3700 | |
3701 | |
3702 void ExternalUint8Array::set(int index, uint8_t value) { | |
3703 DCHECK((index >= 0) && (index < this->length())); | |
3704 uint8_t* ptr = static_cast<uint8_t*>(external_pointer()); | |
3705 ptr[index] = value; | |
3706 } | |
3707 | |
3708 | |
3709 int16_t ExternalInt16Array::get_scalar(int index) { | |
3710 DCHECK((index >= 0) && (index < this->length())); | |
3711 int16_t* ptr = static_cast<int16_t*>(external_pointer()); | |
3712 return ptr[index]; | |
3713 } | |
3714 | |
3715 | |
3716 Handle<Object> ExternalInt16Array::get(Handle<ExternalInt16Array> array, | |
3717 int index) { | |
3718 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), | |
3719 array->GetIsolate()); | |
3720 } | |
3721 | |
3722 | |
3723 void ExternalInt16Array::set(int index, int16_t value) { | |
3724 DCHECK((index >= 0) && (index < this->length())); | |
3725 int16_t* ptr = static_cast<int16_t*>(external_pointer()); | |
3726 ptr[index] = value; | |
3727 } | |
3728 | |
3729 | |
3730 uint16_t ExternalUint16Array::get_scalar(int index) { | |
3731 DCHECK((index >= 0) && (index < this->length())); | |
3732 uint16_t* ptr = static_cast<uint16_t*>(external_pointer()); | |
3733 return ptr[index]; | |
3734 } | |
3735 | |
3736 | |
3737 Handle<Object> ExternalUint16Array::get(Handle<ExternalUint16Array> array, | |
3738 int index) { | |
3739 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), | |
3740 array->GetIsolate()); | |
3741 } | |
3742 | |
3743 | |
3744 void ExternalUint16Array::set(int index, uint16_t value) { | |
3745 DCHECK((index >= 0) && (index < this->length())); | |
3746 uint16_t* ptr = static_cast<uint16_t*>(external_pointer()); | |
3747 ptr[index] = value; | |
3748 } | |
3749 | |
3750 | |
3751 int32_t ExternalInt32Array::get_scalar(int index) { | |
3752 DCHECK((index >= 0) && (index < this->length())); | |
3753 int32_t* ptr = static_cast<int32_t*>(external_pointer()); | |
3754 return ptr[index]; | |
3755 } | |
3756 | |
3757 | |
3758 Handle<Object> ExternalInt32Array::get(Handle<ExternalInt32Array> array, | |
3759 int index) { | |
3760 return array->GetIsolate()->factory()-> | |
3761 NewNumberFromInt(array->get_scalar(index)); | |
3762 } | |
3763 | |
3764 | |
3765 void ExternalInt32Array::set(int index, int32_t value) { | |
3766 DCHECK((index >= 0) && (index < this->length())); | |
3767 int32_t* ptr = static_cast<int32_t*>(external_pointer()); | |
3768 ptr[index] = value; | |
3769 } | |
3770 | |
3771 | |
3772 uint32_t ExternalUint32Array::get_scalar(int index) { | |
3773 DCHECK((index >= 0) && (index < this->length())); | |
3774 uint32_t* ptr = static_cast<uint32_t*>(external_pointer()); | |
3775 return ptr[index]; | |
3776 } | |
3777 | |
3778 | |
3779 Handle<Object> ExternalUint32Array::get(Handle<ExternalUint32Array> array, | |
3780 int index) { | |
3781 return array->GetIsolate()->factory()-> | |
3782 NewNumberFromUint(array->get_scalar(index)); | |
3783 } | |
3784 | |
3785 | |
3786 void ExternalUint32Array::set(int index, uint32_t value) { | |
3787 DCHECK((index >= 0) && (index < this->length())); | |
3788 uint32_t* ptr = static_cast<uint32_t*>(external_pointer()); | |
3789 ptr[index] = value; | |
3790 } | |
3791 | |
3792 | |
3793 float ExternalFloat32Array::get_scalar(int index) { | |
3794 DCHECK((index >= 0) && (index < this->length())); | |
3795 float* ptr = static_cast<float*>(external_pointer()); | |
3796 return ptr[index]; | |
3797 } | |
3798 | |
3799 | |
3800 Handle<Object> ExternalFloat32Array::get(Handle<ExternalFloat32Array> array, | |
3801 int index) { | |
3802 return array->GetIsolate()->factory()->NewNumber(array->get_scalar(index)); | |
3803 } | |
3804 | |
3805 | |
3806 void ExternalFloat32Array::set(int index, float value) { | |
3807 DCHECK((index >= 0) && (index < this->length())); | |
3808 float* ptr = static_cast<float*>(external_pointer()); | |
3809 ptr[index] = value; | |
3810 } | |
3811 | |
3812 | |
3813 double ExternalFloat64Array::get_scalar(int index) { | |
3814 DCHECK((index >= 0) && (index < this->length())); | |
3815 double* ptr = static_cast<double*>(external_pointer()); | |
3816 return ptr[index]; | |
3817 } | |
3818 | |
3819 | |
3820 Handle<Object> ExternalFloat64Array::get(Handle<ExternalFloat64Array> array, | |
3821 int index) { | |
3822 return array->GetIsolate()->factory()->NewNumber(array->get_scalar(index)); | |
3823 } | |
3824 | |
3825 | |
3826 void ExternalFloat64Array::set(int index, double value) { | |
3827 DCHECK((index >= 0) && (index < this->length())); | |
3828 double* ptr = static_cast<double*>(external_pointer()); | |
3829 ptr[index] = value; | |
3830 } | |
3831 | |
3832 | |
3833 ACCESSORS(FixedTypedArrayBase, base_pointer, Object, kBasePointerOffset) | 3602 ACCESSORS(FixedTypedArrayBase, base_pointer, Object, kBasePointerOffset) |
3834 | 3603 |
3835 | 3604 |
3836 void* FixedTypedArrayBase::external_pointer() const { | 3605 void* FixedTypedArrayBase::external_pointer() const { |
3837 intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset); | 3606 intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset); |
3838 return reinterpret_cast<void*>(ptr); | 3607 return reinterpret_cast<void*>(ptr); |
3839 } | 3608 } |
3840 | 3609 |
3841 | 3610 |
3842 void FixedTypedArrayBase::set_external_pointer(void* value, | 3611 void FixedTypedArrayBase::set_external_pointer(void* value, |
(...skipping 22 matching lines...) Expand all Loading... |
3865 #undef TYPED_ARRAY_CASE | 3634 #undef TYPED_ARRAY_CASE |
3866 default: | 3635 default: |
3867 UNREACHABLE(); | 3636 UNREACHABLE(); |
3868 return 0; | 3637 return 0; |
3869 } | 3638 } |
3870 return element_size; | 3639 return element_size; |
3871 } | 3640 } |
3872 | 3641 |
3873 | 3642 |
3874 int FixedTypedArrayBase::DataSize(InstanceType type) { | 3643 int FixedTypedArrayBase::DataSize(InstanceType type) { |
| 3644 if (base_pointer() == Smi::FromInt(0)) return 0; |
3875 return length() * ElementSize(type); | 3645 return length() * ElementSize(type); |
3876 } | 3646 } |
3877 | 3647 |
3878 | 3648 |
3879 int FixedTypedArrayBase::DataSize() { | 3649 int FixedTypedArrayBase::DataSize() { |
3880 return DataSize(map()->instance_type()); | 3650 return DataSize(map()->instance_type()); |
3881 } | 3651 } |
3882 | 3652 |
3883 | 3653 |
3884 int FixedTypedArrayBase::size() { | 3654 int FixedTypedArrayBase::size() { |
(...skipping 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6273 bool JSObject::HasSlowArgumentsElements() { | 6043 bool JSObject::HasSlowArgumentsElements() { |
6274 return GetElementsKind() == SLOW_SLOPPY_ARGUMENTS_ELEMENTS; | 6044 return GetElementsKind() == SLOW_SLOPPY_ARGUMENTS_ELEMENTS; |
6275 } | 6045 } |
6276 | 6046 |
6277 | 6047 |
6278 bool JSObject::HasSloppyArgumentsElements() { | 6048 bool JSObject::HasSloppyArgumentsElements() { |
6279 return IsSloppyArgumentsElements(GetElementsKind()); | 6049 return IsSloppyArgumentsElements(GetElementsKind()); |
6280 } | 6050 } |
6281 | 6051 |
6282 | 6052 |
6283 bool JSObject::HasExternalArrayElements() { | |
6284 HeapObject* array = elements(); | |
6285 DCHECK(array != NULL); | |
6286 return array->IsExternalArray(); | |
6287 } | |
6288 | |
6289 | |
6290 #define EXTERNAL_ELEMENTS_CHECK(Type, type, TYPE, ctype, size) \ | |
6291 bool JSObject::HasExternal##Type##Elements() { \ | |
6292 HeapObject* array = elements(); \ | |
6293 DCHECK(array != NULL); \ | |
6294 if (!array->IsHeapObject()) \ | |
6295 return false; \ | |
6296 return array->map()->instance_type() == EXTERNAL_##TYPE##_ARRAY_TYPE; \ | |
6297 } | |
6298 | |
6299 TYPED_ARRAYS(EXTERNAL_ELEMENTS_CHECK) | |
6300 | |
6301 #undef EXTERNAL_ELEMENTS_CHECK | |
6302 | |
6303 | |
6304 bool JSObject::HasFixedTypedArrayElements() { | 6053 bool JSObject::HasFixedTypedArrayElements() { |
6305 HeapObject* array = elements(); | 6054 HeapObject* array = elements(); |
6306 DCHECK(array != NULL); | 6055 DCHECK(array != NULL); |
6307 return array->IsFixedTypedArrayBase(); | 6056 return array->IsFixedTypedArrayBase(); |
6308 } | 6057 } |
6309 | 6058 |
6310 | 6059 |
6311 #define FIXED_TYPED_ELEMENTS_CHECK(Type, type, TYPE, ctype, size) \ | 6060 #define FIXED_TYPED_ELEMENTS_CHECK(Type, type, TYPE, ctype, size) \ |
6312 bool JSObject::HasFixed##Type##Elements() { \ | 6061 bool JSObject::HasFixed##Type##Elements() { \ |
6313 HeapObject* array = elements(); \ | 6062 HeapObject* array = elements(); \ |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6965 // If the new array won't fit in a some non-trivial fraction of the max old | 6714 // If the new array won't fit in a some non-trivial fraction of the max old |
6966 // space size, then force it to go dictionary mode. | 6715 // space size, then force it to go dictionary mode. |
6967 uint32_t max_fast_array_size = | 6716 uint32_t max_fast_array_size = |
6968 static_cast<uint32_t>((heap->MaxOldGenerationSize() / kDoubleSize) / 4); | 6717 static_cast<uint32_t>((heap->MaxOldGenerationSize() / kDoubleSize) / 4); |
6969 return new_length >= max_fast_array_size; | 6718 return new_length >= max_fast_array_size; |
6970 } | 6719 } |
6971 | 6720 |
6972 | 6721 |
6973 bool JSArray::AllowsSetLength() { | 6722 bool JSArray::AllowsSetLength() { |
6974 bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray(); | 6723 bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray(); |
6975 DCHECK(result == !HasExternalArrayElements()); | 6724 DCHECK(result == !HasFixedTypedArrayElements()); |
6976 return result; | 6725 return result; |
6977 } | 6726 } |
6978 | 6727 |
6979 | 6728 |
6980 void JSArray::SetContent(Handle<JSArray> array, | 6729 void JSArray::SetContent(Handle<JSArray> array, |
6981 Handle<FixedArrayBase> storage) { | 6730 Handle<FixedArrayBase> storage) { |
6982 EnsureCanContainElements(array, storage, storage->length(), | 6731 EnsureCanContainElements(array, storage, storage->length(), |
6983 ALLOW_COPIED_DOUBLE_ELEMENTS); | 6732 ALLOW_COPIED_DOUBLE_ELEMENTS); |
6984 | 6733 |
6985 DCHECK((storage->map() == array->GetHeap()->fixed_double_array_map() && | 6734 DCHECK((storage->map() == array->GetHeap()->fixed_double_array_map() && |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7313 #undef READ_SHORT_FIELD | 7062 #undef READ_SHORT_FIELD |
7314 #undef WRITE_SHORT_FIELD | 7063 #undef WRITE_SHORT_FIELD |
7315 #undef READ_BYTE_FIELD | 7064 #undef READ_BYTE_FIELD |
7316 #undef WRITE_BYTE_FIELD | 7065 #undef WRITE_BYTE_FIELD |
7317 #undef NOBARRIER_READ_BYTE_FIELD | 7066 #undef NOBARRIER_READ_BYTE_FIELD |
7318 #undef NOBARRIER_WRITE_BYTE_FIELD | 7067 #undef NOBARRIER_WRITE_BYTE_FIELD |
7319 | 7068 |
7320 } } // namespace v8::internal | 7069 } } // namespace v8::internal |
7321 | 7070 |
7322 #endif // V8_OBJECTS_INL_H_ | 7071 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |