| 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 28 matching lines...) Expand all Loading... |
| 39 #include "../include/v8-profiler.h" | 39 #include "../include/v8-profiler.h" |
| 40 | 40 |
| 41 namespace v8 { | 41 namespace v8 { |
| 42 namespace internal { | 42 namespace internal { |
| 43 | 43 |
| 44 static const int kEventsBufferSize = 256*KB; | 44 static const int kEventsBufferSize = 256*KB; |
| 45 static const int kTickSamplesBufferChunkSize = 64*KB; | 45 static const int kTickSamplesBufferChunkSize = 64*KB; |
| 46 static const int kTickSamplesBufferChunksCount = 16; | 46 static const int kTickSamplesBufferChunksCount = 16; |
| 47 | 47 |
| 48 | 48 |
| 49 ProfilerEventsProcessor::ProfilerEventsProcessor(Isolate* isolate, | 49 ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator) |
| 50 ProfileGenerator* generator) | 50 : Thread("v8:ProfEvntProc"), |
| 51 : Thread(isolate, "v8:ProfEvntProc"), | |
| 52 generator_(generator), | 51 generator_(generator), |
| 53 running_(true), | 52 running_(true), |
| 54 ticks_buffer_(sizeof(TickSampleEventRecord), | 53 ticks_buffer_(sizeof(TickSampleEventRecord), |
| 55 kTickSamplesBufferChunkSize, | 54 kTickSamplesBufferChunkSize, |
| 56 kTickSamplesBufferChunksCount), | 55 kTickSamplesBufferChunksCount), |
| 57 enqueue_order_(0) { | 56 enqueue_order_(0) { |
| 58 } | 57 } |
| 59 | 58 |
| 60 | 59 |
| 61 void ProfilerEventsProcessor::CallbackCreateEvent(Logger::LogEventsAndTags tag, | 60 void ProfilerEventsProcessor::CallbackCreateEvent(Logger::LogEventsAndTags tag, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 rec->type = CodeEventRecord::CODE_CREATION; | 174 rec->type = CodeEventRecord::CODE_CREATION; |
| 176 rec->order = ++enqueue_order_; | 175 rec->order = ++enqueue_order_; |
| 177 rec->start = start; | 176 rec->start = start; |
| 178 rec->entry = generator_->NewCodeEntry(tag, prefix, name); | 177 rec->entry = generator_->NewCodeEntry(tag, prefix, name); |
| 179 rec->size = size; | 178 rec->size = size; |
| 180 events_buffer_.Enqueue(evt_rec); | 179 events_buffer_.Enqueue(evt_rec); |
| 181 } | 180 } |
| 182 | 181 |
| 183 | 182 |
| 184 void ProfilerEventsProcessor::AddCurrentStack() { | 183 void ProfilerEventsProcessor::AddCurrentStack() { |
| 185 TickSampleEventRecord record; | 184 TickSampleEventRecord record(enqueue_order_); |
| 186 TickSample* sample = &record.sample; | 185 TickSample* sample = &record.sample; |
| 187 Isolate* isolate = Isolate::Current(); | 186 Isolate* isolate = Isolate::Current(); |
| 188 sample->state = isolate->current_vm_state(); | 187 sample->state = isolate->current_vm_state(); |
| 189 sample->pc = reinterpret_cast<Address>(sample); // Not NULL. | 188 sample->pc = reinterpret_cast<Address>(sample); // Not NULL. |
| 190 sample->tos = NULL; | |
| 191 sample->has_external_callback = false; | |
| 192 sample->frames_count = 0; | |
| 193 for (StackTraceFrameIterator it(isolate); | 189 for (StackTraceFrameIterator it(isolate); |
| 194 !it.done() && sample->frames_count < TickSample::kMaxFramesCount; | 190 !it.done() && sample->frames_count < TickSample::kMaxFramesCount; |
| 195 it.Advance()) { | 191 it.Advance()) { |
| 196 sample->stack[sample->frames_count++] = it.frame()->pc(); | 192 sample->stack[sample->frames_count++] = it.frame()->pc(); |
| 197 } | 193 } |
| 198 record.order = enqueue_order_; | |
| 199 ticks_from_vm_buffer_.Enqueue(record); | 194 ticks_from_vm_buffer_.Enqueue(record); |
| 200 } | 195 } |
| 201 | 196 |
| 202 | 197 |
| 203 bool ProfilerEventsProcessor::ProcessCodeEvent(unsigned* dequeue_order) { | 198 bool ProfilerEventsProcessor::ProcessCodeEvent(unsigned* dequeue_order) { |
| 204 if (!events_buffer_.IsEmpty()) { | 199 if (!events_buffer_.IsEmpty()) { |
| 205 CodeEventsContainer record; | 200 CodeEventsContainer record; |
| 206 events_buffer_.Dequeue(&record); | 201 events_buffer_.Dequeue(&record); |
| 207 switch (record.generic.type) { | 202 switch (record.generic.type) { |
| 208 #define PROFILER_TYPE_CASE(type, clss) \ | 203 #define PROFILER_TYPE_CASE(type, clss) \ |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 | 495 |
| 501 | 496 |
| 502 void CpuProfiler::StartProcessorIfNotStarted() { | 497 void CpuProfiler::StartProcessorIfNotStarted() { |
| 503 if (processor_ == NULL) { | 498 if (processor_ == NULL) { |
| 504 Isolate* isolate = Isolate::Current(); | 499 Isolate* isolate = Isolate::Current(); |
| 505 | 500 |
| 506 // Disable logging when using the new implementation. | 501 // Disable logging when using the new implementation. |
| 507 saved_logging_nesting_ = isolate->logger()->logging_nesting_; | 502 saved_logging_nesting_ = isolate->logger()->logging_nesting_; |
| 508 isolate->logger()->logging_nesting_ = 0; | 503 isolate->logger()->logging_nesting_ = 0; |
| 509 generator_ = new ProfileGenerator(profiles_); | 504 generator_ = new ProfileGenerator(profiles_); |
| 510 processor_ = new ProfilerEventsProcessor(isolate, generator_); | 505 processor_ = new ProfilerEventsProcessor(generator_); |
| 511 NoBarrier_Store(&is_profiling_, true); | 506 NoBarrier_Store(&is_profiling_, true); |
| 512 processor_->Start(); | 507 processor_->Start(); |
| 513 // Enumerate stuff we already have in the heap. | 508 // Enumerate stuff we already have in the heap. |
| 514 if (isolate->heap()->HasBeenSetup()) { | 509 if (isolate->heap()->HasBeenSetup()) { |
| 515 if (!FLAG_prof_browser_mode) { | 510 if (!FLAG_prof_browser_mode) { |
| 516 bool saved_log_code_flag = FLAG_log_code; | 511 bool saved_log_code_flag = FLAG_log_code; |
| 517 FLAG_log_code = true; | 512 FLAG_log_code = true; |
| 518 isolate->logger()->LogCodeObjects(); | 513 isolate->logger()->LogCodeObjects(); |
| 519 FLAG_log_code = saved_log_code_flag; | 514 FLAG_log_code = saved_log_code_flag; |
| 520 } | 515 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 #ifdef ENABLE_LOGGING_AND_PROFILING | 595 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 601 Isolate* isolate = Isolate::Current(); | 596 Isolate* isolate = Isolate::Current(); |
| 602 if (isolate->cpu_profiler() != NULL) { | 597 if (isolate->cpu_profiler() != NULL) { |
| 603 delete isolate->cpu_profiler(); | 598 delete isolate->cpu_profiler(); |
| 604 } | 599 } |
| 605 isolate->set_cpu_profiler(NULL); | 600 isolate->set_cpu_profiler(NULL); |
| 606 #endif | 601 #endif |
| 607 } | 602 } |
| 608 | 603 |
| 609 } } // namespace v8::internal | 604 } } // namespace v8::internal |
| OLD | NEW |