| 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/profiler/cpu-profiler.h" | 5 #include "src/profiler/cpu-profiler.h" |
| 6 | 6 |
| 7 #include "src/debug/debug.h" | 7 #include "src/debug/debug.h" |
| 8 #include "src/deoptimizer.h" | 8 #include "src/deoptimizer.h" |
| 9 #include "src/frames-inl.h" | 9 #include "src/frames-inl.h" |
| 10 #include "src/locked-queue-inl.h" | 10 #include "src/locked-queue-inl.h" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 CompilationInfo* info, Name* script_name, | 267 CompilationInfo* info, Name* script_name, |
| 268 int line, int column) { | 268 int line, int column) { |
| 269 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | 269 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); |
| 270 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | 270 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
| 271 rec->start = abstract_code->address(); | 271 rec->start = abstract_code->address(); |
| 272 Script* script = Script::cast(shared->script()); | 272 Script* script = Script::cast(shared->script()); |
| 273 JITLineInfoTable* line_table = NULL; | 273 JITLineInfoTable* line_table = NULL; |
| 274 if (script) { | 274 if (script) { |
| 275 if (abstract_code->IsCode()) { | 275 if (abstract_code->IsCode()) { |
| 276 Code* code = abstract_code->GetCode(); | 276 Code* code = abstract_code->GetCode(); |
| 277 int start_position = shared->start_position(); |
| 278 int end_position = shared->end_position(); |
| 277 line_table = new JITLineInfoTable(); | 279 line_table = new JITLineInfoTable(); |
| 278 for (RelocIterator it(code); !it.done(); it.next()) { | 280 for (RelocIterator it(code); !it.done(); it.next()) { |
| 279 RelocInfo::Mode mode = it.rinfo()->rmode(); | 281 RelocInfo* reloc_info = it.rinfo(); |
| 280 if (RelocInfo::IsPosition(mode)) { | 282 if (!RelocInfo::IsPosition(reloc_info->rmode())) continue; |
| 281 int position = static_cast<int>(it.rinfo()->data()); | 283 int position = static_cast<int>(reloc_info->data()); |
| 282 if (position >= 0) { | 284 // TODO(alph): in case of inlining the position may correspond |
| 283 int pc_offset = | 285 // to an inlined function source code. Do not collect positions |
| 284 static_cast<int>(it.rinfo()->pc() - code->address()); | 286 // that fall beyond the function source code. There's however a |
| 285 int line_number = script->GetLineNumber(position) + 1; | 287 // chance the inlined function has similar positions but in another |
| 286 line_table->SetPosition(pc_offset, line_number); | 288 // script. So the proper fix is to store script_id in some form |
| 287 } | 289 // along with the inlined function positions. |
| 288 } | 290 if (position < start_position || position >= end_position) continue; |
| 291 int pc_offset = static_cast<int>(reloc_info->pc() - code->address()); |
| 292 int line_number = script->GetLineNumber(position) + 1; |
| 293 line_table->SetPosition(pc_offset, line_number); |
| 289 } | 294 } |
| 290 } else { | 295 } else { |
| 291 BytecodeArray* bytecode = abstract_code->GetBytecodeArray(); | 296 BytecodeArray* bytecode = abstract_code->GetBytecodeArray(); |
| 292 line_table = new JITLineInfoTable(); | 297 line_table = new JITLineInfoTable(); |
| 293 interpreter::SourcePositionTableIterator it( | 298 interpreter::SourcePositionTableIterator it( |
| 294 bytecode->source_position_table()); | 299 bytecode->source_position_table()); |
| 295 for (; !it.done(); it.Advance()) { | 300 for (; !it.done(); it.Advance()) { |
| 296 int line_number = script->GetLineNumber(it.source_position()) + 1; | 301 int line_number = script->GetLineNumber(it.source_position()) + 1; |
| 297 int pc_offset = it.bytecode_offset() + BytecodeArray::kHeaderSize; | 302 int pc_offset = it.bytecode_offset() + BytecodeArray::kHeaderSize; |
| 298 line_table->SetPosition(pc_offset, line_number); | 303 line_table->SetPosition(pc_offset, line_number); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 Builtins::Name id = static_cast<Builtins::Name>(i); | 592 Builtins::Name id = static_cast<Builtins::Name>(i); |
| 588 rec->start = builtins->builtin(id)->address(); | 593 rec->start = builtins->builtin(id)->address(); |
| 589 rec->builtin_id = id; | 594 rec->builtin_id = id; |
| 590 processor_->Enqueue(evt_rec); | 595 processor_->Enqueue(evt_rec); |
| 591 } | 596 } |
| 592 } | 597 } |
| 593 | 598 |
| 594 | 599 |
| 595 } // namespace internal | 600 } // namespace internal |
| 596 } // namespace v8 | 601 } // namespace v8 |
| OLD | NEW |