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