Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: src/profiler/cpu-profiler.cc

Issue 1457483002: [profiler] Move away from UnboundedQueue to LockedQueue for regular events. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@locked-queue
Patch Set: Rebase Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/profiler/cpu-profiler.h ('k') | src/profiler/cpu-profiler-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/profiler/cpu-profiler.h" 5 #include "src/profiler/cpu-profiler.h"
6 6
7 #include "src/deoptimizer.h" 7 #include "src/deoptimizer.h"
8 #include "src/frames-inl.h" 8 #include "src/frames-inl.h"
9 #include "src/locked-queue-inl.h"
9 #include "src/log-inl.h" 10 #include "src/log-inl.h"
10 #include "src/profiler/cpu-profiler-inl.h" 11 #include "src/profiler/cpu-profiler-inl.h"
11 #include "src/vm-state-inl.h" 12 #include "src/vm-state-inl.h"
12 13
13 #include "include/v8-profiler.h" 14 #include "include/v8-profiler.h"
14 15
15 namespace v8 { 16 namespace v8 {
16 namespace internal { 17 namespace internal {
17 18
18 static const int kProfilerStackSize = 64 * KB; 19 static const int kProfilerStackSize = 64 * KB;
19 20
20 21
21 ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator, 22 ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator,
22 Sampler* sampler, 23 Sampler* sampler,
23 base::TimeDelta period) 24 base::TimeDelta period)
24 : Thread(Thread::Options("v8:ProfEvntProc", kProfilerStackSize)), 25 : Thread(Thread::Options("v8:ProfEvntProc", kProfilerStackSize)),
25 generator_(generator), 26 generator_(generator),
26 sampler_(sampler), 27 sampler_(sampler),
27 running_(1), 28 running_(1),
28 period_(period), 29 period_(period),
29 last_code_event_id_(0), 30 last_code_event_id_(0),
30 last_processed_code_event_id_(0) {} 31 last_processed_code_event_id_(0) {}
31 32
32 33
33 ProfilerEventsProcessor::~ProfilerEventsProcessor() {} 34 ProfilerEventsProcessor::~ProfilerEventsProcessor() {}
34 35
35 36
36 void ProfilerEventsProcessor::Enqueue(const CodeEventsContainer& event) { 37 void ProfilerEventsProcessor::Enqueue(const CodeEventsContainer& event) {
37 event.generic.order = ++last_code_event_id_; 38 event.generic.order = last_code_event_id_.Increment(1);
38 events_buffer_.Enqueue(event); 39 events_buffer_.Enqueue(event);
39 } 40 }
40 41
41 42
42 void ProfilerEventsProcessor::AddDeoptStack(Isolate* isolate, Address from, 43 void ProfilerEventsProcessor::AddDeoptStack(Isolate* isolate, Address from,
43 int fp_to_sp_delta) { 44 int fp_to_sp_delta) {
44 TickSampleEventRecord record(last_code_event_id_); 45 TickSampleEventRecord record(last_code_event_id_.Value());
45 RegisterState regs; 46 RegisterState regs;
46 Address fp = isolate->c_entry_fp(isolate->thread_local_top()); 47 Address fp = isolate->c_entry_fp(isolate->thread_local_top());
47 regs.sp = fp - fp_to_sp_delta; 48 regs.sp = fp - fp_to_sp_delta;
48 regs.fp = fp; 49 regs.fp = fp;
49 regs.pc = from; 50 regs.pc = from;
50 record.sample.Init(isolate, regs, TickSample::kSkipCEntryFrame); 51 record.sample.Init(isolate, regs, TickSample::kSkipCEntryFrame);
51 ticks_from_vm_buffer_.Enqueue(record); 52 ticks_from_vm_buffer_.Enqueue(record);
52 } 53 }
53 54
54 55
55 void ProfilerEventsProcessor::AddCurrentStack(Isolate* isolate) { 56 void ProfilerEventsProcessor::AddCurrentStack(Isolate* isolate) {
56 TickSampleEventRecord record(last_code_event_id_); 57 TickSampleEventRecord record(last_code_event_id_.Value());
57 RegisterState regs; 58 RegisterState regs;
58 StackFrameIterator it(isolate); 59 StackFrameIterator it(isolate);
59 if (!it.done()) { 60 if (!it.done()) {
60 StackFrame* frame = it.frame(); 61 StackFrame* frame = it.frame();
61 regs.sp = frame->sp(); 62 regs.sp = frame->sp();
62 regs.fp = frame->fp(); 63 regs.fp = frame->fp();
63 regs.pc = frame->pc(); 64 regs.pc = frame->pc();
64 } 65 }
65 record.sample.Init(isolate, regs, TickSample::kSkipCEntryFrame); 66 record.sample.Init(isolate, regs, TickSample::kSkipCEntryFrame);
66 ticks_from_vm_buffer_.Enqueue(record); 67 ticks_from_vm_buffer_.Enqueue(record);
(...skipping 21 matching lines...) Expand all
88 default: return true; // Skip record. 89 default: return true; // Skip record.
89 } 90 }
90 last_processed_code_event_id_ = record.generic.order; 91 last_processed_code_event_id_ = record.generic.order;
91 return true; 92 return true;
92 } 93 }
93 return false; 94 return false;
94 } 95 }
95 96
96 ProfilerEventsProcessor::SampleProcessingResult 97 ProfilerEventsProcessor::SampleProcessingResult
97 ProfilerEventsProcessor::ProcessOneSample() { 98 ProfilerEventsProcessor::ProcessOneSample() {
98 if (!ticks_from_vm_buffer_.IsEmpty() 99 TickSampleEventRecord record1;
99 && ticks_from_vm_buffer_.Peek()->order == 100 if (ticks_from_vm_buffer_.Peek(&record1) &&
100 last_processed_code_event_id_) { 101 (record1.order == last_processed_code_event_id_)) {
101 TickSampleEventRecord record; 102 TickSampleEventRecord record;
102 ticks_from_vm_buffer_.Dequeue(&record); 103 ticks_from_vm_buffer_.Dequeue(&record);
103 generator_->RecordTickSample(record.sample); 104 generator_->RecordTickSample(record.sample);
104 return OneSampleProcessed; 105 return OneSampleProcessed;
105 } 106 }
106 107
107 const TickSampleEventRecord* record = ticks_buffer_.Peek(); 108 const TickSampleEventRecord* record = ticks_buffer_.Peek();
108 if (record == NULL) { 109 if (record == NULL) {
109 if (ticks_from_vm_buffer_.IsEmpty()) return NoSamplesInQueue; 110 if (ticks_from_vm_buffer_.IsEmpty()) return NoSamplesInQueue;
110 return FoundSampleForNextCodeEvent; 111 return FoundSampleForNextCodeEvent;
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 Builtins::Name id = static_cast<Builtins::Name>(i); 519 Builtins::Name id = static_cast<Builtins::Name>(i);
519 rec->start = builtins->builtin(id)->address(); 520 rec->start = builtins->builtin(id)->address();
520 rec->builtin_id = id; 521 rec->builtin_id = id;
521 processor_->Enqueue(evt_rec); 522 processor_->Enqueue(evt_rec);
522 } 523 }
523 } 524 }
524 525
525 526
526 } // namespace internal 527 } // namespace internal
527 } // namespace v8 528 } // namespace v8
OLDNEW
« no previous file with comments | « src/profiler/cpu-profiler.h ('k') | src/profiler/cpu-profiler-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698