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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 rec->shared = NULL; | 373 rec->shared = NULL; |
374 processor_->Enqueue(evt_rec); | 374 processor_->Enqueue(evt_rec); |
375 } | 375 } |
376 | 376 |
377 | 377 |
378 CpuProfiler::CpuProfiler(Isolate* isolate) | 378 CpuProfiler::CpuProfiler(Isolate* isolate) |
379 : isolate_(isolate), | 379 : isolate_(isolate), |
380 sampling_interval_(TimeDelta::FromMicroseconds( | 380 sampling_interval_(TimeDelta::FromMicroseconds( |
381 FLAG_cpu_profiler_sampling_interval)), | 381 FLAG_cpu_profiler_sampling_interval)), |
382 profiles_(new CpuProfilesCollection(isolate->heap())), | 382 profiles_(new CpuProfilesCollection(isolate->heap())), |
383 next_profile_uid_(1), | |
384 generator_(NULL), | 383 generator_(NULL), |
385 processor_(NULL), | 384 processor_(NULL), |
386 is_profiling_(false) { | 385 is_profiling_(false) { |
387 } | 386 } |
388 | 387 |
389 | 388 |
390 CpuProfiler::CpuProfiler(Isolate* isolate, | 389 CpuProfiler::CpuProfiler(Isolate* isolate, |
391 CpuProfilesCollection* test_profiles, | 390 CpuProfilesCollection* test_profiles, |
392 ProfileGenerator* test_generator, | 391 ProfileGenerator* test_generator, |
393 ProfilerEventsProcessor* test_processor) | 392 ProfilerEventsProcessor* test_processor) |
394 : isolate_(isolate), | 393 : isolate_(isolate), |
395 sampling_interval_(TimeDelta::FromMicroseconds( | 394 sampling_interval_(TimeDelta::FromMicroseconds( |
396 FLAG_cpu_profiler_sampling_interval)), | 395 FLAG_cpu_profiler_sampling_interval)), |
397 profiles_(test_profiles), | 396 profiles_(test_profiles), |
398 next_profile_uid_(1), | |
399 generator_(test_generator), | 397 generator_(test_generator), |
400 processor_(test_processor), | 398 processor_(test_processor), |
401 is_profiling_(false) { | 399 is_profiling_(false) { |
402 } | 400 } |
403 | 401 |
404 | 402 |
405 CpuProfiler::~CpuProfiler() { | 403 CpuProfiler::~CpuProfiler() { |
406 ASSERT(!is_profiling_); | 404 ASSERT(!is_profiling_); |
407 delete profiles_; | 405 delete profiles_; |
408 } | 406 } |
409 | 407 |
410 | 408 |
411 void CpuProfiler::set_sampling_interval(TimeDelta value) { | 409 void CpuProfiler::set_sampling_interval(TimeDelta value) { |
412 ASSERT(!is_profiling_); | 410 ASSERT(!is_profiling_); |
413 sampling_interval_ = value; | 411 sampling_interval_ = value; |
414 } | 412 } |
415 | 413 |
416 | 414 |
417 void CpuProfiler::ResetProfiles() { | 415 void CpuProfiler::ResetProfiles() { |
418 delete profiles_; | 416 delete profiles_; |
419 profiles_ = new CpuProfilesCollection(isolate()->heap()); | 417 profiles_ = new CpuProfilesCollection(isolate()->heap()); |
420 } | 418 } |
421 | 419 |
422 | 420 |
423 void CpuProfiler::StartProfiling(const char* title, bool record_samples) { | 421 void CpuProfiler::StartProfiling(const char* title, bool record_samples) { |
424 if (profiles_->StartProfiling(title, next_profile_uid_++, record_samples)) { | 422 if (profiles_->StartProfiling(title, record_samples)) { |
425 StartProcessorIfNotStarted(); | 423 StartProcessorIfNotStarted(); |
426 } | 424 } |
427 processor_->AddCurrentStack(isolate_); | 425 processor_->AddCurrentStack(isolate_); |
428 } | 426 } |
429 | 427 |
430 | 428 |
431 void CpuProfiler::StartProfiling(String* title, bool record_samples) { | 429 void CpuProfiler::StartProfiling(String* title, bool record_samples) { |
432 StartProfiling(profiles_->GetName(title), record_samples); | 430 StartProfiling(profiles_->GetName(title), record_samples); |
433 } | 431 } |
434 | 432 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; | 515 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; |
518 Builtins::Name id = static_cast<Builtins::Name>(i); | 516 Builtins::Name id = static_cast<Builtins::Name>(i); |
519 rec->start = builtins->builtin(id)->address(); | 517 rec->start = builtins->builtin(id)->address(); |
520 rec->builtin_id = id; | 518 rec->builtin_id = id; |
521 processor_->Enqueue(evt_rec); | 519 processor_->Enqueue(evt_rec); |
522 } | 520 } |
523 } | 521 } |
524 | 522 |
525 | 523 |
526 } } // namespace v8::internal | 524 } } // namespace v8::internal |
OLD | NEW |