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 |