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

Side by Side Diff: runtime/vm/profiler.h

Issue 131853007: Add flag to control number of stack frames collected by profiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 | « no previous file | runtime/vm/profiler.cc » ('j') | runtime/vm/profiler.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_PROFILER_H_ 5 #ifndef VM_PROFILER_H_
6 #define VM_PROFILER_H_ 6 #define VM_PROFILER_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/code_observers.h" 9 #include "vm/code_observers.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
11 #include "vm/thread.h" 11 #include "vm/thread.h"
12 #include "vm/thread_interrupter.h" 12 #include "vm/thread_interrupter.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 // Forward declarations. 16 // Forward declarations.
17 class JSONArray; 17 class JSONArray;
18 class JSONStream; 18 class JSONStream;
19 class ProfilerCodeRegionTable; 19 class ProfilerCodeRegionTable;
20 struct Sample; 20 struct Sample;
21 class SampleBuffer;
21 22
22 // Profiler 23 // Profiler
23 class Profiler : public AllStatic { 24 class Profiler : public AllStatic {
24 public: 25 public:
25 static void InitOnce(); 26 static void InitOnce();
26 static void Shutdown(); 27 static void Shutdown();
27 28
28 static void InitProfilingForIsolate(Isolate* isolate, 29 static void InitProfilingForIsolate(Isolate* isolate,
29 bool shared_buffer = true); 30 bool shared_buffer = true);
30 static void ShutdownProfilingForIsolate(Isolate* isolate); 31 static void ShutdownProfilingForIsolate(Isolate* isolate);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 75 }
75 76
76 private: 77 private:
77 SampleBuffer* sample_buffer_; 78 SampleBuffer* sample_buffer_;
78 bool own_sample_buffer_; 79 bool own_sample_buffer_;
79 DISALLOW_COPY_AND_ASSIGN(IsolateProfilerData); 80 DISALLOW_COPY_AND_ASSIGN(IsolateProfilerData);
80 }; 81 };
81 82
82 83
83 // Profile sample. 84 // Profile sample.
84 struct Sample { 85 struct Sample {
siva 2014/01/16 23:34:23 why not just make it class Sample ?
Cutch 2014/01/17 16:02:25 Done.
85 static const intptr_t kNumStackFrames = 6;
86 enum SampleType { 86 enum SampleType {
87 kIsolateStart,
88 kIsolateStop,
89 kIsolateSample, 87 kIsolateSample,
90 }; 88 };
89
91 int64_t timestamp; 90 int64_t timestamp;
92 ThreadId tid; 91 ThreadId tid;
93 Isolate* isolate; 92 Isolate* isolate;
94 uintptr_t pcs[kNumStackFrames];
95 SampleType type; 93 SampleType type;
96 uint16_t vm_tags; 94 uint16_t vm_tags;
97 uint16_t runtime_tags; 95 uint16_t runtime_tags;
96 uintptr_t pcs[0];
siva 2014/01/16 23:34:23 Document that this needs to be the last field, no
Cutch 2014/01/17 16:02:25 Done.
98 97
99 void Init(SampleType type, Isolate* isolate, int64_t timestamp, ThreadId tid); 98 void Init(SampleType type, Isolate* isolate, int64_t timestamp, ThreadId tid);
99 void CopyInto(Sample* dst) const;
100
101 static Sample* Allocate();
102 static intptr_t InstanceSize();
103
104 private:
105 DISALLOW_COPY_AND_ASSIGN(Sample);
100 }; 106 };
101 107
102 108
103 // Ring buffer of samples. 109 // Ring buffer of samples.
104 class SampleBuffer { 110 class SampleBuffer {
105 public: 111 public:
106 static const intptr_t kDefaultBufferCapacity = 120000; // 2 minutes @ 1000hz. 112 static const intptr_t kDefaultBufferCapacity = 120000; // 2 minutes @ 1000hz.
107 113
108 explicit SampleBuffer(intptr_t capacity = kDefaultBufferCapacity); 114 explicit SampleBuffer(intptr_t capacity = kDefaultBufferCapacity);
109 ~SampleBuffer(); 115 ~SampleBuffer();
110 116
111 intptr_t capacity() const { return capacity_; } 117 intptr_t capacity() const { return capacity_; }
112
113 Sample* ReserveSample(); 118 Sample* ReserveSample();
114 119 void CopySample(intptr_t i, Sample* sample) const;
115 Sample GetSample(intptr_t i) const { 120 Sample* At(intptr_t idx) const;
116 ASSERT(i >= 0);
117 ASSERT(i < capacity_);
118 return samples_[i];
119 }
120 121
121 private: 122 private:
122 Sample* samples_; 123 Sample* samples_;
123 intptr_t capacity_; 124 intptr_t capacity_;
124 uintptr_t cursor_; 125 uintptr_t cursor_;
125 126
126 DISALLOW_COPY_AND_ASSIGN(SampleBuffer); 127 DISALLOW_COPY_AND_ASSIGN(SampleBuffer);
127 }; 128 };
128 129
129 130
(...skipping 22 matching lines...) Expand all
152 const uintptr_t original_pc_; 153 const uintptr_t original_pc_;
153 const uintptr_t original_fp_; 154 const uintptr_t original_fp_;
154 const uintptr_t original_sp_; 155 const uintptr_t original_sp_;
155 uintptr_t lower_bound_; 156 uintptr_t lower_bound_;
156 }; 157 };
157 158
158 159
159 } // namespace dart 160 } // namespace dart
160 161
161 #endif // VM_PROFILER_H_ 162 #endif // VM_PROFILER_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/profiler.cc » ('j') | runtime/vm/profiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698