| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 IsExternalArray() || IsTypeFeedbackVector(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 | 148 |
| 149 // External objects are not extensible, so the map check is enough. | 149 // External objects are not extensible, so the map check is enough. |
| 150 bool Object::IsExternal() const { | 150 bool Object::IsExternal() const { |
| 151 return Object::IsHeapObject() && | 151 return Object::IsHeapObject() && |
| 152 HeapObject::cast(this)->map() == | 152 HeapObject::cast(this)->map() == |
| 153 HeapObject::cast(this)->GetHeap()->external_map(); | 153 HeapObject::cast(this)->GetHeap()->external_map(); |
| 154 } | 154 } |
| 155 | 155 |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 TYPE_CHECKER(JSMap, JS_MAP_TYPE) | 711 TYPE_CHECKER(JSMap, JS_MAP_TYPE) |
| 712 TYPE_CHECKER(JSSetIterator, JS_SET_ITERATOR_TYPE) | 712 TYPE_CHECKER(JSSetIterator, JS_SET_ITERATOR_TYPE) |
| 713 TYPE_CHECKER(JSMapIterator, JS_MAP_ITERATOR_TYPE) | 713 TYPE_CHECKER(JSMapIterator, JS_MAP_ITERATOR_TYPE) |
| 714 TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE) | 714 TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE) |
| 715 TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE) | 715 TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE) |
| 716 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE) | 716 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE) |
| 717 TYPE_CHECKER(Map, MAP_TYPE) | 717 TYPE_CHECKER(Map, MAP_TYPE) |
| 718 TYPE_CHECKER(FixedArray, FIXED_ARRAY_TYPE) | 718 TYPE_CHECKER(FixedArray, FIXED_ARRAY_TYPE) |
| 719 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE) | 719 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE) |
| 720 TYPE_CHECKER(WeakFixedArray, FIXED_ARRAY_TYPE) | 720 TYPE_CHECKER(WeakFixedArray, FIXED_ARRAY_TYPE) |
| 721 TYPE_CHECKER(TypeFeedbackVector, FEEDBACK_VECTOR_TYPE) |
| 721 | 722 |
| 722 | 723 |
| 723 bool Object::IsJSWeakCollection() const { | 724 bool Object::IsJSWeakCollection() const { |
| 724 return IsJSWeakMap() || IsJSWeakSet(); | 725 return IsJSWeakMap() || IsJSWeakSet(); |
| 725 } | 726 } |
| 726 | 727 |
| 727 | 728 |
| 728 bool Object::IsDescriptorArray() const { | 729 bool Object::IsDescriptorArray() const { |
| 729 return IsFixedArray(); | 730 return IsFixedArray(); |
| 730 } | 731 } |
| 731 | 732 |
| 732 | 733 |
| 733 bool Object::IsArrayList() const { return IsFixedArray(); } | 734 bool Object::IsArrayList() const { return IsFixedArray(); } |
| 734 | 735 |
| 735 | 736 |
| 736 bool Object::IsLayoutDescriptor() const { | 737 bool Object::IsLayoutDescriptor() const { |
| 737 return IsSmi() || IsFixedTypedArrayBase(); | 738 return IsSmi() || IsFixedTypedArrayBase(); |
| 738 } | 739 } |
| 739 | 740 |
| 740 | 741 |
| 741 bool Object::IsTransitionArray() const { | 742 bool Object::IsTransitionArray() const { |
| 742 return IsFixedArray(); | 743 return IsFixedArray(); |
| 743 } | 744 } |
| 744 | 745 |
| 745 | 746 |
| 746 bool Object::IsTypeFeedbackVector() const { return IsFixedArray(); } | |
| 747 | |
| 748 | |
| 749 bool Object::IsDeoptimizationInputData() const { | 747 bool Object::IsDeoptimizationInputData() const { |
| 750 // Must be a fixed array. | 748 // Must be a fixed array. |
| 751 if (!IsFixedArray()) return false; | 749 if (!IsFixedArray()) return false; |
| 752 | 750 |
| 753 // There's no sure way to detect the difference between a fixed array and | 751 // There's no sure way to detect the difference between a fixed array and |
| 754 // a deoptimization data array. Since this is used for asserts we can | 752 // a deoptimization data array. Since this is used for asserts we can |
| 755 // check that the length is zero or else the fixed size plus a multiple of | 753 // check that the length is zero or else the fixed size plus a multiple of |
| 756 // the entry size. | 754 // the entry size. |
| 757 int length = FixedArray::cast(this)->length(); | 755 int length = FixedArray::cast(this)->length(); |
| 758 if (length == 0) return true; | 756 if (length == 0) return true; |
| (...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2262 DCHECK(map() != GetHeap()->fixed_cow_array_map()); | 2260 DCHECK(map() != GetHeap()->fixed_cow_array_map()); |
| 2263 DCHECK(index >= 0 && index < this->length()); | 2261 DCHECK(index >= 0 && index < this->length()); |
| 2264 DCHECK(reinterpret_cast<Object*>(value)->IsSmi()); | 2262 DCHECK(reinterpret_cast<Object*>(value)->IsSmi()); |
| 2265 int offset = kHeaderSize + index * kPointerSize; | 2263 int offset = kHeaderSize + index * kPointerSize; |
| 2266 WRITE_FIELD(this, offset, value); | 2264 WRITE_FIELD(this, offset, value); |
| 2267 } | 2265 } |
| 2268 | 2266 |
| 2269 | 2267 |
| 2270 void FixedArray::set(int index, Object* value) { | 2268 void FixedArray::set(int index, Object* value) { |
| 2271 DCHECK_NE(GetHeap()->fixed_cow_array_map(), map()); | 2269 DCHECK_NE(GetHeap()->fixed_cow_array_map(), map()); |
| 2272 DCHECK_EQ(FIXED_ARRAY_TYPE, map()->instance_type()); | 2270 DCHECK(map()->instance_type() == FIXED_ARRAY_TYPE || |
| 2271 map()->instance_type() == FEEDBACK_VECTOR_TYPE); |
| 2273 DCHECK(index >= 0 && index < this->length()); | 2272 DCHECK(index >= 0 && index < this->length()); |
| 2274 int offset = kHeaderSize + index * kPointerSize; | 2273 int offset = kHeaderSize + index * kPointerSize; |
| 2275 WRITE_FIELD(this, offset, value); | 2274 WRITE_FIELD(this, offset, value); |
| 2276 WRITE_BARRIER(GetHeap(), this, offset, value); | 2275 WRITE_BARRIER(GetHeap(), this, offset, value); |
| 2277 } | 2276 } |
| 2278 | 2277 |
| 2279 | 2278 |
| 2280 double FixedDoubleArray::get_scalar(int index) { | 2279 double FixedDoubleArray::get_scalar(int index) { |
| 2281 DCHECK(map() != GetHeap()->fixed_cow_array_map() && | 2280 DCHECK(map() != GetHeap()->fixed_cow_array_map() && |
| 2282 map() != GetHeap()->fixed_array_map()); | 2281 map() != GetHeap()->fixed_array_map()); |
| (...skipping 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4104 return CopyInstallDescriptors(map, new_descriptor, descriptors, | 4103 return CopyInstallDescriptors(map, new_descriptor, descriptors, |
| 4105 layout_descriptor); | 4104 layout_descriptor); |
| 4106 } | 4105 } |
| 4107 | 4106 |
| 4108 | 4107 |
| 4109 int HeapObject::SizeFromMap(Map* map) { | 4108 int HeapObject::SizeFromMap(Map* map) { |
| 4110 int instance_size = map->instance_size(); | 4109 int instance_size = map->instance_size(); |
| 4111 if (instance_size != kVariableSizeSentinel) return instance_size; | 4110 if (instance_size != kVariableSizeSentinel) return instance_size; |
| 4112 // Only inline the most frequent cases. | 4111 // Only inline the most frequent cases. |
| 4113 InstanceType instance_type = map->instance_type(); | 4112 InstanceType instance_type = map->instance_type(); |
| 4114 if (instance_type == FIXED_ARRAY_TYPE) { | 4113 if (instance_type == FIXED_ARRAY_TYPE || |
| 4114 instance_type == FEEDBACK_VECTOR_TYPE) { |
| 4115 return FixedArray::BodyDescriptor::SizeOf(map, this); | 4115 return FixedArray::BodyDescriptor::SizeOf(map, this); |
| 4116 } | 4116 } |
| 4117 if (instance_type == ONE_BYTE_STRING_TYPE || | 4117 if (instance_type == ONE_BYTE_STRING_TYPE || |
| 4118 instance_type == ONE_BYTE_INTERNALIZED_STRING_TYPE) { | 4118 instance_type == ONE_BYTE_INTERNALIZED_STRING_TYPE) { |
| 4119 // Strings may get concurrently truncated, hence we have to access its | 4119 // Strings may get concurrently truncated, hence we have to access its |
| 4120 // length synchronized. | 4120 // length synchronized. |
| 4121 return SeqOneByteString::SizeFor( | 4121 return SeqOneByteString::SizeFor( |
| 4122 reinterpret_cast<SeqOneByteString*>(this)->synchronized_length()); | 4122 reinterpret_cast<SeqOneByteString*>(this)->synchronized_length()); |
| 4123 } | 4123 } |
| 4124 if (instance_type == BYTE_ARRAY_TYPE) { | 4124 if (instance_type == BYTE_ARRAY_TYPE) { |
| (...skipping 3172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7297 #undef READ_SHORT_FIELD | 7297 #undef READ_SHORT_FIELD |
| 7298 #undef WRITE_SHORT_FIELD | 7298 #undef WRITE_SHORT_FIELD |
| 7299 #undef READ_BYTE_FIELD | 7299 #undef READ_BYTE_FIELD |
| 7300 #undef WRITE_BYTE_FIELD | 7300 #undef WRITE_BYTE_FIELD |
| 7301 #undef NOBARRIER_READ_BYTE_FIELD | 7301 #undef NOBARRIER_READ_BYTE_FIELD |
| 7302 #undef NOBARRIER_WRITE_BYTE_FIELD | 7302 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 7303 | 7303 |
| 7304 } } // namespace v8::internal | 7304 } } // namespace v8::internal |
| 7305 | 7305 |
| 7306 #endif // V8_OBJECTS_INL_H_ | 7306 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |