| OLD | NEW |
| 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 14 matching lines...) Expand all Loading... |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "cpu-profiler-inl.h" | 30 #include "cpu-profiler-inl.h" |
| 31 | 31 |
| 32 namespace v8 { | 32 namespace v8 { |
| 33 namespace internal { | 33 namespace internal { |
| 34 | 34 |
| 35 #ifdef ENABLE_CPP_PROFILES_PROCESSOR |
| 35 | 36 |
| 36 static const int kEventsBufferSize = 256*KB; | 37 static const int kEventsBufferSize = 256*KB; |
| 37 static const int kTickSamplesBufferChunkSize = 64*KB; | 38 static const int kTickSamplesBufferChunkSize = 64*KB; |
| 38 static const int kTickSamplesBufferChunksCount = 16; | 39 static const int kTickSamplesBufferChunksCount = 16; |
| 39 | 40 |
| 40 | 41 |
| 41 ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator) | 42 ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator) |
| 42 : generator_(generator), | 43 : generator_(generator), |
| 43 running_(false), | 44 running_(false), |
| 44 events_buffer_(kEventsBufferSize), | 45 events_buffer_(kEventsBufferSize), |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 *dequeue_order = record.generic.order; | 157 *dequeue_order = record.generic.order; |
| 157 return true; | 158 return true; |
| 158 } | 159 } |
| 159 return false; | 160 return false; |
| 160 } | 161 } |
| 161 | 162 |
| 162 | 163 |
| 163 bool ProfilerEventsProcessor::ProcessTicks(unsigned dequeue_order) { | 164 bool ProfilerEventsProcessor::ProcessTicks(unsigned dequeue_order) { |
| 164 while (true) { | 165 while (true) { |
| 165 const TickSampleEventRecord* rec = | 166 const TickSampleEventRecord* rec = |
| 166 reinterpret_cast<TickSampleEventRecord*>(ticks_buffer_.StartDequeue()); | 167 TickSampleEventRecord::cast(ticks_buffer_.StartDequeue()); |
| 167 if (rec == NULL) return false; | 168 if (rec == NULL) return false; |
| 168 if (rec->order == dequeue_order) { | 169 if (rec->order == dequeue_order) { |
| 169 generator_->RecordTickSample(rec->sample); | 170 generator_->RecordTickSample(rec->sample); |
| 170 ticks_buffer_.FinishDequeue(); | 171 ticks_buffer_.FinishDequeue(); |
| 171 } else { | 172 } else { |
| 172 return true; | 173 return true; |
| 173 } | 174 } |
| 174 } | 175 } |
| 175 } | 176 } |
| 176 | 177 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 188 } | 189 } |
| 189 YieldCPU(); | 190 YieldCPU(); |
| 190 } | 191 } |
| 191 | 192 |
| 192 // Process remaining tick events. | 193 // Process remaining tick events. |
| 193 ticks_buffer_.FlushResidualRecords(); | 194 ticks_buffer_.FlushResidualRecords(); |
| 194 // Perform processing until we have tick events, skip remaining code events. | 195 // Perform processing until we have tick events, skip remaining code events. |
| 195 while (ProcessTicks(dequeue_order) && ProcessCodeEvent(&dequeue_order)) { } | 196 while (ProcessTicks(dequeue_order) && ProcessCodeEvent(&dequeue_order)) { } |
| 196 } | 197 } |
| 197 | 198 |
| 199 #endif // ENABLE_CPP_PROFILES_PROCESSOR |
| 198 | 200 |
| 199 } } // namespace v8::internal | 201 } } // namespace v8::internal |
| OLD | NEW |