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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 77 } |
78 | 78 |
79 void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, | 79 void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, |
80 AbstractCode* abstract_code, | 80 AbstractCode* abstract_code, |
81 SharedFunctionInfo* shared, | 81 SharedFunctionInfo* shared, |
82 Name* script_name, int line, | 82 Name* script_name, int line, |
83 int column) { | 83 int column) { |
84 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | 84 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); |
85 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | 85 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
86 rec->start = abstract_code->address(); | 86 rec->start = abstract_code->address(); |
87 Script* script = Script::cast(shared->script()); | |
88 JITLineInfoTable* line_table = NULL; | 87 JITLineInfoTable* line_table = NULL; |
89 if (script) { | 88 if (shared->script()->IsScript()) { |
| 89 Script* script = Script::cast(shared->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 for (SourcePositionTableIterator it(abstract_code->source_position_table()); | 93 for (SourcePositionTableIterator it(abstract_code->source_position_table()); |
94 !it.done(); it.Advance()) { | 94 !it.done(); it.Advance()) { |
95 // TODO(alph,tebbi) Skipping inlined positions for now, because they might | 95 // TODO(alph,tebbi) Skipping inlined positions for now, because they might |
96 // refer to a different script. | 96 // refer to a different script. |
97 if (it.source_position().InliningId() != SourcePosition::kNotInlined) | 97 if (it.source_position().InliningId() != SourcePosition::kNotInlined) |
98 continue; | 98 continue; |
99 int position = it.source_position().ScriptOffset(); | 99 int position = it.source_position().ScriptOffset(); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 int inlining_id = static_cast<int>(it.rinfo()->data()); | 262 int inlining_id = static_cast<int>(it.rinfo()->data()); |
263 last_position = SourcePosition(script_offset, inlining_id); | 263 last_position = SourcePosition(script_offset, inlining_id); |
264 continue; | 264 continue; |
265 } | 265 } |
266 if (info->rmode() == RelocInfo::DEOPT_ID) { | 266 if (info->rmode() == RelocInfo::DEOPT_ID) { |
267 int deopt_id = static_cast<int>(info->data()); | 267 int deopt_id = static_cast<int>(info->data()); |
268 DCHECK(last_position.IsKnown()); | 268 DCHECK(last_position.IsKnown()); |
269 std::vector<CpuProfileDeoptFrame> inlined_frames; | 269 std::vector<CpuProfileDeoptFrame> inlined_frames; |
270 for (SourcePositionInfo& pos_info : last_position.InliningStack(code)) { | 270 for (SourcePositionInfo& pos_info : last_position.InliningStack(code)) { |
271 DCHECK(pos_info.position.ScriptOffset() != kNoSourcePosition); | 271 DCHECK(pos_info.position.ScriptOffset() != kNoSourcePosition); |
| 272 if (!pos_info.function->script()->IsScript()) continue; |
| 273 int script_id = Script::cast(pos_info.function->script())->id(); |
272 size_t offset = static_cast<size_t>(pos_info.position.ScriptOffset()); | 274 size_t offset = static_cast<size_t>(pos_info.position.ScriptOffset()); |
273 int script_id = Script::cast(pos_info.function->script())->id(); | |
274 inlined_frames.push_back(CpuProfileDeoptFrame({script_id, offset})); | 275 inlined_frames.push_back(CpuProfileDeoptFrame({script_id, offset})); |
275 } | 276 } |
276 if (!inlined_frames.empty() && | 277 if (!inlined_frames.empty() && |
277 !entry->HasDeoptInlinedFramesFor(deopt_id)) { | 278 !entry->HasDeoptInlinedFramesFor(deopt_id)) { |
278 entry->AddDeoptInlinedFrames(deopt_id, std::move(inlined_frames)); | 279 entry->AddDeoptInlinedFrames(deopt_id, std::move(inlined_frames)); |
279 } | 280 } |
280 } | 281 } |
281 } | 282 } |
282 } | 283 } |
283 | 284 |
(...skipping 18 matching lines...) Expand all Loading... |
302 | 303 |
303 void ProfilerListener::RemoveObserver(CodeEventObserver* observer) { | 304 void ProfilerListener::RemoveObserver(CodeEventObserver* observer) { |
304 base::LockGuard<base::Mutex> guard(&mutex_); | 305 base::LockGuard<base::Mutex> guard(&mutex_); |
305 auto it = std::find(observers_.begin(), observers_.end(), observer); | 306 auto it = std::find(observers_.begin(), observers_.end(), observer); |
306 if (it == observers_.end()) return; | 307 if (it == observers_.end()) return; |
307 observers_.erase(it); | 308 observers_.erase(it); |
308 } | 309 } |
309 | 310 |
310 } // namespace internal | 311 } // namespace internal |
311 } // namespace v8 | 312 } // namespace v8 |
OLD | NEW |