| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 115 |
| 116 // Pause and Resume TickSample data collection. | 116 // Pause and Resume TickSample data collection. |
| 117 bool paused() const { return paused_; } | 117 bool paused() const { return paused_; } |
| 118 void pause() { paused_ = true; } | 118 void pause() { paused_ = true; } |
| 119 void resume() { paused_ = false; } | 119 void resume() { paused_ = false; } |
| 120 | 120 |
| 121 private: | 121 private: |
| 122 // Returns the next index in the cyclic buffer. | 122 // Returns the next index in the cyclic buffer. |
| 123 int Succ(int index) { return (index + 1) % kBufferSize; } | 123 int Succ(int index) { return (index + 1) % kBufferSize; } |
| 124 | 124 |
| 125 Isolate* isolate_; |
| 125 // Cyclic buffer for communicating profiling samples | 126 // Cyclic buffer for communicating profiling samples |
| 126 // between the signal handler and the worker thread. | 127 // between the signal handler and the worker thread. |
| 127 static const int kBufferSize = 128; | 128 static const int kBufferSize = 128; |
| 128 TickSample buffer_[kBufferSize]; // Buffer storage. | 129 TickSample buffer_[kBufferSize]; // Buffer storage. |
| 129 int head_; // Index to the buffer head. | 130 int head_; // Index to the buffer head. |
| 130 int tail_; // Index to the buffer tail. | 131 int tail_; // Index to the buffer tail. |
| 131 bool overflow_; // Tell whether a buffer overflow has occurred. | 132 bool overflow_; // Tell whether a buffer overflow has occurred. |
| 132 Semaphore* buffer_semaphore_; // Sempahore used for buffer synchronization. | 133 Semaphore* buffer_semaphore_; // Sempahore used for buffer synchronization. |
| 133 | 134 |
| 134 // Tells whether profiler is engaged, that is, processing thread is stated. | 135 // Tells whether profiler is engaged, that is, processing thread is stated. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 IncrementStateCounter(state); | 265 IncrementStateCounter(state); |
| 265 ASSERT(IsPowerOf2(kBufferSize)); | 266 ASSERT(IsPowerOf2(kBufferSize)); |
| 266 current_index_ = (current_index_ + 1) & (kBufferSize - 1); | 267 current_index_ = (current_index_ + 1) & (kBufferSize - 1); |
| 267 } | 268 } |
| 268 | 269 |
| 269 | 270 |
| 270 // | 271 // |
| 271 // Profiler implementation. | 272 // Profiler implementation. |
| 272 // | 273 // |
| 273 Profiler::Profiler(Isolate* isolate) | 274 Profiler::Profiler(Isolate* isolate) |
| 274 : Thread(isolate, "v8:Profiler"), | 275 : Thread("v8:Profiler"), |
| 276 isolate_(isolate), |
| 275 head_(0), | 277 head_(0), |
| 276 tail_(0), | 278 tail_(0), |
| 277 overflow_(false), | 279 overflow_(false), |
| 278 buffer_semaphore_(OS::CreateSemaphore(0)), | 280 buffer_semaphore_(OS::CreateSemaphore(0)), |
| 279 engaged_(false), | 281 engaged_(false), |
| 280 running_(false), | 282 running_(false), |
| 281 paused_(false) { | 283 paused_(false) { |
| 282 } | 284 } |
| 283 | 285 |
| 284 | 286 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 Insert(&sample); | 321 Insert(&sample); |
| 320 Join(); | 322 Join(); |
| 321 | 323 |
| 322 LOG(ISOLATE, UncheckedStringEvent("profiler", "end")); | 324 LOG(ISOLATE, UncheckedStringEvent("profiler", "end")); |
| 323 } | 325 } |
| 324 | 326 |
| 325 | 327 |
| 326 void Profiler::Run() { | 328 void Profiler::Run() { |
| 327 TickSample sample; | 329 TickSample sample; |
| 328 bool overflow = Remove(&sample); | 330 bool overflow = Remove(&sample); |
| 329 i::Isolate* isolate = ISOLATE; | |
| 330 while (running_) { | 331 while (running_) { |
| 331 LOG(isolate, TickEvent(&sample, overflow)); | 332 LOG(isolate_, TickEvent(&sample, overflow)); |
| 332 overflow = Remove(&sample); | 333 overflow = Remove(&sample); |
| 333 } | 334 } |
| 334 } | 335 } |
| 335 | 336 |
| 336 | 337 |
| 337 // Low-level profiling event structures. | 338 // Low-level profiling event structures. |
| 338 | 339 |
| 339 struct LowLevelCodeCreateStruct { | 340 struct LowLevelCodeCreateStruct { |
| 340 static const char kTag = 'C'; | 341 static const char kTag = 'C'; |
| 341 | 342 |
| (...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1835 } | 1836 } |
| 1836 | 1837 |
| 1837 // TODO(isolates): this assert introduces cyclic dependency (logger | 1838 // TODO(isolates): this assert introduces cyclic dependency (logger |
| 1838 // -> thread local top -> heap -> logger). | 1839 // -> thread local top -> heap -> logger). |
| 1839 // ASSERT(VMState::is_outermost_external()); | 1840 // ASSERT(VMState::is_outermost_external()); |
| 1840 | 1841 |
| 1841 log_->Initialize(); | 1842 log_->Initialize(); |
| 1842 | 1843 |
| 1843 if (FLAG_ll_prof) LogCodeInfo(); | 1844 if (FLAG_ll_prof) LogCodeInfo(); |
| 1844 | 1845 |
| 1845 ticker_ = new Ticker(Isolate::Current(), kSamplingIntervalMs); | 1846 Isolate* isolate = Isolate::Current(); |
| 1847 ticker_ = new Ticker(isolate, kSamplingIntervalMs); |
| 1846 | 1848 |
| 1847 Isolate* isolate = Isolate::Current(); | |
| 1848 if (FLAG_sliding_state_window && sliding_state_window_ == NULL) { | 1849 if (FLAG_sliding_state_window && sliding_state_window_ == NULL) { |
| 1849 sliding_state_window_ = new SlidingStateWindow(isolate); | 1850 sliding_state_window_ = new SlidingStateWindow(isolate); |
| 1850 } | 1851 } |
| 1851 | 1852 |
| 1852 bool start_logging = FLAG_log || FLAG_log_runtime || FLAG_log_api | 1853 bool start_logging = FLAG_log || FLAG_log_runtime || FLAG_log_api |
| 1853 || FLAG_log_code || FLAG_log_gc || FLAG_log_handles || FLAG_log_suspect | 1854 || FLAG_log_code || FLAG_log_gc || FLAG_log_handles || FLAG_log_suspect |
| 1854 || FLAG_log_regexp || FLAG_log_state_changes || FLAG_ll_prof; | 1855 || FLAG_log_regexp || FLAG_log_state_changes || FLAG_ll_prof; |
| 1855 | 1856 |
| 1856 if (start_logging) { | 1857 if (start_logging) { |
| 1857 logging_nesting_ = 1; | 1858 logging_nesting_ = 1; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1990 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { | 1991 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { |
| 1991 ASSERT(sampler->IsActive()); | 1992 ASSERT(sampler->IsActive()); |
| 1992 ScopedLock lock(mutex_); | 1993 ScopedLock lock(mutex_); |
| 1993 ASSERT(active_samplers_ != NULL); | 1994 ASSERT(active_samplers_ != NULL); |
| 1994 bool removed = active_samplers_->RemoveElement(sampler); | 1995 bool removed = active_samplers_->RemoveElement(sampler); |
| 1995 ASSERT(removed); | 1996 ASSERT(removed); |
| 1996 USE(removed); | 1997 USE(removed); |
| 1997 } | 1998 } |
| 1998 | 1999 |
| 1999 } } // namespace v8::internal | 2000 } } // namespace v8::internal |
| OLD | NEW |