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

Unified Diff: include/v8.h

Issue 422593003: Initial GetSample implementation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Moved thread logic out of GetSample Created 6 years, 3 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') | src/sampler.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 73384946ba7d93594fd5c3d78753dfe01c2726f6..b2a41b97ae60f9ddee7bc4e3b288f0670b26d059 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -17,6 +17,10 @@
#include "v8stdint.h"
+#if V8_OS_WIN || V8_OS_CYGWIN
+#include "src/base/win32-headers.h"
+#endif
+
// We reserve the V8_* prefix for macros defined in V8 public API and
// assume there are no name conflicts with the embedder's code.
@@ -1298,6 +1302,41 @@ class V8_EXPORT StackFrame {
/**
+ * Isolate::GetSample collects the current JS execution state as a sample.
+ * A collected sample contains program counter values.
+ *
+ * Example: Printing out the stack frames' addresses, from top to bottom.
+ *
+ * Isolate* isolate = Isolate::Current();
+ * Sample sample;
+ * isolate->GetSample(&sample);
+ * const void* const* i;
+ * for (i = sample.begin(); i != sample.end(); ++i) {
+ * printf("%p\n", *i);
+ * }
+ */
+class V8_EXPORT Sample {
+ public:
+ enum { kMaxSize = 255u };
+
+ Sample() : size_(0) {}
+ template <class InputIterator>
+ Sample(InputIterator first, InputIterator last) : size_(0) {
+ for (; first != last && size_ < kMaxSize; ++first)
+ data_[size_++] = *first;
+ }
+
+ typedef const void* const* const_iterator;
+ const_iterator begin() const { return &data_[0]; }
+ const_iterator end() const { return &data_[size_]; }
+ size_t size() const { return size_; }
+
+ private:
+ const void* data_[kMaxSize];
+ size_t size_;
+};
+
+/**
* A JSON Parser.
*/
class V8_EXPORT JSON {
@@ -4217,6 +4256,15 @@ class V8_EXPORT Isolate {
void GetHeapStatistics(HeapStatistics* heap_statistics);
/**
+ * Get a sample from the isolate.
+ */
+#if V8_OS_POSIX && !V8_OS_CYGWIN
+ void GetSample(Sample* sample);
+#elif V8_OS_WIN || V8_OS_CYGWIN
+ void GetSample(const CONTEXT& context, Sample* sample);
+#endif
+
+ /**
* Adjusts the amount of registered external memory. Used to give V8 an
* indication of the amount of externally allocated memory that is kept alive
* by JavaScript objects. V8 uses this to decide when to perform global
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/sampler.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698