5 #ifndef V8_TRACING_TRACE_EVENT_H_ 6 #define V8_TRACING_TRACE_EVENT_H_ 11 #include "base/trace_event/common/trace_event_common.h" 12 #include "include/v8-platform.h" 13 #include "src/base/atomicops.h" 14 #include "src/base/macros.h" 26 enum CategoryGroupEnabledFlags {
28 kEnabledForRecording_CategoryGroupEnabledFlags = 1 << 0,
30 kEnabledForEventCallback_CategoryGroupEnabledFlags = 1 << 2,
32 kEnabledForETWExport_CategoryGroupEnabledFlags = 1 << 3,
37 #define TRACE_STR_COPY(str) v8::internal::tracing::TraceStringWithCopy(str) 41 #define TRACE_ID_MANGLE(id) v8::internal::tracing::TraceID::ForceMangle(id) 45 #define TRACE_ID_DONT_MANGLE(id) v8::internal::tracing::TraceID::DontMangle(id) 49 #define TRACE_ID_WITH_SCOPE(scope, id) \ 50 trace_event_internal::TraceID::WithScope(scope, id) 52 #define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE() \ 53 TRACE_EVENT_API_LOAD_CATEGORY_GROUP_ENABLED() & \ 54 (kEnabledForRecording_CategoryGroupEnabledFlags | \ 55 kEnabledForEventCallback_CategoryGroupEnabledFlags) 60 #define INTERNAL_TRACE_MEMORY(category, name) 75 #define TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED \ 76 v8::internal::tracing::TraceEventHelper::GetTracingController() \ 77 ->GetCategoryGroupEnabled 82 #define TRACE_EVENT_API_GET_NUM_TRACES_RECORDED UNIMPLEMENTED() 97 #define TRACE_EVENT_API_ADD_TRACE_EVENT v8::internal::tracing::AddTraceEventImpl 113 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP \ 114 v8::internal::tracing::AddTraceEventWithTimestampImpl 121 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \ 122 v8::internal::tracing::TraceEventHelper::GetTracingController() \ 123 ->UpdateTraceEventDuration 126 #define TRACE_EVENT_API_ATOMIC_WORD v8::base::AtomicWord 127 #define TRACE_EVENT_API_ATOMIC_LOAD(var) v8::base::Relaxed_Load(&(var)) 128 #define TRACE_EVENT_API_ATOMIC_STORE(var, value) \ 129 v8::base::Relaxed_Store(&(var), (value)) 130 #define TRACE_EVENT_API_LOAD_CATEGORY_GROUP_ENABLED() \ 131 v8::base::Relaxed_Load(reinterpret_cast<const v8::base::Atomic8*>( \ 132 INTERNAL_TRACE_EVENT_UID(category_group_enabled))) 139 #define INTERNAL_TRACE_EVENT_UID3(a, b) trace_event_unique_##a##b 140 #define INTERNAL_TRACE_EVENT_UID2(a, b) INTERNAL_TRACE_EVENT_UID3(a, b) 141 #define INTERNAL_TRACE_EVENT_UID(name_prefix) \ 142 INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__) 151 #define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO_CUSTOM_VARIABLES( \ 152 category_group, atomic, category_group_enabled) \ 153 category_group_enabled = \ 154 reinterpret_cast<const uint8_t*>(TRACE_EVENT_API_ATOMIC_LOAD(atomic)); \ 155 if (!category_group_enabled) { \ 156 category_group_enabled = \ 157 TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); \ 158 TRACE_EVENT_API_ATOMIC_STORE( \ 159 atomic, reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>( \ 160 category_group_enabled)); \ 163 #define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group) \ 164 static TRACE_EVENT_API_ATOMIC_WORD INTERNAL_TRACE_EVENT_UID(atomic) = 0; \ 165 const uint8_t* INTERNAL_TRACE_EVENT_UID(category_group_enabled); \ 166 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO_CUSTOM_VARIABLES( \ 167 category_group, INTERNAL_TRACE_EVENT_UID(atomic), \ 168 INTERNAL_TRACE_EVENT_UID(category_group_enabled)); 172 #define INTERNAL_TRACE_EVENT_ADD(phase, category_group, name, flags, ...) \ 174 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 175 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 176 v8::internal::tracing::AddTraceEvent( \ 177 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ 178 v8::internal::tracing::kGlobalScope, v8::internal::tracing::kNoId, \ 179 v8::internal::tracing::kNoId, flags, ##__VA_ARGS__); \ 186 #define INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, ...) \ 187 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 188 v8::internal::tracing::ScopedTracer INTERNAL_TRACE_EVENT_UID(tracer); \ 189 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 190 uint64_t h = v8::internal::tracing::AddTraceEvent( \ 191 TRACE_EVENT_PHASE_COMPLETE, \ 192 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ 193 v8::internal::tracing::kGlobalScope, v8::internal::tracing::kNoId, \ 194 v8::internal::tracing::kNoId, TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \ 195 INTERNAL_TRACE_EVENT_UID(tracer) \ 196 .Initialize(INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ 200 #define INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW(category_group, name, \ 201 bind_id, flow_flags, ...) \ 202 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 203 v8::internal::tracing::ScopedTracer INTERNAL_TRACE_EVENT_UID(tracer); \ 204 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 205 unsigned int trace_event_flags = flow_flags; \ 206 v8::internal::tracing::TraceID trace_event_bind_id(bind_id, \ 207 &trace_event_flags); \ 208 uint64_t h = v8::internal::tracing::AddTraceEvent( \ 209 TRACE_EVENT_PHASE_COMPLETE, \ 210 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ 211 v8::internal::tracing::kGlobalScope, v8::internal::tracing::kNoId, \ 212 trace_event_bind_id.raw_id(), trace_event_flags, ##__VA_ARGS__); \ 213 INTERNAL_TRACE_EVENT_UID(tracer) \ 214 .Initialize(INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ 220 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \ 223 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 224 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 225 unsigned int trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ 226 v8::internal::tracing::TraceID trace_event_trace_id(id, \ 227 &trace_event_flags); \ 228 v8::internal::tracing::AddTraceEvent( \ 229 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ 230 trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \ 231 v8::internal::tracing::kNoId, trace_event_flags, ##__VA_ARGS__); \ 236 #define INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP(phase, category_group, name, \ 237 timestamp, flags, ...) \ 239 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 240 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 241 v8::internal::tracing::AddTraceEventWithTimestamp( \ 242 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ 243 v8::internal::tracing::kGlobalScope, v8::internal::tracing::kNoId, \ 244 v8::internal::tracing::kNoId, flags, timestamp, ##__VA_ARGS__); \ 249 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_AND_TIMESTAMP( \ 250 phase, category_group, name, id, timestamp, flags, ...) \ 252 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 253 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 254 unsigned int trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ 255 v8::internal::tracing::TraceID trace_event_trace_id(id, \ 256 &trace_event_flags); \ 257 v8::internal::tracing::AddTraceEventWithTimestamp( \ 258 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ 259 trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \ 260 v8::internal::tracing::kNoId, trace_event_flags, timestamp, \ 268 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 269 phase, category_group, name, id, thread_id, timestamp, flags, ...) \ 270 INTERNAL_TRACE_EVENT_ADD_WITH_ID_AND_TIMESTAMP( \ 271 phase, category_group, name, id, timestamp, flags, ##__VA_ARGS__) 274 #define INTERNAL_TRACE_EVENT_SCOPED_CONTEXT(category_group, name, context) \ 275 struct INTERNAL_TRACE_EVENT_UID(ScopedContext) { \ 277 INTERNAL_TRACE_EVENT_UID(ScopedContext)(uint64_t cid) : cid_(cid) { \ 278 TRACE_EVENT_ENTER_CONTEXT(category_group, name, cid_); \ 280 ~INTERNAL_TRACE_EVENT_UID(ScopedContext)() { \ 281 TRACE_EVENT_LEAVE_CONTEXT(category_group, name, cid_); \ 286 INTERNAL_TRACE_EVENT_UID(ScopedContext) \ 287 (const INTERNAL_TRACE_EVENT_UID(ScopedContext)&) {} \ 288 void operator=(const INTERNAL_TRACE_EVENT_UID(ScopedContext)&) {} \ 291 INTERNAL_TRACE_EVENT_UID(ScopedContext) \ 292 INTERNAL_TRACE_EVENT_UID(scoped_context)(context); 294 #define TRACE_EVENT_CALL_STATS_SCOPED(isolate, category_group, name) \ 295 INTERNAL_TRACE_EVENT_CALL_STATS_SCOPED(isolate, category_group, name) 297 #define INTERNAL_TRACE_EVENT_CALL_STATS_SCOPED(isolate, category_group, name) \ 298 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 299 v8::internal::tracing::CallStatsScopedTracer INTERNAL_TRACE_EVENT_UID( \ 301 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 302 INTERNAL_TRACE_EVENT_UID(tracer) \ 303 .Initialize(isolate, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ 316 const int kZeroNumArgs = 0;
317 const decltype(
nullptr) kGlobalScope =
nullptr;
318 const uint64_t kNoId = 0;
332 WithScope(
const char* scope, uint64_t raw_id)
333 : scope_(scope), raw_id_(raw_id) {}
334 uint64_t raw_id()
const {
return raw_id_; }
335 const char* scope()
const {
return scope_; }
338 const char* scope_ =
nullptr;
345 : raw_id_(static_cast<uint64_t>(reinterpret_cast<uintptr_t>(raw_id))) {}
346 explicit DontMangle(uint64_t raw_id) : raw_id_(raw_id) {}
347 explicit DontMangle(
unsigned int raw_id) : raw_id_(raw_id) {}
348 explicit DontMangle(uint16_t raw_id) : raw_id_(raw_id) {}
349 explicit DontMangle(
unsigned char raw_id) : raw_id_(raw_id) {}
351 : raw_id_(static_cast<uint64_t>(raw_id)) {}
352 explicit DontMangle(
int raw_id) : raw_id_(static_cast<uint64_t>(raw_id)) {}
354 : raw_id_(static_cast<uint64_t>(raw_id)) {}
356 : raw_id_(static_cast<uint64_t>(raw_id)) {}
358 : scope_(scoped_id.scope()), raw_id_(scoped_id.raw_id()) {}
359 const char* scope()
const {
return scope_; }
360 uint64_t raw_id()
const {
return raw_id_; }
363 const char* scope_ =
nullptr;
369 explicit ForceMangle(uint64_t raw_id) : raw_id_(raw_id) {}
370 explicit ForceMangle(
unsigned int raw_id) : raw_id_(raw_id) {}
371 explicit ForceMangle(uint16_t raw_id) : raw_id_(raw_id) {}
372 explicit ForceMangle(
unsigned char raw_id) : raw_id_(raw_id) {}
374 : raw_id_(static_cast<uint64_t>(raw_id)) {}
375 explicit ForceMangle(
int raw_id) : raw_id_(static_cast<uint64_t>(raw_id)) {}
377 : raw_id_(static_cast<uint64_t>(raw_id)) {}
379 : raw_id_(static_cast<uint64_t>(raw_id)) {}
380 uint64_t raw_id()
const {
return raw_id_; }
386 TraceID(
const void* raw_id,
unsigned int* flags)
387 : raw_id_(static_cast<uint64_t>(reinterpret_cast<
uintptr_t>(raw_id))) {
388 *flags |= TRACE_EVENT_FLAG_MANGLE_ID;
390 TraceID(ForceMangle raw_id,
unsigned int* flags) : raw_id_(raw_id.raw_id()) {
391 *flags |= TRACE_EVENT_FLAG_MANGLE_ID;
393 TraceID(DontMangle maybe_scoped_id,
unsigned int* flags)
394 : scope_(maybe_scoped_id.scope()), raw_id_(maybe_scoped_id.raw_id()) {}
395 TraceID(uint64_t raw_id,
unsigned int* flags) : raw_id_(raw_id) {
398 TraceID(
unsigned int raw_id,
unsigned int* flags) : raw_id_(raw_id) {
401 TraceID(uint16_t raw_id,
unsigned int* flags) : raw_id_(raw_id) {
404 TraceID(
unsigned char raw_id,
unsigned int* flags) : raw_id_(raw_id) {
407 TraceID(
int64_t raw_id,
unsigned int* flags)
408 : raw_id_(static_cast<uint64_t>(raw_id)) {
411 TraceID(
int raw_id,
unsigned int* flags)
412 : raw_id_(static_cast<uint64_t>(raw_id)) {
415 TraceID(int16_t raw_id,
unsigned int* flags)
416 : raw_id_(static_cast<uint64_t>(raw_id)) {
419 TraceID(
signed char raw_id,
unsigned int* flags)
420 : raw_id_(static_cast<uint64_t>(raw_id)) {
423 TraceID(WithScope scoped_id,
unsigned int* flags)
424 : scope_(scoped_id.scope()), raw_id_(scoped_id.raw_id()) {}
426 uint64_t raw_id()
const {
return raw_id_; }
427 const char* scope()
const {
return scope_; }
430 const char* scope_ =
nullptr;
440 const void* as_pointer;
441 const char* as_string;
448 operator const char*()
const {
return str_; }
454 static V8_INLINE uint64_t AddTraceEventImpl(
455 char phase,
const uint8_t* category_group_enabled,
const char* name,
456 const char* scope, uint64_t
id, uint64_t bind_id, int32_t num_args,
457 const char** arg_names,
const uint8_t* arg_types,
458 const uint64_t* arg_values,
unsigned int flags) {
459 std::unique_ptr<ConvertableToTraceFormat> arg_convertables[2];
460 if (num_args > 0 && arg_types[0] == TRACE_VALUE_TYPE_CONVERTABLE) {
461 arg_convertables[0].reset(reinterpret_cast<ConvertableToTraceFormat*>(
462 static_cast<intptr_t>(arg_values[0])));
464 if (num_args > 1 && arg_types[1] == TRACE_VALUE_TYPE_CONVERTABLE) {
465 arg_convertables[1].reset(reinterpret_cast<ConvertableToTraceFormat*>(
466 static_cast<intptr_t>(arg_values[1])));
468 DCHECK_LE(num_args, 2);
470 v8::internal::tracing::TraceEventHelper::GetTracingController();
471 return controller->
AddTraceEvent(phase, category_group_enabled, name, scope,
472 id, bind_id, num_args, arg_names, arg_types,
473 arg_values, arg_convertables, flags);
476 static V8_INLINE uint64_t AddTraceEventWithTimestampImpl(
477 char phase,
const uint8_t* category_group_enabled,
const char* name,
478 const char* scope, uint64_t
id, uint64_t bind_id, int32_t num_args,
479 const char** arg_names,
const uint8_t* arg_types,
480 const uint64_t* arg_values,
unsigned int flags,
int64_t timestamp) {
481 std::unique_ptr<ConvertableToTraceFormat> arg_convertables[2];
482 if (num_args > 0 && arg_types[0] == TRACE_VALUE_TYPE_CONVERTABLE) {
483 arg_convertables[0].reset(reinterpret_cast<ConvertableToTraceFormat*>(
484 static_cast<intptr_t>(arg_values[0])));
486 if (num_args > 1 && arg_types[1] == TRACE_VALUE_TYPE_CONVERTABLE) {
487 arg_convertables[1].reset(reinterpret_cast<ConvertableToTraceFormat*>(
488 static_cast<intptr_t>(arg_values[1])));
490 DCHECK_LE(num_args, 2);
492 v8::internal::tracing::TraceEventHelper::GetTracingController();
493 return controller->AddTraceEventWithTimestamp(
494 phase, category_group_enabled, name, scope,
id, bind_id, num_args,
495 arg_names, arg_types, arg_values, arg_convertables, flags, timestamp);
501 #define INTERNAL_DECLARE_SET_TRACE_VALUE(actual_type, union_member, \ 503 static V8_INLINE void SetTraceValue(actual_type arg, unsigned char* type, \ 505 TraceValueUnion type_value; \ 506 type_value.union_member = arg; \ 507 *type = value_type_id; \ 508 *value = type_value.as_uint; \ 511 #define INTERNAL_DECLARE_SET_TRACE_VALUE_INT(actual_type, value_type_id) \ 512 static V8_INLINE void SetTraceValue(actual_type arg, unsigned char* type, \ 514 *type = value_type_id; \ 515 *value = static_cast<uint64_t>(arg); \ 518 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(uint64_t, TRACE_VALUE_TYPE_UINT)
519 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(
unsigned int, TRACE_VALUE_TYPE_UINT)
520 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(uint16_t, TRACE_VALUE_TYPE_UINT)
521 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(
unsigned char, TRACE_VALUE_TYPE_UINT)
522 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(
int64_t, TRACE_VALUE_TYPE_INT)
523 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(
int, TRACE_VALUE_TYPE_INT)
524 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(int16_t, TRACE_VALUE_TYPE_INT)
525 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(
signed char, TRACE_VALUE_TYPE_INT)
526 INTERNAL_DECLARE_SET_TRACE_VALUE(
bool, as_bool, TRACE_VALUE_TYPE_BOOL)
527 INTERNAL_DECLARE_SET_TRACE_VALUE(
double, as_double, TRACE_VALUE_TYPE_DOUBLE)
528 INTERNAL_DECLARE_SET_TRACE_VALUE(
const void*, as_pointer,
529 TRACE_VALUE_TYPE_POINTER)
530 INTERNAL_DECLARE_SET_TRACE_VALUE(
const char*, as_string,
531 TRACE_VALUE_TYPE_STRING)
532 INTERNAL_DECLARE_SET_TRACE_VALUE(
const TraceStringWithCopy&, as_string,
533 TRACE_VALUE_TYPE_COPY_STRING)
535 #undef INTERNAL_DECLARE_SET_TRACE_VALUE 536 #undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT 538 static V8_INLINE
void SetTraceValue(ConvertableToTraceFormat* convertable_value,
539 unsigned char* type, uint64_t* value) {
540 *type = TRACE_VALUE_TYPE_CONVERTABLE;
541 *value =
static_cast<uint64_t
>(
reinterpret_cast<intptr_t
>(convertable_value));
544 template <
typename T>
545 static V8_INLINE
typename std::enable_if<
546 std::is_convertible<T*, ConvertableToTraceFormat*>::value>::type
547 SetTraceValue(std::unique_ptr<T> ptr,
unsigned char* type, uint64_t* value) {
548 SetTraceValue(ptr.release(), type, value);
557 static V8_INLINE uint64_t AddTraceEvent(
char phase,
558 const uint8_t* category_group_enabled,
559 const char* name,
const char* scope,
560 uint64_t
id, uint64_t bind_id,
561 unsigned int flags) {
562 return TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_group_enabled, name,
563 scope,
id, bind_id, kZeroNumArgs,
564 nullptr,
nullptr,
nullptr, flags);
567 template <
class ARG1_TYPE>
568 static V8_INLINE uint64_t AddTraceEvent(
569 char phase,
const uint8_t* category_group_enabled,
const char* name,
570 const char* scope, uint64_t
id, uint64_t bind_id,
unsigned int flags,
571 const char* arg1_name, ARG1_TYPE&& arg1_val) {
572 const int num_args = 1;
575 SetTraceValue(std::forward<ARG1_TYPE>(arg1_val), &arg_type, &arg_value);
576 return TRACE_EVENT_API_ADD_TRACE_EVENT(
577 phase, category_group_enabled, name, scope,
id, bind_id, num_args,
578 &arg1_name, &arg_type, &arg_value, flags);
581 template <
class ARG1_TYPE,
class ARG2_TYPE>
582 static V8_INLINE uint64_t AddTraceEvent(
583 char phase,
const uint8_t* category_group_enabled,
const char* name,
584 const char* scope, uint64_t
id, uint64_t bind_id,
unsigned int flags,
585 const char* arg1_name, ARG1_TYPE&& arg1_val,
const char* arg2_name,
586 ARG2_TYPE&& arg2_val) {
587 const int num_args = 2;
588 const char* arg_names[2] = {arg1_name, arg2_name};
589 unsigned char arg_types[2];
590 uint64_t arg_values[2];
591 SetTraceValue(std::forward<ARG1_TYPE>(arg1_val), &arg_types[0],
593 SetTraceValue(std::forward<ARG2_TYPE>(arg2_val), &arg_types[1],
595 return TRACE_EVENT_API_ADD_TRACE_EVENT(
596 phase, category_group_enabled, name, scope,
id, bind_id, num_args,
597 arg_names, arg_types, arg_values, flags);
600 static V8_INLINE uint64_t AddTraceEventWithTimestamp(
601 char phase,
const uint8_t* category_group_enabled,
const char* name,
602 const char* scope, uint64_t
id, uint64_t bind_id,
unsigned int flags,
604 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP(
605 phase, category_group_enabled, name, scope,
id, bind_id, kZeroNumArgs,
606 nullptr,
nullptr,
nullptr, flags, timestamp);
609 template <
class ARG1_TYPE>
610 static V8_INLINE uint64_t AddTraceEventWithTimestamp(
611 char phase,
const uint8_t* category_group_enabled,
const char* name,
612 const char* scope, uint64_t
id, uint64_t bind_id,
unsigned int flags,
613 int64_t timestamp,
const char* arg1_name, ARG1_TYPE&& arg1_val) {
614 const int num_args = 1;
617 SetTraceValue(std::forward<ARG1_TYPE>(arg1_val), &arg_type, &arg_value);
618 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP(
619 phase, category_group_enabled, name, scope,
id, bind_id, num_args,
620 &arg1_name, &arg_type, &arg_value, flags, timestamp);
623 template <
class ARG1_TYPE,
class ARG2_TYPE>
624 static V8_INLINE uint64_t AddTraceEventWithTimestamp(
625 char phase,
const uint8_t* category_group_enabled,
const char* name,
626 const char* scope, uint64_t
id, uint64_t bind_id,
unsigned int flags,
627 int64_t timestamp,
const char* arg1_name, ARG1_TYPE&& arg1_val,
628 const char* arg2_name, ARG2_TYPE&& arg2_val) {
629 const int num_args = 2;
630 const char* arg_names[2] = {arg1_name, arg2_name};
631 unsigned char arg_types[2];
632 uint64_t arg_values[2];
633 SetTraceValue(std::forward<ARG1_TYPE>(arg1_val), &arg_types[0],
635 SetTraceValue(std::forward<ARG2_TYPE>(arg2_val), &arg_types[1],
637 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP(
638 phase, category_group_enabled, name, scope,
id, bind_id, num_args,
639 arg_names, arg_types, arg_values, flags, timestamp);
649 if (p_data_ && *data_.category_group_enabled)
650 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
651 data_.category_group_enabled, data_.name, data_.event_handle);
654 void Initialize(
const uint8_t* category_group_enabled,
const char* name,
655 uint64_t event_handle) {
656 data_.category_group_enabled = category_group_enabled;
658 data_.event_handle = event_handle;
669 const uint8_t* category_group_enabled;
671 uint64_t event_handle;
682 if (V8_UNLIKELY(p_data_ && *data_.category_group_enabled)) {
688 const uint8_t* category_group_enabled,
const char* name);
691 void AddEndTraceEvent();
693 const uint8_t* category_group_enabled;
697 bool has_parent_scope_;
706 #endif // V8_TRACING_TRACE_EVENT_H_
virtual uint64_t AddTraceEvent(char phase, const uint8_t *category_enabled_flag, const char *name, const char *scope, uint64_t id, uint64_t bind_id, int32_t num_args, const char **arg_names, const uint8_t *arg_types, const uint64_t *arg_values, std::unique_ptr< ConvertableToTraceFormat > *arg_convertables, unsigned int flags)