 Chromium Code Reviews
 Chromium Code Reviews Issue 422593003:
  Initial GetSample implementation.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 422593003:
  Initial GetSample implementation.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| Index: include/v8.h | 
| diff --git a/include/v8.h b/include/v8.h | 
| index e3cd10fa8d690cca9ddf4ed5b8fdbc4a1f366f67..9b46a742dd1a7553c06a339e6688087684b285a6 100644 | 
| --- a/include/v8.h | 
| +++ b/include/v8.h | 
| @@ -1322,6 +1322,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 { | 
| @@ -4319,6 +4354,11 @@ class V8_EXPORT Isolate { | 
| void GetHeapStatistics(HeapStatistics* heap_statistics); | 
| /** | 
| + * Get a sample from the isolate. | 
| + */ | 
| + void GetSample(Sample* sample); | 
| 
yurys
2014/09/09 14:35:20
This is not what the document proposed. The idea w
 
jochen (gone - plz use gerrit)
2014/09/10 07:39:20
Agreed.
We'll soon delete threads from v8 and ins
 
gholap
2014/09/17 02:35:06
Acknowledged.
 | 
| + | 
| + /** | 
| * 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 |