Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 11 matching lines...) Expand all Loading... | |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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 #include "compiler.h" | |
| 32 #include "frames-inl.h" | 33 #include "frames-inl.h" |
| 33 #include "hashmap.h" | 34 #include "hashmap.h" |
| 34 #include "log-inl.h" | 35 #include "log-inl.h" |
| 35 #include "vm-state-inl.h" | 36 #include "vm-state-inl.h" |
| 36 | 37 |
| 37 #include "../include/v8-profiler.h" | 38 #include "../include/v8-profiler.h" |
| 38 | 39 |
| 39 namespace v8 { | 40 namespace v8 { |
| 40 namespace internal { | 41 namespace internal { |
| 41 | 42 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 events_buffer_.Enqueue(evt_rec); | 74 events_buffer_.Enqueue(evt_rec); |
| 74 } | 75 } |
| 75 | 76 |
| 76 | 77 |
| 77 void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, | 78 void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 78 Name* name, | 79 Name* name, |
| 79 String* resource_name, | 80 String* resource_name, |
| 80 int line_number, | 81 int line_number, |
| 81 Address start, | 82 Address start, |
| 82 unsigned size, | 83 unsigned size, |
| 83 Address shared) { | 84 Address shared, |
| 85 CompilationInfo* info) { | |
| 84 if (FilterOutCodeCreateEvent(tag)) return; | 86 if (FilterOutCodeCreateEvent(tag)) return; |
| 85 CodeEventsContainer evt_rec; | 87 CodeEventsContainer evt_rec; |
| 86 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | 88 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
| 87 rec->type = CodeEventRecord::CODE_CREATION; | 89 rec->type = CodeEventRecord::CODE_CREATION; |
| 88 rec->order = ++enqueue_order_; | 90 rec->order = ++enqueue_order_; |
| 89 rec->start = start; | 91 rec->start = start; |
| 90 rec->entry = profiles_->NewCodeEntry(tag, name, resource_name, line_number); | 92 rec->entry = profiles_->NewCodeEntry(tag, name, resource_name, line_number); |
| 93 if (info) { | |
| 94 rec->entry->set_frame_setup_offset(info->prologue_offset()); | |
| 95 rec->entry->set_frame_destroy_offset(info->frame_destroy_offset()); | |
| 96 } | |
| 91 rec->size = size; | 97 rec->size = size; |
| 92 rec->shared = shared; | 98 rec->shared = shared; |
| 93 events_buffer_.Enqueue(evt_rec); | 99 events_buffer_.Enqueue(evt_rec); |
| 94 } | 100 } |
| 95 | 101 |
| 96 | 102 |
| 97 void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, | 103 void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 98 const char* name, | 104 const char* name, |
| 99 Address start, | 105 Address start, |
| 100 unsigned size) { | 106 unsigned size) { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 | 322 |
| 317 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | 323 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 318 Code* code, Name* name) { | 324 Code* code, Name* name) { |
| 319 processor_->CodeCreateEvent( | 325 processor_->CodeCreateEvent( |
| 320 tag, | 326 tag, |
| 321 name, | 327 name, |
| 322 isolate_->heap()->empty_string(), | 328 isolate_->heap()->empty_string(), |
| 323 v8::CpuProfileNode::kNoLineNumberInfo, | 329 v8::CpuProfileNode::kNoLineNumberInfo, |
| 324 code->address(), | 330 code->address(), |
| 325 code->ExecutableSize(), | 331 code->ExecutableSize(), |
| 332 NULL, | |
| 326 NULL); | 333 NULL); |
| 327 } | 334 } |
| 328 | 335 |
| 329 | 336 |
| 330 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | 337 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 331 Code* code, | 338 Code* code, |
| 332 SharedFunctionInfo* shared, | 339 SharedFunctionInfo* shared, |
| 340 CompilationInfo* info, | |
| 333 Name* name) { | 341 Name* name) { |
| 334 processor_->CodeCreateEvent( | 342 processor_->CodeCreateEvent( |
| 335 tag, | 343 tag, |
| 336 name, | 344 name, |
| 337 isolate_->heap()->empty_string(), | 345 isolate_->heap()->empty_string(), |
| 338 v8::CpuProfileNode::kNoLineNumberInfo, | 346 v8::CpuProfileNode::kNoLineNumberInfo, |
| 339 code->address(), | 347 code->address(), |
| 340 code->ExecutableSize(), | 348 code->ExecutableSize(), |
| 341 shared->address()); | 349 shared->address(), |
| 350 info); | |
| 342 } | 351 } |
| 343 | 352 |
| 344 | 353 |
| 345 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | 354 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 346 Code* code, | 355 Code* code, |
| 347 SharedFunctionInfo* shared, | 356 SharedFunctionInfo* shared, |
| 357 CompilationInfo* info, | |
| 348 String* source, int line) { | 358 String* source, int line) { |
| 349 processor_->CodeCreateEvent( | 359 processor_->CodeCreateEvent( |
| 350 tag, | 360 tag, |
| 351 shared->DebugName(), | 361 shared->DebugName(), |
| 352 source, | 362 source, |
| 353 line, | 363 line, |
| 354 code->address(), | 364 code->address(), |
| 355 code->ExecutableSize(), | 365 code->ExecutableSize(), |
| 356 shared->address()); | 366 shared->address(), |
| 367 info); | |
| 357 } | 368 } |
| 358 | 369 |
| 359 | 370 |
| 360 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | 371 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 361 Code* code, int args_count) { | 372 Code* code, int args_count) { |
| 362 processor_->CodeCreateEvent( | 373 processor_->CodeCreateEvent( |
| 363 tag, | 374 tag, |
| 364 args_count, | 375 args_count, |
| 365 code->address(), | 376 code->address(), |
| 366 code->ExecutableSize()); | 377 code->ExecutableSize()); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 if (!is_profiling_) return NULL; | 500 if (!is_profiling_) return NULL; |
| 490 const double actual_sampling_rate = generator_->actual_sampling_rate(); | 501 const double actual_sampling_rate = generator_->actual_sampling_rate(); |
| 491 const char* profile_title = profiles_->GetName(title); | 502 const char* profile_title = profiles_->GetName(title); |
| 492 StopProcessorIfLastProfile(profile_title); | 503 StopProcessorIfLastProfile(profile_title); |
| 493 int token = token_enumerator_->GetTokenId(security_token); | 504 int token = token_enumerator_->GetTokenId(security_token); |
| 494 return profiles_->StopProfiling(token, profile_title, actual_sampling_rate); | 505 return profiles_->StopProfiling(token, profile_title, actual_sampling_rate); |
| 495 } | 506 } |
| 496 | 507 |
| 497 | 508 |
| 498 void CpuProfiler::StopProcessorIfLastProfile(const char* title) { | 509 void CpuProfiler::StopProcessorIfLastProfile(const char* title) { |
| 510 printf("CompilationInfo size = %lu\n", sizeof(CompilationInfo)); | |
|
loislo
2013/04/26 13:36:56
please remove that
loislo
2013/04/26 13:36:56
please remove that
yurys
2013/04/26 13:43:51
Done.
yurys
2013/04/26 13:43:51
Done.
| |
| 499 if (profiles_->IsLastProfile(title)) StopProcessor(); | 511 if (profiles_->IsLastProfile(title)) StopProcessor(); |
| 500 } | 512 } |
| 501 | 513 |
| 502 | 514 |
| 503 void CpuProfiler::StopProcessor() { | 515 void CpuProfiler::StopProcessor() { |
| 504 Logger* logger = isolate_->logger(); | 516 Logger* logger = isolate_->logger(); |
| 505 Sampler* sampler = reinterpret_cast<Sampler*>(logger->ticker_); | 517 Sampler* sampler = reinterpret_cast<Sampler*>(logger->ticker_); |
| 506 sampler->DecreaseProfilingDepth(); | 518 sampler->DecreaseProfilingDepth(); |
| 507 if (need_to_stop_sampler_) { | 519 if (need_to_stop_sampler_) { |
| 508 sampler->Stop(); | 520 sampler->Stop(); |
| 509 need_to_stop_sampler_ = false; | 521 need_to_stop_sampler_ = false; |
| 510 } | 522 } |
| 511 is_profiling_ = false; | 523 is_profiling_ = false; |
| 512 processor_->Stop(); | 524 processor_->Stop(); |
| 513 processor_->Join(); | 525 processor_->Join(); |
| 514 delete processor_; | 526 delete processor_; |
| 515 delete generator_; | 527 delete generator_; |
| 516 processor_ = NULL; | 528 processor_ = NULL; |
| 517 generator_ = NULL; | 529 generator_ = NULL; |
| 518 logger->logging_nesting_ = saved_logging_nesting_; | 530 logger->logging_nesting_ = saved_logging_nesting_; |
| 519 } | 531 } |
| 520 | 532 |
| 521 | 533 |
| 522 } } // namespace v8::internal | 534 } } // namespace v8::internal |
| OLD | NEW |