cppgc: Add HoH::Trace utility method

Bug: chromium:1056170
Change-Id: I65a2b38c85a93ac2822cb7d2b7ac4bd66540348a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2468996
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70498}
This commit is contained in:
Michael Lippautz 2020-10-13 21:29:43 +02:00 committed by Commit Bot
parent 2e7a9b0449
commit 0b48da8be8
4 changed files with 14 additions and 2 deletions

View File

@ -23,6 +23,9 @@ class V8_EXPORT_PRIVATE CppHeap final : public cppgc::internal::HeapBase,
const std::vector<std::unique_ptr<cppgc::CustomSpaceBase>>&
custom_spaces);
CppHeap(const CppHeap&) = delete;
CppHeap& operator=(const CppHeap&) = delete;
HeapBase& AsBase() { return *this; }
const HeapBase& AsBase() const { return *this; }

View File

@ -32,5 +32,10 @@ HeapObjectName HeapObjectHeader::GetName() const {
return gc_info.name(Payload());
}
void HeapObjectHeader::Trace(Visitor* visitor) const {
const GCInfo& gc_info = GlobalGCInfoTable::GCInfoFromIndex(GetGCInfoIndex());
return gc_info.trace(visitor, Payload());
}
} // namespace internal
} // namespace cppgc

View File

@ -20,6 +20,9 @@
#include "src/heap/cppgc/globals.h"
namespace cppgc {
class Visitor;
namespace internal {
// HeapObjectHeader contains meta data per object and is prepended to each
@ -96,6 +99,8 @@ class HeapObjectHeader {
V8_EXPORT_PRIVATE HeapObjectName GetName() const;
V8_EXPORT_PRIVATE void Trace(Visitor*) const;
private:
enum class EncodedHalf : uint8_t { kLow, kHigh };

View File

@ -70,8 +70,7 @@ bool MarkingVerifier::VisitHeapObjectHeader(HeapObjectHeader* header) {
parent_ = header;
if (!header->IsInConstruction()) {
GlobalGCInfoTable::GCInfoFromIndex(header->GetGCInfoIndex())
.trace(this, header->Payload());
header->Trace(this);
} else {
// Dispatches to conservative tracing implementation.
TraceConservativelyIfNeeded(*header);