Chromium Code Reviews| Index: include/v8.h |
| diff --git a/include/v8.h b/include/v8.h |
| index e4c7087d304d8d88da2b7f12a7c903566021805f..a83be2612be50b8dc215dbcfc090a0db9f53f9cb 100644 |
| --- a/include/v8.h |
| +++ b/include/v8.h |
| @@ -55,6 +55,21 @@ |
| #endif // V8_OS_WIN |
| +#if V8_OS_POSIX && !V8_OS_CYGWIN |
| +#include <ucontext.h> |
| +typedef ucontext_t context_t; |
| +#elif V8_OS_WIN || V8_OS_CYGWIN |
| +#include "src/base/win32-headers.h" |
| +/* #include <windows.h> */ |
| +/* #if !defined(__MINGW32__) || defined(__MINGW64_VERSION_MAJOR) */ |
|
yurys
2014/09/19 08:08:11
We shouldn't expose all this platform-specific stu
|
| +/* #include <dbghelp.h> // For SymLoadModule64 and al. */ |
| +/* #endif // !defined(__MINGW32__) || defined(__MINGW64_VERSION_MAJOR) */ |
| +/* #include <ws2tcpip.h> */ |
| +/* #undef CONST */ |
| +/* #undef STRICT */ |
| +typedef CONTEXT context_t; |
| +#endif |
| + |
| /** |
| * The v8 JavaScript engine. |
| */ |
| @@ -1415,6 +1430,41 @@ class V8_EXPORT StackFrame { |
| }; |
| +struct RegisterState { |
| + RegisterState() : pc(NULL), sp(NULL), fp(NULL) {} |
| + explicit RegisterState(const context_t& context); |
|
yurys
2014/09/19 08:08:11
This is a platform-specific constructor, please do
|
| + void* pc; // Instruction pointer. |
| + void* sp; // Stack pointer. |
| + void* fp; // Frame pointer. |
| +}; |
| + |
| + |
| +/** |
| + * Isolate::GetSample collects the current JS execution state as a sample. |
| + * A collected sample contains program counter values. |
| + */ |
| +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. |
| */ |
| @@ -4549,6 +4599,17 @@ class V8_EXPORT Isolate { |
| void GetHeapStatistics(HeapStatistics* heap_statistics); |
| /** |
| + * Get a sample from the isolate. |
| + * \param sp Stack pointer. |
|
yurys
2014/09/19 08:08:11
There are not such params, they are passed as |sta
|
| + * \param fp Frame pointer. |
| + * \param sample Pointer to (a pre-allocated) sample which will be filled. |
| + * \note GetSample should only be called when the JS thread is paused or |
| + * interrupted. If that is not the case, |
| + * GetSample behaviour is undefined. |
| + */ |
| + void GetSample(const RegisterState& state, 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 |