| 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 7894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7905 void ExternalTwoByteString::ExternalTwoByteStringIterateBody() { | 7905 void ExternalTwoByteString::ExternalTwoByteStringIterateBody() { |
| 7906 typedef v8::String::ExternalStringResource Resource; | 7906 typedef v8::String::ExternalStringResource Resource; |
| 7907 StaticVisitor::VisitExternalTwoByteString( | 7907 StaticVisitor::VisitExternalTwoByteString( |
| 7908 reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset))); | 7908 reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset))); |
| 7909 } | 7909 } |
| 7910 | 7910 |
| 7911 | 7911 |
| 7912 void BodyDescriptorBase::IterateBodyImpl(HeapObject* obj, int start_offset, | 7912 void BodyDescriptorBase::IterateBodyImpl(HeapObject* obj, int start_offset, |
| 7913 int end_offset, ObjectVisitor* v) { | 7913 int end_offset, ObjectVisitor* v) { |
| 7914 if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) { | 7914 if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) { |
| 7915 v->VisitPointers(HeapObject::RawField(obj, start_offset), | 7915 IteratePointers(obj, start_offset, end_offset, v); |
| 7916 HeapObject::RawField(obj, end_offset)); | |
| 7917 } else { | 7916 } else { |
| 7918 DCHECK(FLAG_unbox_double_fields); | 7917 DCHECK(FLAG_unbox_double_fields); |
| 7919 DCHECK(IsAligned(start_offset, kPointerSize) && | 7918 DCHECK(IsAligned(start_offset, kPointerSize) && |
| 7920 IsAligned(end_offset, kPointerSize)); | 7919 IsAligned(end_offset, kPointerSize)); |
| 7921 | 7920 |
| 7922 LayoutDescriptorHelper helper(obj->map()); | 7921 LayoutDescriptorHelper helper(obj->map()); |
| 7923 DCHECK(!helper.all_fields_tagged()); | 7922 DCHECK(!helper.all_fields_tagged()); |
| 7924 for (int offset = start_offset; offset < end_offset;) { | 7923 for (int offset = start_offset; offset < end_offset;) { |
| 7925 int end_of_region_offset; | 7924 int end_of_region_offset; |
| 7926 if (helper.IsTagged(offset, end_offset, &end_of_region_offset)) { | 7925 if (helper.IsTagged(offset, end_offset, &end_of_region_offset)) { |
| 7927 v->VisitPointers(HeapObject::RawField(obj, offset), | 7926 IteratePointers(obj, offset, end_of_region_offset, v); |
| 7928 HeapObject::RawField(obj, end_of_region_offset)); | |
| 7929 } | 7927 } |
| 7930 offset = end_of_region_offset; | 7928 offset = end_of_region_offset; |
| 7931 } | 7929 } |
| 7932 } | 7930 } |
| 7933 } | 7931 } |
| 7934 | 7932 |
| 7935 | 7933 |
| 7936 template <typename StaticVisitor> | 7934 template <typename StaticVisitor> |
| 7937 void BodyDescriptorBase::IterateBodyImpl(HeapObject* obj, int start_offset, | 7935 void BodyDescriptorBase::IterateBodyImpl(Heap* heap, HeapObject* obj, |
| 7938 int end_offset) { | 7936 int start_offset, int end_offset) { |
| 7939 Heap* heap = obj->GetHeap(); | |
| 7940 if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) { | 7937 if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) { |
| 7941 StaticVisitor::VisitPointers(heap, obj, | 7938 IteratePointers<StaticVisitor>(heap, obj, start_offset, end_offset); |
| 7942 HeapObject::RawField(obj, start_offset), | |
| 7943 HeapObject::RawField(obj, end_offset)); | |
| 7944 } else { | 7939 } else { |
| 7945 DCHECK(FLAG_unbox_double_fields); | 7940 DCHECK(FLAG_unbox_double_fields); |
| 7946 DCHECK(IsAligned(start_offset, kPointerSize) && | 7941 DCHECK(IsAligned(start_offset, kPointerSize) && |
| 7947 IsAligned(end_offset, kPointerSize)); | 7942 IsAligned(end_offset, kPointerSize)); |
| 7948 | 7943 |
| 7949 LayoutDescriptorHelper helper(obj->map()); | 7944 LayoutDescriptorHelper helper(obj->map()); |
| 7950 DCHECK(!helper.all_fields_tagged()); | 7945 DCHECK(!helper.all_fields_tagged()); |
| 7951 for (int offset = start_offset; offset < end_offset;) { | 7946 for (int offset = start_offset; offset < end_offset;) { |
| 7952 int end_of_region_offset; | 7947 int end_of_region_offset; |
| 7953 if (helper.IsTagged(offset, end_offset, &end_of_region_offset)) { | 7948 if (helper.IsTagged(offset, end_offset, &end_of_region_offset)) { |
| 7954 StaticVisitor::VisitPointers( | 7949 IteratePointers<StaticVisitor>(heap, obj, offset, end_of_region_offset); |
| 7955 heap, obj, HeapObject::RawField(obj, offset), | |
| 7956 HeapObject::RawField(obj, end_of_region_offset)); | |
| 7957 } | 7950 } |
| 7958 offset = end_of_region_offset; | 7951 offset = end_of_region_offset; |
| 7959 } | 7952 } |
| 7960 } | 7953 } |
| 7961 } | 7954 } |
| 7962 | 7955 |
| 7963 | 7956 |
| 7957 void BodyDescriptorBase::IteratePointers(HeapObject* obj, int start_offset, |
| 7958 int end_offset, ObjectVisitor* v) { |
| 7959 v->VisitPointers(HeapObject::RawField(obj, start_offset), |
| 7960 HeapObject::RawField(obj, end_offset)); |
| 7961 } |
| 7962 |
| 7963 |
| 7964 template <typename StaticVisitor> |
| 7965 void BodyDescriptorBase::IteratePointers(Heap* heap, HeapObject* obj, |
| 7966 int start_offset, int end_offset) { |
| 7967 StaticVisitor::VisitPointers(heap, obj, |
| 7968 HeapObject::RawField(obj, start_offset), |
| 7969 HeapObject::RawField(obj, end_offset)); |
| 7970 } |
| 7971 |
| 7972 |
| 7973 // Iterates the function object according to the visiting policy. |
| 7974 template <JSFunction::BodyVisitingPolicy body_visiting_policy> |
| 7975 class JSFunction::BodyDescriptorImpl : public BodyDescriptorBase { |
| 7976 public: |
| 7977 STATIC_ASSERT(kNonWeakFieldsEndOffset == kCodeEntryOffset); |
| 7978 STATIC_ASSERT(kCodeEntryOffset + kPointerSize == kNextFunctionLinkOffset); |
| 7979 STATIC_ASSERT(kNextFunctionLinkOffset + kPointerSize == kSize); |
| 7980 |
| 7981 static inline void IterateBody(HeapObject* obj, int object_size, |
| 7982 ObjectVisitor* v) { |
| 7983 IteratePointers(obj, kPropertiesOffset, kNonWeakFieldsEndOffset, v); |
| 7984 |
| 7985 if (body_visiting_policy & kVisitCodeEntry) { |
| 7986 v->VisitCodeEntry(obj->address() + kCodeEntryOffset); |
| 7987 } |
| 7988 |
| 7989 if (body_visiting_policy & kVisitNextFunction) { |
| 7990 IteratePointers(obj, kNextFunctionLinkOffset, kSize, v); |
| 7991 } |
| 7992 |
| 7993 // TODO(ishell): v8:4531, fix when JFunctions are allowed to have in-object |
| 7994 // properties |
| 7995 // IterateBodyImpl(obj, kSize, object_size, v); |
| 7996 } |
| 7997 |
| 7998 template <typename StaticVisitor> |
| 7999 static inline void IterateBody(HeapObject* obj, int object_size) { |
| 8000 Heap* heap = obj->GetHeap(); |
| 8001 IteratePointers<StaticVisitor>(heap, obj, kPropertiesOffset, |
| 8002 kNonWeakFieldsEndOffset); |
| 8003 |
| 8004 if (body_visiting_policy & kVisitCodeEntry) { |
| 8005 StaticVisitor::VisitCodeEntry(heap, obj, |
| 8006 obj->address() + kCodeEntryOffset); |
| 8007 } |
| 8008 |
| 8009 if (body_visiting_policy & kVisitNextFunction) { |
| 8010 IteratePointers<StaticVisitor>(heap, obj, kNextFunctionLinkOffset, kSize); |
| 8011 } |
| 8012 |
| 8013 // TODO(ishell): v8:4531, fix when JFunctions are allowed to have in-object |
| 8014 // properties |
| 8015 // IterateBodyImpl<StaticVisitor>(heap, obj, kSize, object_size); |
| 8016 } |
| 8017 |
| 8018 static inline int SizeOf(Map* map, HeapObject* object) { |
| 8019 // TODO(ishell): v8:4531, fix when JFunctions are allowed to have in-object |
| 8020 // properties |
| 8021 return JSFunction::kSize; |
| 8022 } |
| 8023 }; |
| 8024 |
| 8025 |
| 7964 template<class Derived, class TableType> | 8026 template<class Derived, class TableType> |
| 7965 Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() { | 8027 Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() { |
| 7966 TableType* table(TableType::cast(this->table())); | 8028 TableType* table(TableType::cast(this->table())); |
| 7967 int index = Smi::cast(this->index())->value(); | 8029 int index = Smi::cast(this->index())->value(); |
| 7968 Object* key = table->KeyAt(index); | 8030 Object* key = table->KeyAt(index); |
| 7969 DCHECK(!key->IsTheHole()); | 8031 DCHECK(!key->IsTheHole()); |
| 7970 return key; | 8032 return key; |
| 7971 } | 8033 } |
| 7972 | 8034 |
| 7973 | 8035 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8087 #undef WRITE_INT64_FIELD | 8149 #undef WRITE_INT64_FIELD |
| 8088 #undef READ_BYTE_FIELD | 8150 #undef READ_BYTE_FIELD |
| 8089 #undef WRITE_BYTE_FIELD | 8151 #undef WRITE_BYTE_FIELD |
| 8090 #undef NOBARRIER_READ_BYTE_FIELD | 8152 #undef NOBARRIER_READ_BYTE_FIELD |
| 8091 #undef NOBARRIER_WRITE_BYTE_FIELD | 8153 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 8092 | 8154 |
| 8093 } // namespace internal | 8155 } // namespace internal |
| 8094 } // namespace v8 | 8156 } // namespace v8 |
| 8095 | 8157 |
| 8096 #endif // V8_OBJECTS_INL_H_ | 8158 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |