• 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 #ifndef V8_LIBPLATFORM_TRACING_RECORDER_MAC_H_
5 #define V8_LIBPLATFORM_TRACING_RECORDER_MAC_H_
6 
7 #include "src/libplatform/tracing/recorder.h"
8 
9 #pragma clang diagnostic push
10 #pragma clang diagnostic ignored "-Wunguarded-availability"
11 
12 namespace v8 {
13 namespace platform {
14 namespace tracing {
15 
Recorder()16 Recorder::Recorder() { v8Provider = os_log_create("v8", ""); }
~Recorder()17 Recorder::~Recorder() {}
18 
IsEnabled()19 bool Recorder::IsEnabled() {
20   return os_log_type_enabled(v8Provider, OS_LOG_TYPE_DEFAULT);
21 }
IsEnabled(const uint8_t level)22 bool Recorder::IsEnabled(const uint8_t level) {
23   if (level == OS_LOG_TYPE_DEFAULT || level == OS_LOG_TYPE_INFO ||
24       level == OS_LOG_TYPE_DEBUG || level == OS_LOG_TYPE_ERROR ||
25       level == OS_LOG_TYPE_FAULT) {
26     return os_log_type_enabled(v8Provider, static_cast<os_log_type_t>(level));
27   }
28   return false;
29 }
30 
AddEvent(TraceObject * trace_event)31 void Recorder::AddEvent(TraceObject* trace_event) {
32   os_signpost_event_emit(v8Provider, OS_SIGNPOST_ID_EXCLUSIVE, "",
33                          "%s, cpu_duration: %d", trace_event->name(),
34                          static_cast<int>(trace_event->cpu_duration()));
35 }
36 
37 }  // namespace tracing
38 }  // namespace platform
39 }  // namespace v8
40 
41 #pragma clang diagnostic pop
42 
43 #endif  // V8_LIBPLATFORM_TRACING_RECORDER_MAC_H_
44