Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1139)

Unified Diff: src/tracing/event-tracer.cc

Issue 988893003: Implement tracing interface for v8 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Minor Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/tracing/event-tracer.cc
diff --git a/src/tracing/event-tracer.cc b/src/tracing/event-tracer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..39c6e095bf4e47073b4c64e1261d6ea00e1b3c8c
--- /dev/null
+++ b/src/tracing/event-tracer.cc
@@ -0,0 +1,55 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <include/v8-tracing.h>
+
+#include "src/log.h"
+#include "src/v8.h"
+
+class DefaultEventTracer : public v8::EventTracer {
+ virtual v8::EventTracer::Handle AddTraceEvent(
+ char phase, const uint8_t* categoryEnabledFlag, const char* name,
+ uint64_t id, uint64_t context_id, uint64_t bind_id, int numArgs,
+ const char** argNames, const uint8_t* argTypes, const uint64_t* argValues,
+ unsigned int flags) {
+ return 0;
+ }
+
+ virtual void UpdateTraceEventDuration(const uint8_t* categoryEnabledFlag,
+ const char* name,
+ EventTracer::Handle handle) {}
+
+ virtual const uint8_t* GetCategoryGroupEnabled(const char* name) {
+ static uint8_t no = 0;
+ return &no;
+ }
+
+ virtual const char* GetCategoryGroupName(const uint8_t* categoryEnabledFlag) {
+ static const char* dummy = "dummy";
+ return dummy;
+ }
+};
+
+
+static void CleanupTracer() {
+ // calling SetInstance will delete the existing instance.
+ v8::EventTracer::SetInstance(NULL);
+}
+
+
+static void IntializeDefaultTracer(v8::EventTracer* current_instance) {
+ if (current_instance == NULL) {
+ v8::EventTracer::SetInstance(new (DefaultEventTracer));
+ }
dsinclair 2015/08/25 13:56:22 nit: no {}'s on single line bodies
fmeawad 2015/08/25 21:32:01 Done.
+ atexit(CleanupTracer);
+}
+
+
+V8_DECLARE_ONCE(init_once);
+v8::EventTracer* v8::EventTracer::instance;
+v8::EventTracer* v8::EventTracer::GetInstance() {
+ base::CallOnce(&init_once, IntializeDefaultTracer, v8::EventTracer::instance);
+ DCHECK(v8::EventTracer::instance);
+ return v8::EventTracer::instance;
+}

Powered by Google App Engine
This is Rietveld 408576698