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