OLD | NEW |
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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/cpu-profiler-inl.h" | 7 #include "src/cpu-profiler-inl.h" |
8 | 8 |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/frames-inl.h" | 10 #include "src/frames-inl.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 } | 194 } |
195 | 195 |
196 | 196 |
197 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | 197 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
198 Code* code, | 198 Code* code, |
199 const char* name) { | 199 const char* name) { |
200 if (FilterOutCodeCreateEvent(tag)) return; | 200 if (FilterOutCodeCreateEvent(tag)) return; |
201 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | 201 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); |
202 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | 202 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
203 rec->start = code->address(); | 203 rec->start = code->address(); |
204 rec->entry = profiles_->NewCodeEntry( | 204 rec->entry = profiles_->NewCodeEntry(tag, profiles_->GetFunctionName(name)); |
205 tag, profiles_->GetFunctionName(name), CodeEntry::kEmptyNamePrefix, | |
206 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo, | |
207 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start()); | |
208 rec->size = code->ExecutableSize(); | 205 rec->size = code->ExecutableSize(); |
209 rec->shared = NULL; | 206 rec->shared = NULL; |
210 processor_->Enqueue(evt_rec); | 207 processor_->Enqueue(evt_rec); |
211 } | 208 } |
212 | 209 |
213 | 210 |
214 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | 211 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
215 Code* code, | 212 Code* code, |
216 Name* name) { | 213 Name* name) { |
217 if (FilterOutCodeCreateEvent(tag)) return; | 214 if (FilterOutCodeCreateEvent(tag)) return; |
218 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | 215 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); |
219 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | 216 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
220 rec->start = code->address(); | 217 rec->start = code->address(); |
221 rec->entry = profiles_->NewCodeEntry( | 218 rec->entry = profiles_->NewCodeEntry(tag, profiles_->GetFunctionName(name)); |
222 tag, profiles_->GetFunctionName(name), CodeEntry::kEmptyNamePrefix, | |
223 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo, | |
224 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start()); | |
225 rec->size = code->ExecutableSize(); | 219 rec->size = code->ExecutableSize(); |
226 rec->shared = NULL; | 220 rec->shared = NULL; |
227 processor_->Enqueue(evt_rec); | 221 processor_->Enqueue(evt_rec); |
228 } | 222 } |
229 | 223 |
230 | 224 |
231 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code, | 225 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code, |
232 SharedFunctionInfo* shared, | 226 SharedFunctionInfo* shared, |
233 CompilationInfo* info, Name* script_name) { | 227 CompilationInfo* info, Name* script_name) { |
234 if (FilterOutCodeCreateEvent(tag)) return; | 228 if (FilterOutCodeCreateEvent(tag)) return; |
235 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | 229 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); |
236 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | 230 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
237 rec->start = code->address(); | 231 rec->start = code->address(); |
238 rec->entry = profiles_->NewCodeEntry( | 232 rec->entry = profiles_->NewCodeEntry( |
239 tag, profiles_->GetFunctionName(shared->DebugName()), | 233 tag, profiles_->GetFunctionName(shared->DebugName()), |
240 CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name), | 234 CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name)); |
241 CpuProfileNode::kNoLineNumberInfo, CpuProfileNode::kNoColumnNumberInfo, | |
242 NULL, code->instruction_start()); | |
243 if (info) { | 235 if (info) { |
244 rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges()); | 236 rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges()); |
245 } | 237 } |
246 if (shared->script()->IsScript()) { | 238 if (shared->script()->IsScript()) { |
247 DCHECK(Script::cast(shared->script())); | 239 DCHECK(Script::cast(shared->script())); |
248 Script* script = Script::cast(shared->script()); | 240 Script* script = Script::cast(shared->script()); |
249 rec->entry->set_script_id(script->id()->value()); | 241 rec->entry->set_script_id(script->id()->value()); |
250 rec->entry->set_bailout_reason( | 242 rec->entry->set_bailout_reason( |
251 GetBailoutReason(shared->DisableOptimizationReason())); | 243 GetBailoutReason(shared->DisableOptimizationReason())); |
252 } | 244 } |
253 rec->size = code->ExecutableSize(); | 245 rec->size = code->ExecutableSize(); |
254 rec->shared = shared->address(); | 246 rec->shared = shared->address(); |
255 processor_->Enqueue(evt_rec); | 247 processor_->Enqueue(evt_rec); |
256 } | 248 } |
257 | 249 |
258 | 250 |
259 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code, | 251 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code, |
260 SharedFunctionInfo* shared, | 252 SharedFunctionInfo* shared, |
261 CompilationInfo* info, Name* script_name, | 253 CompilationInfo* info, Name* script_name, |
262 int line, int column) { | 254 int line, int column) { |
263 if (FilterOutCodeCreateEvent(tag)) return; | 255 if (FilterOutCodeCreateEvent(tag)) return; |
264 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | 256 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); |
265 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | 257 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
266 rec->start = code->address(); | 258 rec->start = code->address(); |
267 Script* script = Script::cast(shared->script()); | |
268 JITLineInfoTable* line_table = NULL; | |
269 if (script) { | |
270 line_table = new JITLineInfoTable(); | |
271 for (RelocIterator it(code); !it.done(); it.next()) { | |
272 RelocInfo::Mode mode = it.rinfo()->rmode(); | |
273 if (RelocInfo::IsPosition(mode)) { | |
274 int position = static_cast<int>(it.rinfo()->data()); | |
275 if (position >= 0) { | |
276 int pc_offset = static_cast<int>(it.rinfo()->pc() - code->address()); | |
277 int line_number = script->GetLineNumber(position) + 1; | |
278 line_table->SetPosition(pc_offset, line_number); | |
279 } | |
280 } | |
281 } | |
282 } | |
283 rec->entry = profiles_->NewCodeEntry( | 259 rec->entry = profiles_->NewCodeEntry( |
284 tag, profiles_->GetFunctionName(shared->DebugName()), | 260 tag, profiles_->GetFunctionName(shared->DebugName()), |
285 CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name), line, | 261 CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name), line, |
286 column, line_table, code->instruction_start()); | 262 column); |
287 if (info) { | 263 if (info) { |
288 rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges()); | 264 rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges()); |
289 } | 265 } |
| 266 DCHECK(Script::cast(shared->script())); |
| 267 Script* script = Script::cast(shared->script()); |
290 rec->entry->set_script_id(script->id()->value()); | 268 rec->entry->set_script_id(script->id()->value()); |
291 rec->size = code->ExecutableSize(); | 269 rec->size = code->ExecutableSize(); |
292 rec->shared = shared->address(); | 270 rec->shared = shared->address(); |
293 rec->entry->set_bailout_reason( | 271 rec->entry->set_bailout_reason( |
294 GetBailoutReason(shared->DisableOptimizationReason())); | 272 GetBailoutReason(shared->DisableOptimizationReason())); |
295 processor_->Enqueue(evt_rec); | 273 processor_->Enqueue(evt_rec); |
296 } | 274 } |
297 | 275 |
298 | 276 |
299 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | 277 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
300 Code* code, | 278 Code* code, |
301 int args_count) { | 279 int args_count) { |
302 if (FilterOutCodeCreateEvent(tag)) return; | 280 if (FilterOutCodeCreateEvent(tag)) return; |
303 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | 281 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); |
304 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | 282 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
305 rec->start = code->address(); | 283 rec->start = code->address(); |
306 rec->entry = profiles_->NewCodeEntry( | 284 rec->entry = profiles_->NewCodeEntry( |
307 tag, profiles_->GetName(args_count), "args_count: ", | 285 tag, |
308 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo, | 286 profiles_->GetName(args_count), |
309 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start()); | 287 "args_count: "); |
310 rec->size = code->ExecutableSize(); | 288 rec->size = code->ExecutableSize(); |
311 rec->shared = NULL; | 289 rec->shared = NULL; |
312 processor_->Enqueue(evt_rec); | 290 processor_->Enqueue(evt_rec); |
313 } | 291 } |
314 | 292 |
315 | 293 |
316 void CpuProfiler::CodeMoveEvent(Address from, Address to) { | 294 void CpuProfiler::CodeMoveEvent(Address from, Address to) { |
317 CodeEventsContainer evt_rec(CodeEventRecord::CODE_MOVE); | 295 CodeEventsContainer evt_rec(CodeEventRecord::CODE_MOVE); |
318 CodeMoveEventRecord* rec = &evt_rec.CodeMoveEventRecord_; | 296 CodeMoveEventRecord* rec = &evt_rec.CodeMoveEventRecord_; |
319 rec->from = from; | 297 rec->from = from; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 processor_->Enqueue(evt_rec); | 337 processor_->Enqueue(evt_rec); |
360 } | 338 } |
361 | 339 |
362 | 340 |
363 void CpuProfiler::RegExpCodeCreateEvent(Code* code, String* source) { | 341 void CpuProfiler::RegExpCodeCreateEvent(Code* code, String* source) { |
364 if (FilterOutCodeCreateEvent(Logger::REG_EXP_TAG)) return; | 342 if (FilterOutCodeCreateEvent(Logger::REG_EXP_TAG)) return; |
365 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | 343 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); |
366 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | 344 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
367 rec->start = code->address(); | 345 rec->start = code->address(); |
368 rec->entry = profiles_->NewCodeEntry( | 346 rec->entry = profiles_->NewCodeEntry( |
369 Logger::REG_EXP_TAG, profiles_->GetName(source), "RegExp: ", | 347 Logger::REG_EXP_TAG, |
370 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo, | 348 profiles_->GetName(source), |
371 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start()); | 349 "RegExp: "); |
372 rec->size = code->ExecutableSize(); | 350 rec->size = code->ExecutableSize(); |
373 processor_->Enqueue(evt_rec); | 351 processor_->Enqueue(evt_rec); |
374 } | 352 } |
375 | 353 |
376 | 354 |
377 void CpuProfiler::SetterCallbackEvent(Name* name, Address entry_point) { | 355 void CpuProfiler::SetterCallbackEvent(Name* name, Address entry_point) { |
378 if (FilterOutCodeCreateEvent(Logger::CALLBACK_TAG)) return; | 356 if (FilterOutCodeCreateEvent(Logger::CALLBACK_TAG)) return; |
379 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | 357 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); |
380 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | 358 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
381 rec->start = entry_point; | 359 rec->start = entry_point; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; | 499 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; |
522 Builtins::Name id = static_cast<Builtins::Name>(i); | 500 Builtins::Name id = static_cast<Builtins::Name>(i); |
523 rec->start = builtins->builtin(id)->address(); | 501 rec->start = builtins->builtin(id)->address(); |
524 rec->builtin_id = id; | 502 rec->builtin_id = id; |
525 processor_->Enqueue(evt_rec); | 503 processor_->Enqueue(evt_rec); |
526 } | 504 } |
527 } | 505 } |
528 | 506 |
529 | 507 |
530 } } // namespace v8::internal | 508 } } // namespace v8::internal |
OLD | NEW |