| 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 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2389 DCHECK(map() != GetHeap()->fixed_cow_array_map()); | 2392 DCHECK(map() != GetHeap()->fixed_cow_array_map()); |
| 2390 DCHECK(index >= 0 && index < this->length()); | 2393 DCHECK(index >= 0 && index < this->length()); |
| 2391 DCHECK(reinterpret_cast<Object*>(value)->IsSmi()); | 2394 DCHECK(reinterpret_cast<Object*>(value)->IsSmi()); |
| 2392 int offset = kHeaderSize + index * kPointerSize; | 2395 int offset = kHeaderSize + index * kPointerSize; |
| 2393 WRITE_FIELD(this, offset, value); | 2396 WRITE_FIELD(this, offset, value); |
| 2394 } | 2397 } |
| 2395 | 2398 |
| 2396 | 2399 |
| 2397 void FixedArray::set(int index, Object* value) { | 2400 void FixedArray::set(int index, Object* value) { |
| 2398 DCHECK_NE(GetHeap()->fixed_cow_array_map(), map()); | 2401 DCHECK_NE(GetHeap()->fixed_cow_array_map(), map()); |
| 2399 DCHECK_EQ(FIXED_ARRAY_TYPE, map()->instance_type()); | 2402 DCHECK(IsFixedArray()); |
| 2400 DCHECK(index >= 0 && index < this->length()); | 2403 DCHECK(index >= 0 && index < this->length()); |
| 2401 int offset = kHeaderSize + index * kPointerSize; | 2404 int offset = kHeaderSize + index * kPointerSize; |
| 2402 WRITE_FIELD(this, offset, value); | 2405 WRITE_FIELD(this, offset, value); |
| 2403 WRITE_BARRIER(GetHeap(), this, offset, value); | 2406 WRITE_BARRIER(GetHeap(), this, offset, value); |
| 2404 } | 2407 } |
| 2405 | 2408 |
| 2406 | 2409 |
| 2407 double FixedDoubleArray::get_scalar(int index) { | 2410 double FixedDoubleArray::get_scalar(int index) { |
| 2408 DCHECK(map() != GetHeap()->fixed_cow_array_map() && | 2411 DCHECK(map() != GetHeap()->fixed_cow_array_map() && |
| 2409 map() != GetHeap()->fixed_array_map()); | 2412 map() != GetHeap()->fixed_array_map()); |
| (...skipping 2029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4439 return CopyInstallDescriptors(map, new_descriptor, descriptors, | 4442 return CopyInstallDescriptors(map, new_descriptor, descriptors, |
| 4440 layout_descriptor); | 4443 layout_descriptor); |
| 4441 } | 4444 } |
| 4442 | 4445 |
| 4443 | 4446 |
| 4444 int HeapObject::SizeFromMap(Map* map) { | 4447 int HeapObject::SizeFromMap(Map* map) { |
| 4445 int instance_size = map->instance_size(); | 4448 int instance_size = map->instance_size(); |
| 4446 if (instance_size != kVariableSizeSentinel) return instance_size; | 4449 if (instance_size != kVariableSizeSentinel) return instance_size; |
| 4447 // Only inline the most frequent cases. | 4450 // Only inline the most frequent cases. |
| 4448 InstanceType instance_type = map->instance_type(); | 4451 InstanceType instance_type = map->instance_type(); |
| 4449 if (instance_type == FIXED_ARRAY_TYPE) { | 4452 if (instance_type == FIXED_ARRAY_TYPE || |
| 4453 instance_type == TRANSITION_ARRAY_TYPE) { |
| 4450 return FixedArray::SizeFor( | 4454 return FixedArray::SizeFor( |
| 4451 reinterpret_cast<FixedArray*>(this)->synchronized_length()); | 4455 reinterpret_cast<FixedArray*>(this)->synchronized_length()); |
| 4452 } | 4456 } |
| 4453 if (instance_type == ONE_BYTE_STRING_TYPE || | 4457 if (instance_type == ONE_BYTE_STRING_TYPE || |
| 4454 instance_type == ONE_BYTE_INTERNALIZED_STRING_TYPE) { | 4458 instance_type == ONE_BYTE_INTERNALIZED_STRING_TYPE) { |
| 4455 // Strings may get concurrently truncated, hence we have to access its | 4459 // Strings may get concurrently truncated, hence we have to access its |
| 4456 // length synchronized. | 4460 // length synchronized. |
| 4457 return SeqOneByteString::SizeFor( | 4461 return SeqOneByteString::SizeFor( |
| 4458 reinterpret_cast<SeqOneByteString*>(this)->synchronized_length()); | 4462 reinterpret_cast<SeqOneByteString*>(this)->synchronized_length()); |
| 4459 } | 4463 } |
| (...skipping 3396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7856 #undef WRITE_INT64_FIELD | 7860 #undef WRITE_INT64_FIELD |
| 7857 #undef READ_BYTE_FIELD | 7861 #undef READ_BYTE_FIELD |
| 7858 #undef WRITE_BYTE_FIELD | 7862 #undef WRITE_BYTE_FIELD |
| 7859 #undef NOBARRIER_READ_BYTE_FIELD | 7863 #undef NOBARRIER_READ_BYTE_FIELD |
| 7860 #undef NOBARRIER_WRITE_BYTE_FIELD | 7864 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 7861 | 7865 |
| 7862 } // namespace internal | 7866 } // namespace internal |
| 7863 } // namespace v8 | 7867 } // namespace v8 |
| 7864 | 7868 |
| 7865 #endif // V8_OBJECTS_INL_H_ | 7869 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |