jkummerow@chromium.org | ab7dad4 | 2012-02-07 12:07:34 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #include "v8.h" |
| 29 | |
| 30 | #include "cpu-profiler-inl.h" |
| 31 | |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 32 | #include "frames-inl.h" |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 33 | #include "hashmap.h" |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 34 | #include "log-inl.h" |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 35 | #include "vm-state-inl.h" |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 36 | |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 37 | #include "../include/v8-profiler.h" |
| 38 | |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 39 | namespace v8 { |
| 40 | namespace internal { |
| 41 | |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 42 | static const int kEventsBufferSize = 256 * KB; |
| 43 | static const int kTickSamplesBufferChunkSize = 64 * KB; |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 44 | static const int kTickSamplesBufferChunksCount = 16; |
jkummerow@chromium.org | ab7dad4 | 2012-02-07 12:07:34 +0000 | [diff] [blame] | 45 | static const int kProfilerStackSize = 64 * KB; |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 46 | |
| 47 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 48 | ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator) |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 49 | : Thread(Thread::Options("v8:ProfEvntProc", kProfilerStackSize)), |
lrn@chromium.org | 5d00b60 | 2011-01-05 09:51:43 +0000 | [diff] [blame] | 50 | generator_(generator), |
erik.corry@gmail.com | 145eff5 | 2010-08-23 11:36:18 +0000 | [diff] [blame] | 51 | running_(true), |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 52 | ticks_buffer_(sizeof(TickSampleEventRecord), |
| 53 | kTickSamplesBufferChunkSize, |
| 54 | kTickSamplesBufferChunksCount), |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 55 | enqueue_order_(0) { |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 56 | } |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 57 | |
| 58 | |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 59 | void ProfilerEventsProcessor::CallbackCreateEvent(Logger::LogEventsAndTags tag, |
| 60 | const char* prefix, |
| 61 | String* name, |
| 62 | Address start) { |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 63 | if (FilterOutCodeCreateEvent(tag)) return; |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 64 | CodeEventsContainer evt_rec; |
| 65 | CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
| 66 | rec->type = CodeEventRecord::CODE_CREATION; |
| 67 | rec->order = ++enqueue_order_; |
| 68 | rec->start = start; |
| 69 | rec->entry = generator_->NewCodeEntry(tag, prefix, name); |
| 70 | rec->size = 1; |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 71 | rec->shared = NULL; |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 72 | events_buffer_.Enqueue(evt_rec); |
| 73 | } |
| 74 | |
| 75 | |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 76 | void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 77 | String* name, |
| 78 | String* resource_name, |
| 79 | int line_number, |
| 80 | Address start, |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 81 | unsigned size, |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 82 | Address shared) { |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 83 | if (FilterOutCodeCreateEvent(tag)) return; |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 84 | CodeEventsContainer evt_rec; |
| 85 | CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
| 86 | rec->type = CodeEventRecord::CODE_CREATION; |
| 87 | rec->order = ++enqueue_order_; |
| 88 | rec->start = start; |
| 89 | rec->entry = generator_->NewCodeEntry(tag, name, resource_name, line_number); |
| 90 | rec->size = size; |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 91 | rec->shared = shared; |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 92 | events_buffer_.Enqueue(evt_rec); |
| 93 | } |
| 94 | |
| 95 | |
| 96 | void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 97 | const char* name, |
| 98 | Address start, |
| 99 | unsigned size) { |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 100 | if (FilterOutCodeCreateEvent(tag)) return; |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 101 | CodeEventsContainer evt_rec; |
| 102 | CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
| 103 | rec->type = CodeEventRecord::CODE_CREATION; |
| 104 | rec->order = ++enqueue_order_; |
| 105 | rec->start = start; |
| 106 | rec->entry = generator_->NewCodeEntry(tag, name); |
| 107 | rec->size = size; |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 108 | rec->shared = NULL; |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 109 | events_buffer_.Enqueue(evt_rec); |
| 110 | } |
| 111 | |
| 112 | |
| 113 | void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 114 | int args_count, |
| 115 | Address start, |
| 116 | unsigned size) { |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 117 | if (FilterOutCodeCreateEvent(tag)) return; |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 118 | CodeEventsContainer evt_rec; |
| 119 | CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
| 120 | rec->type = CodeEventRecord::CODE_CREATION; |
| 121 | rec->order = ++enqueue_order_; |
| 122 | rec->start = start; |
| 123 | rec->entry = generator_->NewCodeEntry(tag, args_count); |
| 124 | rec->size = size; |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 125 | rec->shared = NULL; |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 126 | events_buffer_.Enqueue(evt_rec); |
| 127 | } |
| 128 | |
| 129 | |
| 130 | void ProfilerEventsProcessor::CodeMoveEvent(Address from, Address to) { |
| 131 | CodeEventsContainer evt_rec; |
| 132 | CodeMoveEventRecord* rec = &evt_rec.CodeMoveEventRecord_; |
| 133 | rec->type = CodeEventRecord::CODE_MOVE; |
| 134 | rec->order = ++enqueue_order_; |
| 135 | rec->from = from; |
| 136 | rec->to = to; |
| 137 | events_buffer_.Enqueue(evt_rec); |
| 138 | } |
| 139 | |
| 140 | |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 141 | void ProfilerEventsProcessor::SharedFunctionInfoMoveEvent(Address from, |
| 142 | Address to) { |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 143 | CodeEventsContainer evt_rec; |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 144 | SharedFunctionInfoMoveEventRecord* rec = |
| 145 | &evt_rec.SharedFunctionInfoMoveEventRecord_; |
| 146 | rec->type = CodeEventRecord::SHARED_FUNC_MOVE; |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 147 | rec->order = ++enqueue_order_; |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 148 | rec->from = from; |
| 149 | rec->to = to; |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 150 | events_buffer_.Enqueue(evt_rec); |
whesse@chromium.org | 4a5224e | 2010-10-20 12:37:07 +0000 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 154 | void ProfilerEventsProcessor::RegExpCodeCreateEvent( |
| 155 | Logger::LogEventsAndTags tag, |
| 156 | const char* prefix, |
| 157 | String* name, |
| 158 | Address start, |
| 159 | unsigned size) { |
| 160 | if (FilterOutCodeCreateEvent(tag)) return; |
| 161 | CodeEventsContainer evt_rec; |
| 162 | CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
| 163 | rec->type = CodeEventRecord::CODE_CREATION; |
| 164 | rec->order = ++enqueue_order_; |
| 165 | rec->start = start; |
| 166 | rec->entry = generator_->NewCodeEntry(tag, prefix, name); |
| 167 | rec->size = size; |
| 168 | events_buffer_.Enqueue(evt_rec); |
| 169 | } |
| 170 | |
| 171 | |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 172 | void ProfilerEventsProcessor::AddCurrentStack() { |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 173 | TickSampleEventRecord record(enqueue_order_); |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 174 | TickSample* sample = &record.sample; |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 175 | Isolate* isolate = Isolate::Current(); |
| 176 | sample->state = isolate->current_vm_state(); |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 177 | sample->pc = reinterpret_cast<Address>(sample); // Not NULL. |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 178 | for (StackTraceFrameIterator it(isolate); |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 179 | !it.done() && sample->frames_count < TickSample::kMaxFramesCount; |
| 180 | it.Advance()) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 181 | sample->stack[sample->frames_count++] = it.frame()->pc(); |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 182 | } |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 183 | ticks_from_vm_buffer_.Enqueue(record); |
| 184 | } |
| 185 | |
| 186 | |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 187 | bool ProfilerEventsProcessor::ProcessCodeEvent(unsigned* dequeue_order) { |
| 188 | if (!events_buffer_.IsEmpty()) { |
| 189 | CodeEventsContainer record; |
| 190 | events_buffer_.Dequeue(&record); |
| 191 | switch (record.generic.type) { |
| 192 | #define PROFILER_TYPE_CASE(type, clss) \ |
| 193 | case CodeEventRecord::type: \ |
| 194 | record.clss##_.UpdateCodeMap(generator_->code_map()); \ |
| 195 | break; |
| 196 | |
| 197 | CODE_EVENTS_TYPE_LIST(PROFILER_TYPE_CASE) |
| 198 | |
| 199 | #undef PROFILER_TYPE_CASE |
| 200 | default: return true; // Skip record. |
| 201 | } |
| 202 | *dequeue_order = record.generic.order; |
| 203 | return true; |
| 204 | } |
| 205 | return false; |
| 206 | } |
| 207 | |
| 208 | |
| 209 | bool ProfilerEventsProcessor::ProcessTicks(unsigned dequeue_order) { |
| 210 | while (true) { |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 211 | if (!ticks_from_vm_buffer_.IsEmpty() |
| 212 | && ticks_from_vm_buffer_.Peek()->order == dequeue_order) { |
| 213 | TickSampleEventRecord record; |
| 214 | ticks_from_vm_buffer_.Dequeue(&record); |
| 215 | generator_->RecordTickSample(record.sample); |
| 216 | } |
| 217 | |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 218 | const TickSampleEventRecord* rec = |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 219 | TickSampleEventRecord::cast(ticks_buffer_.StartDequeue()); |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 220 | if (rec == NULL) return !ticks_from_vm_buffer_.IsEmpty(); |
kmillikin@chromium.org | 3cdd9e1 | 2010-09-06 11:39:48 +0000 | [diff] [blame] | 221 | // Make a local copy of tick sample record to ensure that it won't |
| 222 | // be modified as we are processing it. This is possible as the |
| 223 | // sampler writes w/o any sync to the queue, so if the processor |
| 224 | // will get far behind, a record may be modified right under its |
| 225 | // feet. |
| 226 | TickSampleEventRecord record = *rec; |
| 227 | if (record.order == dequeue_order) { |
| 228 | // A paranoid check to make sure that we don't get a memory overrun |
| 229 | // in case of frames_count having a wild value. |
| 230 | if (record.sample.frames_count < 0 |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 231 | || record.sample.frames_count > TickSample::kMaxFramesCount) |
kmillikin@chromium.org | 3cdd9e1 | 2010-09-06 11:39:48 +0000 | [diff] [blame] | 232 | record.sample.frames_count = 0; |
| 233 | generator_->RecordTickSample(record.sample); |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 234 | ticks_buffer_.FinishDequeue(); |
| 235 | } else { |
| 236 | return true; |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | |
| 242 | void ProfilerEventsProcessor::Run() { |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 243 | unsigned dequeue_order = 0; |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 244 | |
| 245 | while (running_) { |
| 246 | // Process ticks until we have any. |
| 247 | if (ProcessTicks(dequeue_order)) { |
| 248 | // All ticks of the current dequeue_order are processed, |
| 249 | // proceed to the next code event. |
| 250 | ProcessCodeEvent(&dequeue_order); |
| 251 | } |
| 252 | YieldCPU(); |
| 253 | } |
| 254 | |
| 255 | // Process remaining tick events. |
| 256 | ticks_buffer_.FlushResidualRecords(); |
| 257 | // Perform processing until we have tick events, skip remaining code events. |
| 258 | while (ProcessTicks(dequeue_order) && ProcessCodeEvent(&dequeue_order)) { } |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 262 | void CpuProfiler::StartProfiling(const char* title) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 263 | ASSERT(Isolate::Current()->cpu_profiler() != NULL); |
| 264 | Isolate::Current()->cpu_profiler()->StartCollectingProfile(title); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | |
| 268 | void CpuProfiler::StartProfiling(String* title) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 269 | ASSERT(Isolate::Current()->cpu_profiler() != NULL); |
| 270 | Isolate::Current()->cpu_profiler()->StartCollectingProfile(title); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | |
| 274 | CpuProfile* CpuProfiler::StopProfiling(const char* title) { |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 275 | Isolate* isolate = Isolate::Current(); |
| 276 | return is_profiling(isolate) ? |
| 277 | isolate->cpu_profiler()->StopCollectingProfile(title) : NULL; |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 281 | CpuProfile* CpuProfiler::StopProfiling(Object* security_token, String* title) { |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 282 | Isolate* isolate = Isolate::Current(); |
| 283 | return is_profiling(isolate) ? |
| 284 | isolate->cpu_profiler()->StopCollectingProfile( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 285 | security_token, title) : NULL; |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | |
| 289 | int CpuProfiler::GetProfilesCount() { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 290 | ASSERT(Isolate::Current()->cpu_profiler() != NULL); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 291 | // The count of profiles doesn't depend on a security token. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 292 | return Isolate::Current()->cpu_profiler()->profiles_->Profiles( |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 293 | TokenEnumerator::kNoSecurityToken)->length(); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 297 | CpuProfile* CpuProfiler::GetProfile(Object* security_token, int index) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 298 | ASSERT(Isolate::Current()->cpu_profiler() != NULL); |
| 299 | CpuProfiler* profiler = Isolate::Current()->cpu_profiler(); |
| 300 | const int token = profiler->token_enumerator_->GetTokenId(security_token); |
| 301 | return profiler->profiles_->Profiles(token)->at(index); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 305 | CpuProfile* CpuProfiler::FindProfile(Object* security_token, unsigned uid) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 306 | ASSERT(Isolate::Current()->cpu_profiler() != NULL); |
| 307 | CpuProfiler* profiler = Isolate::Current()->cpu_profiler(); |
| 308 | const int token = profiler->token_enumerator_->GetTokenId(security_token); |
| 309 | return profiler->profiles_->GetProfile(token, uid); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 313 | TickSample* CpuProfiler::TickSampleEvent(Isolate* isolate) { |
| 314 | if (CpuProfiler::is_profiling(isolate)) { |
| 315 | return isolate->cpu_profiler()->processor_->TickSampleEvent(); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 316 | } else { |
| 317 | return NULL; |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 322 | void CpuProfiler::DeleteAllProfiles() { |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 323 | Isolate* isolate = Isolate::Current(); |
| 324 | ASSERT(isolate->cpu_profiler() != NULL); |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 325 | if (is_profiling(isolate)) { |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 326 | isolate->cpu_profiler()->StopProcessor(); |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 327 | } |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 328 | isolate->cpu_profiler()->ResetProfiles(); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | |
| 332 | void CpuProfiler::DeleteProfile(CpuProfile* profile) { |
| 333 | ASSERT(Isolate::Current()->cpu_profiler() != NULL); |
| 334 | Isolate::Current()->cpu_profiler()->profiles_->RemoveProfile(profile); |
| 335 | delete profile; |
| 336 | } |
| 337 | |
| 338 | |
| 339 | bool CpuProfiler::HasDetachedProfiles() { |
| 340 | ASSERT(Isolate::Current()->cpu_profiler() != NULL); |
| 341 | return Isolate::Current()->cpu_profiler()->profiles_->HasDetachedProfiles(); |
| 342 | } |
| 343 | |
| 344 | |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 345 | void CpuProfiler::CallbackEvent(String* name, Address entry_point) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 346 | Isolate::Current()->cpu_profiler()->processor_->CallbackCreateEvent( |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 347 | Logger::CALLBACK_TAG, CodeEntry::kEmptyNamePrefix, name, entry_point); |
| 348 | } |
| 349 | |
| 350 | |
| 351 | void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 352 | Code* code, const char* comment) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 353 | Isolate::Current()->cpu_profiler()->processor_->CodeCreateEvent( |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 354 | tag, comment, code->address(), code->ExecutableSize()); |
| 355 | } |
| 356 | |
| 357 | |
| 358 | void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 359 | Code* code, String* name) { |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 360 | Isolate* isolate = Isolate::Current(); |
| 361 | isolate->cpu_profiler()->processor_->CodeCreateEvent( |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 362 | tag, |
| 363 | name, |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 364 | isolate->heap()->empty_string(), |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 365 | v8::CpuProfileNode::kNoLineNumberInfo, |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 366 | code->address(), |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 367 | code->ExecutableSize(), |
| 368 | NULL); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | |
| 372 | void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 373 | Code* code, |
| 374 | SharedFunctionInfo* shared, |
| 375 | String* name) { |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 376 | Isolate* isolate = Isolate::Current(); |
| 377 | isolate->cpu_profiler()->processor_->CodeCreateEvent( |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 378 | tag, |
| 379 | name, |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 380 | isolate->heap()->empty_string(), |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 381 | v8::CpuProfileNode::kNoLineNumberInfo, |
| 382 | code->address(), |
| 383 | code->ExecutableSize(), |
| 384 | shared->address()); |
| 385 | } |
| 386 | |
| 387 | |
| 388 | void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 389 | Code* code, |
| 390 | SharedFunctionInfo* shared, |
| 391 | String* source, int line) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 392 | Isolate::Current()->cpu_profiler()->processor_->CodeCreateEvent( |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 393 | tag, |
| 394 | shared->DebugName(), |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 395 | source, |
| 396 | line, |
| 397 | code->address(), |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 398 | code->ExecutableSize(), |
| 399 | shared->address()); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | |
| 403 | void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 404 | Code* code, int args_count) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 405 | Isolate::Current()->cpu_profiler()->processor_->CodeCreateEvent( |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 406 | tag, |
| 407 | args_count, |
| 408 | code->address(), |
| 409 | code->ExecutableSize()); |
| 410 | } |
| 411 | |
| 412 | |
| 413 | void CpuProfiler::CodeMoveEvent(Address from, Address to) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 414 | Isolate::Current()->cpu_profiler()->processor_->CodeMoveEvent(from, to); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | |
| 418 | void CpuProfiler::CodeDeleteEvent(Address from) { |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 422 | void CpuProfiler::SharedFunctionInfoMoveEvent(Address from, Address to) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 423 | CpuProfiler* profiler = Isolate::Current()->cpu_profiler(); |
| 424 | profiler->processor_->SharedFunctionInfoMoveEvent(from, to); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | |
| 428 | void CpuProfiler::GetterCallbackEvent(String* name, Address entry_point) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 429 | Isolate::Current()->cpu_profiler()->processor_->CallbackCreateEvent( |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 430 | Logger::CALLBACK_TAG, "get ", name, entry_point); |
| 431 | } |
| 432 | |
| 433 | |
| 434 | void CpuProfiler::RegExpCodeCreateEvent(Code* code, String* source) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 435 | Isolate::Current()->cpu_profiler()->processor_->RegExpCodeCreateEvent( |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 436 | Logger::REG_EXP_TAG, |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 437 | "RegExp: ", |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 438 | source, |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 439 | code->address(), |
| 440 | code->ExecutableSize()); |
| 441 | } |
| 442 | |
| 443 | |
| 444 | void CpuProfiler::SetterCallbackEvent(String* name, Address entry_point) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 445 | Isolate::Current()->cpu_profiler()->processor_->CallbackCreateEvent( |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 446 | Logger::CALLBACK_TAG, "set ", name, entry_point); |
| 447 | } |
| 448 | |
| 449 | |
| 450 | CpuProfiler::CpuProfiler() |
| 451 | : profiles_(new CpuProfilesCollection()), |
| 452 | next_profile_uid_(1), |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 453 | token_enumerator_(new TokenEnumerator()), |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 454 | generator_(NULL), |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 455 | processor_(NULL), |
| 456 | need_to_stop_sampler_(false), |
| 457 | is_profiling_(false) { |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | |
| 461 | CpuProfiler::~CpuProfiler() { |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 462 | delete token_enumerator_; |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 463 | delete profiles_; |
| 464 | } |
| 465 | |
| 466 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 467 | void CpuProfiler::ResetProfiles() { |
| 468 | delete profiles_; |
| 469 | profiles_ = new CpuProfilesCollection(); |
| 470 | } |
| 471 | |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 472 | void CpuProfiler::StartCollectingProfile(const char* title) { |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 473 | if (profiles_->StartProfiling(title, next_profile_uid_++)) { |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 474 | StartProcessorIfNotStarted(); |
| 475 | } |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 476 | processor_->AddCurrentStack(); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | |
| 480 | void CpuProfiler::StartCollectingProfile(String* title) { |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 481 | StartCollectingProfile(profiles_->GetName(title)); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | |
| 485 | void CpuProfiler::StartProcessorIfNotStarted() { |
| 486 | if (processor_ == NULL) { |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 487 | Isolate* isolate = Isolate::Current(); |
| 488 | |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 489 | // Disable logging when using the new implementation. |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 490 | saved_logging_nesting_ = isolate->logger()->logging_nesting_; |
| 491 | isolate->logger()->logging_nesting_ = 0; |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 492 | generator_ = new ProfileGenerator(profiles_); |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 493 | processor_ = new ProfilerEventsProcessor(generator_); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 494 | NoBarrier_Store(&is_profiling_, true); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 495 | processor_->Start(); |
| 496 | // Enumerate stuff we already have in the heap. |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 497 | if (isolate->heap()->HasBeenSetUp()) { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 498 | if (!FLAG_prof_browser_mode) { |
| 499 | bool saved_log_code_flag = FLAG_log_code; |
| 500 | FLAG_log_code = true; |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 501 | isolate->logger()->LogCodeObjects(); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 502 | FLAG_log_code = saved_log_code_flag; |
| 503 | } |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 504 | isolate->logger()->LogCompiledFunctions(); |
| 505 | isolate->logger()->LogAccessorCallbacks(); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 506 | } |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 507 | // Enable stack sampling. |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 508 | Sampler* sampler = reinterpret_cast<Sampler*>(isolate->logger()->ticker_); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 509 | if (!sampler->IsActive()) { |
| 510 | sampler->Start(); |
| 511 | need_to_stop_sampler_ = true; |
| 512 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 513 | sampler->IncreaseProfilingDepth(); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 514 | } |
| 515 | } |
| 516 | |
| 517 | |
| 518 | CpuProfile* CpuProfiler::StopCollectingProfile(const char* title) { |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 519 | const double actual_sampling_rate = generator_->actual_sampling_rate(); |
vegorov@chromium.org | 26c16f8 | 2010-08-11 13:41:03 +0000 | [diff] [blame] | 520 | StopProcessorIfLastProfile(title); |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 521 | CpuProfile* result = |
| 522 | profiles_->StopProfiling(TokenEnumerator::kNoSecurityToken, |
| 523 | title, |
| 524 | actual_sampling_rate); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 525 | if (result != NULL) { |
| 526 | result->Print(); |
| 527 | } |
| 528 | return result; |
| 529 | } |
| 530 | |
| 531 | |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 532 | CpuProfile* CpuProfiler::StopCollectingProfile(Object* security_token, |
| 533 | String* title) { |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 534 | const double actual_sampling_rate = generator_->actual_sampling_rate(); |
vegorov@chromium.org | 26c16f8 | 2010-08-11 13:41:03 +0000 | [diff] [blame] | 535 | const char* profile_title = profiles_->GetName(title); |
| 536 | StopProcessorIfLastProfile(profile_title); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 537 | int token = token_enumerator_->GetTokenId(security_token); |
vegorov@chromium.org | 26c16f8 | 2010-08-11 13:41:03 +0000 | [diff] [blame] | 538 | return profiles_->StopProfiling(token, profile_title, actual_sampling_rate); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | |
vegorov@chromium.org | 26c16f8 | 2010-08-11 13:41:03 +0000 | [diff] [blame] | 542 | void CpuProfiler::StopProcessorIfLastProfile(const char* title) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 543 | if (profiles_->IsLastProfile(title)) StopProcessor(); |
| 544 | } |
| 545 | |
| 546 | |
| 547 | void CpuProfiler::StopProcessor() { |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 548 | Logger* logger = Isolate::Current()->logger(); |
| 549 | Sampler* sampler = reinterpret_cast<Sampler*>(logger->ticker_); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 550 | sampler->DecreaseProfilingDepth(); |
| 551 | if (need_to_stop_sampler_) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 552 | sampler->Stop(); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 553 | need_to_stop_sampler_ = false; |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 554 | } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 555 | NoBarrier_Store(&is_profiling_, false); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 556 | processor_->Stop(); |
| 557 | processor_->Join(); |
| 558 | delete processor_; |
| 559 | delete generator_; |
| 560 | processor_ = NULL; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 561 | generator_ = NULL; |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 562 | logger->logging_nesting_ = saved_logging_nesting_; |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 563 | } |
| 564 | |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 565 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 566 | void CpuProfiler::SetUp() { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 567 | Isolate* isolate = Isolate::Current(); |
| 568 | if (isolate->cpu_profiler() == NULL) { |
| 569 | isolate->set_cpu_profiler(new CpuProfiler()); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 570 | } |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | |
| 574 | void CpuProfiler::TearDown() { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 575 | Isolate* isolate = Isolate::Current(); |
| 576 | if (isolate->cpu_profiler() != NULL) { |
| 577 | delete isolate->cpu_profiler(); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 578 | } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 579 | isolate->set_cpu_profiler(NULL); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 580 | } |
| 581 | |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 582 | } } // namespace v8::internal |