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

Side by Side Diff: src/profiler/cpu-profiler.h

Issue 2079273003: Revert of Refactor CpuProfiler. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « src/log.cc ('k') | src/profiler/cpu-profiler.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_CPU_PROFILER_H_ 5 #ifndef V8_PROFILER_CPU_PROFILER_H_
6 #define V8_PROFILER_CPU_PROFILER_H_ 6 #define V8_PROFILER_CPU_PROFILER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
11 #include "src/base/atomic-utils.h" 11 #include "src/base/atomic-utils.h"
12 #include "src/base/atomicops.h" 12 #include "src/base/atomicops.h"
13 #include "src/base/platform/time.h" 13 #include "src/base/platform/time.h"
14 #include "src/compiler.h" 14 #include "src/compiler.h"
15 #include "src/isolate.h" 15 #include "src/isolate.h"
16 #include "src/libsampler/v8-sampler.h" 16 #include "src/libsampler/v8-sampler.h"
17 #include "src/locked-queue.h" 17 #include "src/locked-queue.h"
18 #include "src/profiler/circular-queue.h" 18 #include "src/profiler/circular-queue.h"
19 #include "src/profiler/profiler-listener.h"
20 #include "src/profiler/tick-sample.h" 19 #include "src/profiler/tick-sample.h"
21 20
22 namespace v8 { 21 namespace v8 {
23 namespace internal { 22 namespace internal {
24 23
25 // Forward declarations. 24 // Forward declarations.
26 class CodeEntry; 25 class CodeEntry;
27 class CodeMap; 26 class CodeMap;
28 class CpuProfile; 27 class CpuProfile;
29 class CpuProfilesCollection; 28 class CpuProfilesCollection;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 INLINE(void UpdateCodeMap(CodeMap* code_map)); 78 INLINE(void UpdateCodeMap(CodeMap* code_map));
80 }; 79 };
81 80
82 81
83 class CodeDeoptEventRecord : public CodeEventRecord { 82 class CodeDeoptEventRecord : public CodeEventRecord {
84 public: 83 public:
85 Address start; 84 Address start;
86 const char* deopt_reason; 85 const char* deopt_reason;
87 SourcePosition position; 86 SourcePosition position;
88 int deopt_id; 87 int deopt_id;
89 void* pc;
90 int fp_to_sp_delta;
91 88
92 INLINE(void UpdateCodeMap(CodeMap* code_map)); 89 INLINE(void UpdateCodeMap(CodeMap* code_map));
93 }; 90 };
94 91
95 92
96 class ReportBuiltinEventRecord : public CodeEventRecord { 93 class ReportBuiltinEventRecord : public CodeEventRecord {
97 public: 94 public:
98 Address start; 95 Address start;
99 Builtins::Name builtin_id; 96 Builtins::Name builtin_id;
100 97
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 static const size_t kTickSampleBufferSize = 1 * MB; 176 static const size_t kTickSampleBufferSize = 1 * MB;
180 static const size_t kTickSampleQueueLength = 177 static const size_t kTickSampleQueueLength =
181 kTickSampleBufferSize / sizeof(TickSampleEventRecord); 178 kTickSampleBufferSize / sizeof(TickSampleEventRecord);
182 SamplingCircularQueue<TickSampleEventRecord, 179 SamplingCircularQueue<TickSampleEventRecord,
183 kTickSampleQueueLength> ticks_buffer_; 180 kTickSampleQueueLength> ticks_buffer_;
184 LockedQueue<TickSampleEventRecord> ticks_from_vm_buffer_; 181 LockedQueue<TickSampleEventRecord> ticks_from_vm_buffer_;
185 base::AtomicNumber<unsigned> last_code_event_id_; 182 base::AtomicNumber<unsigned> last_code_event_id_;
186 unsigned last_processed_code_event_id_; 183 unsigned last_processed_code_event_id_;
187 }; 184 };
188 185
189 class CpuProfiler : public CodeEventObserver { 186 class CpuProfiler : public CodeEventListener {
190 public: 187 public:
191 explicit CpuProfiler(Isolate* isolate); 188 explicit CpuProfiler(Isolate* isolate);
192 189
193 CpuProfiler(Isolate* isolate, CpuProfilesCollection* profiles, 190 CpuProfiler(Isolate* isolate, CpuProfilesCollection* profiles,
194 ProfileGenerator* test_generator, 191 ProfileGenerator* test_generator,
195 ProfilerEventsProcessor* test_processor); 192 ProfilerEventsProcessor* test_processor);
196 193
197 ~CpuProfiler() override; 194 ~CpuProfiler() override;
198 195
199 void set_sampling_interval(base::TimeDelta value); 196 void set_sampling_interval(base::TimeDelta value);
200 void CollectSample(); 197 void CollectSample();
201 void StartProfiling(const char* title, bool record_samples = false); 198 void StartProfiling(const char* title, bool record_samples = false);
202 void StartProfiling(String* title, bool record_samples); 199 void StartProfiling(String* title, bool record_samples);
203 CpuProfile* StopProfiling(const char* title); 200 CpuProfile* StopProfiling(const char* title);
204 CpuProfile* StopProfiling(String* title); 201 CpuProfile* StopProfiling(String* title);
205 int GetProfilesCount(); 202 int GetProfilesCount();
206 CpuProfile* GetProfile(int index); 203 CpuProfile* GetProfile(int index);
207 void DeleteAllProfiles(); 204 void DeleteAllProfiles();
208 void DeleteProfile(CpuProfile* profile); 205 void DeleteProfile(CpuProfile* profile);
209 206
210 void CodeEventHandler(const CodeEventsContainer& evt_rec) override;
211
212 // Invoked from stack sampler (thread or signal handler.) 207 // Invoked from stack sampler (thread or signal handler.)
213 inline TickSample* StartTickSample(); 208 inline TickSample* StartTickSample();
214 inline void FinishTickSample(); 209 inline void FinishTickSample();
215 210
211 // Must be called via PROFILE macro, otherwise will crash when
212 // profiling is not enabled.
213 void CallbackEvent(Name* name, Address entry_point) override;
214 void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
215 const char* comment) override;
216 void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
217 Name* name) override;
218 void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
219 SharedFunctionInfo* shared, Name* script_name) override;
220 void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
221 SharedFunctionInfo* shared, Name* script_name, int line,
222 int column) override;
223 void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
224 int args_count) override;
225 void CodeMovingGCEvent() override {}
226 void CodeMoveEvent(AbstractCode* from, Address to) override;
227 void CodeDisableOptEvent(AbstractCode* code,
228 SharedFunctionInfo* shared) override;
229 void CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta) override;
230 void GetterCallbackEvent(Name* name, Address entry_point) override;
231 void RegExpCodeCreateEvent(AbstractCode* code, String* source) override;
232 void SetterCallbackEvent(Name* name, Address entry_point) override;
233 void SharedFunctionInfoMoveEvent(Address from, Address to) override {}
234
216 bool is_profiling() const { return is_profiling_; } 235 bool is_profiling() const { return is_profiling_; }
217 236
218 ProfileGenerator* generator() const { return generator_.get(); } 237 ProfileGenerator* generator() const { return generator_.get(); }
219 ProfilerEventsProcessor* processor() const { return processor_.get(); } 238 ProfilerEventsProcessor* processor() const { return processor_.get(); }
220 Isolate* isolate() const { return isolate_; } 239 Isolate* isolate() const { return isolate_; }
221 240
222 private: 241 private:
223 void StartProcessorIfNotStarted(); 242 void StartProcessorIfNotStarted();
224 void StopProcessorIfLastProfile(const char* title); 243 void StopProcessorIfLastProfile(const char* title);
225 void StopProcessor(); 244 void StopProcessor();
226 void ResetProfiles(); 245 void ResetProfiles();
227 void LogBuiltins(); 246 void LogBuiltins();
247 void RecordInliningInfo(CodeEntry* entry, AbstractCode* abstract_code);
248 void RecordDeoptInlinedFrames(CodeEntry* entry, AbstractCode* abstract_code);
249 Name* InferScriptName(Name* name, SharedFunctionInfo* info);
228 250
229 Isolate* const isolate_; 251 Isolate* const isolate_;
230 base::TimeDelta sampling_interval_; 252 base::TimeDelta sampling_interval_;
231 std::unique_ptr<CpuProfilesCollection> profiles_; 253 std::unique_ptr<CpuProfilesCollection> profiles_;
232 std::unique_ptr<ProfileGenerator> generator_; 254 std::unique_ptr<ProfileGenerator> generator_;
233 std::unique_ptr<ProfilerEventsProcessor> processor_; 255 std::unique_ptr<ProfilerEventsProcessor> processor_;
234 bool saved_is_logging_; 256 bool saved_is_logging_;
235 bool is_profiling_; 257 bool is_profiling_;
236 258
237 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); 259 DISALLOW_COPY_AND_ASSIGN(CpuProfiler);
238 }; 260 };
239 261
240 } // namespace internal 262 } // namespace internal
241 } // namespace v8 263 } // namespace v8
242 264
243 265
244 #endif // V8_PROFILER_CPU_PROFILER_H_ 266 #endif // V8_PROFILER_CPU_PROFILER_H_
OLDNEW
« no previous file with comments | « src/log.cc ('k') | src/profiler/cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698