src: update trace event macros to v8 6.4 version
PR-URL: https://github.com/nodejs/node/pull/17640 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit is contained in:
parent
7dffabbb84
commit
d8ec49ed9d
@ -92,6 +92,23 @@ enum CategoryGroupEnabledFlags {
|
|||||||
// unsigned int flags)
|
// unsigned int flags)
|
||||||
#define TRACE_EVENT_API_ADD_TRACE_EVENT node::tracing::AddTraceEventImpl
|
#define TRACE_EVENT_API_ADD_TRACE_EVENT node::tracing::AddTraceEventImpl
|
||||||
|
|
||||||
|
// Add a trace event to the platform tracing system.
|
||||||
|
// uint64_t TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP(
|
||||||
|
// char phase,
|
||||||
|
// const uint8_t* category_group_enabled,
|
||||||
|
// const char* name,
|
||||||
|
// const char* scope,
|
||||||
|
// uint64_t id,
|
||||||
|
// uint64_t bind_id,
|
||||||
|
// int num_args,
|
||||||
|
// const char** arg_names,
|
||||||
|
// const uint8_t* arg_types,
|
||||||
|
// const uint64_t* arg_values,
|
||||||
|
// unsigned int flags,
|
||||||
|
// int64_t timestamp)
|
||||||
|
#define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP \
|
||||||
|
node::tracing::AddTraceEventWithTimestampImpl
|
||||||
|
|
||||||
// Set the duration field of a COMPLETE trace event.
|
// Set the duration field of a COMPLETE trace event.
|
||||||
// void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
|
// void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
|
||||||
// const uint8_t* category_group_enabled,
|
// const uint8_t* category_group_enabled,
|
||||||
@ -207,10 +224,18 @@ enum CategoryGroupEnabledFlags {
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
// Adds a trace event with a given timestamp. Not Implemented.
|
// Adds a trace event with a given timestamp.
|
||||||
#define INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP(phase, category_group, name, \
|
#define INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP(phase, category_group, name, \
|
||||||
timestamp, flags, ...) \
|
timestamp, flags, ...) \
|
||||||
UNIMPLEMENTED()
|
do { \
|
||||||
|
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
|
||||||
|
if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
|
||||||
|
node::tracing::AddTraceEventWithTimestamp( \
|
||||||
|
phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \
|
||||||
|
node::tracing::kGlobalScope, node::tracing::kNoId, \
|
||||||
|
node::tracing::kNoId, flags, timestamp, ##__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
// Adds a trace event with a given id and timestamp. Not Implemented.
|
// Adds a trace event with a given id and timestamp. Not Implemented.
|
||||||
#define INTERNAL_TRACE_EVENT_ADD_WITH_ID_AND_TIMESTAMP( \
|
#define INTERNAL_TRACE_EVENT_ADD_WITH_ID_AND_TIMESTAMP( \
|
||||||
@ -253,8 +278,6 @@ const int kZeroNumArgs = 0;
|
|||||||
const decltype(nullptr) kGlobalScope = nullptr;
|
const decltype(nullptr) kGlobalScope = nullptr;
|
||||||
const uint64_t kNoId = 0;
|
const uint64_t kNoId = 0;
|
||||||
|
|
||||||
extern intptr_t kRuntimeCallStatsTracingEnabled;
|
|
||||||
|
|
||||||
class TraceEventHelper {
|
class TraceEventHelper {
|
||||||
public:
|
public:
|
||||||
static v8::TracingController* GetTracingController();
|
static v8::TracingController* GetTracingController();
|
||||||
@ -404,7 +427,7 @@ static inline uint64_t AddTraceEventImpl(
|
|||||||
arg_convertibles[1].reset(reinterpret_cast<v8::ConvertableToTraceFormat*>(
|
arg_convertibles[1].reset(reinterpret_cast<v8::ConvertableToTraceFormat*>(
|
||||||
static_cast<intptr_t>(arg_values[1])));
|
static_cast<intptr_t>(arg_values[1])));
|
||||||
}
|
}
|
||||||
// DCHECK(num_args <= 2);
|
// DCHECK(num_args, 2);
|
||||||
v8::TracingController* controller =
|
v8::TracingController* controller =
|
||||||
node::tracing::TraceEventHelper::GetTracingController();
|
node::tracing::TraceEventHelper::GetTracingController();
|
||||||
return controller->AddTraceEvent(phase, category_group_enabled, name, scope, id,
|
return controller->AddTraceEvent(phase, category_group_enabled, name, scope, id,
|
||||||
@ -412,6 +435,28 @@ static inline uint64_t AddTraceEventImpl(
|
|||||||
arg_values, arg_convertibles, flags);
|
arg_values, arg_convertibles, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static V8_INLINE uint64_t AddTraceEventWithTimestampImpl(
|
||||||
|
char phase, const uint8_t* category_group_enabled, 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, unsigned int flags, int64_t timestamp) {
|
||||||
|
std::unique_ptr<v8::ConvertableToTraceFormat> arg_convertables[2];
|
||||||
|
if (num_args > 0 && arg_types[0] == TRACE_VALUE_TYPE_CONVERTABLE) {
|
||||||
|
arg_convertables[0].reset(reinterpret_cast<v8::ConvertableToTraceFormat*>(
|
||||||
|
static_cast<intptr_t>(arg_values[0])));
|
||||||
|
}
|
||||||
|
if (num_args > 1 && arg_types[1] == TRACE_VALUE_TYPE_CONVERTABLE) {
|
||||||
|
arg_convertables[1].reset(reinterpret_cast<v8::ConvertableToTraceFormat*>(
|
||||||
|
static_cast<intptr_t>(arg_values[1])));
|
||||||
|
}
|
||||||
|
// DCHECK_LE(num_args, 2);
|
||||||
|
v8::TracingController* controller =
|
||||||
|
node::tracing::TraceEventHelper::GetTracingController();
|
||||||
|
return controller->AddTraceEventWithTimestamp(
|
||||||
|
phase, category_group_enabled, name, scope, id, bind_id, num_args,
|
||||||
|
arg_names, arg_types, arg_values, arg_convertables, flags, timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
// Define SetTraceValue for each allowed type. It stores the type and
|
// Define SetTraceValue for each allowed type. It stores the type and
|
||||||
// value in the return arguments. This allows this API to avoid declaring any
|
// value in the return arguments. This allows this API to avoid declaring any
|
||||||
// structures so that it is portable to third_party libraries.
|
// structures so that it is portable to third_party libraries.
|
||||||
@ -514,6 +559,48 @@ static inline uint64_t AddTraceEvent(
|
|||||||
arg_names, arg_types, arg_values, flags);
|
arg_names, arg_types, arg_values, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static V8_INLINE uint64_t AddTraceEventWithTimestamp(
|
||||||
|
char phase, const uint8_t* category_group_enabled, const char* name,
|
||||||
|
const char* scope, uint64_t id, uint64_t bind_id, unsigned int flags,
|
||||||
|
int64_t timestamp) {
|
||||||
|
return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP(
|
||||||
|
phase, category_group_enabled, name, scope, id, bind_id, kZeroNumArgs,
|
||||||
|
nullptr, nullptr, nullptr, flags, timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class ARG1_TYPE>
|
||||||
|
static V8_INLINE uint64_t AddTraceEventWithTimestamp(
|
||||||
|
char phase, const uint8_t* category_group_enabled, const char* name,
|
||||||
|
const char* scope, uint64_t id, uint64_t bind_id, unsigned int flags,
|
||||||
|
int64_t timestamp, const char* arg1_name, ARG1_TYPE&& arg1_val) {
|
||||||
|
const int num_args = 1;
|
||||||
|
uint8_t arg_type;
|
||||||
|
uint64_t arg_value;
|
||||||
|
SetTraceValue(std::forward<ARG1_TYPE>(arg1_val), &arg_type, &arg_value);
|
||||||
|
return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP(
|
||||||
|
phase, category_group_enabled, name, scope, id, bind_id, num_args,
|
||||||
|
&arg1_name, &arg_type, &arg_value, flags, timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class ARG1_TYPE, class ARG2_TYPE>
|
||||||
|
static V8_INLINE uint64_t AddTraceEventWithTimestamp(
|
||||||
|
char phase, const uint8_t* category_group_enabled, const char* name,
|
||||||
|
const char* scope, uint64_t id, uint64_t bind_id, unsigned int flags,
|
||||||
|
int64_t timestamp, const char* arg1_name, ARG1_TYPE&& arg1_val,
|
||||||
|
const char* arg2_name, ARG2_TYPE&& arg2_val) {
|
||||||
|
const int num_args = 2;
|
||||||
|
const char* arg_names[2] = {arg1_name, arg2_name};
|
||||||
|
unsigned char arg_types[2];
|
||||||
|
uint64_t arg_values[2];
|
||||||
|
SetTraceValue(std::forward<ARG1_TYPE>(arg1_val), &arg_types[0],
|
||||||
|
&arg_values[0]);
|
||||||
|
SetTraceValue(std::forward<ARG2_TYPE>(arg2_val), &arg_types[1],
|
||||||
|
&arg_values[1]);
|
||||||
|
return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP(
|
||||||
|
phase, category_group_enabled, name, scope, id, bind_id, num_args,
|
||||||
|
arg_names, arg_types, arg_values, flags, timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
// Used by TRACE_EVENTx macros. Do not use directly.
|
// Used by TRACE_EVENTx macros. Do not use directly.
|
||||||
class ScopedTracer {
|
class ScopedTracer {
|
||||||
public:
|
public:
|
||||||
|
@ -189,6 +189,8 @@
|
|||||||
// trace points would carry a significant performance cost of acquiring a lock
|
// trace points would carry a significant performance cost of acquiring a lock
|
||||||
// and resolving the category.
|
// and resolving the category.
|
||||||
|
|
||||||
|
// Check that nobody includes this file directly. Clients are supposed to
|
||||||
|
// include the surrounding "trace_event.h" of their project instead.
|
||||||
#if defined(TRACE_EVENT0)
|
#if defined(TRACE_EVENT0)
|
||||||
#error "Another copy of this file has already been included."
|
#error "Another copy of this file has already been included."
|
||||||
#endif
|
#endif
|
||||||
@ -258,6 +260,12 @@
|
|||||||
TRACE_EVENT_PHASE_INSTANT, category_group, name, timestamp, \
|
TRACE_EVENT_PHASE_INSTANT, category_group, name, timestamp, \
|
||||||
TRACE_EVENT_FLAG_NONE | scope)
|
TRACE_EVENT_FLAG_NONE | scope)
|
||||||
|
|
||||||
|
#define TRACE_EVENT_INSTANT_WITH_TIMESTAMP1(category_group, name, scope, \
|
||||||
|
timestamp, arg_name, arg_val) \
|
||||||
|
INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP( \
|
||||||
|
TRACE_EVENT_PHASE_INSTANT, category_group, name, timestamp, \
|
||||||
|
TRACE_EVENT_FLAG_NONE | scope, arg_name, arg_val)
|
||||||
|
|
||||||
// Records a single BEGIN event called "name" immediately, with 0, 1 or 2
|
// Records a single BEGIN event called "name" immediately, with 0, 1 or 2
|
||||||
// associated arguments. If the category is not enabled, then this
|
// associated arguments. If the category is not enabled, then this
|
||||||
// does nothing.
|
// does nothing.
|
||||||
@ -353,6 +361,12 @@
|
|||||||
TRACE_EVENT_PHASE_MARK, category_group, name, timestamp, \
|
TRACE_EVENT_PHASE_MARK, category_group, name, timestamp, \
|
||||||
TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
|
TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
|
||||||
|
|
||||||
|
#define TRACE_EVENT_MARK_WITH_TIMESTAMP2( \
|
||||||
|
category_group, name, timestamp, arg1_name, arg1_val, arg2_name, arg2_val) \
|
||||||
|
INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP( \
|
||||||
|
TRACE_EVENT_PHASE_MARK, category_group, name, timestamp, \
|
||||||
|
TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val)
|
||||||
|
|
||||||
#define TRACE_EVENT_COPY_MARK(category_group, name) \
|
#define TRACE_EVENT_COPY_MARK(category_group, name) \
|
||||||
INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_MARK, category_group, name, \
|
INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_MARK, category_group, name, \
|
||||||
TRACE_EVENT_FLAG_COPY)
|
TRACE_EVENT_FLAG_COPY)
|
||||||
@ -771,13 +785,22 @@
|
|||||||
INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
|
INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
|
||||||
TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, category_group, name, id, \
|
TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, category_group, name, id, \
|
||||||
TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE)
|
TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE)
|
||||||
|
|
||||||
#define TRACE_EVENT_NESTABLE_ASYNC_END_WITH_TIMESTAMP0(category_group, name, \
|
#define TRACE_EVENT_NESTABLE_ASYNC_END_WITH_TIMESTAMP0(category_group, name, \
|
||||||
id, timestamp) \
|
id, timestamp) \
|
||||||
INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
|
INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
|
||||||
TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, category_group, name, id, \
|
TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, category_group, name, id, \
|
||||||
TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE)
|
TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE)
|
||||||
|
#define TRACE_EVENT_NESTABLE_ASYNC_END_WITH_TIMESTAMP1( \
|
||||||
|
category_group, name, id, timestamp, arg1_name, arg1_val) \
|
||||||
|
INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
|
||||||
|
TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, category_group, name, id, \
|
||||||
|
TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE, \
|
||||||
|
arg1_name, arg1_val)
|
||||||
|
#define TRACE_EVENT_NESTABLE_ASYNC_INSTANT_WITH_TIMESTAMP0( \
|
||||||
|
category_group, name, id, timestamp) \
|
||||||
|
INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
|
||||||
|
TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT, category_group, name, id, \
|
||||||
|
TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE)
|
||||||
#define TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0( \
|
#define TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0( \
|
||||||
category_group, name, id, timestamp) \
|
category_group, name, id, timestamp) \
|
||||||
INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
|
INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user