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

Unified Diff: include/v8-sampler.h

Issue 422593003: Initial GetSample implementation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed typo. Made sure SIGPROF handler is always installed. Added a test. Created 6 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
« no previous file with comments | « no previous file | src/api.cc » ('j') | test/cctest/test-sampler-api.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8-sampler.h
diff --git a/include/v8-sampler.h b/include/v8-sampler.h
new file mode 100644
index 0000000000000000000000000000000000000000..7e9177022e0cbe5aa0c3a5334dafca373e2fa55b
--- /dev/null
+++ b/include/v8-sampler.h
@@ -0,0 +1,60 @@
+// Copyright 2014 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.
+
+#ifndef V8_V8_SAMPLER_H_
+#define V8_V8_SAMPLER_H_
+
+#include "v8.h"
+
+/**
+ * Sampler API for the V8 JavaScript engine.
+ * The API to be consumed by any code which
+ * wants to build a sampling profiler for v8.
+ */
+namespace v8 {
+ /* TODO(gholap): This should go away and struct Sample should
+ just use const void* instead of Address.
+ Currently we need it because of implementation details. */
+ typedef unsigned char* Address;
+
+/**
+ * A collected sample contains,
+ * - state : The state of the VM at the time of collecting the sample.
+ * - stack : An array of addresses.
+ * One address per stack frame.
+ * The address is the instruction pointer,
+ * pointing to the instruction which led to the
+ * creation of the stack frame.
+ * (for example, a function call)
+ * - frames_count: Number of stack frames that were captured.
+ * That is, stack[frames_count+i] might contain meaningless
+ * addresses for any i >= 0.
+ */
+struct Sample {
+ Sample()
+ : frames_count(0) {}
+ static const unsigned kMaxFramesCountLog2 = 8;
+ static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1;
+
+ Address stack[kMaxFramesCount]; // Call stack.
+ unsigned frames_count : kMaxFramesCountLog2; // Number of captured frames.
+};
+
+/**
+ * Interface for collecting execution stack samples.
+ */
+class V8_EXPORT Sampler {
+ public:
+ /**
+ * Obtain a sample from the isolate.
+ * Updates the sample pointer with the newly obtained
+ * sampling information.
+ * On success, returns the sample pointer.
+ * On failure, returns NULL.
+ */
+ static Sample* GetSample(Isolate* isolate,
+ Sample* sample);
+};
+} // namespace v8
+#endif // V8_V8_SAMPLER_H_
« no previous file with comments | « no previous file | src/api.cc » ('j') | test/cctest/test-sampler-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698