v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
heap-object-header.cc
Go to the documentation of this file.
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/allocation.h
"
8
#include "
include/cppgc/internal/api-constants.h
"
9
#include "
src/base/macros.h
"
10
#include "
src/base/sanitizer/asan.h
"
11
#include "
src/heap/cppgc/gc-info-table.h
"
12
#include "
src/heap/cppgc/heap-base.h
"
13
#include "
src/heap/cppgc/heap-page.h
"
14
15
namespace
cppgc
{
16
namespace
internal
{
17
18
static_assert
((
kAllocationGranularity
%
sizeof
(HeapObjectHeader)) == 0);
19
20
void
HeapObjectHeader::CheckApiConstants
() {
21
static_assert
(
api_constants::kFullyConstructedBitMask
==
22
FullyConstructedField::kMask
);
23
static_assert
(
api_constants::kFullyConstructedBitFieldOffsetFromPayload
==
24
(
sizeof
(
encoded_high_
) +
sizeof
(
encoded_low_
)));
25
}
26
27
void
HeapObjectHeader::Finalize
() {
28
#ifdef V8_USE_ADDRESS_SANITIZER
29
const
size_t
size =
30
IsLargeObject
()
31
?
LargePage::From
(
BasePage::FromPayload
(
this
))->
ObjectSize
()
32
:
ObjectSize
();
33
ASAN_UNPOISON_MEMORY_REGION
(
ObjectStart
(), size);
34
#endif
// V8_USE_ADDRESS_SANITIZER
35
const
GCInfo
& gc_info =
GlobalGCInfoTable::GCInfoFromIndex
(
GetGCInfoIndex
());
36
if
(gc_info.
finalize
) {
37
gc_info.
finalize
(
ObjectStart
());
38
}
39
}
40
41
HeapObjectName
HeapObjectHeader::GetName
()
const
{
42
return
GetName
(
BasePage::FromPayload
(
this
)->
heap
().name_of_unnamed_object());
43
}
44
45
HeapObjectName
HeapObjectHeader::GetName
(
46
HeapObjectNameForUnnamedObject
heap_object_name)
const
{
47
const
GCInfo
& gc_info =
GlobalGCInfoTable::GCInfoFromIndex
(
GetGCInfoIndex
());
48
return
gc_info.
name
(
ObjectStart
(), heap_object_name);
49
}
50
51
void
HeapObjectHeader::MarkAsFullyConstructed
() {
52
MakeGarbageCollectedTraitInternal::MarkObjectAsFullyConstructed
(
53
ObjectStart
());
54
}
55
56
}
// namespace internal
57
}
// namespace cppgc
api-constants.h
asan.h
ASAN_UNPOISON_MEMORY_REGION
#define ASAN_UNPOISON_MEMORY_REGION(start, size)
Definition
asan.h:71
cppgc::internal::BasePage::FromPayload
static BasePage * FromPayload(void *)
Definition
heap-page.h:314
cppgc::internal::GlobalGCInfoTable::GCInfoFromIndex
static const GCInfo & GCInfoFromIndex(GCInfoIndex index)
Definition
gc-info-table.h:115
cppgc::internal::HeapObjectHeader::MarkAsFullyConstructed
V8_EXPORT_PRIVATE void MarkAsFullyConstructed()
Definition
heap-object-header.cc:51
cppgc::internal::HeapObjectHeader::ObjectStart
Address ObjectStart() const
Definition
heap-object-header.h:208
cppgc::internal::HeapObjectHeader::Finalize
void Finalize()
Definition
heap-object-header.cc:27
cppgc::internal::HeapObjectHeader::GetGCInfoIndex
GCInfoIndex GetGCInfoIndex() const
Definition
heap-object-header.h:221
cppgc::internal::HeapObjectHeader::CheckApiConstants
V8_EXPORT_PRIVATE void CheckApiConstants()
Definition
heap-object-header.cc:20
cppgc::internal::HeapObjectHeader::encoded_high_
uint16_t encoded_high_
Definition
heap-object-header.h:165
cppgc::internal::HeapObjectHeader::encoded_low_
uint16_t encoded_low_
Definition
heap-object-header.h:166
cppgc::internal::HeapObjectHeader::GetName
V8_EXPORT_PRIVATE HeapObjectName GetName() const
Definition
heap-object-header.cc:41
cppgc::internal::HeapObjectHeader::IsLargeObject
bool IsLargeObject() const
Definition
heap-object-header.h:258
cppgc::internal::HeapObjectHeader::ObjectSize
size_t ObjectSize() const
Definition
heap-object-header.h:251
cppgc::internal::LargePage::From
static LargePage * From(BasePage *page)
Definition
heap-page.h:275
cppgc::internal::LargePage::ObjectSize
size_t ObjectSize() const
Definition
heap-page.h:292
cppgc::internal::MakeGarbageCollectedTraitInternal::MarkObjectAsFullyConstructed
static void MarkObjectAsFullyConstructed(const void *payload)
Definition
allocation.h:51
v8::base::BitField::kMask
static constexpr U kMask
Definition
bit-field.h:41
gc-info-table.h
heap-base.h
heap-object-header.h
heap-page.h
allocation.h
cppgc::internal::api_constants::kFullyConstructedBitFieldOffsetFromPayload
static constexpr size_t kFullyConstructedBitFieldOffsetFromPayload
Definition
api-constants.h:28
cppgc::internal::api_constants::kFullyConstructedBitMask
static constexpr uint16_t kFullyConstructedBitMask
Definition
api-constants.h:31
cppgc::internal::HeapObjectNameForUnnamedObject
HeapObjectNameForUnnamedObject
Definition
name-trait.h:62
cppgc::internal::kAllocationGranularity
constexpr size_t kAllocationGranularity
Definition
globals.h:37
cppgc
Definition
cross-heap-remembered-set.h:14
heap
Definition
platform.h:72
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
macros.h
cppgc::internal::GCInfo
Definition
gc-info-table.h:24
cppgc::internal::GCInfo::finalize
FinalizationCallback finalize
Definition
gc-info-table.h:29
cppgc::internal::GCInfo::name
NameCallback name
Definition
gc-info-table.h:31
cppgc::internal::HeapObjectName
Definition
name-trait.h:57
src
heap
cppgc
heap-object-header.cc
Generated on Sun Apr 6 2025 21:08:54 for v8 by
1.12.0