• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 INCLUDE_CPPGC_PROCESS_HEAP_STATISTICS_H_
6 #define INCLUDE_CPPGC_PROCESS_HEAP_STATISTICS_H_
7 
8 #include <atomic>
9 #include <cstddef>
10 
11 #include "v8config.h"  // NOLINT(build/include_directory)
12 
13 namespace cppgc {
14 namespace internal {
15 class ProcessHeapStatisticsUpdater;
16 }  // namespace internal
17 
18 class V8_EXPORT ProcessHeapStatistics final {
19  public:
TotalAllocatedObjectSize()20   static size_t TotalAllocatedObjectSize() {
21     return total_allocated_object_size_.load(std::memory_order_relaxed);
22   }
TotalAllocatedSpace()23   static size_t TotalAllocatedSpace() {
24     return total_allocated_space_.load(std::memory_order_relaxed);
25   }
26 
27  private:
28   static std::atomic_size_t total_allocated_space_;
29   static std::atomic_size_t total_allocated_object_size_;
30 
31   friend class internal::ProcessHeapStatisticsUpdater;
32 };
33 
34 }  // namespace cppgc
35 
36 #endif  // INCLUDE_CPPGC_PROCESS_HEAP_STATISTICS_H_
37