Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
dart::Cids Class Reference

#include <il.h>

Inheritance diagram for dart::Cids:
dart::ZoneAllocated dart::CallTargets

Public Member Functions

 Cids (Zone *zone)
 
bool Equals (const Cids &other) const
 
bool HasClassId (intptr_t cid) const
 
void Add (CidRange *target)
 
CidRangeoperator[] (intptr_t index) const
 
CidRangeAt (int index) const
 
intptr_t length () const
 
void SetLength (intptr_t len)
 
bool is_empty () const
 
void Sort (int compare(CidRange *const *a, CidRange *const *b))
 
bool IsMonomorphic () const
 
intptr_t MonomorphicReceiverCid () const
 
intptr_t ComputeLowestCid () const
 
intptr_t ComputeHighestCid () const
 
- 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)
 

Static Public Member Functions

static CidsCreateForArgument (Zone *zone, const BinaryFeedback &binary_feedback, int argument_number)
 
static CidsCreateMonomorphic (Zone *zone, intptr_t cid)
 

Protected Attributes

GrowableArray< CidRange * > cid_ranges_
 

Detailed Description

Definition at line 736 of file il.h.

Constructor & Destructor Documentation

◆ Cids()

dart::Cids::Cids ( Zone zone)
inlineexplicit

Definition at line 738 of file il.h.

738: cid_ranges_(zone, 6) {}
GrowableArray< CidRange * > cid_ranges_
Definition: il.h:774

Member Function Documentation

◆ Add()

void dart::Cids::Add ( CidRange target)
inline

Definition at line 752 of file il.h.

752{ cid_ranges_.Add(target); }
uint32_t * target

◆ At()

CidRange * dart::Cids::At ( int  index) const
inline

Definition at line 756 of file il.h.

756{ return cid_ranges_[index]; }

◆ ComputeHighestCid()

intptr_t dart::Cids::ComputeHighestCid ( ) const

Definition at line 674 of file il.cc.

674 {
675 intptr_t max = -1;
676 for (intptr_t i = 0; i < cid_ranges_.length(); ++i) {
677 max = Utils::Maximum(max, cid_ranges_[i]->cid_end);
678 }
679 return max;
680}
static constexpr T Maximum(T x, T y)
Definition: utils.h:41
static float max(float r, float g, float b)
Definition: hsl.cpp:49

◆ ComputeLowestCid()

intptr_t dart::Cids::ComputeLowestCid ( ) const

Definition at line 666 of file il.cc.

666 {
667 intptr_t min = kIntptrMax;
668 for (intptr_t i = 0; i < cid_ranges_.length(); ++i) {
669 min = Utils::Minimum(min, cid_ranges_[i]->cid_start);
670 }
671 return min;
672}
static T Minimum(T x, T y)
Definition: utils.h:36
static float min(float r, float g, float b)
Definition: hsl.cpp:48
constexpr intptr_t kIntptrMax
Definition: globals.h:557

◆ CreateForArgument()

Cids * dart::Cids::CreateForArgument ( Zone zone,
const BinaryFeedback binary_feedback,
int  argument_number 
)
static

Definition at line 697 of file il.cc.

699 {
700 Cids* cids = new (zone) Cids(zone);
701 for (intptr_t i = 0; i < binary_feedback.feedback_.length(); i++) {
702 ASSERT((argument_number == 0) || (argument_number == 1));
703 const intptr_t cid = argument_number == 0
704 ? binary_feedback.feedback_[i].first
705 : binary_feedback.feedback_[i].second;
706 cids->Add(new (zone) CidRange(cid, cid));
707 }
708
709 if (cids->length() != 0) {
710 cids->Sort(OrderById);
711
712 // Merge adjacent class id ranges.
713 int dest = 0;
714 for (int src = 1; src < cids->length(); src++) {
715 if (cids->cid_ranges_[dest]->cid_end + 1 >=
716 cids->cid_ranges_[src]->cid_start) {
717 cids->cid_ranges_[dest]->cid_end = cids->cid_ranges_[src]->cid_end;
718 } else {
719 dest++;
720 if (src != dest) cids->cid_ranges_[dest] = cids->cid_ranges_[src];
721 }
722 }
723 cids->SetLength(dest + 1);
724 }
725
726 return cids;
727}
Cids(Zone *zone)
Definition: il.h:738
#define ASSERT(E)
static int OrderById(CidRange *const *a, CidRange *const *b)
Definition: il.cc:637
const intptr_t cid
dest
Definition: zip.py:79

◆ CreateMonomorphic()

Cids * dart::Cids::CreateMonomorphic ( Zone zone,
intptr_t  cid 
)
static

Definition at line 691 of file il.cc.

691 {
692 Cids* cids = new (zone) Cids(zone);
693 cids->Add(new (zone) CidRange(cid, cid));
694 return cids;
695}

◆ Equals()

bool dart::Cids::Equals ( const Cids other) const

Definition at line 655 of file il.cc.

655 {
656 if (length() != other.length()) return false;
657 for (int i = 0; i < length(); i++) {
658 if (cid_ranges_[i]->cid_start != other.cid_ranges_[i]->cid_start ||
659 cid_ranges_[i]->cid_end != other.cid_ranges_[i]->cid_end) {
660 return false;
661 }
662 }
663 return true;
664}
intptr_t length() const
Definition: il.h:758

◆ HasClassId()

bool dart::Cids::HasClassId ( intptr_t  cid) const

Definition at line 682 of file il.cc.

682 {
683 for (int i = 0; i < length(); i++) {
684 if (cid_ranges_[i]->Contains(cid)) {
685 return true;
686 }
687 }
688 return false;
689}
bool Contains(const Container &container, const Value &value)

◆ is_empty()

bool dart::Cids::is_empty ( ) const
inline

Definition at line 762 of file il.h.

762{ return cid_ranges_.is_empty(); }

◆ IsMonomorphic()

bool dart::Cids::IsMonomorphic ( ) const

Definition at line 801 of file il.cc.

801 {
802 if (length() != 1) return false;
803 return cid_ranges_[0]->IsSingleCid();
804}

◆ length()

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

Definition at line 758 of file il.h.

758{ return cid_ranges_.length(); }

◆ MonomorphicReceiverCid()

intptr_t dart::Cids::MonomorphicReceiverCid ( ) const

Definition at line 806 of file il.cc.

806 {
808 return cid_ranges_[0]->cid_start;
809}
bool IsMonomorphic() const
Definition: il.cc:801

◆ operator[]()

CidRange & dart::Cids::operator[] ( intptr_t  index) const
inline

Definition at line 754 of file il.h.

754{ return *cid_ranges_[index]; }

◆ SetLength()

void dart::Cids::SetLength ( intptr_t  len)
inline

Definition at line 760 of file il.h.

760{ cid_ranges_.SetLength(len); }

◆ Sort()

void dart::Cids::Sort ( int   compareCidRange *const *a, CidRange *const *b)
inline

Definition at line 764 of file il.h.

764 {
765 cid_ranges_.Sort(compare);
766 }
int compare(const void *untyped_lhs, const void *untyped_rhs)
Definition: skdiff.h:161

Member Data Documentation

◆ cid_ranges_

GrowableArray<CidRange*> dart::Cids::cid_ranges_
protected

Definition at line 774 of file il.h.


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