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

Side by Side Diff: src/profile-generator.cc

Issue 1332683002: Profiler code clean-up (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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/profile-generator.h ('k') | src/profile-generator-inl.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/profile-generator.h" 5 #include "src/profile-generator.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/global-handles.h" 10 #include "src/global-handles.h"
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 CodeTree::Locator locator; 398 CodeTree::Locator locator;
399 if (!tree_.FindGreatestLessThan(addr, &locator)) break; 399 if (!tree_.FindGreatestLessThan(addr, &locator)) break;
400 Address start2 = locator.key(), end2 = start2 + locator.value().size; 400 Address start2 = locator.key(), end2 = start2 + locator.value().size;
401 if (start2 < end && start < end2) to_delete.Add(start2); 401 if (start2 < end && start < end2) to_delete.Add(start2);
402 addr = start2 - 1; 402 addr = start2 - 1;
403 } 403 }
404 for (int i = 0; i < to_delete.length(); ++i) tree_.Remove(to_delete[i]); 404 for (int i = 0; i < to_delete.length(); ++i) tree_.Remove(to_delete[i]);
405 } 405 }
406 406
407 407
408 CodeEntry* CodeMap::FindEntry(Address addr, Address* start) { 408 CodeEntry* CodeMap::FindEntry(Address addr) {
409 CodeTree::Locator locator; 409 CodeTree::Locator locator;
410 if (tree_.FindGreatestLessThan(addr, &locator)) { 410 if (tree_.FindGreatestLessThan(addr, &locator)) {
411 // locator.key() <= addr. Need to check that addr is within entry. 411 // locator.key() <= addr. Need to check that addr is within entry.
412 const CodeEntryInfo& entry = locator.value(); 412 const CodeEntryInfo& entry = locator.value();
413 if (addr < (locator.key() + entry.size)) { 413 if (addr < (locator.key() + entry.size)) {
414 if (start) {
415 *start = locator.key();
416 }
417 return entry.entry; 414 return entry.entry;
418 } 415 }
419 } 416 }
420 return NULL; 417 return NULL;
421 } 418 }
422 419
423 420
424 void CodeMap::MoveCode(Address from, Address to) { 421 void CodeMap::MoveCode(Address from, Address to) {
425 if (from == to) return; 422 if (from == to) return;
426 CodeTree::Locator locator; 423 CodeTree::Locator locator;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 bool src_line_not_found = true; 591 bool src_line_not_found = true;
595 592
596 if (sample.pc != NULL) { 593 if (sample.pc != NULL) {
597 if (sample.has_external_callback && sample.state == EXTERNAL && 594 if (sample.has_external_callback && sample.state == EXTERNAL &&
598 sample.top_frame_type == StackFrame::EXIT) { 595 sample.top_frame_type == StackFrame::EXIT) {
599 // Don't use PC when in external callback code, as it can point 596 // Don't use PC when in external callback code, as it can point
600 // inside callback's code, and we will erroneously report 597 // inside callback's code, and we will erroneously report
601 // that a callback calls itself. 598 // that a callback calls itself.
602 *entry++ = code_map_.FindEntry(sample.external_callback); 599 *entry++ = code_map_.FindEntry(sample.external_callback);
603 } else { 600 } else {
604 Address start; 601 CodeEntry* pc_entry = code_map_.FindEntry(sample.pc);
605 CodeEntry* pc_entry = code_map_.FindEntry(sample.pc, &start);
606 // If there is no pc_entry we're likely in native code. 602 // If there is no pc_entry we're likely in native code.
607 // Find out, if top of stack was pointing inside a JS function 603 // Find out, if top of stack was pointing inside a JS function
608 // meaning that we have encountered a frameless invocation. 604 // meaning that we have encountered a frameless invocation.
609 if (!pc_entry && (sample.top_frame_type == StackFrame::JAVA_SCRIPT || 605 if (!pc_entry && (sample.top_frame_type == StackFrame::JAVA_SCRIPT ||
610 sample.top_frame_type == StackFrame::OPTIMIZED)) { 606 sample.top_frame_type == StackFrame::OPTIMIZED)) {
611 pc_entry = code_map_.FindEntry(sample.tos); 607 pc_entry = code_map_.FindEntry(sample.tos);
612 } 608 }
613 // If pc is in the function code before it set up stack frame or after the 609 // If pc is in the function code before it set up stack frame or after the
614 // frame was destroyed SafeStackFrameIterator incorrectly thinks that 610 // frame was destroyed SafeStackFrameIterator incorrectly thinks that
615 // ebp contains return address of the current function and skips caller's 611 // ebp contains return address of the current function and skips caller's
(...skipping 28 matching lines...) Expand all
644 *entry++ = unresolved_entry_; 640 *entry++ = unresolved_entry_;
645 } 641 }
646 } 642 }
647 } 643 }
648 } 644 }
649 645
650 for (const Address* stack_pos = sample.stack, 646 for (const Address* stack_pos = sample.stack,
651 *stack_end = stack_pos + sample.frames_count; 647 *stack_end = stack_pos + sample.frames_count;
652 stack_pos != stack_end; 648 stack_pos != stack_end;
653 ++stack_pos) { 649 ++stack_pos) {
654 Address start = NULL; 650 *entry = code_map_.FindEntry(*stack_pos);
655 *entry = code_map_.FindEntry(*stack_pos, &start);
656 651
657 // Skip unresolved frames (e.g. internal frame) and get source line of 652 // Skip unresolved frames (e.g. internal frame) and get source line of
658 // the first JS caller. 653 // the first JS caller.
659 if (src_line_not_found && *entry) { 654 if (src_line_not_found && *entry) {
660 int pc_offset = 655 int pc_offset =
661 static_cast<int>(*stack_pos - (*entry)->instruction_start()); 656 static_cast<int>(*stack_pos - (*entry)->instruction_start());
662 src_line = (*entry)->GetSourceLine(pc_offset); 657 src_line = (*entry)->GetSourceLine(pc_offset);
663 if (src_line == v8::CpuProfileNode::kNoLineNumberInfo) { 658 if (src_line == v8::CpuProfileNode::kNoLineNumberInfo) {
664 src_line = (*entry)->line_number(); 659 src_line = (*entry)->line_number();
665 } 660 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 case EXTERNAL: 696 case EXTERNAL:
702 return program_entry_; 697 return program_entry_;
703 case IDLE: 698 case IDLE:
704 return idle_entry_; 699 return idle_entry_;
705 default: return NULL; 700 default: return NULL;
706 } 701 }
707 } 702 }
708 703
709 } // namespace internal 704 } // namespace internal
710 } // namespace v8 705 } // namespace v8
OLDNEW
« no previous file with comments | « src/profile-generator.h ('k') | src/profile-generator-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698