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 2061623002: Introduce JIT code events dispatcher for the isolate. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebaseline 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/objects.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 "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/base/atomic-utils.h" 9 #include "src/base/atomic-utils.h"
10 #include "src/base/atomicops.h" 10 #include "src/base/atomicops.h"
11 #include "src/base/platform/time.h" 11 #include "src/base/platform/time.h"
12 #include "src/compiler.h" 12 #include "src/compiler.h"
13 #include "src/isolate.h"
13 #include "src/libsampler/v8-sampler.h" 14 #include "src/libsampler/v8-sampler.h"
14 #include "src/locked-queue.h" 15 #include "src/locked-queue.h"
15 #include "src/profiler/circular-queue.h" 16 #include "src/profiler/circular-queue.h"
16 #include "src/profiler/tick-sample.h" 17 #include "src/profiler/tick-sample.h"
17 18
18 namespace v8 { 19 namespace v8 {
19 namespace internal { 20 namespace internal {
20 21
21 // Forward declarations. 22 // Forward declarations.
22 class CodeEntry; 23 class CodeEntry;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 static const size_t kTickSampleBufferSize = 1 * MB; 174 static const size_t kTickSampleBufferSize = 1 * MB;
174 static const size_t kTickSampleQueueLength = 175 static const size_t kTickSampleQueueLength =
175 kTickSampleBufferSize / sizeof(TickSampleEventRecord); 176 kTickSampleBufferSize / sizeof(TickSampleEventRecord);
176 SamplingCircularQueue<TickSampleEventRecord, 177 SamplingCircularQueue<TickSampleEventRecord,
177 kTickSampleQueueLength> ticks_buffer_; 178 kTickSampleQueueLength> ticks_buffer_;
178 LockedQueue<TickSampleEventRecord> ticks_from_vm_buffer_; 179 LockedQueue<TickSampleEventRecord> ticks_from_vm_buffer_;
179 base::AtomicNumber<unsigned> last_code_event_id_; 180 base::AtomicNumber<unsigned> last_code_event_id_;
180 unsigned last_processed_code_event_id_; 181 unsigned last_processed_code_event_id_;
181 }; 182 };
182 183
183 #define PROFILE(IsolateGetter, Call) \
184 do { \
185 Isolate* the_isolate = (IsolateGetter); \
186 v8::internal::Logger* logger = the_isolate->logger(); \
187 if (logger->is_logging_code_events() || the_isolate->is_profiling()) { \
188 logger->Call; \
189 } \
190 } while (false)
191
192 class CpuProfiler : public CodeEventListener { 184 class CpuProfiler : public CodeEventListener {
193 public: 185 public:
194 explicit CpuProfiler(Isolate* isolate); 186 explicit CpuProfiler(Isolate* isolate);
195 187
196 CpuProfiler(Isolate* isolate, 188 CpuProfiler(Isolate* isolate,
197 CpuProfilesCollection* test_collection, 189 CpuProfilesCollection* test_collection,
198 ProfileGenerator* test_generator, 190 ProfileGenerator* test_generator,
199 ProfilerEventsProcessor* test_processor); 191 ProfilerEventsProcessor* test_processor);
200 192
201 ~CpuProfiler() override; 193 ~CpuProfiler() override;
202 194
203 void set_sampling_interval(base::TimeDelta value); 195 void set_sampling_interval(base::TimeDelta value);
204 void CollectSample(); 196 void CollectSample();
205 void StartProfiling(const char* title, bool record_samples = false); 197 void StartProfiling(const char* title, bool record_samples = false);
206 void StartProfiling(String* title, bool record_samples); 198 void StartProfiling(String* title, bool record_samples);
207 CpuProfile* StopProfiling(const char* title); 199 CpuProfile* StopProfiling(const char* title);
208 CpuProfile* StopProfiling(String* title); 200 CpuProfile* StopProfiling(String* title);
209 int GetProfilesCount(); 201 int GetProfilesCount();
210 CpuProfile* GetProfile(int index); 202 CpuProfile* GetProfile(int index);
211 void DeleteAllProfiles(); 203 void DeleteAllProfiles();
212 void DeleteProfile(CpuProfile* profile); 204 void DeleteProfile(CpuProfile* profile);
213 205
214 // Invoked from stack sampler (thread or signal handler.) 206 // Invoked from stack sampler (thread or signal handler.)
215 inline TickSample* StartTickSample(); 207 inline TickSample* StartTickSample();
216 inline void FinishTickSample(); 208 inline void FinishTickSample();
217 209
218 // Must be called via PROFILE macro, otherwise will crash when 210 // Must be called via PROFILE macro, otherwise will crash when
219 // profiling is not enabled. 211 // profiling is not enabled.
220 void CallbackEvent(Name* name, Address entry_point) override; 212 void CallbackEvent(Name* name, Address entry_point) override;
221 void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, 213 void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
222 const char* comment) override; 214 const char* comment) override;
223 void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, 215 void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
224 Name* name) override; 216 Name* name) override;
225 void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, 217 void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
226 SharedFunctionInfo* shared, Name* script_name) override; 218 SharedFunctionInfo* shared, Name* script_name) override;
227 void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, 219 void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
228 SharedFunctionInfo* shared, Name* script_name, int line, 220 SharedFunctionInfo* shared, Name* script_name, int line,
229 int column) override; 221 int column) override;
230 void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, 222 void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
231 int args_count) override; 223 int args_count) override;
232 void CodeMovingGCEvent() override {} 224 void CodeMovingGCEvent() override {}
233 void CodeMoveEvent(AbstractCode* from, Address to) override; 225 void CodeMoveEvent(AbstractCode* from, Address to) override;
234 void CodeDisableOptEvent(AbstractCode* code, 226 void CodeDisableOptEvent(AbstractCode* code,
235 SharedFunctionInfo* shared) override; 227 SharedFunctionInfo* shared) override;
236 void CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta); 228 void CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta) override;
237 void GetterCallbackEvent(Name* name, Address entry_point) override; 229 void GetterCallbackEvent(Name* name, Address entry_point) override;
238 void RegExpCodeCreateEvent(AbstractCode* code, String* source) override; 230 void RegExpCodeCreateEvent(AbstractCode* code, String* source) override;
239 void SetterCallbackEvent(Name* name, Address entry_point) override; 231 void SetterCallbackEvent(Name* name, Address entry_point) override;
240 void SharedFunctionInfoMoveEvent(Address from, Address to) override {} 232 void SharedFunctionInfoMoveEvent(Address from, Address to) override {}
241 233
242 bool is_profiling() const { return is_profiling_; } 234 bool is_profiling() const { return is_profiling_; }
243 235
244 ProfileGenerator* generator() const { return generator_; } 236 ProfileGenerator* generator() const { return generator_; }
245 ProfilerEventsProcessor* processor() const { return processor_; } 237 ProfilerEventsProcessor* processor() const { return processor_; }
246 Isolate* isolate() const { return isolate_; } 238 Isolate* isolate() const { return isolate_; }
(...skipping 17 matching lines...) Expand all
264 bool is_profiling_; 256 bool is_profiling_;
265 257
266 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); 258 DISALLOW_COPY_AND_ASSIGN(CpuProfiler);
267 }; 259 };
268 260
269 } // namespace internal 261 } // namespace internal
270 } // namespace v8 262 } // namespace v8
271 263
272 264
273 #endif // V8_PROFILER_CPU_PROFILER_H_ 265 #endif // V8_PROFILER_CPU_PROFILER_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/profiler/cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698