diff options
Diffstat (limited to 'deps/v8/src/objects-body-descriptors-inl.h')
-rw-r--r-- | deps/v8/src/objects-body-descriptors-inl.h | 95 |
1 files changed, 85 insertions, 10 deletions
diff --git a/deps/v8/src/objects-body-descriptors-inl.h b/deps/v8/src/objects-body-descriptors-inl.h index 3f54f6f690..7d83d51a17 100644 --- a/deps/v8/src/objects-body-descriptors-inl.h +++ b/deps/v8/src/objects-body-descriptors-inl.h @@ -79,7 +79,7 @@ DISABLE_CFI_PERF void BodyDescriptorBase::IteratePointers(HeapObject* obj, int start_offset, int end_offset, ObjectVisitor* v) { - v->VisitPointers(HeapObject::RawField(obj, start_offset), + v->VisitPointers(obj, HeapObject::RawField(obj, start_offset), HeapObject::RawField(obj, end_offset)); } @@ -96,7 +96,7 @@ DISABLE_CFI_PERF void BodyDescriptorBase::IteratePointers(Heap* heap, template <typename ObjectVisitor> void BodyDescriptorBase::IteratePointer(HeapObject* obj, int offset, ObjectVisitor* v) { - v->VisitPointer(HeapObject::RawField(obj, offset)); + v->VisitPointer(obj, HeapObject::RawField(obj, offset)); } template <typename StaticVisitor> @@ -175,7 +175,8 @@ class JSFunction::BodyDescriptorImpl final : public BodyDescriptorBase { IteratePointers(obj, kPropertiesOffset, kNonWeakFieldsEndOffset, v); if (body_visiting_policy & kVisitCodeEntry) { - v->VisitCodeEntry(obj->address() + kCodeEntryOffset); + v->VisitCodeEntry(JSFunction::cast(obj), + obj->address() + kCodeEntryOffset); } if (body_visiting_policy & kVisitNextFunction) { @@ -209,11 +210,11 @@ class JSFunction::BodyDescriptorImpl final : public BodyDescriptorBase { class JSArrayBuffer::BodyDescriptor final : public BodyDescriptorBase { public: STATIC_ASSERT(kByteLengthOffset + kPointerSize == kBackingStoreOffset); - STATIC_ASSERT(kBackingStoreOffset + kPointerSize == kBitFieldSlot); + STATIC_ASSERT(kAllocationLengthOffset + kPointerSize == kBitFieldSlot); STATIC_ASSERT(kBitFieldSlot + kPointerSize == kSize); static bool IsValidSlot(HeapObject* obj, int offset) { - if (offset < kBackingStoreOffset) return true; + if (offset < kAllocationLengthOffset) return true; if (offset < kSize) return false; return IsValidSlotImpl(obj, offset); } @@ -221,6 +222,9 @@ class JSArrayBuffer::BodyDescriptor final : public BodyDescriptorBase { template <typename ObjectVisitor> static inline void IterateBody(HeapObject* obj, int object_size, ObjectVisitor* v) { + // Array buffers contain raw pointers that the GC does not know about. These + // are stored at kBackStoreOffset and later, so we do not iterate over + // those. IteratePointers(obj, kPropertiesOffset, kBackingStoreOffset, v); IterateBodyImpl(obj, kSize, object_size, v); } @@ -228,6 +232,9 @@ class JSArrayBuffer::BodyDescriptor final : public BodyDescriptorBase { template <typename StaticVisitor> static inline void IterateBody(HeapObject* obj, int object_size) { Heap* heap = obj->GetHeap(); + // Array buffers contain raw pointers that the GC does not know about. These + // are stored at kBackStoreOffset and later, so we do not iterate over + // those. IteratePointers<StaticVisitor>(heap, obj, kPropertiesOffset, kBackingStoreOffset); IterateBodyImpl<StaticVisitor>(heap, obj, kSize, object_size); @@ -238,6 +245,22 @@ class JSArrayBuffer::BodyDescriptor final : public BodyDescriptorBase { } }; +class ByteArray::BodyDescriptor final : public BodyDescriptorBase { + public: + static bool IsValidSlot(HeapObject* obj, int offset) { return false; } + + template <typename ObjectVisitor> + static inline void IterateBody(HeapObject* obj, int object_size, + ObjectVisitor* v) {} + + template <typename StaticVisitor> + static inline void IterateBody(HeapObject* obj, int object_size) {} + + static inline int SizeOf(Map* map, HeapObject* obj) { + return reinterpret_cast<ByteArray*>(obj)->ByteArraySize(); + } +}; + class BytecodeArray::BodyDescriptor final : public BodyDescriptorBase { public: static bool IsValidSlot(HeapObject* obj, int offset) { @@ -266,6 +289,23 @@ class BytecodeArray::BodyDescriptor final : public BodyDescriptorBase { } }; +class FixedDoubleArray::BodyDescriptor final : public BodyDescriptorBase { + public: + static bool IsValidSlot(HeapObject* obj, int offset) { return false; } + + template <typename ObjectVisitor> + static inline void IterateBody(HeapObject* obj, int object_size, + ObjectVisitor* v) {} + + template <typename StaticVisitor> + static inline void IterateBody(HeapObject* obj, int object_size) {} + + static inline int SizeOf(Map* map, HeapObject* obj) { + return FixedDoubleArray::SizeFor( + reinterpret_cast<FixedDoubleArray*>(obj)->length()); + } +}; + class FixedTypedArrayBase::BodyDescriptor final : public BodyDescriptorBase { public: static bool IsValidSlot(HeapObject* obj, int offset) { @@ -334,8 +374,9 @@ class Foreign::BodyDescriptor final : public BodyDescriptorBase { template <typename ObjectVisitor> static inline void IterateBody(HeapObject* obj, int object_size, ObjectVisitor* v) { - v->VisitExternalReference(reinterpret_cast<Address*>( - HeapObject::RawField(obj, kForeignAddressOffset))); + v->VisitExternalReference(Foreign::cast(obj), + reinterpret_cast<Address*>(HeapObject::RawField( + obj, kForeignAddressOffset))); } template <typename StaticVisitor> @@ -408,9 +449,10 @@ class Code::BodyDescriptor final : public BodyDescriptorBase { RelocInfo::kDebugBreakSlotMask; IteratePointers(obj, kRelocationInfoOffset, kNextCodeLinkOffset, v); - v->VisitNextCodeLink(HeapObject::RawField(obj, kNextCodeLinkOffset)); + v->VisitNextCodeLink(Code::cast(obj), + HeapObject::RawField(obj, kNextCodeLinkOffset)); - RelocIterator it(reinterpret_cast<Code*>(obj), mode_mask); + RelocIterator it(Code::cast(obj), mode_mask); Isolate* isolate = obj->GetIsolate(); for (; !it.done(); it.next()) { it.rinfo()->Visit(isolate, v); @@ -440,7 +482,7 @@ class Code::BodyDescriptor final : public BodyDescriptorBase { StaticVisitor::VisitNextCodeLink( heap, HeapObject::RawField(obj, kNextCodeLinkOffset)); - RelocIterator it(reinterpret_cast<Code*>(obj), mode_mask); + RelocIterator it(Code::cast(obj), mode_mask); for (; !it.done(); it.next()) { it.rinfo()->template Visit<StaticVisitor>(heap); } @@ -456,6 +498,39 @@ class Code::BodyDescriptor final : public BodyDescriptorBase { } }; +class SeqOneByteString::BodyDescriptor final : public BodyDescriptorBase { + public: + static bool IsValidSlot(HeapObject* obj, int offset) { return false; } + + template <typename ObjectVisitor> + static inline void IterateBody(HeapObject* obj, int object_size, + ObjectVisitor* v) {} + + template <typename StaticVisitor> + static inline void IterateBody(HeapObject* obj, int object_size) {} + + static inline int SizeOf(Map* map, HeapObject* obj) { + SeqOneByteString* string = SeqOneByteString::cast(obj); + return string->SizeFor(string->length()); + } +}; + +class SeqTwoByteString::BodyDescriptor final : public BodyDescriptorBase { + public: + static bool IsValidSlot(HeapObject* obj, int offset) { return false; } + + template <typename ObjectVisitor> + static inline void IterateBody(HeapObject* obj, int object_size, + ObjectVisitor* v) {} + + template <typename StaticVisitor> + static inline void IterateBody(HeapObject* obj, int object_size) {} + + static inline int SizeOf(Map* map, HeapObject* obj) { + SeqTwoByteString* string = SeqTwoByteString::cast(obj); + return string->SizeFor(string->length()); + } +}; template <typename Op, typename ReturnType, typename T1, typename T2, typename T3> |