Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dart::SampleBuffer Class Referenceabstract

#include <profiler.h>

Inheritance diagram for dart::SampleBuffer:
dart::SampleBlock

Public Member Functions

 SampleBuffer ()=default
 
virtual ~SampleBuffer ()=default
 
virtual void Init (Sample *samples, intptr_t capacity)
 
void VisitSamples (SampleVisitor *visitor)
 
virtual SampleReserveSample ()=0
 
virtual SampleReserveSampleAndLink (Sample *previous)=0
 
SampleAt (intptr_t idx) const
 
intptr_t capacity () const
 
ProcessedSampleBufferBuildProcessedSampleBuffer (SampleFilter *filter, ProcessedSampleBuffer *buffer=nullptr)
 

Protected Member Functions

SampleNext (Sample *sample)
 
ProcessedSampleBuildProcessedSample (Sample *sample, const CodeLookupTable &clt)
 
 DISALLOW_COPY_AND_ASSIGN (SampleBuffer)
 

Protected Attributes

Samplesamples_
 
intptr_t capacity_
 

Detailed Description

Definition at line 572 of file profiler.h.

Constructor & Destructor Documentation

◆ SampleBuffer()

dart::SampleBuffer::SampleBuffer ( )
default

◆ ~SampleBuffer()

virtual dart::SampleBuffer::~SampleBuffer ( )
virtualdefault

Member Function Documentation

◆ At()

Sample * dart::SampleBuffer::At ( intptr_t  idx) const
inline

Definition at line 617 of file profiler.h.

617 {
618 ASSERT(idx >= 0);
619 ASSERT(idx < capacity_);
620 return &samples_[idx];
621 }
intptr_t capacity_
Definition profiler.h:636
Sample * samples_
Definition profiler.h:635
#define ASSERT(E)

◆ BuildProcessedSample()

ProcessedSample * dart::SampleBuffer::BuildProcessedSample ( Sample sample,
const CodeLookupTable clt 
)
protected

Definition at line 1629 of file profiler.cc.

1631 {
1632 Thread* thread = Thread::Current();
1633 Zone* zone = thread->zone();
1634
1635 ProcessedSample* processed_sample = new (zone) ProcessedSample();
1636
1637 // Copy state bits from sample.
1638 processed_sample->set_timestamp(sample->timestamp());
1639 processed_sample->set_tid(sample->tid());
1640 processed_sample->set_vm_tag(sample->vm_tag());
1641 processed_sample->set_user_tag(sample->user_tag());
1642 if (sample->is_allocation_sample()) {
1643 processed_sample->set_allocation_cid(sample->allocation_cid());
1644 processed_sample->set_allocation_identity_hash(
1645 sample->allocation_identity_hash());
1646 }
1647 processed_sample->set_first_frame_executing(!sample->exit_frame_sample());
1648
1649 // Copy stack trace from sample(s).
1650 bool truncated = false;
1651 Sample* current = sample;
1652 while (current != nullptr) {
1653 for (intptr_t i = 0; i < Sample::kPCArraySizeInWords; i++) {
1654 if (current->At(i) == 0) {
1655 break;
1656 }
1657 processed_sample->Add(current->At(i));
1658 }
1659
1660 truncated = truncated || current->truncated_trace();
1661 current = Next(current);
1662 }
1663
1664 if (!sample->exit_frame_sample()) {
1665 processed_sample->FixupCaller(clt, /* pc_marker */ 0,
1666 sample->GetStackBuffer());
1667 }
1668
1669 processed_sample->set_truncated(truncated);
1670 return processed_sample;
1671}
Sample * Next(Sample *sample)
Definition profiler.cc:1673
static constexpr int kPCArraySizeInWords
Definition profiler.h:362
static Thread * Current()
Definition thread.h:361

◆ BuildProcessedSampleBuffer()

ProcessedSampleBuffer * dart::SampleBuffer::BuildProcessedSampleBuffer ( SampleFilter filter,
ProcessedSampleBuffer buffer = nullptr 
)

Definition at line 1574 of file profiler.cc.

1576 {
1577 Thread* thread = Thread::Current();
1578 Zone* zone = thread->zone();
1579
1580 if (buffer == nullptr) {
1581 buffer = new (zone) ProcessedSampleBuffer();
1582 }
1583
1584 const intptr_t length = capacity();
1585 for (intptr_t i = 0; i < length; i++) {
1586 thread->CheckForSafepoint();
1587 Sample* sample = At(i);
1588 if (sample->ignore_sample()) {
1589 // Bad sample.
1590 continue;
1591 }
1592 if (!sample->head_sample()) {
1593 // An inner sample in a chain of samples.
1594 continue;
1595 }
1596 if (sample->timestamp() == 0) {
1597 // Empty.
1598 continue;
1599 }
1600 if (sample->At(0) == 0) {
1601 // No frames.
1602 continue;
1603 }
1604 if (filter != nullptr) {
1605 // If we're requesting all the native allocation samples, we don't care
1606 // whether or not we're in the same isolate as the sample.
1607 if (sample->port() != filter->port()) {
1608 // Another isolate.
1609 continue;
1610 }
1611 if (!filter->TimeFilterSample(sample)) {
1612 // Did not pass time filter.
1613 continue;
1614 }
1615 if (!filter->TaskFilterSample(sample)) {
1616 // Did not pass task filter.
1617 continue;
1618 }
1619 if (!filter->FilterSample(sample)) {
1620 // Did not pass filter.
1621 continue;
1622 }
1623 }
1624 buffer->Add(BuildProcessedSample(sample, buffer->code_lookup_table()));
1625 }
1626 return buffer;
1627}
ProcessedSample * BuildProcessedSample(Sample *sample, const CodeLookupTable &clt)
Definition profiler.cc:1629
intptr_t capacity() const
Definition profiler.h:623
Sample * At(intptr_t idx) const
Definition profiler.h:617
static const uint8_t buffer[]
size_t length

◆ capacity()

intptr_t dart::SampleBuffer::capacity ( ) const
inline

Definition at line 623 of file profiler.h.

623{ return capacity_; }

◆ DISALLOW_COPY_AND_ASSIGN()

dart::SampleBuffer::DISALLOW_COPY_AND_ASSIGN ( SampleBuffer  )
protected

◆ Init()

virtual void dart::SampleBuffer::Init ( Sample samples,
intptr_t  capacity 
)
inlinevirtual

Definition at line 577 of file profiler.h.

577 {
578 ASSERT(samples != nullptr);
579 ASSERT(capacity > 0);
580 samples_ = samples;
582 }

◆ Next()

Sample * dart::SampleBuffer::Next ( Sample sample)
protected

Definition at line 1673 of file profiler.cc.

1673 {
1674 if (!sample->is_continuation_sample()) return nullptr;
1675 Sample* next_sample = sample->continuation_sample();
1676 // Sanity check.
1677 ASSERT(sample != next_sample);
1678 // Detect invalid chaining.
1679 if (sample->port() != next_sample->port()) {
1680 return nullptr;
1681 }
1682 if (sample->timestamp() != next_sample->timestamp()) {
1683 return nullptr;
1684 }
1685 if (sample->tid() != next_sample->tid()) {
1686 return nullptr;
1687 }
1688 return next_sample;
1689}

◆ ReserveSample()

virtual Sample * dart::SampleBuffer::ReserveSample ( )
pure virtual

Implemented in dart::SampleBlock.

◆ ReserveSampleAndLink()

virtual Sample * dart::SampleBuffer::ReserveSampleAndLink ( Sample previous)
pure virtual

Implemented in dart::SampleBlock.

◆ VisitSamples()

void dart::SampleBuffer::VisitSamples ( SampleVisitor visitor)
inline

Definition at line 584 of file profiler.h.

584 {
585 ASSERT(visitor != nullptr);
586 const intptr_t length = capacity();
587 for (intptr_t i = 0; i < length; i++) {
588 Sample* sample = At(i);
589 if (!sample->head_sample()) {
590 // An inner sample in a chain of samples.
591 continue;
592 }
593 if (sample->ignore_sample()) {
594 // Bad sample.
595 continue;
596 }
597 if (sample->port() != visitor->port()) {
598 // Another isolate.
599 continue;
600 }
601 if (sample->timestamp() == 0) {
602 // Empty.
603 continue;
604 }
605 if (sample->At(0) == 0) {
606 // No frames.
607 continue;
608 }
609 visitor->IncrementVisited();
610 visitor->VisitSample(sample);
611 }
612 }

Member Data Documentation

◆ capacity_

intptr_t dart::SampleBuffer::capacity_
protected

Definition at line 636 of file profiler.h.

◆ samples_

Sample* dart::SampleBuffer::samples_
protected

Definition at line 635 of file profiler.h.


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