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

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

Issue 151163005: A64: Synchronize with r16356. (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/cpu.cc ('k') | src/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 // 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 class TickSampleEventRecord { 108 class TickSampleEventRecord {
109 public: 109 public:
110 // The parameterless constructor is used when we dequeue data from 110 // The parameterless constructor is used when we dequeue data from
111 // the ticks buffer. 111 // the ticks buffer.
112 TickSampleEventRecord() { } 112 TickSampleEventRecord() { }
113 explicit TickSampleEventRecord(unsigned order) : order(order) { } 113 explicit TickSampleEventRecord(unsigned order) : order(order) { }
114 114
115 unsigned order; 115 unsigned order;
116 TickSample sample; 116 TickSample sample;
117
118 static TickSampleEventRecord* cast(void* value) {
119 return reinterpret_cast<TickSampleEventRecord*>(value);
120 }
121 }; 117 };
122 118
123 119
124 class CodeEventsContainer { 120 class CodeEventsContainer {
125 public: 121 public:
126 explicit CodeEventsContainer( 122 explicit CodeEventsContainer(
127 CodeEventRecord::Type type = CodeEventRecord::NONE) { 123 CodeEventRecord::Type type = CodeEventRecord::NONE) {
128 generic.type = type; 124 generic.type = type;
129 } 125 }
130 union { 126 union {
131 CodeEventRecord generic; 127 CodeEventRecord generic;
132 #define DECLARE_CLASS(ignore, type) type type##_; 128 #define DECLARE_CLASS(ignore, type) type type##_;
133 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS) 129 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS)
134 #undef DECLARE_TYPE 130 #undef DECLARE_TYPE
135 }; 131 };
136 }; 132 };
137 133
138 134
139 // This class implements both the profile events processor thread and 135 // This class implements both the profile events processor thread and
140 // methods called by event producers: VM and stack sampler threads. 136 // methods called by event producers: VM and stack sampler threads.
141 class ProfilerEventsProcessor : public Thread { 137 class ProfilerEventsProcessor : public Thread {
142 public: 138 public:
143 explicit ProfilerEventsProcessor(ProfileGenerator* generator); 139 ProfilerEventsProcessor(ProfileGenerator* generator,
140 Sampler* sampler,
141 int period_in_useconds);
144 virtual ~ProfilerEventsProcessor() {} 142 virtual ~ProfilerEventsProcessor() {}
145 143
146 // Thread control. 144 // Thread control.
147 virtual void Run(); 145 virtual void Run();
148 void StopSynchronously(); 146 void StopSynchronously();
149 INLINE(bool running()) { return running_; } 147 INLINE(bool running()) { return running_; }
150 void Enqueue(const CodeEventsContainer& event); 148 void Enqueue(const CodeEventsContainer& event);
151 149
152 // Puts current stack into tick sample events buffer. 150 // Puts current stack into tick sample events buffer.
153 void AddCurrentStack(Isolate* isolate); 151 void AddCurrentStack(Isolate* isolate);
154 152
155 // Tick sample events are filled directly in the buffer of the circular 153 // Tick sample events are filled directly in the buffer of the circular
156 // queue (because the structure is of fixed width, but usually not all 154 // queue (because the structure is of fixed width, but usually not all
157 // stack frame entries are filled.) This method returns a pointer to the 155 // stack frame entries are filled.) This method returns a pointer to the
158 // next record of the buffer. 156 // next record of the buffer.
159 INLINE(TickSample* TickSampleEvent()); 157 inline TickSample* StartTickSample();
158 inline void FinishTickSample();
160 159
161 private: 160 private:
162 // Called from events processing thread (Run() method.) 161 // Called from events processing thread (Run() method.)
163 bool ProcessCodeEvent(); 162 bool ProcessCodeEvent();
164 bool ProcessTicks(); 163 bool ProcessTicks();
165 164
165 void ProcessEventsAndDoSample();
166 void ProcessEventsAndYield();
167
166 ProfileGenerator* generator_; 168 ProfileGenerator* generator_;
169 Sampler* sampler_;
167 bool running_; 170 bool running_;
171 // Sampling period in microseconds.
172 const int period_in_useconds_;
168 UnboundQueue<CodeEventsContainer> events_buffer_; 173 UnboundQueue<CodeEventsContainer> events_buffer_;
169 SamplingCircularQueue ticks_buffer_; 174 static const size_t kTickSampleBufferSize = 1 * MB;
175 static const size_t kTickSampleQueueLength =
176 kTickSampleBufferSize / sizeof(TickSampleEventRecord);
177 SamplingCircularQueue<TickSampleEventRecord,
178 kTickSampleQueueLength> ticks_buffer_;
170 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; 179 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_;
171 unsigned last_code_event_id_; 180 unsigned last_code_event_id_;
172 unsigned last_processed_code_event_id_; 181 unsigned last_processed_code_event_id_;
173 }; 182 };
174 183
175 184
176 #define PROFILE(IsolateGetter, Call) \ 185 #define PROFILE(IsolateGetter, Call) \
177 do { \ 186 do { \
178 Isolate* cpu_profiler_isolate = (IsolateGetter); \ 187 Isolate* cpu_profiler_isolate = (IsolateGetter); \
179 v8::internal::Logger* logger = cpu_profiler_isolate->logger(); \ 188 v8::internal::Logger* logger = cpu_profiler_isolate->logger(); \
(...skipping 18 matching lines...) Expand all
198 void StartProfiling(const char* title, bool record_samples = false); 207 void StartProfiling(const char* title, bool record_samples = false);
199 void StartProfiling(String* title, bool record_samples); 208 void StartProfiling(String* title, bool record_samples);
200 CpuProfile* StopProfiling(const char* title); 209 CpuProfile* StopProfiling(const char* title);
201 CpuProfile* StopProfiling(String* title); 210 CpuProfile* StopProfiling(String* title);
202 int GetProfilesCount(); 211 int GetProfilesCount();
203 CpuProfile* GetProfile(int index); 212 CpuProfile* GetProfile(int index);
204 void DeleteAllProfiles(); 213 void DeleteAllProfiles();
205 void DeleteProfile(CpuProfile* profile); 214 void DeleteProfile(CpuProfile* profile);
206 215
207 // Invoked from stack sampler (thread or signal handler.) 216 // Invoked from stack sampler (thread or signal handler.)
208 TickSample* TickSampleEvent(); 217 inline TickSample* StartTickSample();
218 inline void FinishTickSample();
209 219
210 // Must be called via PROFILE macro, otherwise will crash when 220 // Must be called via PROFILE macro, otherwise will crash when
211 // profiling is not enabled. 221 // profiling is not enabled.
212 virtual void CallbackEvent(Name* name, Address entry_point); 222 virtual void CallbackEvent(Name* name, Address entry_point);
213 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, 223 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
214 Code* code, const char* comment); 224 Code* code, const char* comment);
215 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, 225 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
216 Code* code, Name* name); 226 Code* code, Name* name);
217 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, 227 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
218 Code* code, 228 Code* code,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 bool need_to_stop_sampler_; 269 bool need_to_stop_sampler_;
260 bool is_profiling_; 270 bool is_profiling_;
261 271
262 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); 272 DISALLOW_COPY_AND_ASSIGN(CpuProfiler);
263 }; 273 };
264 274
265 } } // namespace v8::internal 275 } } // namespace v8::internal
266 276
267 277
268 #endif // V8_CPU_PROFILER_H_ 278 #endif // V8_CPU_PROFILER_H_
OLDNEW
« no previous file with comments | « src/cpu.cc ('k') | src/cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698