Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: src/objects-inl.h

Issue 1257223002: Revert of Remove ExternalArray, derived types, and element kinds (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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();
145 } 146 }
146 147
147 148
148 // External objects are not extensible, so the map check is enough. 149 // External objects are not extensible, so the map check is enough.
149 bool Object::IsExternal() const { 150 bool Object::IsExternal() const {
150 return Object::IsHeapObject() && 151 return Object::IsHeapObject() &&
151 HeapObject::cast(this)->map() == 152 HeapObject::cast(this)->map() ==
152 HeapObject::cast(this)->GetHeap()->external_map(); 153 HeapObject::cast(this)->GetHeap()->external_map();
153 } 154 }
154 155
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 263
263 bool Object::IsExternalTwoByteString() const { 264 bool Object::IsExternalTwoByteString() const {
264 if (!IsString()) return false; 265 if (!IsString()) return false;
265 return StringShape(String::cast(this)).IsExternal() && 266 return StringShape(String::cast(this)).IsExternal() &&
266 String::cast(this)->IsTwoByteRepresentation(); 267 String::cast(this)->IsTwoByteRepresentation();
267 } 268 }
268 269
269 270
270 bool Object::HasValidElements() { 271 bool Object::HasValidElements() {
271 // Dictionary is covered under FixedArray. 272 // Dictionary is covered under FixedArray.
272 return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase(); 273 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray() ||
274 IsFixedTypedArrayBase();
273 } 275 }
274 276
275 277
276 bool Object::KeyEquals(Object* second) { 278 bool Object::KeyEquals(Object* second) {
277 Object* first = this; 279 Object* first = this;
278 if (second->IsNumber()) { 280 if (second->IsNumber()) {
279 if (first->IsNumber()) return first->Number() == second->Number(); 281 if (first->IsNumber()) return first->Number() == second->Number();
280 Object* temp = first; 282 Object* temp = first;
281 first = second; 283 first = second;
282 second = temp; 284 second = temp;
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE) 652 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE)
651 653
652 654
653 bool Object::IsFiller() const { 655 bool Object::IsFiller() const {
654 if (!Object::IsHeapObject()) return false; 656 if (!Object::IsHeapObject()) return false;
655 InstanceType instance_type = HeapObject::cast(this)->map()->instance_type(); 657 InstanceType instance_type = HeapObject::cast(this)->map()->instance_type();
656 return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE; 658 return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE;
657 } 659 }
658 660
659 661
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
660 671
661 #define TYPED_ARRAY_TYPE_CHECKER(Type, type, TYPE, ctype, size) \ 672 #define TYPED_ARRAY_TYPE_CHECKER(Type, type, TYPE, ctype, size) \
673 TYPE_CHECKER(External##Type##Array, EXTERNAL_##TYPE##_ARRAY_TYPE) \
662 TYPE_CHECKER(Fixed##Type##Array, FIXED_##TYPE##_ARRAY_TYPE) 674 TYPE_CHECKER(Fixed##Type##Array, FIXED_##TYPE##_ARRAY_TYPE)
663 675
664 TYPED_ARRAYS(TYPED_ARRAY_TYPE_CHECKER) 676 TYPED_ARRAYS(TYPED_ARRAY_TYPE_CHECKER)
665 #undef TYPED_ARRAY_TYPE_CHECKER 677 #undef TYPED_ARRAY_TYPE_CHECKER
666 678
667 679
668 bool Object::IsFixedTypedArrayBase() const { 680 bool Object::IsFixedTypedArrayBase() const {
669 if (!Object::IsHeapObject()) return false; 681 if (!Object::IsHeapObject()) return false;
670 682
671 InstanceType instance_type = 683 InstanceType instance_type =
(...skipping 1952 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 PropertyDetails Map::GetLastDescriptorDetails() { 2636 PropertyDetails Map::GetLastDescriptorDetails() {
2625 return instance_descriptors()->GetDetails(LastAdded()); 2637 return instance_descriptors()->GetDetails(LastAdded());
2626 } 2638 }
2627 2639
2628 2640
2629 FixedArrayBase* Map::GetInitialElements() { 2641 FixedArrayBase* Map::GetInitialElements() {
2630 if (has_fast_smi_or_object_elements() || 2642 if (has_fast_smi_or_object_elements() ||
2631 has_fast_double_elements()) { 2643 has_fast_double_elements()) {
2632 DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); 2644 DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array()));
2633 return GetHeap()->empty_fixed_array(); 2645 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;
2634 } else if (has_fixed_typed_array_elements()) { 2650 } else if (has_fixed_typed_array_elements()) {
2635 FixedTypedArrayBase* empty_array = 2651 FixedTypedArrayBase* empty_array =
2636 GetHeap()->EmptyFixedTypedArrayForMap(this); 2652 GetHeap()->EmptyFixedTypedArrayForMap(this);
2637 DCHECK(!GetHeap()->InNewSpace(empty_array)); 2653 DCHECK(!GetHeap()->InNewSpace(empty_array));
2638 return empty_array; 2654 return empty_array;
2639 } else { 2655 } else {
2640 UNREACHABLE(); 2656 UNREACHABLE();
2641 } 2657 }
2642 return NULL; 2658 return NULL;
2643 } 2659 }
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
2912 CAST_ACCESSOR(BytecodeArray) 2928 CAST_ACCESSOR(BytecodeArray)
2913 CAST_ACCESSOR(Cell) 2929 CAST_ACCESSOR(Cell)
2914 CAST_ACCESSOR(Code) 2930 CAST_ACCESSOR(Code)
2915 CAST_ACCESSOR(CodeCacheHashTable) 2931 CAST_ACCESSOR(CodeCacheHashTable)
2916 CAST_ACCESSOR(CompilationCacheTable) 2932 CAST_ACCESSOR(CompilationCacheTable)
2917 CAST_ACCESSOR(ConsString) 2933 CAST_ACCESSOR(ConsString)
2918 CAST_ACCESSOR(DeoptimizationInputData) 2934 CAST_ACCESSOR(DeoptimizationInputData)
2919 CAST_ACCESSOR(DeoptimizationOutputData) 2935 CAST_ACCESSOR(DeoptimizationOutputData)
2920 CAST_ACCESSOR(DependentCode) 2936 CAST_ACCESSOR(DependentCode)
2921 CAST_ACCESSOR(DescriptorArray) 2937 CAST_ACCESSOR(DescriptorArray)
2938 CAST_ACCESSOR(ExternalArray)
2922 CAST_ACCESSOR(ExternalOneByteString) 2939 CAST_ACCESSOR(ExternalOneByteString)
2940 CAST_ACCESSOR(ExternalFloat32Array)
2941 CAST_ACCESSOR(ExternalFloat64Array)
2942 CAST_ACCESSOR(ExternalInt16Array)
2943 CAST_ACCESSOR(ExternalInt32Array)
2944 CAST_ACCESSOR(ExternalInt8Array)
2923 CAST_ACCESSOR(ExternalString) 2945 CAST_ACCESSOR(ExternalString)
2924 CAST_ACCESSOR(ExternalTwoByteString) 2946 CAST_ACCESSOR(ExternalTwoByteString)
2947 CAST_ACCESSOR(ExternalUint16Array)
2948 CAST_ACCESSOR(ExternalUint32Array)
2949 CAST_ACCESSOR(ExternalUint8Array)
2950 CAST_ACCESSOR(ExternalUint8ClampedArray)
2925 CAST_ACCESSOR(FixedArray) 2951 CAST_ACCESSOR(FixedArray)
2926 CAST_ACCESSOR(FixedArrayBase) 2952 CAST_ACCESSOR(FixedArrayBase)
2927 CAST_ACCESSOR(FixedDoubleArray) 2953 CAST_ACCESSOR(FixedDoubleArray)
2928 CAST_ACCESSOR(FixedTypedArrayBase) 2954 CAST_ACCESSOR(FixedTypedArrayBase)
2929 CAST_ACCESSOR(Float32x4) 2955 CAST_ACCESSOR(Float32x4)
2930 CAST_ACCESSOR(Foreign) 2956 CAST_ACCESSOR(Foreign)
2931 CAST_ACCESSOR(GlobalDictionary) 2957 CAST_ACCESSOR(GlobalDictionary)
2932 CAST_ACCESSOR(GlobalObject) 2958 CAST_ACCESSOR(GlobalObject)
2933 CAST_ACCESSOR(HandlerTable) 2959 CAST_ACCESSOR(HandlerTable)
2934 CAST_ACCESSOR(HeapObject) 2960 CAST_ACCESSOR(HeapObject)
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
3624 int BytecodeArray::frame_size() const { 3650 int BytecodeArray::frame_size() const {
3625 return READ_INT_FIELD(this, kFrameSizeOffset); 3651 return READ_INT_FIELD(this, kFrameSizeOffset);
3626 } 3652 }
3627 3653
3628 3654
3629 Address BytecodeArray::GetFirstBytecodeAddress() { 3655 Address BytecodeArray::GetFirstBytecodeAddress() {
3630 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize; 3656 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize;
3631 } 3657 }
3632 3658
3633 3659
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
3634 ACCESSORS(FixedTypedArrayBase, base_pointer, Object, kBasePointerOffset) 3865 ACCESSORS(FixedTypedArrayBase, base_pointer, Object, kBasePointerOffset)
3635 3866
3636 3867
3637 void* FixedTypedArrayBase::external_pointer() const { 3868 void* FixedTypedArrayBase::external_pointer() const {
3638 intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset); 3869 intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset);
3639 return reinterpret_cast<void*>(ptr); 3870 return reinterpret_cast<void*>(ptr);
3640 } 3871 }
3641 3872
3642 3873
3643 void FixedTypedArrayBase::set_external_pointer(void* value, 3874 void FixedTypedArrayBase::set_external_pointer(void* value,
(...skipping 22 matching lines...) Expand all
3666 #undef TYPED_ARRAY_CASE 3897 #undef TYPED_ARRAY_CASE
3667 default: 3898 default:
3668 UNREACHABLE(); 3899 UNREACHABLE();
3669 return 0; 3900 return 0;
3670 } 3901 }
3671 return element_size; 3902 return element_size;
3672 } 3903 }
3673 3904
3674 3905
3675 int FixedTypedArrayBase::DataSize(InstanceType type) { 3906 int FixedTypedArrayBase::DataSize(InstanceType type) {
3676 if (base_pointer() == Smi::FromInt(0)) return 0;
3677 return length() * ElementSize(type); 3907 return length() * ElementSize(type);
3678 } 3908 }
3679 3909
3680 3910
3681 int FixedTypedArrayBase::DataSize() { 3911 int FixedTypedArrayBase::DataSize() {
3682 return DataSize(map()->instance_type()); 3912 return DataSize(map()->instance_type());
3683 } 3913 }
3684 3914
3685 3915
3686 int FixedTypedArrayBase::size() { 3916 int FixedTypedArrayBase::size() {
(...skipping 2387 matching lines...) Expand 10 before | Expand all | Expand 10 after
6074 bool JSObject::HasSlowArgumentsElements() { 6304 bool JSObject::HasSlowArgumentsElements() {
6075 return GetElementsKind() == SLOW_SLOPPY_ARGUMENTS_ELEMENTS; 6305 return GetElementsKind() == SLOW_SLOPPY_ARGUMENTS_ELEMENTS;
6076 } 6306 }
6077 6307
6078 6308
6079 bool JSObject::HasSloppyArgumentsElements() { 6309 bool JSObject::HasSloppyArgumentsElements() {
6080 return IsSloppyArgumentsElements(GetElementsKind()); 6310 return IsSloppyArgumentsElements(GetElementsKind());
6081 } 6311 }
6082 6312
6083 6313
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
6084 bool JSObject::HasFixedTypedArrayElements() { 6335 bool JSObject::HasFixedTypedArrayElements() {
6085 HeapObject* array = elements(); 6336 HeapObject* array = elements();
6086 DCHECK(array != NULL); 6337 DCHECK(array != NULL);
6087 return array->IsFixedTypedArrayBase(); 6338 return array->IsFixedTypedArrayBase();
6088 } 6339 }
6089 6340
6090 6341
6091 #define FIXED_TYPED_ELEMENTS_CHECK(Type, type, TYPE, ctype, size) \ 6342 #define FIXED_TYPED_ELEMENTS_CHECK(Type, type, TYPE, ctype, size) \
6092 bool JSObject::HasFixed##Type##Elements() { \ 6343 bool JSObject::HasFixed##Type##Elements() { \
6093 HeapObject* array = elements(); \ 6344 HeapObject* array = elements(); \
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
6745 // If the new array won't fit in a some non-trivial fraction of the max old 6996 // If the new array won't fit in a some non-trivial fraction of the max old
6746 // space size, then force it to go dictionary mode. 6997 // space size, then force it to go dictionary mode.
6747 uint32_t max_fast_array_size = 6998 uint32_t max_fast_array_size =
6748 static_cast<uint32_t>((heap->MaxOldGenerationSize() / kDoubleSize) / 4); 6999 static_cast<uint32_t>((heap->MaxOldGenerationSize() / kDoubleSize) / 4);
6749 return new_length >= max_fast_array_size; 7000 return new_length >= max_fast_array_size;
6750 } 7001 }
6751 7002
6752 7003
6753 bool JSArray::AllowsSetLength() { 7004 bool JSArray::AllowsSetLength() {
6754 bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray(); 7005 bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray();
6755 DCHECK(result == !HasFixedTypedArrayElements()); 7006 DCHECK(result == !HasExternalArrayElements());
6756 return result; 7007 return result;
6757 } 7008 }
6758 7009
6759 7010
6760 void JSArray::SetContent(Handle<JSArray> array, 7011 void JSArray::SetContent(Handle<JSArray> array,
6761 Handle<FixedArrayBase> storage) { 7012 Handle<FixedArrayBase> storage) {
6762 EnsureCanContainElements(array, storage, storage->length(), 7013 EnsureCanContainElements(array, storage, storage->length(),
6763 ALLOW_COPIED_DOUBLE_ELEMENTS); 7014 ALLOW_COPIED_DOUBLE_ELEMENTS);
6764 7015
6765 DCHECK((storage->map() == array->GetHeap()->fixed_double_array_map() && 7016 DCHECK((storage->map() == array->GetHeap()->fixed_double_array_map() &&
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
7093 #undef READ_SHORT_FIELD 7344 #undef READ_SHORT_FIELD
7094 #undef WRITE_SHORT_FIELD 7345 #undef WRITE_SHORT_FIELD
7095 #undef READ_BYTE_FIELD 7346 #undef READ_BYTE_FIELD
7096 #undef WRITE_BYTE_FIELD 7347 #undef WRITE_BYTE_FIELD
7097 #undef NOBARRIER_READ_BYTE_FIELD 7348 #undef NOBARRIER_READ_BYTE_FIELD
7098 #undef NOBARRIER_WRITE_BYTE_FIELD 7349 #undef NOBARRIER_WRITE_BYTE_FIELD
7099 7350
7100 } } // namespace v8::internal 7351 } } // namespace v8::internal
7101 7352
7102 #endif // V8_OBJECTS_INL_H_ 7353 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698