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

Unified Diff: include/v8.h

Issue 578163002: Implemented GetSample. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Including win32-headers.h in v8.h for testing on trybots. 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/api.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 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
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698