| 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 profiles_->GetName(name), | 356 profiles_->GetName(name), |
| 357 "set "); | 357 "set "); |
| 358 rec->size = 1; | 358 rec->size = 1; |
| 359 rec->shared = NULL; | 359 rec->shared = NULL; |
| 360 processor_->Enqueue(evt_rec); | 360 processor_->Enqueue(evt_rec); |
| 361 } | 361 } |
| 362 | 362 |
| 363 | 363 |
| 364 CpuProfiler::CpuProfiler(Isolate* isolate) | 364 CpuProfiler::CpuProfiler(Isolate* isolate) |
| 365 : isolate_(isolate), | 365 : isolate_(isolate), |
| 366 sampling_interval_(TimeDelta::FromMicroseconds( |
| 367 FLAG_cpu_profiler_sampling_interval)), |
| 366 profiles_(new CpuProfilesCollection()), | 368 profiles_(new CpuProfilesCollection()), |
| 367 next_profile_uid_(1), | 369 next_profile_uid_(1), |
| 368 generator_(NULL), | 370 generator_(NULL), |
| 369 processor_(NULL), | 371 processor_(NULL), |
| 370 is_profiling_(false) { | 372 is_profiling_(false) { |
| 371 } | 373 } |
| 372 | 374 |
| 373 | 375 |
| 374 CpuProfiler::CpuProfiler(Isolate* isolate, | 376 CpuProfiler::CpuProfiler(Isolate* isolate, |
| 375 CpuProfilesCollection* test_profiles, | 377 CpuProfilesCollection* test_profiles, |
| 376 ProfileGenerator* test_generator, | 378 ProfileGenerator* test_generator, |
| 377 ProfilerEventsProcessor* test_processor) | 379 ProfilerEventsProcessor* test_processor) |
| 378 : isolate_(isolate), | 380 : isolate_(isolate), |
| 381 sampling_interval_(TimeDelta::FromMicroseconds( |
| 382 FLAG_cpu_profiler_sampling_interval)), |
| 379 profiles_(test_profiles), | 383 profiles_(test_profiles), |
| 380 next_profile_uid_(1), | 384 next_profile_uid_(1), |
| 381 generator_(test_generator), | 385 generator_(test_generator), |
| 382 processor_(test_processor), | 386 processor_(test_processor), |
| 383 is_profiling_(false) { | 387 is_profiling_(false) { |
| 384 } | 388 } |
| 385 | 389 |
| 386 | 390 |
| 387 CpuProfiler::~CpuProfiler() { | 391 CpuProfiler::~CpuProfiler() { |
| 388 ASSERT(!is_profiling_); | 392 ASSERT(!is_profiling_); |
| 389 delete profiles_; | 393 delete profiles_; |
| 390 } | 394 } |
| 391 | 395 |
| 392 | 396 |
| 397 void CpuProfiler::set_sampling_interval(TimeDelta value) { |
| 398 ASSERT(!is_profiling_); |
| 399 sampling_interval_ = value; |
| 400 } |
| 401 |
| 402 |
| 393 void CpuProfiler::ResetProfiles() { | 403 void CpuProfiler::ResetProfiles() { |
| 394 delete profiles_; | 404 delete profiles_; |
| 395 profiles_ = new CpuProfilesCollection(); | 405 profiles_ = new CpuProfilesCollection(); |
| 396 } | 406 } |
| 397 | 407 |
| 398 | 408 |
| 399 void CpuProfiler::StartProfiling(const char* title, bool record_samples) { | 409 void CpuProfiler::StartProfiling(const char* title, bool record_samples) { |
| 400 if (profiles_->StartProfiling(title, next_profile_uid_++, record_samples)) { | 410 if (profiles_->StartProfiling(title, next_profile_uid_++, record_samples)) { |
| 401 StartProcessorIfNotStarted(); | 411 StartProcessorIfNotStarted(); |
| 402 } | 412 } |
| 403 processor_->AddCurrentStack(isolate_); | 413 processor_->AddCurrentStack(isolate_); |
| 404 } | 414 } |
| 405 | 415 |
| 406 | 416 |
| 407 void CpuProfiler::StartProfiling(String* title, bool record_samples) { | 417 void CpuProfiler::StartProfiling(String* title, bool record_samples) { |
| 408 StartProfiling(profiles_->GetName(title), record_samples); | 418 StartProfiling(profiles_->GetName(title), record_samples); |
| 409 } | 419 } |
| 410 | 420 |
| 411 | 421 |
| 412 void CpuProfiler::StartProcessorIfNotStarted() { | 422 void CpuProfiler::StartProcessorIfNotStarted() { |
| 413 if (processor_ == NULL) { | 423 if (processor_ == NULL) { |
| 414 Logger* logger = isolate_->logger(); | 424 Logger* logger = isolate_->logger(); |
| 415 // Disable logging when using the new implementation. | 425 // Disable logging when using the new implementation. |
| 416 saved_is_logging_ = logger->is_logging_; | 426 saved_is_logging_ = logger->is_logging_; |
| 417 logger->is_logging_ = false; | 427 logger->is_logging_ = false; |
| 418 generator_ = new ProfileGenerator(profiles_); | 428 generator_ = new ProfileGenerator(profiles_); |
| 419 Sampler* sampler = logger->sampler(); | 429 Sampler* sampler = logger->sampler(); |
| 420 processor_ = new ProfilerEventsProcessor( | 430 processor_ = new ProfilerEventsProcessor( |
| 421 generator_, sampler, | 431 generator_, sampler, sampling_interval_); |
| 422 TimeDelta::FromMicroseconds(FLAG_cpu_profiler_sampling_interval)); | |
| 423 is_profiling_ = true; | 432 is_profiling_ = true; |
| 424 // Enumerate stuff we already have in the heap. | 433 // Enumerate stuff we already have in the heap. |
| 425 ASSERT(isolate_->heap()->HasBeenSetUp()); | 434 ASSERT(isolate_->heap()->HasBeenSetUp()); |
| 426 if (!FLAG_prof_browser_mode) { | 435 if (!FLAG_prof_browser_mode) { |
| 427 logger->LogCodeObjects(); | 436 logger->LogCodeObjects(); |
| 428 } | 437 } |
| 429 logger->LogCompiledFunctions(); | 438 logger->LogCompiledFunctions(); |
| 430 logger->LogAccessorCallbacks(); | 439 logger->LogAccessorCallbacks(); |
| 431 LogBuiltins(); | 440 LogBuiltins(); |
| 432 // Enable stack sampling. | 441 // Enable stack sampling. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; | 493 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; |
| 485 Builtins::Name id = static_cast<Builtins::Name>(i); | 494 Builtins::Name id = static_cast<Builtins::Name>(i); |
| 486 rec->start = builtins->builtin(id)->address(); | 495 rec->start = builtins->builtin(id)->address(); |
| 487 rec->builtin_id = id; | 496 rec->builtin_id = id; |
| 488 processor_->Enqueue(evt_rec); | 497 processor_->Enqueue(evt_rec); |
| 489 } | 498 } |
| 490 } | 499 } |
| 491 | 500 |
| 492 | 501 |
| 493 } } // namespace v8::internal | 502 } } // namespace v8::internal |
| OLD | NEW |