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

Unified Diff: include/v8.h

Issue 422593003: Initial GetSample implementation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Made the Sample class into an iterable. 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.cc » ('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..8491b22272240fa7c4c0a855cec86053af87c1ed 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -1298,6 +1298,41 @@ class V8_EXPORT StackFrame {
/**
+ * Isolate::Getsample collects the current JS execution state as a sample.
alph 2014/09/08 12:47:40 nit: GetSample
gholap 2014/09/08 23:57:38 Done.
+ * 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:
+ void const* data_[kMaxSize];
alph 2014/09/08 12:47:40 nit: const void
gholap 2014/09/08 23:57:38 Done.
+ size_t size_;
+};
+
+/**
* A JSON Parser.
*/
class V8_EXPORT JSON {
@@ -4217,6 +4252,11 @@ class V8_EXPORT Isolate {
void GetHeapStatistics(HeapStatistics* heap_statistics);
/**
+ * Get a sample from the isolate.
+ */
+ void GetSample(Sample* sample);
+
+ /**
* 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.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698