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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 void holder::set_##name(bool value) { \ | 127 void holder::set_##name(bool value) { \ |
128 set_##field(BooleanBit::set(field(), offset, value)); \ | 128 set_##field(BooleanBit::set(field(), offset, value)); \ |
129 } | 129 } |
130 | 130 |
131 | 131 |
132 bool Object::IsFixedArrayBase() const { | 132 bool Object::IsFixedArrayBase() const { |
133 return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase(); | 133 return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase(); |
134 } | 134 } |
135 | 135 |
136 | 136 |
| 137 bool Object::IsFixedArray() const { |
| 138 if (!IsHeapObject()) return false; |
| 139 InstanceType instance_type = HeapObject::cast(this)->map()->instance_type(); |
| 140 return instance_type == FIXED_ARRAY_TYPE || |
| 141 instance_type == TRANSITION_ARRAY_TYPE; |
| 142 } |
| 143 |
| 144 |
137 // External objects are not extensible, so the map check is enough. | 145 // External objects are not extensible, so the map check is enough. |
138 bool Object::IsExternal() const { | 146 bool Object::IsExternal() const { |
139 return Object::IsHeapObject() && | 147 return Object::IsHeapObject() && |
140 HeapObject::cast(this)->map() == | 148 HeapObject::cast(this)->map() == |
141 HeapObject::cast(this)->GetHeap()->external_map(); | 149 HeapObject::cast(this)->GetHeap()->external_map(); |
142 } | 150 } |
143 | 151 |
144 | 152 |
145 bool Object::IsAccessorInfo() const { return IsExecutableAccessorInfo(); } | 153 bool Object::IsAccessorInfo() const { return IsExecutableAccessorInfo(); } |
146 | 154 |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 TYPE_CHECKER(JSFunctionProxy, JS_FUNCTION_PROXY_TYPE) | 718 TYPE_CHECKER(JSFunctionProxy, JS_FUNCTION_PROXY_TYPE) |
711 TYPE_CHECKER(JSSet, JS_SET_TYPE) | 719 TYPE_CHECKER(JSSet, JS_SET_TYPE) |
712 TYPE_CHECKER(JSMap, JS_MAP_TYPE) | 720 TYPE_CHECKER(JSMap, JS_MAP_TYPE) |
713 TYPE_CHECKER(JSSetIterator, JS_SET_ITERATOR_TYPE) | 721 TYPE_CHECKER(JSSetIterator, JS_SET_ITERATOR_TYPE) |
714 TYPE_CHECKER(JSMapIterator, JS_MAP_ITERATOR_TYPE) | 722 TYPE_CHECKER(JSMapIterator, JS_MAP_ITERATOR_TYPE) |
715 TYPE_CHECKER(JSIteratorResult, JS_ITERATOR_RESULT_TYPE) | 723 TYPE_CHECKER(JSIteratorResult, JS_ITERATOR_RESULT_TYPE) |
716 TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE) | 724 TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE) |
717 TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE) | 725 TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE) |
718 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE) | 726 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE) |
719 TYPE_CHECKER(Map, MAP_TYPE) | 727 TYPE_CHECKER(Map, MAP_TYPE) |
720 TYPE_CHECKER(FixedArray, FIXED_ARRAY_TYPE) | |
721 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE) | 728 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE) |
722 TYPE_CHECKER(WeakFixedArray, FIXED_ARRAY_TYPE) | 729 TYPE_CHECKER(WeakFixedArray, FIXED_ARRAY_TYPE) |
| 730 TYPE_CHECKER(TransitionArray, TRANSITION_ARRAY_TYPE) |
723 | 731 |
724 | 732 |
725 bool Object::IsJSWeakCollection() const { | 733 bool Object::IsJSWeakCollection() const { |
726 return IsJSWeakMap() || IsJSWeakSet(); | 734 return IsJSWeakMap() || IsJSWeakSet(); |
727 } | 735 } |
728 | 736 |
729 | 737 |
730 bool Object::IsDescriptorArray() const { | 738 bool Object::IsDescriptorArray() const { |
731 return IsFixedArray(); | 739 return IsFixedArray(); |
732 } | 740 } |
733 | 741 |
734 | 742 |
735 bool Object::IsArrayList() const { return IsFixedArray(); } | 743 bool Object::IsArrayList() const { return IsFixedArray(); } |
736 | 744 |
737 | 745 |
738 bool Object::IsLayoutDescriptor() const { | 746 bool Object::IsLayoutDescriptor() const { |
739 return IsSmi() || IsFixedTypedArrayBase(); | 747 return IsSmi() || IsFixedTypedArrayBase(); |
740 } | 748 } |
741 | 749 |
742 | 750 |
743 bool Object::IsTransitionArray() const { | |
744 return IsFixedArray(); | |
745 } | |
746 | |
747 | |
748 bool Object::IsTypeFeedbackVector() const { return IsFixedArray(); } | 751 bool Object::IsTypeFeedbackVector() const { return IsFixedArray(); } |
749 | 752 |
750 | 753 |
751 bool Object::IsTypeFeedbackMetadata() const { return IsFixedArray(); } | 754 bool Object::IsTypeFeedbackMetadata() const { return IsFixedArray(); } |
752 | 755 |
753 | 756 |
754 bool Object::IsLiteralsArray() const { return IsFixedArray(); } | 757 bool Object::IsLiteralsArray() const { return IsFixedArray(); } |
755 bool Object::IsBindingsArray() const { return IsFixedArray(); } | 758 bool Object::IsBindingsArray() const { return IsFixedArray(); } |
756 | 759 |
757 | 760 |
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2399 DCHECK(map() != GetHeap()->fixed_cow_array_map()); | 2402 DCHECK(map() != GetHeap()->fixed_cow_array_map()); |
2400 DCHECK(index >= 0 && index < this->length()); | 2403 DCHECK(index >= 0 && index < this->length()); |
2401 DCHECK(reinterpret_cast<Object*>(value)->IsSmi()); | 2404 DCHECK(reinterpret_cast<Object*>(value)->IsSmi()); |
2402 int offset = kHeaderSize + index * kPointerSize; | 2405 int offset = kHeaderSize + index * kPointerSize; |
2403 WRITE_FIELD(this, offset, value); | 2406 WRITE_FIELD(this, offset, value); |
2404 } | 2407 } |
2405 | 2408 |
2406 | 2409 |
2407 void FixedArray::set(int index, Object* value) { | 2410 void FixedArray::set(int index, Object* value) { |
2408 DCHECK_NE(GetHeap()->fixed_cow_array_map(), map()); | 2411 DCHECK_NE(GetHeap()->fixed_cow_array_map(), map()); |
2409 DCHECK_EQ(FIXED_ARRAY_TYPE, map()->instance_type()); | 2412 DCHECK(IsFixedArray()); |
2410 DCHECK(index >= 0 && index < this->length()); | 2413 DCHECK(index >= 0 && index < this->length()); |
2411 int offset = kHeaderSize + index * kPointerSize; | 2414 int offset = kHeaderSize + index * kPointerSize; |
2412 WRITE_FIELD(this, offset, value); | 2415 WRITE_FIELD(this, offset, value); |
2413 WRITE_BARRIER(GetHeap(), this, offset, value); | 2416 WRITE_BARRIER(GetHeap(), this, offset, value); |
2414 } | 2417 } |
2415 | 2418 |
2416 | 2419 |
2417 double FixedDoubleArray::get_scalar(int index) { | 2420 double FixedDoubleArray::get_scalar(int index) { |
2418 DCHECK(map() != GetHeap()->fixed_cow_array_map() && | 2421 DCHECK(map() != GetHeap()->fixed_cow_array_map() && |
2419 map() != GetHeap()->fixed_array_map()); | 2422 map() != GetHeap()->fixed_array_map()); |
(...skipping 2029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4449 return CopyInstallDescriptors(map, new_descriptor, descriptors, | 4452 return CopyInstallDescriptors(map, new_descriptor, descriptors, |
4450 layout_descriptor); | 4453 layout_descriptor); |
4451 } | 4454 } |
4452 | 4455 |
4453 | 4456 |
4454 int HeapObject::SizeFromMap(Map* map) { | 4457 int HeapObject::SizeFromMap(Map* map) { |
4455 int instance_size = map->instance_size(); | 4458 int instance_size = map->instance_size(); |
4456 if (instance_size != kVariableSizeSentinel) return instance_size; | 4459 if (instance_size != kVariableSizeSentinel) return instance_size; |
4457 // Only inline the most frequent cases. | 4460 // Only inline the most frequent cases. |
4458 InstanceType instance_type = map->instance_type(); | 4461 InstanceType instance_type = map->instance_type(); |
4459 if (instance_type == FIXED_ARRAY_TYPE) { | 4462 if (instance_type == FIXED_ARRAY_TYPE || |
| 4463 instance_type == TRANSITION_ARRAY_TYPE) { |
4460 return FixedArray::SizeFor( | 4464 return FixedArray::SizeFor( |
4461 reinterpret_cast<FixedArray*>(this)->synchronized_length()); | 4465 reinterpret_cast<FixedArray*>(this)->synchronized_length()); |
4462 } | 4466 } |
4463 if (instance_type == ONE_BYTE_STRING_TYPE || | 4467 if (instance_type == ONE_BYTE_STRING_TYPE || |
4464 instance_type == ONE_BYTE_INTERNALIZED_STRING_TYPE) { | 4468 instance_type == ONE_BYTE_INTERNALIZED_STRING_TYPE) { |
4465 // Strings may get concurrently truncated, hence we have to access its | 4469 // Strings may get concurrently truncated, hence we have to access its |
4466 // length synchronized. | 4470 // length synchronized. |
4467 return SeqOneByteString::SizeFor( | 4471 return SeqOneByteString::SizeFor( |
4468 reinterpret_cast<SeqOneByteString*>(this)->synchronized_length()); | 4472 reinterpret_cast<SeqOneByteString*>(this)->synchronized_length()); |
4469 } | 4473 } |
(...skipping 3395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7865 #undef WRITE_INT64_FIELD | 7869 #undef WRITE_INT64_FIELD |
7866 #undef READ_BYTE_FIELD | 7870 #undef READ_BYTE_FIELD |
7867 #undef WRITE_BYTE_FIELD | 7871 #undef WRITE_BYTE_FIELD |
7868 #undef NOBARRIER_READ_BYTE_FIELD | 7872 #undef NOBARRIER_READ_BYTE_FIELD |
7869 #undef NOBARRIER_WRITE_BYTE_FIELD | 7873 #undef NOBARRIER_WRITE_BYTE_FIELD |
7870 | 7874 |
7871 } // namespace internal | 7875 } // namespace internal |
7872 } // namespace v8 | 7876 } // namespace v8 |
7873 | 7877 |
7874 #endif // V8_OBJECTS_INL_H_ | 7878 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |