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

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

Issue 23615011: Revert r16548 due to cpu profiler test falkiness (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « src/cpu-profiler.h ('k') | no next file » | 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 // 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 #undef PROFILER_TYPE_CASE 97 #undef PROFILER_TYPE_CASE
98 default: return true; // Skip record. 98 default: return true; // Skip record.
99 } 99 }
100 last_processed_code_event_id_ = record.generic.order; 100 last_processed_code_event_id_ = record.generic.order;
101 return true; 101 return true;
102 } 102 }
103 return false; 103 return false;
104 } 104 }
105 105
106 106
107 bool ProfilerEventsProcessor::ProcessOneSample() { 107 bool ProfilerEventsProcessor::ProcessTicks() {
108 if (!ticks_from_vm_buffer_.IsEmpty() 108 while (true) {
109 && ticks_from_vm_buffer_.Peek()->order == 109 while (!ticks_from_vm_buffer_.IsEmpty()
110 last_processed_code_event_id_) { 110 && ticks_from_vm_buffer_.Peek()->order ==
111 TickSampleEventRecord record; 111 last_processed_code_event_id_) {
112 ticks_from_vm_buffer_.Dequeue(&record); 112 TickSampleEventRecord record;
113 generator_->RecordTickSample(record.sample); 113 ticks_from_vm_buffer_.Dequeue(&record);
114 return false; 114 generator_->RecordTickSample(record.sample);
115 }
116
117 const TickSampleEventRecord* record = ticks_buffer_.Peek();
118 if (record == NULL) return !ticks_from_vm_buffer_.IsEmpty();
119 if (record->order != last_processed_code_event_id_) return true;
120 generator_->RecordTickSample(record->sample);
121 ticks_buffer_.Remove();
115 } 122 }
123 }
116 124
117 const TickSampleEventRecord* record = ticks_buffer_.Peek(); 125
118 if (record == NULL) return true; 126 void ProfilerEventsProcessor::ProcessEventsAndDoSample() {
119 if (record->order != last_processed_code_event_id_) return true; 127 ElapsedTimer timer;
120 generator_->RecordTickSample(record->sample); 128 timer.Start();
121 ticks_buffer_.Remove(); 129 // Keep processing existing events until we need to do next sample.
122 return false; 130 while (!timer.HasExpired(period_)) {
131 if (ProcessTicks()) {
132 // All ticks of the current dequeue_order are processed,
133 // proceed to the next code event.
134 ProcessCodeEvent();
135 }
136 }
137 // Schedule next sample. sampler_ is NULL in tests.
138 if (sampler_) sampler_->DoSample();
123 } 139 }
124 140
125 141
126 void ProfilerEventsProcessor::Run() { 142 void ProfilerEventsProcessor::Run() {
127 while (running_) { 143 while (running_) {
128 ElapsedTimer timer; 144 ProcessEventsAndDoSample();
129 timer.Start();
130 // Keep processing existing events until we need to do next sample.
131 do {
132 if (ProcessOneSample()) {
133 // All ticks of the current last_processed_code_event_id_ are
134 // processed, proceed to the next code event.
135 ProcessCodeEvent();
136 }
137 } while (!timer.HasExpired(period_));
138
139 // Schedule next sample. sampler_ is NULL in tests.
140 if (sampler_) sampler_->DoSample();
141 } 145 }
142 146
143 // Process remaining tick events. 147 // Process remaining tick events.
144 do { 148 do {
145 while (!ProcessOneSample()) {} 149 ProcessTicks();
146 } while (ProcessCodeEvent()); 150 } while (ProcessCodeEvent());
147 } 151 }
148 152
149 153
150 int CpuProfiler::GetProfilesCount() { 154 int CpuProfiler::GetProfilesCount() {
151 // The count of profiles doesn't depend on a security token. 155 // The count of profiles doesn't depend on a security token.
152 return profiles_->profiles()->length(); 156 return profiles_->profiles()->length();
153 } 157 }
154 158
155 159
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; 493 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_;
490 Builtins::Name id = static_cast<Builtins::Name>(i); 494 Builtins::Name id = static_cast<Builtins::Name>(i);
491 rec->start = builtins->builtin(id)->address(); 495 rec->start = builtins->builtin(id)->address();
492 rec->builtin_id = id; 496 rec->builtin_id = id;
493 processor_->Enqueue(evt_rec); 497 processor_->Enqueue(evt_rec);
494 } 498 }
495 } 499 }
496 500
497 501
498 } } // namespace v8::internal 502 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/cpu-profiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698