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

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

Issue 11065034: Rollback trunk to bleeding_edge revision 12524 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 8 years, 2 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/arm/simulator-arm.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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 static TickSampleEventRecord* cast(void* value) { 117 static TickSampleEventRecord* cast(void* value) {
118 return reinterpret_cast<TickSampleEventRecord*>(value); 118 return reinterpret_cast<TickSampleEventRecord*>(value);
119 } 119 }
120 }; 120 };
121 121
122 122
123 // This class implements both the profile events processor thread and 123 // This class implements both the profile events processor thread and
124 // methods called by event producers: VM and stack sampler threads. 124 // methods called by event producers: VM and stack sampler threads.
125 class ProfilerEventsProcessor : public Thread { 125 class ProfilerEventsProcessor : public Thread {
126 public: 126 public:
127 explicit ProfilerEventsProcessor(ProfileGenerator* generator); 127 explicit ProfilerEventsProcessor(ProfileGenerator* generator,
128 Sampler* sampler,
129 int period_in_useconds);
128 virtual ~ProfilerEventsProcessor() {} 130 virtual ~ProfilerEventsProcessor() {}
129 131
130 // Thread control. 132 // Thread control.
131 virtual void Run(); 133 virtual void Run();
132 inline void Stop() { running_ = false; } 134 inline void Stop() { running_ = false; }
133 INLINE(bool running()) { return running_; } 135 INLINE(bool running()) { return running_; }
134 136
135 // Events adding methods. Called by VM threads. 137 // Events adding methods. Called by VM threads.
136 void CallbackCreateEvent(Logger::LogEventsAndTags tag, 138 void CallbackCreateEvent(Logger::LogEventsAndTags tag,
137 const char* prefix, String* name, 139 const char* prefix, String* name,
(...skipping 11 matching lines...) Expand all
149 Address start, unsigned size); 151 Address start, unsigned size);
150 void CodeMoveEvent(Address from, Address to); 152 void CodeMoveEvent(Address from, Address to);
151 void CodeDeleteEvent(Address from); 153 void CodeDeleteEvent(Address from);
152 void SharedFunctionInfoMoveEvent(Address from, Address to); 154 void SharedFunctionInfoMoveEvent(Address from, Address to);
153 void RegExpCodeCreateEvent(Logger::LogEventsAndTags tag, 155 void RegExpCodeCreateEvent(Logger::LogEventsAndTags tag,
154 const char* prefix, String* name, 156 const char* prefix, String* name,
155 Address start, unsigned size); 157 Address start, unsigned size);
156 // Puts current stack into tick sample events buffer. 158 // Puts current stack into tick sample events buffer.
157 void AddCurrentStack(); 159 void AddCurrentStack();
158 160
159 // Tick sample events are filled directly in the buffer of the circular 161 // StartTickSampleEvent returns a pointer only if the ticks_buffer_ is empty,
160 // queue (because the structure is of fixed width, but usually not all 162 // FinishTickSampleEvent marks the ticks_buffer_ as filled.
161 // stack frame entries are filled.) This method returns a pointer to the 163 // Finish should be called only after successful Start (returning non-NULL
162 // next record of the buffer. 164 // pointer).
163 INLINE(TickSample* TickSampleEvent()); 165 INLINE(TickSample* StartTickSampleEvent());
166 INLINE(void FinishTickSampleEvent());
164 167
165 private: 168 private:
166 union CodeEventsContainer { 169 union CodeEventsContainer {
167 CodeEventRecord generic; 170 CodeEventRecord generic;
168 #define DECLARE_CLASS(ignore, type) type type##_; 171 #define DECLARE_CLASS(ignore, type) type type##_;
169 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS) 172 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS)
170 #undef DECLARE_TYPE 173 #undef DECLARE_TYPE
171 }; 174 };
172 175
173 // Called from events processing thread (Run() method.) 176 // Called from events processing thread (Run() method.)
174 bool ProcessCodeEvent(unsigned* dequeue_order); 177 bool ProcessCodeEvent(unsigned* dequeue_order);
175 bool ProcessTicks(unsigned dequeue_order); 178 bool ProcessTicks(unsigned dequeue_order);
179 void ProcessEventsQueue(int64_t stop_time, unsigned* dequeue_order);
176 180
177 INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag)); 181 INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag));
178 182
179 ProfileGenerator* generator_; 183 ProfileGenerator* generator_;
184 Sampler* sampler_;
180 bool running_; 185 bool running_;
186 // Sampling period in microseconds.
187 const int period_in_useconds_;
181 UnboundQueue<CodeEventsContainer> events_buffer_; 188 UnboundQueue<CodeEventsContainer> events_buffer_;
182 SamplingCircularQueue ticks_buffer_; 189 TickSampleEventRecord ticks_buffer_;
190 bool ticks_buffer_is_empty_;
191 bool ticks_buffer_is_initialized_;
183 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; 192 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_;
184 unsigned enqueue_order_; 193 unsigned enqueue_order_;
185 }; 194 };
186 195
187 } } // namespace v8::internal 196 } } // namespace v8::internal
188 197
189 198
190 #define PROFILE(isolate, Call) \ 199 #define PROFILE(isolate, Call) \
191 LOG_CODE_EVENT(isolate, Call); \ 200 LOG_CODE_EVENT(isolate, Call); \
192 do { \ 201 do { \
(...skipping 18 matching lines...) Expand all
211 static CpuProfile* StopProfiling(const char* title); 220 static CpuProfile* StopProfiling(const char* title);
212 static CpuProfile* StopProfiling(Object* security_token, String* title); 221 static CpuProfile* StopProfiling(Object* security_token, String* title);
213 static int GetProfilesCount(); 222 static int GetProfilesCount();
214 static CpuProfile* GetProfile(Object* security_token, int index); 223 static CpuProfile* GetProfile(Object* security_token, int index);
215 static CpuProfile* FindProfile(Object* security_token, unsigned uid); 224 static CpuProfile* FindProfile(Object* security_token, unsigned uid);
216 static void DeleteAllProfiles(); 225 static void DeleteAllProfiles();
217 static void DeleteProfile(CpuProfile* profile); 226 static void DeleteProfile(CpuProfile* profile);
218 static bool HasDetachedProfiles(); 227 static bool HasDetachedProfiles();
219 228
220 // Invoked from stack sampler (thread or signal handler.) 229 // Invoked from stack sampler (thread or signal handler.)
221 static TickSample* TickSampleEvent(Isolate* isolate); 230 // Finish should be called only after successful Start (returning non-NULL
231 // pointer).
232 static TickSample* StartTickSampleEvent(Isolate* isolate);
233 static void FinishTickSampleEvent(Isolate* isolate);
222 234
223 // Must be called via PROFILE macro, otherwise will crash when 235 // Must be called via PROFILE macro, otherwise will crash when
224 // profiling is not enabled. 236 // profiling is not enabled.
225 static void CallbackEvent(String* name, Address entry_point); 237 static void CallbackEvent(String* name, Address entry_point);
226 static void CodeCreateEvent(Logger::LogEventsAndTags tag, 238 static void CodeCreateEvent(Logger::LogEventsAndTags tag,
227 Code* code, const char* comment); 239 Code* code, const char* comment);
228 static void CodeCreateEvent(Logger::LogEventsAndTags tag, 240 static void CodeCreateEvent(Logger::LogEventsAndTags tag,
229 Code* code, String* name); 241 Code* code, String* name);
230 static void CodeCreateEvent(Logger::LogEventsAndTags tag, 242 static void CodeCreateEvent(Logger::LogEventsAndTags tag,
231 Code* code, 243 Code* code,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 Atomic32 is_profiling_; 286 Atomic32 is_profiling_;
275 287
276 private: 288 private:
277 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); 289 DISALLOW_COPY_AND_ASSIGN(CpuProfiler);
278 }; 290 };
279 291
280 } } // namespace v8::internal 292 } } // namespace v8::internal
281 293
282 294
283 #endif // V8_CPU_PROFILER_H_ 295 #endif // V8_CPU_PROFILER_H_
OLDNEW
« no previous file with comments | « src/arm/simulator-arm.cc ('k') | src/cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698