11cb0ef41Sopenharmony_ci// Copyright 2020 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#ifndef INCLUDE_CPPGC_PROCESS_HEAP_STATISTICS_H_ 61cb0ef41Sopenharmony_ci#define INCLUDE_CPPGC_PROCESS_HEAP_STATISTICS_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include <atomic> 91cb0ef41Sopenharmony_ci#include <cstddef> 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ci#include "v8config.h" // NOLINT(build/include_directory) 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_cinamespace cppgc { 141cb0ef41Sopenharmony_cinamespace internal { 151cb0ef41Sopenharmony_ciclass ProcessHeapStatisticsUpdater; 161cb0ef41Sopenharmony_ci} // namespace internal 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ciclass V8_EXPORT ProcessHeapStatistics final { 191cb0ef41Sopenharmony_ci public: 201cb0ef41Sopenharmony_ci static size_t TotalAllocatedObjectSize() { 211cb0ef41Sopenharmony_ci return total_allocated_object_size_.load(std::memory_order_relaxed); 221cb0ef41Sopenharmony_ci } 231cb0ef41Sopenharmony_ci static size_t TotalAllocatedSpace() { 241cb0ef41Sopenharmony_ci return total_allocated_space_.load(std::memory_order_relaxed); 251cb0ef41Sopenharmony_ci } 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci private: 281cb0ef41Sopenharmony_ci static std::atomic_size_t total_allocated_space_; 291cb0ef41Sopenharmony_ci static std::atomic_size_t total_allocated_object_size_; 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ci friend class internal::ProcessHeapStatisticsUpdater; 321cb0ef41Sopenharmony_ci}; 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci} // namespace cppgc 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci#endif // INCLUDE_CPPGC_PROCESS_HEAP_STATISTICS_H_ 37