summaryrefslogtreecommitdiff
path: root/deps/v8/src/tracing/trace-event.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/tracing/trace-event.h')
-rw-r--r--deps/v8/src/tracing/trace-event.h93
1 files changed, 91 insertions, 2 deletions
diff --git a/deps/v8/src/tracing/trace-event.h b/deps/v8/src/tracing/trace-event.h
index 6ca39506f4..0ff2b82503 100644
--- a/deps/v8/src/tracing/trace-event.h
+++ b/deps/v8/src/tracing/trace-event.h
@@ -96,6 +96,23 @@ enum CategoryGroupEnabledFlags {
// unsigned int flags)
#define TRACE_EVENT_API_ADD_TRACE_EVENT v8::internal::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 \
+ v8::internal::tracing::AddTraceEventWithTimestampImpl
+
// Set the duration field of a COMPLETE trace event.
// void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
// const uint8_t* category_group_enabled,
@@ -212,10 +229,18 @@ enum CategoryGroupEnabledFlags {
} \
} 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, \
timestamp, flags, ...) \
- UNIMPLEMENTED()
+ do { \
+ INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
+ if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
+ v8::internal::tracing::AddTraceEventWithTimestamp( \
+ phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \
+ v8::internal::tracing::kGlobalScope, v8::internal::tracing::kNoId, \
+ v8::internal::tracing::kNoId, flags, timestamp, ##__VA_ARGS__); \
+ } \
+ } while (0)
// Adds a trace event with a given id and timestamp. Not Implemented.
#define INTERNAL_TRACE_EVENT_ADD_WITH_ID_AND_TIMESTAMP( \
@@ -431,6 +456,28 @@ static V8_INLINE uint64_t AddTraceEventImpl(
arg_values, arg_convertables, 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<ConvertableToTraceFormat> arg_convertables[2];
+ if (num_args > 0 && arg_types[0] == TRACE_VALUE_TYPE_CONVERTABLE) {
+ arg_convertables[0].reset(reinterpret_cast<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<ConvertableToTraceFormat*>(
+ static_cast<intptr_t>(arg_values[1])));
+ }
+ DCHECK_LE(num_args, 2);
+ v8::TracingController* controller =
+ v8::internal::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
// value in the return arguments. This allows this API to avoid declaring any
// structures so that it is portable to third_party libraries.
@@ -533,6 +580,48 @@ static V8_INLINE uint64_t AddTraceEvent(
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.
class ScopedTracer {
public: