Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: src/profiler/profiler-listener.cc

Issue 2109673003: Use source position table in turbofan code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: drive-by fix for relocation info size reservation Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects-inl.h ('k') | src/x87/deoptimizer-x87.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
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()); 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 if (abstract_code->IsCode()) { 91 int offset = abstract_code->IsCode() ? Code::kHeaderSize
92 Code* code = abstract_code->GetCode(); 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 if (code->kind() == Code::FUNCTION || 95 for (SourcePositionTableIterator it(abstract_code->source_position_table());
96 (code->is_optimized_code() && !code->is_turbofanned())) { 96 !it.done(); it.Advance()) {
97 for (SourcePositionTableIterator it(code->source_position_table()); 97 int position = it.source_position();
98 !it.done(); it.Advance()) { 98 // TODO(alph): in case of inlining the position may correspond to an
99 int position = it.source_position(); 99 // inlined function source code. Do not collect positions that fall
100 // TODO(alph): in case of inlining the position may correspond to an 100 // beyond the function source code. There's however a chance the
101 // inlined function source code. Do not collect positions that fall 101 // inlined function has similar positions but in another script. So
102 // beyond the function source code. There's however a chance the 102 // the proper fix is to store script_id in some form along with the
103 // inlined function has similar positions but in another script. So 103 // inlined function positions.
104 // the proper fix is to store script_id in some form along with the 104 if (position < start_position || position >= end_position) continue;
105 // inlined function positions. 105 int line_number = script->GetLineNumber(position) + 1;
106 if (position < start_position || position >= end_position) continue; 106 int pc_offset = it.code_offset() + offset;
107 int line_number = script->GetLineNumber(it.source_position()) + 1; 107 line_table->SetPosition(pc_offset, line_number);
108 int pc_offset = it.code_offset() + Code::kHeaderSize;
109 line_table->SetPosition(pc_offset, line_number);
110 }
111 } else {
112 for (RelocIterator it(code); !it.done(); it.next()) {
113 RelocInfo* reloc_info = it.rinfo();
114 if (!RelocInfo::IsPosition(reloc_info->rmode())) continue;
115 int position = static_cast<int>(reloc_info->data());
116 // TODO(alph): in case of inlining the position may correspond to an
117 // inlined function source code. Do not collect positions that fall
118 // beyond the function source code. There's however a chance the
119 // inlined function has similar positions but in another script. So
120 // the proper fix is to store script_id in some form along with the
121 // inlined function positions.
122 if (position < start_position || position >= end_position) continue;
123 int pc_offset = static_cast<int>(reloc_info->pc() - code->address());
124 int line_number = script->GetLineNumber(position) + 1;
125 line_table->SetPosition(pc_offset, line_number);
126 }
127 }
128 } else {
129 BytecodeArray* bytecode = abstract_code->GetBytecodeArray();
130 SourcePositionTableIterator it(bytecode->source_position_table());
131 for (; !it.done(); it.Advance()) {
132 int line_number = script->GetLineNumber(it.source_position()) + 1;
133 int pc_offset = it.code_offset() + BytecodeArray::kHeaderSize;
134 line_table->SetPosition(pc_offset, line_number);
135 }
136 } 108 }
137 } 109 }
138 rec->entry = NewCodeEntry( 110 rec->entry = NewCodeEntry(
139 tag, GetFunctionName(shared->DebugName()), CodeEntry::kEmptyNamePrefix, 111 tag, GetFunctionName(shared->DebugName()), CodeEntry::kEmptyNamePrefix,
140 GetName(InferScriptName(script_name, shared)), line, column, line_table, 112 GetName(InferScriptName(script_name, shared)), line, column, line_table,
141 abstract_code->instruction_start()); 113 abstract_code->instruction_start());
142 RecordInliningInfo(rec->entry, abstract_code); 114 RecordInliningInfo(rec->entry, abstract_code);
143 RecordDeoptInlinedFrames(rec->entry, abstract_code); 115 RecordDeoptInlinedFrames(rec->entry, abstract_code);
144 rec->entry->FillFunctionInfo(shared); 116 rec->entry->FillFunctionInfo(shared);
145 rec->size = abstract_code->ExecutableSize(); 117 rec->size = abstract_code->ExecutableSize();
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 } 318 }
347 319
348 void ProfilerListener::RemoveObserver(CodeEventObserver* observer) { 320 void ProfilerListener::RemoveObserver(CodeEventObserver* observer) {
349 auto it = std::find(observers_.begin(), observers_.end(), observer); 321 auto it = std::find(observers_.begin(), observers_.end(), observer);
350 if (it == observers_.end()) return; 322 if (it == observers_.end()) return;
351 observers_.erase(it); 323 observers_.erase(it);
352 } 324 }
353 325
354 } // namespace internal 326 } // namespace internal
355 } // namespace v8 327 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/x87/deoptimizer-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698