| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 enqueue_order_(0) { | 55 enqueue_order_(0) { |
| 56 } | 56 } |
| 57 | 57 |
| 58 | 58 |
| 59 void ProfilerEventsProcessor::Enqueue(const CodeEventsContainer& event) { | 59 void ProfilerEventsProcessor::Enqueue(const CodeEventsContainer& event) { |
| 60 event.generic.order = ++enqueue_order_; | 60 event.generic.order = ++enqueue_order_; |
| 61 events_buffer_.Enqueue(event); | 61 events_buffer_.Enqueue(event); |
| 62 } | 62 } |
| 63 | 63 |
| 64 | 64 |
| 65 void ProfilerEventsProcessor::AddCurrentStack() { | 65 void ProfilerEventsProcessor::AddCurrentStack(Isolate* isolate) { |
| 66 TickSampleEventRecord record(enqueue_order_); | 66 TickSampleEventRecord record(enqueue_order_); |
| 67 TickSample* sample = &record.sample; | 67 TickSample* sample = &record.sample; |
| 68 Isolate* isolate = Isolate::Current(); | |
| 69 sample->state = isolate->current_vm_state(); | 68 sample->state = isolate->current_vm_state(); |
| 70 sample->pc = reinterpret_cast<Address>(sample); // Not NULL. | 69 sample->pc = reinterpret_cast<Address>(sample); // Not NULL. |
| 71 for (StackTraceFrameIterator it(isolate); | 70 for (StackTraceFrameIterator it(isolate); |
| 72 !it.done() && sample->frames_count < TickSample::kMaxFramesCount; | 71 !it.done() && sample->frames_count < TickSample::kMaxFramesCount; |
| 73 it.Advance()) { | 72 it.Advance()) { |
| 74 sample->stack[sample->frames_count++] = it.frame()->pc(); | 73 sample->stack[sample->frames_count++] = it.frame()->pc(); |
| 75 } | 74 } |
| 76 ticks_from_vm_buffer_.Enqueue(record); | 75 ticks_from_vm_buffer_.Enqueue(record); |
| 77 } | 76 } |
| 78 | 77 |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 420 |
| 422 void CpuProfiler::ResetProfiles() { | 421 void CpuProfiler::ResetProfiles() { |
| 423 delete profiles_; | 422 delete profiles_; |
| 424 profiles_ = new CpuProfilesCollection(); | 423 profiles_ = new CpuProfilesCollection(); |
| 425 } | 424 } |
| 426 | 425 |
| 427 void CpuProfiler::StartProfiling(const char* title, bool record_samples) { | 426 void CpuProfiler::StartProfiling(const char* title, bool record_samples) { |
| 428 if (profiles_->StartProfiling(title, next_profile_uid_++, record_samples)) { | 427 if (profiles_->StartProfiling(title, next_profile_uid_++, record_samples)) { |
| 429 StartProcessorIfNotStarted(); | 428 StartProcessorIfNotStarted(); |
| 430 } | 429 } |
| 431 processor_->AddCurrentStack(); | 430 processor_->AddCurrentStack(isolate_); |
| 432 } | 431 } |
| 433 | 432 |
| 434 | 433 |
| 435 void CpuProfiler::StartProfiling(String* title, bool record_samples) { | 434 void CpuProfiler::StartProfiling(String* title, bool record_samples) { |
| 436 StartProfiling(profiles_->GetName(title), record_samples); | 435 StartProfiling(profiles_->GetName(title), record_samples); |
| 437 } | 436 } |
| 438 | 437 |
| 439 | 438 |
| 440 void CpuProfiler::StartProcessorIfNotStarted() { | 439 void CpuProfiler::StartProcessorIfNotStarted() { |
| 441 if (processor_ == NULL) { | 440 if (processor_ == NULL) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; | 522 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; |
| 524 Builtins::Name id = static_cast<Builtins::Name>(i); | 523 Builtins::Name id = static_cast<Builtins::Name>(i); |
| 525 rec->start = builtins->builtin(id)->address(); | 524 rec->start = builtins->builtin(id)->address(); |
| 526 rec->builtin_id = id; | 525 rec->builtin_id = id; |
| 527 processor_->Enqueue(evt_rec); | 526 processor_->Enqueue(evt_rec); |
| 528 } | 527 } |
| 529 } | 528 } |
| 530 | 529 |
| 531 | 530 |
| 532 } } // namespace v8::internal | 531 } } // namespace v8::internal |
| OLD | NEW |