| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef V8_OBJECTS_BODY_DESCRIPTORS_INL_H_ | 5 #ifndef V8_OBJECTS_BODY_DESCRIPTORS_INL_H_ |
| 6 #define V8_OBJECTS_BODY_DESCRIPTORS_INL_H_ | 6 #define V8_OBJECTS_BODY_DESCRIPTORS_INL_H_ |
| 7 | 7 |
| 8 #include "src/objects-body-descriptors.h" | 8 #include "src/objects-body-descriptors.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // Iterates the function object according to the visiting policy. | 109 // Iterates the function object according to the visiting policy. |
| 110 template <JSFunction::BodyVisitingPolicy body_visiting_policy> | 110 template <JSFunction::BodyVisitingPolicy body_visiting_policy> |
| 111 class JSFunction::BodyDescriptorImpl final : public BodyDescriptorBase { | 111 class JSFunction::BodyDescriptorImpl final : public BodyDescriptorBase { |
| 112 public: | 112 public: |
| 113 STATIC_ASSERT(kNonWeakFieldsEndOffset == kCodeEntryOffset); | 113 STATIC_ASSERT(kNonWeakFieldsEndOffset == kCodeEntryOffset); |
| 114 STATIC_ASSERT(kCodeEntryOffset + kPointerSize == kNextFunctionLinkOffset); | 114 STATIC_ASSERT(kCodeEntryOffset + kPointerSize == kNextFunctionLinkOffset); |
| 115 STATIC_ASSERT(kNextFunctionLinkOffset + kPointerSize == kSize); | 115 STATIC_ASSERT(kNextFunctionLinkOffset + kPointerSize == kSize); |
| 116 | 116 |
| 117 static bool IsValidSlot(HeapObject* obj, int offset) { | 117 static bool IsValidSlot(HeapObject* obj, int offset) { |
| 118 if (offset < kSize) return true; | 118 if (offset < kSize) return true; |
| 119 // TODO(ishell): v8:4531, fix when JFunctions are allowed to have | 119 return IsValidSlotImpl(obj, offset); |
| 120 // in-object properties | |
| 121 // return IsValidSlotImpl(obj, offset); | |
| 122 return true; | |
| 123 } | 120 } |
| 124 | 121 |
| 125 template <typename ObjectVisitor> | 122 template <typename ObjectVisitor> |
| 126 static inline void IterateBody(HeapObject* obj, int object_size, | 123 static inline void IterateBody(HeapObject* obj, int object_size, |
| 127 ObjectVisitor* v) { | 124 ObjectVisitor* v) { |
| 128 IteratePointers(obj, kPropertiesOffset, kNonWeakFieldsEndOffset, v); | 125 IteratePointers(obj, kPropertiesOffset, kNonWeakFieldsEndOffset, v); |
| 129 | 126 |
| 130 if (body_visiting_policy & kVisitCodeEntry) { | 127 if (body_visiting_policy & kVisitCodeEntry) { |
| 131 v->VisitCodeEntry(obj->address() + kCodeEntryOffset); | 128 v->VisitCodeEntry(obj->address() + kCodeEntryOffset); |
| 132 } | 129 } |
| 133 | 130 |
| 134 if (body_visiting_policy & kVisitNextFunction) { | 131 if (body_visiting_policy & kVisitNextFunction) { |
| 135 IteratePointers(obj, kNextFunctionLinkOffset, kSize, v); | 132 IteratePointers(obj, kNextFunctionLinkOffset, kSize, v); |
| 136 } | 133 } |
| 137 | 134 IterateBodyImpl(obj, kSize, object_size, v); |
| 138 // TODO(ishell): v8:4531, fix when JFunctions are allowed to have in-object | |
| 139 // properties | |
| 140 // IterateBodyImpl(obj, kSize, object_size, v); | |
| 141 } | 135 } |
| 142 | 136 |
| 143 template <typename StaticVisitor> | 137 template <typename StaticVisitor> |
| 144 static inline void IterateBody(HeapObject* obj, int object_size) { | 138 static inline void IterateBody(HeapObject* obj, int object_size) { |
| 145 Heap* heap = obj->GetHeap(); | 139 Heap* heap = obj->GetHeap(); |
| 146 IteratePointers<StaticVisitor>(heap, obj, kPropertiesOffset, | 140 IteratePointers<StaticVisitor>(heap, obj, kPropertiesOffset, |
| 147 kNonWeakFieldsEndOffset); | 141 kNonWeakFieldsEndOffset); |
| 148 | 142 |
| 149 if (body_visiting_policy & kVisitCodeEntry) { | 143 if (body_visiting_policy & kVisitCodeEntry) { |
| 150 StaticVisitor::VisitCodeEntry(heap, obj, | 144 StaticVisitor::VisitCodeEntry(heap, obj, |
| 151 obj->address() + kCodeEntryOffset); | 145 obj->address() + kCodeEntryOffset); |
| 152 } | 146 } |
| 153 | 147 |
| 154 if (body_visiting_policy & kVisitNextFunction) { | 148 if (body_visiting_policy & kVisitNextFunction) { |
| 155 IteratePointers<StaticVisitor>(heap, obj, kNextFunctionLinkOffset, kSize); | 149 IteratePointers<StaticVisitor>(heap, obj, kNextFunctionLinkOffset, kSize); |
| 156 } | 150 } |
| 157 | 151 IterateBodyImpl<StaticVisitor>(heap, obj, kSize, object_size); |
| 158 // TODO(ishell): v8:4531, fix when JFunctions are allowed to have in-object | |
| 159 // properties | |
| 160 // IterateBodyImpl<StaticVisitor>(heap, obj, kSize, object_size); | |
| 161 } | 152 } |
| 162 | 153 |
| 163 static inline int SizeOf(Map* map, HeapObject* object) { | 154 static inline int SizeOf(Map* map, HeapObject* object) { |
| 164 // TODO(ishell): v8:4531, fix when JFunctions are allowed to have in-object | 155 return map->instance_size(); |
| 165 // properties | |
| 166 return JSFunction::kSize; | |
| 167 } | 156 } |
| 168 }; | 157 }; |
| 169 | 158 |
| 170 | 159 |
| 171 class JSArrayBuffer::BodyDescriptor final : public BodyDescriptorBase { | 160 class JSArrayBuffer::BodyDescriptor final : public BodyDescriptorBase { |
| 172 public: | 161 public: |
| 173 STATIC_ASSERT(kByteLengthOffset + kPointerSize == kBackingStoreOffset); | 162 STATIC_ASSERT(kByteLengthOffset + kPointerSize == kBackingStoreOffset); |
| 174 STATIC_ASSERT(kBackingStoreOffset + kPointerSize == kBitFieldSlot); | 163 STATIC_ASSERT(kBackingStoreOffset + kPointerSize == kBitFieldSlot); |
| 175 STATIC_ASSERT(kBitFieldSlot + kPointerSize == kSize); | 164 STATIC_ASSERT(kBitFieldSlot + kPointerSize == kSize); |
| 176 | 165 |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 PrintF("Unknown type: %d\n", type); | 537 PrintF("Unknown type: %d\n", type); |
| 549 UNREACHABLE(); | 538 UNREACHABLE(); |
| 550 return ReturnType(); | 539 return ReturnType(); |
| 551 } | 540 } |
| 552 } | 541 } |
| 553 | 542 |
| 554 | 543 |
| 555 template <typename ObjectVisitor> | 544 template <typename ObjectVisitor> |
| 556 void HeapObject::IterateFast(ObjectVisitor* v) { | 545 void HeapObject::IterateFast(ObjectVisitor* v) { |
| 557 BodyDescriptorBase::IteratePointer(this, kMapOffset, v); | 546 BodyDescriptorBase::IteratePointer(this, kMapOffset, v); |
| 558 IterateBody(v); | 547 IterateBodyFast(v); |
| 559 } | 548 } |
| 560 | 549 |
| 561 | 550 |
| 562 template <typename ObjectVisitor> | 551 template <typename ObjectVisitor> |
| 563 void HeapObject::IterateBodyFast(ObjectVisitor* v) { | 552 void HeapObject::IterateBodyFast(ObjectVisitor* v) { |
| 564 Map* m = map(); | 553 Map* m = map(); |
| 565 IterateBody(m->instance_type(), SizeFromMap(m), v); | 554 IterateBodyFast(m->instance_type(), SizeFromMap(m), v); |
| 566 } | 555 } |
| 567 | 556 |
| 568 | 557 |
| 569 struct CallIterateBody { | 558 struct CallIterateBody { |
| 570 template <typename BodyDescriptor, typename ObjectVisitor> | 559 template <typename BodyDescriptor, typename ObjectVisitor> |
| 571 static void apply(HeapObject* obj, int object_size, ObjectVisitor* v) { | 560 static void apply(HeapObject* obj, int object_size, ObjectVisitor* v) { |
| 572 BodyDescriptor::IterateBody(obj, object_size, v); | 561 BodyDescriptor::IterateBody(obj, object_size, v); |
| 573 } | 562 } |
| 574 }; | 563 }; |
| 575 | 564 |
| 576 template <typename ObjectVisitor> | 565 template <typename ObjectVisitor> |
| 577 void HeapObject::IterateBodyFast(InstanceType type, int object_size, | 566 void HeapObject::IterateBodyFast(InstanceType type, int object_size, |
| 578 ObjectVisitor* v) { | 567 ObjectVisitor* v) { |
| 579 BodyDescriptorApply<CallIterateBody, void>(type, this, object_size, v); | 568 BodyDescriptorApply<CallIterateBody, void>(type, this, object_size, v); |
| 580 } | 569 } |
| 581 } // namespace internal | 570 } // namespace internal |
| 582 } // namespace v8 | 571 } // namespace v8 |
| 583 | 572 |
| 584 #endif // V8_OBJECTS_BODY_DESCRIPTORS_INL_H_ | 573 #endif // V8_OBJECTS_BODY_DESCRIPTORS_INL_H_ |
| OLD | NEW |