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

Side by Side Diff: src/sampler.h

Issue 148503002: A64: Synchronize with r15545. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime-profiler.cc ('k') | src/sampler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_SAMPLER_H_ 28 #ifndef V8_SAMPLER_H_
29 #define V8_SAMPLER_H_ 29 #define V8_SAMPLER_H_
30 30
31 #include "atomicops.h" 31 #include "atomicops.h"
32 #include "frames.h"
32 #include "v8globals.h" 33 #include "v8globals.h"
33 34
34 namespace v8 { 35 namespace v8 {
35 namespace internal { 36 namespace internal {
36 37
37 class Isolate; 38 class Isolate;
38 39
39 // ---------------------------------------------------------------------------- 40 // ----------------------------------------------------------------------------
40 // Sampler 41 // Sampler
41 // 42 //
42 // A sampler periodically samples the state of the VM and optionally 43 // A sampler periodically samples the state of the VM and optionally
43 // (if used for profiling) the program counter and stack pointer for 44 // (if used for profiling) the program counter and stack pointer for
44 // the thread that created it. 45 // the thread that created it.
45 46
47 struct RegisterState {
48 RegisterState() : pc(NULL), sp(NULL), fp(NULL) {}
49 Address pc; // Instruction pointer.
50 Address sp; // Stack pointer.
51 Address fp; // Frame pointer.
52 };
53
46 // TickSample captures the information collected for each sample. 54 // TickSample captures the information collected for each sample.
47 struct TickSample { 55 struct TickSample {
48 TickSample() 56 TickSample()
49 : state(OTHER), 57 : state(OTHER),
50 pc(NULL), 58 pc(NULL),
51 sp(NULL),
52 fp(NULL),
53 external_callback(NULL), 59 external_callback(NULL),
54 frames_count(0), 60 frames_count(0),
55 has_external_callback(false) {} 61 has_external_callback(false),
56 void Trace(Isolate* isolate); 62 top_frame_type(StackFrame::NONE) {}
63 void Init(Isolate* isolate, const RegisterState& state);
57 StateTag state; // The state of the VM. 64 StateTag state; // The state of the VM.
58 Address pc; // Instruction pointer. 65 Address pc; // Instruction pointer.
59 Address sp; // Stack pointer.
60 Address fp; // Frame pointer.
61 union { 66 union {
62 Address tos; // Top stack value (*sp). 67 Address tos; // Top stack value (*sp).
63 Address external_callback; 68 Address external_callback;
64 }; 69 };
65 static const int kMaxFramesCount = 64; 70 static const int kMaxFramesCount = 64;
66 Address stack[kMaxFramesCount]; // Call stack. 71 Address stack[kMaxFramesCount]; // Call stack.
67 int frames_count : 8; // Number of captured frames. 72 int frames_count : 8; // Number of captured frames.
68 bool has_external_callback : 1; 73 bool has_external_callback : 1;
74 StackFrame::Type top_frame_type : 4;
69 }; 75 };
70 76
71 class Sampler { 77 class Sampler {
72 public: 78 public:
73 // Initializes the Sampler support. Called once at VM startup. 79 // Initializes the Sampler support. Called once at VM startup.
74 static void SetUp(); 80 static void SetUp();
75 static void TearDown(); 81 static void TearDown();
76 82
77 // Initialize sampler. 83 // Initialize sampler.
78 Sampler(Isolate* isolate, int interval); 84 Sampler(Isolate* isolate, int interval);
79 virtual ~Sampler(); 85 virtual ~Sampler();
80 86
81 Isolate* isolate() const { return isolate_; } 87 Isolate* isolate() const { return isolate_; }
82 int interval() const { return interval_; } 88 int interval() const { return interval_; }
83 89
84 // Performs stack sampling. 90 // Performs stack sampling.
85 void SampleStack(TickSample* sample); 91 void SampleStack(const RegisterState& regs);
86
87 // This method is called for each sampling period with the current
88 // program counter.
89 virtual void Tick(TickSample* sample) = 0;
90 92
91 // Start and stop sampler. 93 // Start and stop sampler.
92 void Start(); 94 void Start();
93 void Stop(); 95 void Stop();
94 96
95 // Is the sampler used for profiling? 97 // Is the sampler used for profiling?
96 bool IsProfiling() const { return NoBarrier_Load(&profiling_) > 0; } 98 bool IsProfiling() const { return NoBarrier_Load(&profiling_) > 0; }
97 void IncreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, 1); } 99 void IncreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, 1); }
98 void DecreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, -1); } 100 void DecreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, -1); }
99 101
100 // Whether the sampler is running (that is, consumes resources). 102 // Whether the sampler is running (that is, consumes resources).
101 bool IsActive() const { return NoBarrier_Load(&active_); } 103 bool IsActive() const { return NoBarrier_Load(&active_); }
102 104
103 // Used in tests to make sure that stack sampling is performed. 105 // Used in tests to make sure that stack sampling is performed.
104 int samples_taken() const { return samples_taken_; } 106 int samples_taken() const { return samples_taken_; }
105 void ResetSamplesTaken() { samples_taken_ = 0; } 107 void ResetSamplesTaken() { samples_taken_ = 0; }
106 108
107 class PlatformData; 109 class PlatformData;
108 PlatformData* platform_data() const { return data_; } 110 PlatformData* platform_data() const { return data_; }
109 111
112 protected:
113 // This method is called for each sampling period with the current
114 // program counter.
115 virtual void Tick(TickSample* sample) = 0;
116
110 private: 117 private:
111 void SetActive(bool value) { NoBarrier_Store(&active_, value); } 118 void SetActive(bool value) { NoBarrier_Store(&active_, value); }
112 119
113 Isolate* isolate_; 120 Isolate* isolate_;
114 const int interval_; 121 const int interval_;
115 Atomic32 profiling_; 122 Atomic32 profiling_;
116 Atomic32 active_; 123 Atomic32 active_;
117 PlatformData* data_; // Platform specific data. 124 PlatformData* data_; // Platform specific data.
118 int samples_taken_; // Counts stack samples taken. 125 int samples_taken_; // Counts stack samples taken.
119 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); 126 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
120 }; 127 };
121 128
122 129
123 } } // namespace v8::internal 130 } } // namespace v8::internal
124 131
125 #endif // V8_SAMPLER_H_ 132 #endif // V8_SAMPLER_H_
OLDNEW
« no previous file with comments | « src/runtime-profiler.cc ('k') | src/sampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698