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 V8_LOGGING_TRACING_FLAGS_H_
61cb0ef41Sopenharmony_ci#define V8_LOGGING_TRACING_FLAGS_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include <atomic>
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci#include "src/base/macros.h"
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_cinamespace v8 {
131cb0ef41Sopenharmony_cinamespace internal {
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci// This struct contains a set of flags that can be modified from multiple
161cb0ef41Sopenharmony_ci// threads at runtime unlike the normal FLAG_-like flags which are not modified
171cb0ef41Sopenharmony_ci// after V8 instance is initialized.
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_cistruct TracingFlags {
201cb0ef41Sopenharmony_ci  static V8_EXPORT_PRIVATE std::atomic_uint runtime_stats;
211cb0ef41Sopenharmony_ci  static V8_EXPORT_PRIVATE std::atomic_uint gc;
221cb0ef41Sopenharmony_ci  static V8_EXPORT_PRIVATE std::atomic_uint gc_stats;
231cb0ef41Sopenharmony_ci  static V8_EXPORT_PRIVATE std::atomic_uint ic_stats;
241cb0ef41Sopenharmony_ci  static V8_EXPORT_PRIVATE std::atomic_uint zone_stats;
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ci#ifdef V8_RUNTIME_CALL_STATS
271cb0ef41Sopenharmony_ci  static bool is_runtime_stats_enabled() {
281cb0ef41Sopenharmony_ci    return runtime_stats.load(std::memory_order_relaxed) != 0;
291cb0ef41Sopenharmony_ci  }
301cb0ef41Sopenharmony_ci#endif
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ci  static bool is_gc_enabled() {
331cb0ef41Sopenharmony_ci    return gc.load(std::memory_order_relaxed) != 0;
341cb0ef41Sopenharmony_ci  }
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci  static bool is_gc_stats_enabled() {
371cb0ef41Sopenharmony_ci    return gc_stats.load(std::memory_order_relaxed) != 0;
381cb0ef41Sopenharmony_ci  }
391cb0ef41Sopenharmony_ci
401cb0ef41Sopenharmony_ci  static bool is_ic_stats_enabled() {
411cb0ef41Sopenharmony_ci    return ic_stats.load(std::memory_order_relaxed) != 0;
421cb0ef41Sopenharmony_ci  }
431cb0ef41Sopenharmony_ci
441cb0ef41Sopenharmony_ci  static bool is_zone_stats_enabled() {
451cb0ef41Sopenharmony_ci    return zone_stats.load(std::memory_order_relaxed) != 0;
461cb0ef41Sopenharmony_ci  }
471cb0ef41Sopenharmony_ci};
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ci}  // namespace internal
501cb0ef41Sopenharmony_ci}  // namespace v8
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ci#endif  // V8_LOGGING_TRACING_FLAGS_H_
53