OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/profiler-listener.h" | 5 #include "src/profiler/profiler-listener.h" |
6 | 6 |
7 #include "src/deoptimizer.h" | 7 #include "src/deoptimizer.h" |
8 #include "src/profiler/cpu-profiler.h" | 8 #include "src/profiler/cpu-profiler.h" |
9 #include "src/profiler/profile-generator-inl.h" | 9 #include "src/profiler/profile-generator-inl.h" |
10 #include "src/source-position-table.h" | 10 #include "src/source-position-table.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 Script* script = Script::cast(shared->script()); | 87 Script* script = Script::cast(shared->script()); |
88 JITLineInfoTable* line_table = NULL; | 88 JITLineInfoTable* line_table = NULL; |
89 if (script) { | 89 if (script) { |
90 line_table = new JITLineInfoTable(); | 90 line_table = new JITLineInfoTable(); |
91 int offset = abstract_code->IsCode() ? Code::kHeaderSize | 91 int offset = abstract_code->IsCode() ? Code::kHeaderSize |
92 : BytecodeArray::kHeaderSize; | 92 : BytecodeArray::kHeaderSize; |
93 int start_position = shared->start_position(); | 93 int start_position = shared->start_position(); |
94 int end_position = shared->end_position(); | 94 int end_position = shared->end_position(); |
95 for (SourcePositionTableIterator it(abstract_code->source_position_table()); | 95 for (SourcePositionTableIterator it(abstract_code->source_position_table()); |
96 !it.done(); it.Advance()) { | 96 !it.done(); it.Advance()) { |
97 int position = it.source_position(); | 97 int position = it.source_position().ScriptOffset(); |
98 // TODO(alph): in case of inlining the position may correspond to an | 98 // TODO(alph): in case of inlining the position may correspond to an |
99 // inlined function source code. Do not collect positions that fall | 99 // inlined function source code. Do not collect positions that fall |
100 // beyond the function source code. There's however a chance the | 100 // beyond the function source code. There's however a chance the |
101 // inlined function has similar positions but in another script. So | 101 // inlined function has similar positions but in another script. So |
102 // the proper fix is to store script_id in some form along with the | 102 // the proper fix is to store script_id in some form along with the |
103 // inlined function positions. | 103 // inlined function positions. |
104 if (position < start_position || position >= end_position) continue; | 104 if (position < start_position || position >= end_position) continue; |
105 int line_number = script->GetLineNumber(position) + 1; | 105 int line_number = script->GetLineNumber(position) + 1; |
106 int pc_offset = it.code_offset() + offset; | 106 int pc_offset = it.code_offset() + offset; |
107 line_table->SetPosition(pc_offset, line_number); | 107 line_table->SetPosition(pc_offset, line_number); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 328 |
329 void ProfilerListener::RemoveObserver(CodeEventObserver* observer) { | 329 void ProfilerListener::RemoveObserver(CodeEventObserver* observer) { |
330 base::LockGuard<base::Mutex> guard(&mutex_); | 330 base::LockGuard<base::Mutex> guard(&mutex_); |
331 auto it = std::find(observers_.begin(), observers_.end(), observer); | 331 auto it = std::find(observers_.begin(), observers_.end(), observer); |
332 if (it == observers_.end()) return; | 332 if (it == observers_.end()) return; |
333 observers_.erase(it); | 333 observers_.erase(it); |
334 } | 334 } |
335 | 335 |
336 } // namespace internal | 336 } // namespace internal |
337 } // namespace v8 | 337 } // namespace v8 |
OLD | NEW |