| OLD | NEW | 
|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #ifndef V8_PROFILER_SAMPLER_H_ | 5 #ifndef V8_PROFILER_SAMPLER_H_ | 
| 6 #define V8_PROFILER_SAMPLER_H_ | 6 #define V8_PROFILER_SAMPLER_H_ | 
| 7 | 7 | 
| 8 #include "include/v8.h" | 8 #include "include/v8.h" | 
| 9 | 9 | 
| 10 #include "src/base/atomicops.h" | 10 #include "src/base/atomicops.h" | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 30   // include the runtime function we're calling. Externally exposed tick | 30   // include the runtime function we're calling. Externally exposed tick | 
| 31   // samples don't care. | 31   // samples don't care. | 
| 32   enum RecordCEntryFrame { kIncludeCEntryFrame, kSkipCEntryFrame }; | 32   enum RecordCEntryFrame { kIncludeCEntryFrame, kSkipCEntryFrame }; | 
| 33 | 33 | 
| 34   TickSample() | 34   TickSample() | 
| 35       : state(OTHER), | 35       : state(OTHER), | 
| 36         pc(NULL), | 36         pc(NULL), | 
| 37         external_callback(NULL), | 37         external_callback(NULL), | 
| 38         frames_count(0), | 38         frames_count(0), | 
| 39         has_external_callback(false), | 39         has_external_callback(false), | 
|  | 40         update_stats(true), | 
| 40         top_frame_type(StackFrame::NONE) {} | 41         top_frame_type(StackFrame::NONE) {} | 
| 41   void Init(Isolate* isolate, const v8::RegisterState& state, | 42   void Init(Isolate* isolate, const v8::RegisterState& state, | 
| 42             RecordCEntryFrame record_c_entry_frame); | 43             RecordCEntryFrame record_c_entry_frame, bool update_stats); | 
| 43   static void GetStackSample(Isolate* isolate, const v8::RegisterState& state, | 44   static void GetStackSample(Isolate* isolate, const v8::RegisterState& state, | 
| 44                              RecordCEntryFrame record_c_entry_frame, | 45                              RecordCEntryFrame record_c_entry_frame, | 
| 45                              void** frames, size_t frames_limit, | 46                              void** frames, size_t frames_limit, | 
| 46                              v8::SampleInfo* sample_info); | 47                              v8::SampleInfo* sample_info); | 
| 47   StateTag state;  // The state of the VM. | 48   StateTag state;  // The state of the VM. | 
| 48   Address pc;      // Instruction pointer. | 49   Address pc;      // Instruction pointer. | 
| 49   union { | 50   union { | 
| 50     Address tos;   // Top stack value (*sp). | 51     Address tos;   // Top stack value (*sp). | 
| 51     Address external_callback; | 52     Address external_callback; | 
| 52   }; | 53   }; | 
| 53   static const unsigned kMaxFramesCountLog2 = 8; | 54   static const unsigned kMaxFramesCountLog2 = 8; | 
| 54   static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1; | 55   static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1; | 
| 55   Address stack[kMaxFramesCount];  // Call stack. | 56   Address stack[kMaxFramesCount];  // Call stack. | 
| 56   base::TimeTicks timestamp; | 57   base::TimeTicks timestamp; | 
| 57   unsigned frames_count : kMaxFramesCountLog2;  // Number of captured frames. | 58   unsigned frames_count : kMaxFramesCountLog2;  // Number of captured frames. | 
| 58   bool has_external_callback : 1; | 59   bool has_external_callback : 1; | 
|  | 60   bool update_stats : 1;  // Whether the sample should update aggregated stats. | 
| 59   StackFrame::Type top_frame_type : 4; | 61   StackFrame::Type top_frame_type : 4; | 
| 60 }; | 62 }; | 
| 61 | 63 | 
| 62 class Sampler { | 64 class Sampler { | 
| 63  public: | 65  public: | 
| 64   // Initializes the Sampler support. Called once at VM startup. | 66   // Initializes the Sampler support. Called once at VM startup. | 
| 65   static void SetUp(); | 67   static void SetUp(); | 
| 66   static void TearDown(); | 68   static void TearDown(); | 
| 67 | 69 | 
| 68   // Initialize sampler. | 70   // Initialize sampler. | 
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 127   // Counts stack samples taken in JS VM state. | 129   // Counts stack samples taken in JS VM state. | 
| 128   unsigned js_and_external_sample_count_; | 130   unsigned js_and_external_sample_count_; | 
| 129   DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); | 131   DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); | 
| 130 }; | 132 }; | 
| 131 | 133 | 
| 132 | 134 | 
| 133 }  // namespace internal | 135 }  // namespace internal | 
| 134 }  // namespace v8 | 136 }  // namespace v8 | 
| 135 | 137 | 
| 136 #endif  // V8_PROFILER_SAMPLER_H_ | 138 #endif  // V8_PROFILER_SAMPLER_H_ | 
| OLD | NEW | 
|---|