| 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 7825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7836 } | 7836 } |
| 7837 | 7837 |
| 7838 | 7838 |
| 7839 Relocatable::~Relocatable() { | 7839 Relocatable::~Relocatable() { |
| 7840 DCHECK_EQ(isolate_->relocatable_top(), this); | 7840 DCHECK_EQ(isolate_->relocatable_top(), this); |
| 7841 isolate_->set_relocatable_top(prev_); | 7841 isolate_->set_relocatable_top(prev_); |
| 7842 } | 7842 } |
| 7843 | 7843 |
| 7844 | 7844 |
| 7845 // static | 7845 // static |
| 7846 int JSObject::BodyDescriptor::SizeOf(Map* map, HeapObject* object) { | 7846 template <int start_offset> |
| 7847 int FlexibleBodyDescriptor<start_offset>::SizeOf(Map* map, HeapObject* object) { |
| 7847 return map->instance_size(); | 7848 return map->instance_size(); |
| 7848 } | 7849 } |
| 7849 | 7850 |
| 7850 | 7851 |
| 7851 // static | 7852 // static |
| 7852 int FixedArray::BodyDescriptor::SizeOf(Map* map, HeapObject* object) { | 7853 int FixedArray::BodyDescriptor::SizeOf(Map* map, HeapObject* object) { |
| 7853 return SizeFor(reinterpret_cast<FixedArray*>(object)->synchronized_length()); | 7854 return SizeFor(reinterpret_cast<FixedArray*>(object)->synchronized_length()); |
| 7854 } | 7855 } |
| 7855 | 7856 |
| 7856 | 7857 |
| 7857 // static | |
| 7858 int StructBodyDescriptor::SizeOf(Map* map, HeapObject* object) { | |
| 7859 return map->instance_size(); | |
| 7860 } | |
| 7861 | |
| 7862 | |
| 7863 void Foreign::ForeignIterateBody(ObjectVisitor* v) { | 7858 void Foreign::ForeignIterateBody(ObjectVisitor* v) { |
| 7864 v->VisitExternalReference( | 7859 v->VisitExternalReference( |
| 7865 reinterpret_cast<Address*>(FIELD_ADDR(this, kForeignAddressOffset))); | 7860 reinterpret_cast<Address*>(FIELD_ADDR(this, kForeignAddressOffset))); |
| 7866 } | 7861 } |
| 7867 | 7862 |
| 7868 | 7863 |
| 7869 template<typename StaticVisitor> | 7864 template<typename StaticVisitor> |
| 7870 void Foreign::ForeignIterateBody() { | 7865 void Foreign::ForeignIterateBody() { |
| 7871 StaticVisitor::VisitExternalReference( | 7866 StaticVisitor::VisitExternalReference( |
| 7872 reinterpret_cast<Address*>(FIELD_ADDR(this, kForeignAddressOffset))); | 7867 reinterpret_cast<Address*>(FIELD_ADDR(this, kForeignAddressOffset))); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7909 | 7904 |
| 7910 | 7905 |
| 7911 template<typename StaticVisitor> | 7906 template<typename StaticVisitor> |
| 7912 void ExternalTwoByteString::ExternalTwoByteStringIterateBody() { | 7907 void ExternalTwoByteString::ExternalTwoByteStringIterateBody() { |
| 7913 typedef v8::String::ExternalStringResource Resource; | 7908 typedef v8::String::ExternalStringResource Resource; |
| 7914 StaticVisitor::VisitExternalTwoByteString( | 7909 StaticVisitor::VisitExternalTwoByteString( |
| 7915 reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset))); | 7910 reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset))); |
| 7916 } | 7911 } |
| 7917 | 7912 |
| 7918 | 7913 |
| 7919 static inline void IterateBodyUsingLayoutDescriptor(HeapObject* object, | 7914 void BodyDescriptorBase::IterateBodyImpl(HeapObject* obj, int start_offset, |
| 7920 int start_offset, | 7915 int end_offset, ObjectVisitor* v) { |
| 7921 int end_offset, | 7916 if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) { |
| 7922 ObjectVisitor* v) { | 7917 v->VisitPointers(HeapObject::RawField(obj, start_offset), |
| 7923 DCHECK(FLAG_unbox_double_fields); | 7918 HeapObject::RawField(obj, end_offset)); |
| 7924 DCHECK(IsAligned(start_offset, kPointerSize) && | 7919 } else { |
| 7925 IsAligned(end_offset, kPointerSize)); | 7920 DCHECK(FLAG_unbox_double_fields); |
| 7921 DCHECK(IsAligned(start_offset, kPointerSize) && |
| 7922 IsAligned(end_offset, kPointerSize)); |
| 7926 | 7923 |
| 7927 LayoutDescriptorHelper helper(object->map()); | 7924 LayoutDescriptorHelper helper(obj->map()); |
| 7928 DCHECK(!helper.all_fields_tagged()); | 7925 DCHECK(!helper.all_fields_tagged()); |
| 7929 | 7926 for (int offset = start_offset; offset < end_offset;) { |
| 7930 for (int offset = start_offset; offset < end_offset; offset += kPointerSize) { | 7927 int end_of_region_offset; |
| 7931 // Visit all tagged fields. | 7928 if (helper.IsTagged(offset, end_offset, &end_of_region_offset)) { |
| 7932 if (helper.IsTagged(offset)) { | 7929 v->VisitPointers(HeapObject::RawField(obj, offset), |
| 7933 v->VisitPointer(HeapObject::RawField(object, offset)); | 7930 HeapObject::RawField(obj, end_of_region_offset)); |
| 7931 } |
| 7932 offset = end_of_region_offset; |
| 7934 } | 7933 } |
| 7935 } | 7934 } |
| 7936 } | 7935 } |
| 7937 | 7936 |
| 7938 | 7937 |
| 7939 template<int start_offset, int end_offset, int size> | 7938 template <typename StaticVisitor> |
| 7940 void FixedBodyDescriptor<start_offset, end_offset, size>::IterateBody( | 7939 void BodyDescriptorBase::IterateBodyImpl(HeapObject* obj, int start_offset, |
| 7941 HeapObject* obj, | 7940 int end_offset) { |
| 7942 ObjectVisitor* v) { | 7941 Heap* heap = obj->GetHeap(); |
| 7943 if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) { | 7942 if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) { |
| 7944 v->VisitPointers(HeapObject::RawField(obj, start_offset), | 7943 StaticVisitor::VisitPointers(heap, obj, |
| 7945 HeapObject::RawField(obj, end_offset)); | 7944 HeapObject::RawField(obj, start_offset), |
| 7945 HeapObject::RawField(obj, end_offset)); |
| 7946 } else { | 7946 } else { |
| 7947 IterateBodyUsingLayoutDescriptor(obj, start_offset, end_offset, v); | 7947 DCHECK(FLAG_unbox_double_fields); |
| 7948 DCHECK(IsAligned(start_offset, kPointerSize) && |
| 7949 IsAligned(end_offset, kPointerSize)); |
| 7950 |
| 7951 LayoutDescriptorHelper helper(obj->map()); |
| 7952 DCHECK(!helper.all_fields_tagged()); |
| 7953 for (int offset = start_offset; offset < end_offset;) { |
| 7954 int end_of_region_offset; |
| 7955 if (helper.IsTagged(offset, end_offset, &end_of_region_offset)) { |
| 7956 StaticVisitor::VisitPointers( |
| 7957 heap, obj, HeapObject::RawField(obj, offset), |
| 7958 HeapObject::RawField(obj, end_of_region_offset)); |
| 7959 } |
| 7960 offset = end_of_region_offset; |
| 7961 } |
| 7948 } | 7962 } |
| 7949 } | 7963 } |
| 7950 | 7964 |
| 7951 | |
| 7952 template<int start_offset> | |
| 7953 void FlexibleBodyDescriptor<start_offset>::IterateBody(HeapObject* obj, | |
| 7954 int object_size, | |
| 7955 ObjectVisitor* v) { | |
| 7956 if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) { | |
| 7957 v->VisitPointers(HeapObject::RawField(obj, start_offset), | |
| 7958 HeapObject::RawField(obj, object_size)); | |
| 7959 } else { | |
| 7960 IterateBodyUsingLayoutDescriptor(obj, start_offset, object_size, v); | |
| 7961 } | |
| 7962 } | |
| 7963 | |
| 7964 | 7965 |
| 7965 template<class Derived, class TableType> | 7966 template<class Derived, class TableType> |
| 7966 Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() { | 7967 Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() { |
| 7967 TableType* table(TableType::cast(this->table())); | 7968 TableType* table(TableType::cast(this->table())); |
| 7968 int index = Smi::cast(this->index())->value(); | 7969 int index = Smi::cast(this->index())->value(); |
| 7969 Object* key = table->KeyAt(index); | 7970 Object* key = table->KeyAt(index); |
| 7970 DCHECK(!key->IsTheHole()); | 7971 DCHECK(!key->IsTheHole()); |
| 7971 return key; | 7972 return key; |
| 7972 } | 7973 } |
| 7973 | 7974 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8088 #undef WRITE_INT64_FIELD | 8089 #undef WRITE_INT64_FIELD |
| 8089 #undef READ_BYTE_FIELD | 8090 #undef READ_BYTE_FIELD |
| 8090 #undef WRITE_BYTE_FIELD | 8091 #undef WRITE_BYTE_FIELD |
| 8091 #undef NOBARRIER_READ_BYTE_FIELD | 8092 #undef NOBARRIER_READ_BYTE_FIELD |
| 8092 #undef NOBARRIER_WRITE_BYTE_FIELD | 8093 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 8093 | 8094 |
| 8094 } // namespace internal | 8095 } // namespace internal |
| 8095 } // namespace v8 | 8096 } // namespace v8 |
| 8096 | 8097 |
| 8097 #endif // V8_OBJECTS_INL_H_ | 8098 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |