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

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

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 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/counters.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 127
128 INLINE(static TickSampleEventRecord* init(void* value)); 128 INLINE(static TickSampleEventRecord* init(void* value));
129 }; 129 };
130 130
131 131
132 // This class implements both the profile events processor thread and 132 // This class implements both the profile events processor thread and
133 // methods called by event producers: VM and stack sampler threads. 133 // methods called by event producers: VM and stack sampler threads.
134 class ProfilerEventsProcessor : public Thread { 134 class ProfilerEventsProcessor : public Thread {
135 public: 135 public:
136 explicit ProfilerEventsProcessor(ProfileGenerator* generator); 136 explicit ProfilerEventsProcessor(Isolate* isolate,
137 ProfileGenerator* generator);
137 virtual ~ProfilerEventsProcessor() {} 138 virtual ~ProfilerEventsProcessor() {}
138 139
139 // Thread control. 140 // Thread control.
140 virtual void Run(); 141 virtual void Run();
141 inline void Stop() { running_ = false; } 142 inline void Stop() { running_ = false; }
142 INLINE(bool running()) { return running_; } 143 INLINE(bool running()) { return running_; }
143 144
144 // Events adding methods. Called by VM threads. 145 // Events adding methods. Called by VM threads.
145 void CallbackCreateEvent(Logger::LogEventsAndTags tag, 146 void CallbackCreateEvent(Logger::LogEventsAndTags tag,
146 const char* prefix, String* name, 147 const char* prefix, String* name,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 bool running_; 190 bool running_;
190 UnboundQueue<CodeEventsContainer> events_buffer_; 191 UnboundQueue<CodeEventsContainer> events_buffer_;
191 SamplingCircularQueue ticks_buffer_; 192 SamplingCircularQueue ticks_buffer_;
192 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; 193 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_;
193 unsigned enqueue_order_; 194 unsigned enqueue_order_;
194 }; 195 };
195 196
196 } } // namespace v8::internal 197 } } // namespace v8::internal
197 198
198 199
199 #define PROFILE(Call) \ 200 #define PROFILE(isolate, Call) \
200 LOG(Call); \ 201 LOG(isolate, Call); \
201 do { \ 202 do { \
202 if (v8::internal::CpuProfiler::is_profiling()) { \ 203 if (v8::internal::CpuProfiler::is_profiling()) { \
203 v8::internal::CpuProfiler::Call; \ 204 v8::internal::CpuProfiler::Call; \
204 } \ 205 } \
205 } while (false) 206 } while (false)
206 #else 207 #else
207 #define PROFILE(Call) LOG(Call) 208 #define PROFILE(isolate, Call) LOG(isolate, Call)
208 #endif // ENABLE_LOGGING_AND_PROFILING 209 #endif // ENABLE_LOGGING_AND_PROFILING
209 210
210 211
211 namespace v8 { 212 namespace v8 {
212 namespace internal { 213 namespace internal {
213 214
215
216 // TODO(isolates): isolatify this class.
214 class CpuProfiler { 217 class CpuProfiler {
215 public: 218 public:
216 static void Setup(); 219 static void Setup();
217 static void TearDown(); 220 static void TearDown();
218 221
219 #ifdef ENABLE_LOGGING_AND_PROFILING 222 #ifdef ENABLE_LOGGING_AND_PROFILING
220 static void StartProfiling(const char* title); 223 static void StartProfiling(const char* title);
221 static void StartProfiling(String* title); 224 static void StartProfiling(String* title);
222 static CpuProfile* StopProfiling(const char* title); 225 static CpuProfile* StopProfiling(const char* title);
223 static CpuProfile* StopProfiling(Object* security_token, String* title); 226 static CpuProfile* StopProfiling(Object* security_token, String* title);
224 static int GetProfilesCount(); 227 static int GetProfilesCount();
225 static CpuProfile* GetProfile(Object* security_token, int index); 228 static CpuProfile* GetProfile(Object* security_token, int index);
226 static CpuProfile* FindProfile(Object* security_token, unsigned uid); 229 static CpuProfile* FindProfile(Object* security_token, unsigned uid);
227 230
228 // Invoked from stack sampler (thread or signal handler.) 231 // Invoked from stack sampler (thread or signal handler.)
229 static TickSample* TickSampleEvent(); 232 static TickSample* TickSampleEvent(Isolate* isolate);
230 233
231 // Must be called via PROFILE macro, otherwise will crash when 234 // Must be called via PROFILE macro, otherwise will crash when
232 // profiling is not enabled. 235 // profiling is not enabled.
233 static void CallbackEvent(String* name, Address entry_point); 236 static void CallbackEvent(String* name, Address entry_point);
234 static void CodeCreateEvent(Logger::LogEventsAndTags tag, 237 static void CodeCreateEvent(Logger::LogEventsAndTags tag,
235 Code* code, const char* comment); 238 Code* code, const char* comment);
236 static void CodeCreateEvent(Logger::LogEventsAndTags tag, 239 static void CodeCreateEvent(Logger::LogEventsAndTags tag,
237 Code* code, String* name); 240 Code* code, String* name);
238 static void CodeCreateEvent(Logger::LogEventsAndTags tag, 241 static void CodeCreateEvent(Logger::LogEventsAndTags tag,
239 Code* code, 242 Code* code,
240 SharedFunctionInfo *shared, 243 SharedFunctionInfo *shared,
241 String* name); 244 String* name);
242 static void CodeCreateEvent(Logger::LogEventsAndTags tag, 245 static void CodeCreateEvent(Logger::LogEventsAndTags tag,
243 Code* code, 246 Code* code,
244 SharedFunctionInfo *shared, 247 SharedFunctionInfo *shared,
245 String* source, int line); 248 String* source, int line);
246 static void CodeCreateEvent(Logger::LogEventsAndTags tag, 249 static void CodeCreateEvent(Logger::LogEventsAndTags tag,
247 Code* code, int args_count); 250 Code* code, int args_count);
248 static void CodeMovingGCEvent() {} 251 static void CodeMovingGCEvent() {}
249 static void CodeMoveEvent(Address from, Address to); 252 static void CodeMoveEvent(Address from, Address to);
250 static void CodeDeleteEvent(Address from); 253 static void CodeDeleteEvent(Address from);
251 static void GetterCallbackEvent(String* name, Address entry_point); 254 static void GetterCallbackEvent(String* name, Address entry_point);
252 static void RegExpCodeCreateEvent(Code* code, String* source); 255 static void RegExpCodeCreateEvent(Code* code, String* source);
253 static void SetterCallbackEvent(String* name, Address entry_point); 256 static void SetterCallbackEvent(String* name, Address entry_point);
254 static void SharedFunctionInfoMoveEvent(Address from, Address to); 257 static void SharedFunctionInfoMoveEvent(Address from, Address to);
255 258
259 // TODO(isolates): this doesn't have to use atomics anymore.
260
256 static INLINE(bool is_profiling()) { 261 static INLINE(bool is_profiling()) {
257 return NoBarrier_Load(&is_profiling_); 262 return is_profiling(Isolate::Current());
263 }
264
265 static INLINE(bool is_profiling(Isolate* isolate)) {
266 CpuProfiler* profiler = isolate->cpu_profiler();
267 return profiler != NULL && NoBarrier_Load(&profiler->is_profiling_);
258 } 268 }
259 269
260 private: 270 private:
261 CpuProfiler(); 271 CpuProfiler();
262 ~CpuProfiler(); 272 ~CpuProfiler();
263 void StartCollectingProfile(const char* title); 273 void StartCollectingProfile(const char* title);
264 void StartCollectingProfile(String* title); 274 void StartCollectingProfile(String* title);
265 void StartProcessorIfNotStarted(); 275 void StartProcessorIfNotStarted();
266 CpuProfile* StopCollectingProfile(const char* title); 276 CpuProfile* StopCollectingProfile(const char* title);
267 CpuProfile* StopCollectingProfile(Object* security_token, String* title); 277 CpuProfile* StopCollectingProfile(Object* security_token, String* title);
268 void StopProcessorIfLastProfile(const char* title); 278 void StopProcessorIfLastProfile(const char* title);
269 279
270 CpuProfilesCollection* profiles_; 280 CpuProfilesCollection* profiles_;
271 unsigned next_profile_uid_; 281 unsigned next_profile_uid_;
272 TokenEnumerator* token_enumerator_; 282 TokenEnumerator* token_enumerator_;
273 ProfileGenerator* generator_; 283 ProfileGenerator* generator_;
274 ProfilerEventsProcessor* processor_; 284 ProfilerEventsProcessor* processor_;
275 int saved_logging_nesting_; 285 int saved_logging_nesting_;
276 286 Atomic32 is_profiling_;
277 static CpuProfiler* singleton_;
278 static Atomic32 is_profiling_;
279 287
280 #else 288 #else
281 static INLINE(bool is_profiling()) { return false; } 289 static INLINE(bool is_profiling()) { return false; }
282 #endif // ENABLE_LOGGING_AND_PROFILING 290 #endif // ENABLE_LOGGING_AND_PROFILING
283 291
284 private: 292 private:
285 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); 293 DISALLOW_COPY_AND_ASSIGN(CpuProfiler);
286 }; 294 };
287 295
288 } } // namespace v8::internal 296 } } // namespace v8::internal
289 297
290 298
291 #endif // V8_CPU_PROFILER_H_ 299 #endif // V8_CPU_PROFILER_H_
OLDNEW
« no previous file with comments | « src/counters.cc ('k') | src/cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698