1 // Copyright 2020 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "src/heap/cppgc/heap-object-header.h" 6 7 #include "include/cppgc/internal/api-constants.h" 8 #include "src/base/macros.h" 9 #include "src/heap/cppgc/gc-info-table.h" 10 11 namespace cppgc { 12 namespace internal { 13 14 STATIC_ASSERT((kAllocationGranularity % sizeof(HeapObjectHeader)) == 0); 15 CheckApiConstants()16void HeapObjectHeader::CheckApiConstants() { 17 STATIC_ASSERT(api_constants::kFullyConstructedBitMask == 18 FullyConstructedField::kMask); 19 STATIC_ASSERT(api_constants::kFullyConstructedBitFieldOffsetFromPayload == 20 (sizeof(encoded_high_) + sizeof(encoded_low_))); 21 } 22 Finalize()23void HeapObjectHeader::Finalize() { 24 const GCInfo& gc_info = GlobalGCInfoTable::GCInfoFromIndex(GetGCInfoIndex()); 25 if (gc_info.finalize) { 26 gc_info.finalize(Payload()); 27 } 28 } 29 GetName() const30HeapObjectName HeapObjectHeader::GetName() const { 31 const GCInfo& gc_info = GlobalGCInfoTable::GCInfoFromIndex(GetGCInfoIndex()); 32 return gc_info.name(Payload()); 33 } 34 Trace(Visitor * visitor) const35void HeapObjectHeader::Trace(Visitor* visitor) const { 36 const GCInfo& gc_info = GlobalGCInfoTable::GCInfoFromIndex(GetGCInfoIndex()); 37 return gc_info.trace(visitor, Payload()); 38 } 39 40 } // namespace internal 41 } // namespace cppgc 42