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

Side by Side Diff: src/perf-jit.cc

Issue 1843563002: Linux perf support - fix debug info. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | no next file » | 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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 abstract_code->kind() != AbstractCode::INTERPRETED_FUNCTION && 164 abstract_code->kind() != AbstractCode::INTERPRETED_FUNCTION &&
165 abstract_code->kind() != AbstractCode::OPTIMIZED_FUNCTION)) { 165 abstract_code->kind() != AbstractCode::OPTIMIZED_FUNCTION)) {
166 return; 166 return;
167 } 167 }
168 168
169 // We only support non-interpreted functions. 169 // We only support non-interpreted functions.
170 if (!abstract_code->IsCode()) return; 170 if (!abstract_code->IsCode()) return;
171 Code* code = abstract_code->GetCode(); 171 Code* code = abstract_code->GetCode();
172 DCHECK(code->instruction_start() == code->address() + Code::kHeaderSize); 172 DCHECK(code->instruction_start() == code->address() + Code::kHeaderSize);
173 173
174 // Debug info has to be emitted first.
175 if (FLAG_perf_prof_debug_info) {
176 LogWriteDebugInfo(code, shared);
177 }
178
174 const char* code_name = name; 179 const char* code_name = name;
175 uint8_t* code_pointer = reinterpret_cast<uint8_t*>(code->instruction_start()); 180 uint8_t* code_pointer = reinterpret_cast<uint8_t*>(code->instruction_start());
176 uint32_t code_size = code->is_crankshafted() ? code->safepoint_table_offset() 181 uint32_t code_size = code->is_crankshafted() ? code->safepoint_table_offset()
177 : code->instruction_size(); 182 : code->instruction_size();
178 183
179 static const char string_terminator[] = "\0"; 184 static const char string_terminator[] = "\0";
180 185
181 PerfJitCodeLoad code_load; 186 PerfJitCodeLoad code_load;
182 code_load.event_ = PerfJitCodeLoad::kLoad; 187 code_load.event_ = PerfJitCodeLoad::kLoad;
183 code_load.size_ = sizeof(code_load) + length + 1 + code_size; 188 code_load.size_ = sizeof(code_load) + length + 1 + code_size;
184 code_load.time_stamp_ = GetTimestamp(); 189 code_load.time_stamp_ = GetTimestamp();
185 code_load.process_id_ = 190 code_load.process_id_ =
186 static_cast<uint32_t>(base::OS::GetCurrentProcessId()); 191 static_cast<uint32_t>(base::OS::GetCurrentProcessId());
187 code_load.thread_id_ = static_cast<uint32_t>(base::OS::GetCurrentThreadId()); 192 code_load.thread_id_ = static_cast<uint32_t>(base::OS::GetCurrentThreadId());
188 code_load.vma_ = 0x0; // Our addresses are absolute. 193 code_load.vma_ = 0x0; // Our addresses are absolute.
189 code_load.code_address_ = reinterpret_cast<uint64_t>(code_pointer); 194 code_load.code_address_ = reinterpret_cast<uint64_t>(code_pointer);
190 code_load.code_size_ = code_size; 195 code_load.code_size_ = code_size;
191 code_load.code_id_ = code_index_; 196 code_load.code_id_ = code_index_;
192 197
193 code_index_++; 198 code_index_++;
194 199
195 LogWriteBytes(reinterpret_cast<const char*>(&code_load), sizeof(code_load)); 200 LogWriteBytes(reinterpret_cast<const char*>(&code_load), sizeof(code_load));
196 LogWriteBytes(code_name, length); 201 LogWriteBytes(code_name, length);
197 LogWriteBytes(string_terminator, 1); 202 LogWriteBytes(string_terminator, 1);
198 LogWriteBytes(reinterpret_cast<const char*>(code_pointer), code_size); 203 LogWriteBytes(reinterpret_cast<const char*>(code_pointer), code_size);
199
200 if (FLAG_perf_prof_debug_info) {
201 LogWriteDebugInfo(code, shared);
202 }
203 } 204 }
204 205
205 void PerfJitLogger::LogWriteDebugInfo(Code* code, SharedFunctionInfo* shared) { 206 void PerfJitLogger::LogWriteDebugInfo(Code* code, SharedFunctionInfo* shared) {
206 // Compute the entry count and get the name of the script. 207 // Compute the entry count and get the name of the script.
207 uint32_t entry_count = 0; 208 uint32_t entry_count = 0;
208 for (RelocIterator it(code, RelocInfo::kPositionMask); !it.done(); 209 for (RelocIterator it(code, RelocInfo::kPositionMask); !it.done();
209 it.next()) { 210 it.next()) {
210 entry_count++; 211 entry_count++;
211 } 212 }
212 if (entry_count == 0) return; 213 if (entry_count == 0) return;
(...skipping 21 matching lines...) Expand all
234 235
235 debug_info.event_ = PerfJitCodeLoad::kDebugInfo; 236 debug_info.event_ = PerfJitCodeLoad::kDebugInfo;
236 debug_info.time_stamp_ = GetTimestamp(); 237 debug_info.time_stamp_ = GetTimestamp();
237 debug_info.address_ = reinterpret_cast<uint64_t>(code->instruction_start()); 238 debug_info.address_ = reinterpret_cast<uint64_t>(code->instruction_start());
238 debug_info.entry_count_ = entry_count; 239 debug_info.entry_count_ = entry_count;
239 240
240 uint32_t size = sizeof(debug_info); 241 uint32_t size = sizeof(debug_info);
241 // Add the sizes of fixed parts of entries. 242 // Add the sizes of fixed parts of entries.
242 size += entry_count * sizeof(PerfJitDebugEntry); 243 size += entry_count * sizeof(PerfJitDebugEntry);
243 // Add the size of the name after the first entry. 244 // Add the size of the name after the first entry.
244 size += static_cast<uint32_t>(name_length) + 1; 245 size += (static_cast<uint32_t>(name_length) + 1) * entry_count;
245 // Add the sizes of the links to previous name (\0xff\0).
246 size += (entry_count - 1) * 2;
247 246
248 int padding = ((size + 7) & (~7)) - size; 247 int padding = ((size + 7) & (~7)) - size;
249 248
250 debug_info.size_ = size + padding; 249 debug_info.size_ = size + padding;
251 250
252 LogWriteBytes(reinterpret_cast<const char*>(&debug_info), sizeof(debug_info)); 251 LogWriteBytes(reinterpret_cast<const char*>(&debug_info), sizeof(debug_info));
253 252
254 int script_line_offset = script->line_offset(); 253 int script_line_offset = script->line_offset();
255 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); 254 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends()));
256 255
257 bool is_first = true;
258 for (RelocIterator it(code, RelocInfo::kPositionMask); !it.done(); 256 for (RelocIterator it(code, RelocInfo::kPositionMask); !it.done();
259 it.next()) { 257 it.next()) {
260 int position = static_cast<int>(it.rinfo()->data()); 258 int position = static_cast<int>(it.rinfo()->data());
261 int line_number = Script::GetLineNumber(script, position); 259 int line_number = Script::GetLineNumber(script, position);
262 // Compute column. 260 // Compute column.
263 int relative_line_number = line_number - script_line_offset; 261 int relative_line_number = line_number - script_line_offset;
264 int start = 262 int start =
265 (relative_line_number == 0) 263 (relative_line_number == 0)
266 ? 0 264 ? 0
267 : Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1; 265 : Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1;
268 int column_offset = position - start; 266 int column_offset = position - start;
269 if (relative_line_number == 0) { 267 if (relative_line_number == 0) {
270 // For the case where the code is on the same line as the script tag. 268 // For the case where the code is on the same line as the script tag.
271 column_offset += script->column_offset(); 269 column_offset += script->column_offset();
272 } 270 }
273 271
274 PerfJitDebugEntry entry; 272 PerfJitDebugEntry entry;
275 entry.address_ = reinterpret_cast<uint64_t>(it.rinfo()->pc()); 273 entry.address_ = reinterpret_cast<uint64_t>(it.rinfo()->pc());
276 entry.line_number_ = line_number; 274 entry.line_number_ = line_number;
277 entry.column_ = column_offset; 275 entry.column_ = column_offset;
278 LogWriteBytes(reinterpret_cast<const char*>(&entry), sizeof(entry)); 276 LogWriteBytes(reinterpret_cast<const char*>(&entry), sizeof(entry));
279 277 LogWriteBytes(name_string.get(), name_length + 1);
280 if (is_first) {
281 is_first = false;
282 LogWriteBytes(name_string.get(), name_length + 1);
283 } else {
284 LogWriteBytes("\xff", 2);
285 }
286 } 278 }
287 char padding_bytes[] = "\0\0\0\0\0\0\0\0"; 279 char padding_bytes[] = "\0\0\0\0\0\0\0\0";
288 LogWriteBytes(padding_bytes, padding); 280 LogWriteBytes(padding_bytes, padding);
289 } 281 }
290 282
291 void PerfJitLogger::CodeMoveEvent(AbstractCode* from, Address to) { 283 void PerfJitLogger::CodeMoveEvent(AbstractCode* from, Address to) {
292 // Code relocation not supported. 284 // Code relocation not supported.
293 UNREACHABLE(); 285 UNREACHABLE();
294 } 286 }
295 287
(...skipping 16 matching lines...) Expand all
312 header.time_stamp_ = 304 header.time_stamp_ =
313 static_cast<uint64_t>(base::OS::TimeCurrentMillis() * 1000.0); 305 static_cast<uint64_t>(base::OS::TimeCurrentMillis() * 1000.0);
314 header.flags_ = 0; 306 header.flags_ = 0;
315 307
316 LogWriteBytes(reinterpret_cast<const char*>(&header), sizeof(header)); 308 LogWriteBytes(reinterpret_cast<const char*>(&header), sizeof(header));
317 } 309 }
318 310
319 #endif // V8_OS_LINUX 311 #endif // V8_OS_LINUX
320 } // namespace internal 312 } // namespace internal
321 } // namespace v8 313 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698