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

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

Issue 2562973002: [perf-prof] fix crash when logging. (Closed)
Patch Set: remove stray edit Created 4 years 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.cc ('k') | 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 240
241 code_index_++; 241 code_index_++;
242 242
243 LogWriteBytes(reinterpret_cast<const char*>(&code_load), sizeof(code_load)); 243 LogWriteBytes(reinterpret_cast<const char*>(&code_load), sizeof(code_load));
244 LogWriteBytes(code_name, length); 244 LogWriteBytes(code_name, length);
245 LogWriteBytes(string_terminator, 1); 245 LogWriteBytes(string_terminator, 1);
246 LogWriteBytes(reinterpret_cast<const char*>(code_pointer), code_size); 246 LogWriteBytes(reinterpret_cast<const char*>(code_pointer), code_size);
247 } 247 }
248 248
249 void PerfJitLogger::LogWriteDebugInfo(Code* code, SharedFunctionInfo* shared) { 249 void PerfJitLogger::LogWriteDebugInfo(Code* code, SharedFunctionInfo* shared) {
250 DisallowHeapAllocation no_gc;
250 // Compute the entry count and get the name of the script. 251 // Compute the entry count and get the name of the script.
251 uint32_t entry_count = 0; 252 uint32_t entry_count = 0;
252 for (SourcePositionTableIterator iterator(code->source_position_table()); 253 for (SourcePositionTableIterator iterator(code->source_position_table());
253 !iterator.done(); iterator.Advance()) { 254 !iterator.done(); iterator.Advance()) {
254 entry_count++; 255 entry_count++;
255 } 256 }
256 if (entry_count == 0) return; 257 if (entry_count == 0) return;
257 Handle<Script> script(Script::cast(shared->script())); 258 Script* script = Script::cast(shared->script());
258 Handle<Object> name_or_url(Script::GetNameOrSourceURL(script)); 259 Object* name_or_url = script->GetNameOrSourceURL();
259 260
260 int name_length = 0; 261 int name_length = 0;
261 std::unique_ptr<char[]> name_string; 262 std::unique_ptr<char[]> name_string;
262 if (name_or_url->IsString()) { 263 if (name_or_url->IsString()) {
263 name_string = 264 name_string =
264 Handle<String>::cast(name_or_url) 265 String::cast(name_or_url)
265 ->ToCString(DISALLOW_NULLS, FAST_STRING_TRAVERSAL, &name_length); 266 ->ToCString(DISALLOW_NULLS, FAST_STRING_TRAVERSAL, &name_length);
Tobias Tebbi 2016/12/09 12:53:26 only ROBUST_STRING_TRAVERSAL seems to guarantee no
Yang 2016/12/09 14:00:36 Not sure I understand. I don't think ToCString can
266 DCHECK_EQ(0, name_string.get()[name_length]); 267 DCHECK_EQ(0, name_string.get()[name_length]);
267 } else { 268 } else {
268 const char unknown[] = "<unknown>"; 269 const char unknown[] = "<unknown>";
269 name_length = static_cast<int>(strlen(unknown)); 270 name_length = static_cast<int>(strlen(unknown));
270 char* buffer = NewArray<char>(name_length); 271 char* buffer = NewArray<char>(name_length);
271 base::OS::StrNCpy(buffer, name_length + 1, unknown, 272 base::OS::StrNCpy(buffer, name_length + 1, unknown,
272 static_cast<size_t>(name_length)); 273 static_cast<size_t>(name_length));
273 name_string = std::unique_ptr<char[]>(buffer); 274 name_string = std::unique_ptr<char[]>(buffer);
274 } 275 }
275 DCHECK_EQ(name_length, static_cast<int>(strlen(name_string.get()))); 276 DCHECK_EQ(name_length, static_cast<int>(strlen(name_string.get())));
(...skipping 11 matching lines...) Expand all
287 // Add the size of the name after the first entry. 288 // Add the size of the name after the first entry.
288 size += (static_cast<uint32_t>(name_length) + 1) * entry_count; 289 size += (static_cast<uint32_t>(name_length) + 1) * entry_count;
289 290
290 int padding = ((size + 7) & (~7)) - size; 291 int padding = ((size + 7) & (~7)) - size;
291 292
292 debug_info.size_ = size + padding; 293 debug_info.size_ = size + padding;
293 294
294 LogWriteBytes(reinterpret_cast<const char*>(&debug_info), sizeof(debug_info)); 295 LogWriteBytes(reinterpret_cast<const char*>(&debug_info), sizeof(debug_info));
295 296
296 int script_line_offset = script->line_offset(); 297 int script_line_offset = script->line_offset();
297 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); 298 FixedArray* line_ends = FixedArray::cast(script->line_ends());
298 Address code_start = code->instruction_start(); 299 Address code_start = code->instruction_start();
299 300
300 for (SourcePositionTableIterator iterator(code->source_position_table()); 301 for (SourcePositionTableIterator iterator(code->source_position_table());
301 !iterator.done(); iterator.Advance()) { 302 !iterator.done(); iterator.Advance()) {
302 int position = iterator.source_position().ScriptOffset(); 303 int position = iterator.source_position().ScriptOffset();
303 int line_number = Script::GetLineNumber(script, position); 304 int line_number = script->GetLineNumber(position);
304 // Compute column. 305 // Compute column.
305 int relative_line_number = line_number - script_line_offset; 306 int relative_line_number = line_number - script_line_offset;
306 int start = 307 int start =
307 (relative_line_number == 0) 308 (relative_line_number == 0)
308 ? 0 309 ? 0
309 : Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1; 310 : Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1;
310 int column_offset = position - start; 311 int column_offset = position - start;
311 if (relative_line_number == 0) { 312 if (relative_line_number == 0) {
312 // For the case where the code is on the same line as the script tag. 313 // For the case where the code is on the same line as the script tag.
313 column_offset += script->column_offset(); 314 column_offset += script->column_offset();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 header.time_stamp_ = 385 header.time_stamp_ =
385 static_cast<uint64_t>(base::OS::TimeCurrentMillis() * 1000.0); 386 static_cast<uint64_t>(base::OS::TimeCurrentMillis() * 1000.0);
386 header.flags_ = 0; 387 header.flags_ = 0;
387 388
388 LogWriteBytes(reinterpret_cast<const char*>(&header), sizeof(header)); 389 LogWriteBytes(reinterpret_cast<const char*>(&header), sizeof(header));
389 } 390 }
390 391
391 #endif // V8_OS_LINUX 392 #endif // V8_OS_LINUX
392 } // namespace internal 393 } // namespace internal
393 } // namespace v8 394 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698