Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/tracing/trace-event.h')
-rw-r--r--deps/v8/src/tracing/trace-event.h47
1 files changed, 45 insertions, 2 deletions
diff --git a/deps/v8/src/tracing/trace-event.h b/deps/v8/src/tracing/trace-event.h
index 0a650a8ebb7..816e79c5232 100644
--- a/deps/v8/src/tracing/trace-event.h
+++ b/deps/v8/src/tracing/trace-event.h
@@ -8,7 +8,13 @@
#include <stddef.h>
#include <memory>
+#if defined(V8_USE_PERFETTO)
+#include "protos/perfetto/trace/track_event/debug_annotation.pbzero.h"
+#include "src/tracing/trace-categories.h"
+#else
#include "base/trace_event/common/trace_event_common.h"
+#endif // !defined(V8_USE_PERFETTO)
+
#include "include/v8-platform.h"
#include "src/base/atomicops.h"
#include "src/base/macros.h"
@@ -32,6 +38,8 @@ enum CategoryGroupEnabledFlags {
kEnabledForETWExport_CategoryGroupEnabledFlags = 1 << 3,
};
+#if !defined(V8_USE_PERFETTO)
+
// TODO(petermarshall): Remove with the old tracing implementation - Perfetto
// copies const char* arguments by default.
// By default, const char* argument values are assumed to have long-lived scope
@@ -284,8 +292,8 @@ class Isolate;
namespace tracing {
-// Specify these values when the corresponding argument of AddTraceEvent is not
-// used.
+// Specify these values when the corresponding argument of AddTraceEvent
+// is not used.
const int kZeroNumArgs = 0;
const decltype(nullptr) kGlobalScope = nullptr;
const uint64_t kNoId = 0;
@@ -605,4 +613,39 @@ class CallStatsScopedTracer {
} // namespace internal
} // namespace v8
+#else // defined(V8_USE_PERFETTO)
+
+#define TRACE_EVENT_CALL_STATS_SCOPED(isolate, category, name) \
+ struct PERFETTO_UID(ScopedEvent) { \
+ struct ScopedStats { \
+ ScopedStats(v8::internal::Isolate* isolate_arg, int) { \
+ TRACE_EVENT_BEGIN(category, name, [&](perfetto::EventContext) { \
+ isolate_ = isolate_arg; \
+ internal::RuntimeCallStats* table = \
+ isolate_->counters()->runtime_call_stats(); \
+ has_parent_scope_ = table->InUse(); \
+ if (!has_parent_scope_) table->Reset(); \
+ }); \
+ } \
+ ~ScopedStats() { \
+ TRACE_EVENT_END(category, [&](perfetto::EventContext ctx) { \
+ if (!has_parent_scope_ && isolate_) { \
+ /* TODO(skyostil): Write as typed event instead of JSON */ \
+ auto value = v8::tracing::TracedValue::Create(); \
+ isolate_->counters()->runtime_call_stats()->Dump(value.get()); \
+ auto annotation = ctx.event()->add_debug_annotations(); \
+ annotation->set_name("runtime-call-stats"); \
+ value->Add(annotation); \
+ } \
+ }); \
+ } \
+ v8::internal::Isolate* isolate_; \
+ bool has_parent_scope_; \
+ } stats; \
+ } PERFETTO_UID(scoped_event) { \
+ { isolate, 0 } \
+ }
+
+#endif // defined(V8_USE_PERFETTO)
+
#endif // V8_TRACING_TRACE_EVENT_H_