v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
process-heap-statistics.h
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
#ifndef V8_HEAP_CPPGC_PROCESS_HEAP_STATISTICS_H_
6
#define V8_HEAP_CPPGC_PROCESS_HEAP_STATISTICS_H_
7
8
#include "
include/cppgc/process-heap-statistics.h
"
9
#include "
src/heap/cppgc/stats-collector.h
"
10
11
namespace
cppgc
{
12
namespace
internal
{
13
14
class
ProcessHeapStatisticsUpdater
{
15
public
:
16
// Allocation observer implementation for heaps should register to contribute
17
// to ProcessHeapStatistics. The heap is responsible for allocating and
18
// registering the observer impl with its stats collector.
19
class
AllocationObserverImpl
final
20
:
public
StatsCollector::AllocationObserver
{
21
public
:
22
void
AllocatedObjectSizeIncreased
(
size_t
bytes)
final
{
23
ProcessHeapStatisticsUpdater::IncreaseTotalAllocatedObjectSize
(bytes);
24
object_size_changes_since_last_reset_
+= bytes;
25
}
26
27
void
AllocatedObjectSizeDecreased
(
size_t
bytes)
final
{
28
ProcessHeapStatisticsUpdater::DecreaseTotalAllocatedObjectSize
(bytes);
29
object_size_changes_since_last_reset_
-= bytes;
30
}
31
32
void
ResetAllocatedObjectSize
(
size_t
bytes)
final
{
33
ProcessHeapStatisticsUpdater::DecreaseTotalAllocatedObjectSize
(
34
object_size_changes_since_last_reset_
);
35
ProcessHeapStatisticsUpdater::IncreaseTotalAllocatedObjectSize
(bytes);
36
object_size_changes_since_last_reset_
= bytes;
37
}
38
39
void
AllocatedSizeIncreased
(
size_t
bytes)
final
{
40
ProcessHeapStatisticsUpdater::IncreaseTotalAllocatedSpace
(bytes);
41
}
42
43
void
AllocatedSizeDecreased
(
size_t
bytes)
final
{
44
ProcessHeapStatisticsUpdater::DecreaseTotalAllocatedSpace
(bytes);
45
}
46
47
private
:
48
size_t
object_size_changes_since_last_reset_
= 0;
49
};
50
51
// For cppgc::ProcessHeapStatistics
52
static
void
IncreaseTotalAllocatedObjectSize
(
size_t
delta) {
53
::cppgc::ProcessHeapStatistics::total_allocated_object_size_
.fetch_add(
54
delta, std::memory_order_relaxed);
55
}
56
static
void
DecreaseTotalAllocatedObjectSize
(
size_t
delta) {
57
::cppgc::ProcessHeapStatistics::total_allocated_object_size_
.fetch_sub(
58
delta, std::memory_order_relaxed);
59
}
60
static
void
IncreaseTotalAllocatedSpace
(
size_t
delta) {
61
::cppgc::ProcessHeapStatistics::total_allocated_space_
.fetch_add(
62
delta, std::memory_order_relaxed);
63
}
64
static
void
DecreaseTotalAllocatedSpace
(
size_t
delta) {
65
::cppgc::ProcessHeapStatistics::total_allocated_space_
.fetch_sub(
66
delta, std::memory_order_relaxed);
67
}
68
};
69
70
}
// namespace internal
71
}
// namespace cppgc
72
73
#endif
// V8_HEAP_CPPGC_PROCESS_HEAP_STATISTICS_H_
cppgc::ProcessHeapStatistics::total_allocated_object_size_
static std::atomic_size_t total_allocated_object_size_
Definition
process-heap-statistics.h:29
cppgc::ProcessHeapStatistics::total_allocated_space_
static std::atomic_size_t total_allocated_space_
Definition
process-heap-statistics.h:28
cppgc::internal::ProcessHeapStatisticsUpdater::AllocationObserverImpl
Definition
process-heap-statistics.h:20
cppgc::internal::ProcessHeapStatisticsUpdater::AllocationObserverImpl::AllocatedObjectSizeIncreased
void AllocatedObjectSizeIncreased(size_t bytes) final
Definition
process-heap-statistics.h:22
cppgc::internal::ProcessHeapStatisticsUpdater::AllocationObserverImpl::AllocatedSizeIncreased
void AllocatedSizeIncreased(size_t bytes) final
Definition
process-heap-statistics.h:39
cppgc::internal::ProcessHeapStatisticsUpdater::AllocationObserverImpl::ResetAllocatedObjectSize
void ResetAllocatedObjectSize(size_t bytes) final
Definition
process-heap-statistics.h:32
cppgc::internal::ProcessHeapStatisticsUpdater::AllocationObserverImpl::AllocatedSizeDecreased
void AllocatedSizeDecreased(size_t bytes) final
Definition
process-heap-statistics.h:43
cppgc::internal::ProcessHeapStatisticsUpdater::AllocationObserverImpl::AllocatedObjectSizeDecreased
void AllocatedObjectSizeDecreased(size_t bytes) final
Definition
process-heap-statistics.h:27
cppgc::internal::ProcessHeapStatisticsUpdater::AllocationObserverImpl::object_size_changes_since_last_reset_
size_t object_size_changes_since_last_reset_
Definition
process-heap-statistics.h:48
cppgc::internal::ProcessHeapStatisticsUpdater
Definition
process-heap-statistics.h:14
cppgc::internal::ProcessHeapStatisticsUpdater::DecreaseTotalAllocatedObjectSize
static void DecreaseTotalAllocatedObjectSize(size_t delta)
Definition
process-heap-statistics.h:56
cppgc::internal::ProcessHeapStatisticsUpdater::DecreaseTotalAllocatedSpace
static void DecreaseTotalAllocatedSpace(size_t delta)
Definition
process-heap-statistics.h:64
cppgc::internal::ProcessHeapStatisticsUpdater::IncreaseTotalAllocatedSpace
static void IncreaseTotalAllocatedSpace(size_t delta)
Definition
process-heap-statistics.h:60
cppgc::internal::ProcessHeapStatisticsUpdater::IncreaseTotalAllocatedObjectSize
static void IncreaseTotalAllocatedObjectSize(size_t delta)
Definition
process-heap-statistics.h:52
cppgc::internal::StatsCollector::AllocationObserver
Definition
stats-collector.h:244
process-heap-statistics.h
cppgc
Definition
cross-heap-remembered-set.h:14
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
stats-collector.h
src
heap
cppgc
process-heap-statistics.h
Generated on Sun Apr 6 2025 21:08:54 for v8 by
1.12.0