Index: src/sampler.h |
diff --git a/src/sampler.h b/src/sampler.h |
index c3dce4ed7c2fec7e353cb06d1641f63e82092a84..197bdba67972220f73e4016a22fcf51579c30560 100644 |
--- a/src/sampler.h |
+++ b/src/sampler.h |
@@ -5,14 +5,30 @@ |
#ifndef V8_SAMPLER_H_ |
#define V8_SAMPLER_H_ |
+#include "include/v8.h" |
+ |
#include "src/base/atomicops.h" |
#include "src/frames.h" |
#include "src/globals.h" |
+#if V8_OS_WIN || V8_OS_CYGWIN |
+#include "src/base/win32-headers.h" |
+#endif |
+ |
namespace v8 { |
namespace internal { |
class Isolate; |
+class SignalHandler; |
alph
2014/09/17 11:55:43
seems to be unused in the header.
|
+ |
+class ScopedSemaphore { |
+ public: |
+ explicit ScopedSemaphore(base::Semaphore* sem) {semaphore_ = sem;} |
alph
2014/09/17 11:55:43
nit: should be an initializer.
|
+ ~ScopedSemaphore() {semaphore_->Signal();} |
+ private: |
+ base::Semaphore* semaphore_; |
+}; |
+ |
// ---------------------------------------------------------------------------- |
// Sampler |
@@ -34,21 +50,20 @@ struct TickSample { |
: state(OTHER), |
pc(NULL), |
external_callback(NULL), |
- frames_count(0), |
has_external_callback(false), |
top_frame_type(StackFrame::NONE) {} |
void Init(Isolate* isolate, const RegisterState& state); |
- StateTag state; // The state of the VM. |
- Address pc; // Instruction pointer. |
+ enum { kMaxFramesCount = 255u }; |
+ |
+ void* stack[kMaxFramesCount]; // Call stack. |
+ size_t frames_count; // Number of captured frames. |
+ StateTag state; // The state of the VM. |
+ Address pc; // Instruction pointer. |
union { |
Address tos; // Top stack value (*sp). |
Address external_callback; |
}; |
- static const unsigned kMaxFramesCountLog2 = 8; |
- static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1; |
- Address stack[kMaxFramesCount]; // Call stack. |
base::TimeTicks timestamp; |
- unsigned frames_count : kMaxFramesCountLog2; // Number of captured frames. |
bool has_external_callback : 1; |
StackFrame::Type top_frame_type : 4; |
}; |
@@ -59,6 +74,9 @@ class Sampler { |
static void SetUp(); |
static void TearDown(); |
+ // For new sampling API, initialize and install just the SignalHandler |
+ static void SetUpForNewSamplingAPI(); |
alph
2014/09/17 11:55:43
Avoid using words like 'old' and 'new' in the func
|
+ |
// Initialize sampler. |
Sampler(Isolate* isolate, int interval); |
virtual ~Sampler(); |
@@ -85,6 +103,13 @@ class Sampler { |
bool IsActive() const { return base::NoBarrier_Load(&active_); } |
void DoSample(); |
+#if V8_OS_POSIX && !V8_OS_CYGWIN |
+ static void GetSample(v8::Sample* sample); |
+#elif V8_OS_WIN || V8_OS_CYGWIN |
+ static void GetSample(Isolate* isolate, |
+ const CONTEXT& context, |
+ v8::Sample* sample); |
+#endif |
// If true next sample must be initiated on the profiler event processor |
// thread right after latest sample is processed. |
void SetHasProcessingThread(bool value) { |