Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dart::ProfileCodeTable Class Reference

#include <profiler_service.h>

Inheritance diagram for dart::ProfileCodeTable:
dart::ZoneAllocated

Public Member Functions

 ProfileCodeTable ()
 
intptr_t length () const
 
ProfileCodeAt (intptr_t index) const
 
intptr_t FindCodeIndexForPC (uword pc) const
 
ProfileCodeFindCodeForPC (uword pc) const
 
intptr_t InsertCode (ProfileCode *new_code)
 
- Public Member Functions inherited from dart::ZoneAllocated
 ZoneAllocated ()
 
void * operator new (size_t size)
 
void * operator new (size_t size, Zone *zone)
 
void operator delete (void *pointer)
 

Detailed Description

Definition at line 327 of file profiler_service.h.

Constructor & Destructor Documentation

◆ ProfileCodeTable()

dart::ProfileCodeTable::ProfileCodeTable ( )
inline

Definition at line 329 of file profiler_service.h.

329: table_(8) {}

Member Function Documentation

◆ At()

ProfileCode * dart::ProfileCodeTable::At ( intptr_t  index) const
inline

Definition at line 333 of file profiler_service.h.

333 {
334 ASSERT(index >= 0);
335 ASSERT(index < length());
336 return table_[index];
337 }
#define ASSERT(E)

◆ FindCodeForPC()

ProfileCode * dart::ProfileCodeTable::FindCodeForPC ( uword  pc) const
inline

Definition at line 343 of file profiler_service.h.

343 {
344 intptr_t index = FindCodeIndexForPC(pc);
345 if (index < 0) {
346 return nullptr;
347 }
348 return At(index);
349 }
ProfileCode * At(intptr_t index) const
intptr_t FindCodeIndexForPC(uword pc) const

◆ FindCodeIndexForPC()

intptr_t dart::ProfileCodeTable::FindCodeIndexForPC ( uword  pc) const

Definition at line 680 of file profiler_service.cc.

680 {
681 intptr_t length = table_.length();
682 if (length == 0) {
683 return -1; // Not found.
684 }
685 intptr_t lo = 0;
686 intptr_t hi = length - 1;
687 while (lo <= hi) {
688 intptr_t mid = (hi - lo + 1) / 2 + lo;
689 ASSERT(mid >= lo);
690 ASSERT(mid <= hi);
691 ProfileCode* code = At(mid);
692 if (code->Contains(pc)) {
693 return mid;
694 } else if (pc < code->start()) {
695 hi = mid - 1;
696 } else {
697 lo = mid + 1;
698 }
699 }
700 return -1;
701}

◆ InsertCode()

intptr_t dart::ProfileCodeTable::InsertCode ( ProfileCode new_code)

Definition at line 703 of file profiler_service.cc.

703 {
704 const intptr_t length = table_.length();
705 if (length == 0) {
706 table_.Add(new_code);
707 return length;
708 }
709
710 // Determine the correct place to insert or merge |new_code| into table.
711 intptr_t lo = -1;
712 intptr_t hi = -1;
713 ProfileCode* lo_code = nullptr;
714 ProfileCode* hi_code = nullptr;
715 const uword pc = new_code->end() - 1;
716 FindNeighbors(pc, &lo, &hi, &lo_code, &hi_code);
717 ASSERT((lo_code != nullptr) || (hi_code != nullptr));
718
719 if (lo != -1) {
720 // Has left neighbor.
721 new_code->TruncateLower(lo_code->end());
722 ASSERT(!new_code->Overlaps(lo_code));
723 }
724 if (hi != -1) {
725 // Has right neighbor.
726 new_code->TruncateUpper(hi_code->start());
727 ASSERT(!new_code->Overlaps(hi_code));
728 }
729
730 if ((lo != -1) && (lo_code->kind() == ProfileCode::kNativeCode) &&
731 (new_code->kind() == ProfileCode::kNativeCode) &&
732 (lo_code->end() == new_code->start())) {
733 // Adjacent left neighbor of the same kind: merge.
734 // (dladdr doesn't give us symbol size so processing more samples may see
735 // more PCs we didn't previously know belonged to it.)
736 lo_code->ExpandUpper(new_code->end());
737 return lo;
738 }
739
740 if ((hi != -1) && (hi_code->kind() == ProfileCode::kNativeCode) &&
741 (new_code->kind() == ProfileCode::kNativeCode) &&
742 (new_code->end() == hi_code->start())) {
743 // Adjacent right neighbor of the same kind: merge.
744 // (dladdr doesn't give us symbol size so processing more samples may see
745 // more PCs we didn't previously know belonged to it.)
746 hi_code->ExpandLower(new_code->start());
747 return hi;
748 }
749
750 intptr_t insert;
751 if (lo == -1) {
752 insert = 0;
753 } else if (hi == -1) {
754 insert = length;
755 } else {
756 insert = lo + 1;
757 }
758 table_.InsertAt(insert, new_code);
759 return insert;
760}
uintptr_t uword
Definition globals.h:501

◆ length()

intptr_t dart::ProfileCodeTable::length ( ) const
inline

Definition at line 331 of file profiler_service.h.

331{ return table_.length(); }

The documentation for this class was generated from the following files: