| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/cpu-profiler-inl.h" | 7 #include "src/cpu-profiler-inl.h" |
| 8 | 8 |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/frames-inl.h" | 10 #include "src/frames-inl.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 Name* name) { | 229 Name* name) { |
| 230 if (FilterOutCodeCreateEvent(tag)) return; | 230 if (FilterOutCodeCreateEvent(tag)) return; |
| 231 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | 231 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); |
| 232 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | 232 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
| 233 rec->start = code->address(); | 233 rec->start = code->address(); |
| 234 rec->entry = profiles_->NewCodeEntry(tag, profiles_->GetFunctionName(name)); | 234 rec->entry = profiles_->NewCodeEntry(tag, profiles_->GetFunctionName(name)); |
| 235 if (info) { | 235 if (info) { |
| 236 rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges()); | 236 rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges()); |
| 237 } | 237 } |
| 238 if (shared->script()->IsScript()) { | 238 if (shared->script()->IsScript()) { |
| 239 ASSERT(Script::cast(shared->script())); | 239 DCHECK(Script::cast(shared->script())); |
| 240 Script* script = Script::cast(shared->script()); | 240 Script* script = Script::cast(shared->script()); |
| 241 rec->entry->set_script_id(script->id()->value()); | 241 rec->entry->set_script_id(script->id()->value()); |
| 242 rec->entry->set_bailout_reason( | 242 rec->entry->set_bailout_reason( |
| 243 GetBailoutReason(shared->DisableOptimizationReason())); | 243 GetBailoutReason(shared->DisableOptimizationReason())); |
| 244 } | 244 } |
| 245 rec->size = code->ExecutableSize(); | 245 rec->size = code->ExecutableSize(); |
| 246 rec->shared = shared->address(); | 246 rec->shared = shared->address(); |
| 247 processor_->Enqueue(evt_rec); | 247 processor_->Enqueue(evt_rec); |
| 248 } | 248 } |
| 249 | 249 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 260 rec->entry = profiles_->NewCodeEntry( | 260 rec->entry = profiles_->NewCodeEntry( |
| 261 tag, | 261 tag, |
| 262 profiles_->GetFunctionName(shared->DebugName()), | 262 profiles_->GetFunctionName(shared->DebugName()), |
| 263 CodeEntry::kEmptyNamePrefix, | 263 CodeEntry::kEmptyNamePrefix, |
| 264 profiles_->GetName(source), | 264 profiles_->GetName(source), |
| 265 line, | 265 line, |
| 266 column); | 266 column); |
| 267 if (info) { | 267 if (info) { |
| 268 rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges()); | 268 rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges()); |
| 269 } | 269 } |
| 270 ASSERT(Script::cast(shared->script())); | 270 DCHECK(Script::cast(shared->script())); |
| 271 Script* script = Script::cast(shared->script()); | 271 Script* script = Script::cast(shared->script()); |
| 272 rec->entry->set_script_id(script->id()->value()); | 272 rec->entry->set_script_id(script->id()->value()); |
| 273 rec->size = code->ExecutableSize(); | 273 rec->size = code->ExecutableSize(); |
| 274 rec->shared = shared->address(); | 274 rec->shared = shared->address(); |
| 275 rec->entry->set_bailout_reason( | 275 rec->entry->set_bailout_reason( |
| 276 GetBailoutReason(shared->DisableOptimizationReason())); | 276 GetBailoutReason(shared->DisableOptimizationReason())); |
| 277 processor_->Enqueue(evt_rec); | 277 processor_->Enqueue(evt_rec); |
| 278 } | 278 } |
| 279 | 279 |
| 280 | 280 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 sampling_interval_(base::TimeDelta::FromMicroseconds( | 390 sampling_interval_(base::TimeDelta::FromMicroseconds( |
| 391 FLAG_cpu_profiler_sampling_interval)), | 391 FLAG_cpu_profiler_sampling_interval)), |
| 392 profiles_(test_profiles), | 392 profiles_(test_profiles), |
| 393 generator_(test_generator), | 393 generator_(test_generator), |
| 394 processor_(test_processor), | 394 processor_(test_processor), |
| 395 is_profiling_(false) { | 395 is_profiling_(false) { |
| 396 } | 396 } |
| 397 | 397 |
| 398 | 398 |
| 399 CpuProfiler::~CpuProfiler() { | 399 CpuProfiler::~CpuProfiler() { |
| 400 ASSERT(!is_profiling_); | 400 DCHECK(!is_profiling_); |
| 401 delete profiles_; | 401 delete profiles_; |
| 402 } | 402 } |
| 403 | 403 |
| 404 | 404 |
| 405 void CpuProfiler::set_sampling_interval(base::TimeDelta value) { | 405 void CpuProfiler::set_sampling_interval(base::TimeDelta value) { |
| 406 ASSERT(!is_profiling_); | 406 DCHECK(!is_profiling_); |
| 407 sampling_interval_ = value; | 407 sampling_interval_ = value; |
| 408 } | 408 } |
| 409 | 409 |
| 410 | 410 |
| 411 void CpuProfiler::ResetProfiles() { | 411 void CpuProfiler::ResetProfiles() { |
| 412 delete profiles_; | 412 delete profiles_; |
| 413 profiles_ = new CpuProfilesCollection(isolate()->heap()); | 413 profiles_ = new CpuProfilesCollection(isolate()->heap()); |
| 414 } | 414 } |
| 415 | 415 |
| 416 | 416 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 434 Logger* logger = isolate_->logger(); | 434 Logger* logger = isolate_->logger(); |
| 435 // Disable logging when using the new implementation. | 435 // Disable logging when using the new implementation. |
| 436 saved_is_logging_ = logger->is_logging_; | 436 saved_is_logging_ = logger->is_logging_; |
| 437 logger->is_logging_ = false; | 437 logger->is_logging_ = false; |
| 438 generator_ = new ProfileGenerator(profiles_); | 438 generator_ = new ProfileGenerator(profiles_); |
| 439 Sampler* sampler = logger->sampler(); | 439 Sampler* sampler = logger->sampler(); |
| 440 processor_ = new ProfilerEventsProcessor( | 440 processor_ = new ProfilerEventsProcessor( |
| 441 generator_, sampler, sampling_interval_); | 441 generator_, sampler, sampling_interval_); |
| 442 is_profiling_ = true; | 442 is_profiling_ = true; |
| 443 // Enumerate stuff we already have in the heap. | 443 // Enumerate stuff we already have in the heap. |
| 444 ASSERT(isolate_->heap()->HasBeenSetUp()); | 444 DCHECK(isolate_->heap()->HasBeenSetUp()); |
| 445 if (!FLAG_prof_browser_mode) { | 445 if (!FLAG_prof_browser_mode) { |
| 446 logger->LogCodeObjects(); | 446 logger->LogCodeObjects(); |
| 447 } | 447 } |
| 448 logger->LogCompiledFunctions(); | 448 logger->LogCompiledFunctions(); |
| 449 logger->LogAccessorCallbacks(); | 449 logger->LogAccessorCallbacks(); |
| 450 LogBuiltins(); | 450 LogBuiltins(); |
| 451 // Enable stack sampling. | 451 // Enable stack sampling. |
| 452 sampler->SetHasProcessingThread(true); | 452 sampler->SetHasProcessingThread(true); |
| 453 sampler->IncreaseProfilingDepth(); | 453 sampler->IncreaseProfilingDepth(); |
| 454 processor_->AddCurrentStack(isolate_); | 454 processor_->AddCurrentStack(isolate_); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 processor_ = NULL; | 490 processor_ = NULL; |
| 491 generator_ = NULL; | 491 generator_ = NULL; |
| 492 sampler->SetHasProcessingThread(false); | 492 sampler->SetHasProcessingThread(false); |
| 493 sampler->DecreaseProfilingDepth(); | 493 sampler->DecreaseProfilingDepth(); |
| 494 logger->is_logging_ = saved_is_logging_; | 494 logger->is_logging_ = saved_is_logging_; |
| 495 } | 495 } |
| 496 | 496 |
| 497 | 497 |
| 498 void CpuProfiler::LogBuiltins() { | 498 void CpuProfiler::LogBuiltins() { |
| 499 Builtins* builtins = isolate_->builtins(); | 499 Builtins* builtins = isolate_->builtins(); |
| 500 ASSERT(builtins->is_initialized()); | 500 DCHECK(builtins->is_initialized()); |
| 501 for (int i = 0; i < Builtins::builtin_count; i++) { | 501 for (int i = 0; i < Builtins::builtin_count; i++) { |
| 502 CodeEventsContainer evt_rec(CodeEventRecord::REPORT_BUILTIN); | 502 CodeEventsContainer evt_rec(CodeEventRecord::REPORT_BUILTIN); |
| 503 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; | 503 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; |
| 504 Builtins::Name id = static_cast<Builtins::Name>(i); | 504 Builtins::Name id = static_cast<Builtins::Name>(i); |
| 505 rec->start = builtins->builtin(id)->address(); | 505 rec->start = builtins->builtin(id)->address(); |
| 506 rec->builtin_id = id; | 506 rec->builtin_id = id; |
| 507 processor_->Enqueue(evt_rec); | 507 processor_->Enqueue(evt_rec); |
| 508 } | 508 } |
| 509 } | 509 } |
| 510 | 510 |
| 511 | 511 |
| 512 } } // namespace v8::internal | 512 } } // namespace v8::internal |
| OLD | NEW |