Flutter Engine
The Flutter Engine
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 565 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 610 of file profiler.h.

610 {
611 ASSERT(idx >= 0);
612 ASSERT(idx < capacity_);
613 return &samples_[idx];
614 }
intptr_t capacity_
Definition: profiler.h:629
Sample * samples_
Definition: profiler.h:628
#define ASSERT(E)

◆ BuildProcessedSample()

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

Definition at line 1635 of file profiler.cc.

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

◆ BuildProcessedSampleBuffer()

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

Definition at line 1580 of file profiler.cc.

1582 {
1583 Thread* thread = Thread::Current();
1584 Zone* zone = thread->zone();
1585
1586 if (buffer == nullptr) {
1587 buffer = new (zone) ProcessedSampleBuffer();
1588 }
1589
1590 const intptr_t length = capacity();
1591 for (intptr_t i = 0; i < length; i++) {
1592 thread->CheckForSafepoint();
1593 Sample* sample = At(i);
1594 if (sample->ignore_sample()) {
1595 // Bad sample.
1596 continue;
1597 }
1598 if (!sample->head_sample()) {
1599 // An inner sample in a chain of samples.
1600 continue;
1601 }
1602 if (sample->timestamp() == 0) {
1603 // Empty.
1604 continue;
1605 }
1606 if (sample->At(0) == 0) {
1607 // No frames.
1608 continue;
1609 }
1610 if (filter != nullptr) {
1611 // If we're requesting all the native allocation samples, we don't care
1612 // whether or not we're in the same isolate as the sample.
1613 if (sample->port() != filter->port()) {
1614 // Another isolate.
1615 continue;
1616 }
1617 if (!filter->TimeFilterSample(sample)) {
1618 // Did not pass time filter.
1619 continue;
1620 }
1621 if (!filter->TaskFilterSample(sample)) {
1622 // Did not pass task filter.
1623 continue;
1624 }
1625 if (!filter->FilterSample(sample)) {
1626 // Did not pass filter.
1627 continue;
1628 }
1629 }
1630 buffer->Add(BuildProcessedSample(sample, buffer->code_lookup_table()));
1631 }
1632 return buffer;
1633}
ProcessedSample * BuildProcessedSample(Sample *sample, const CodeLookupTable &clt)
Definition: profiler.cc:1635
intptr_t capacity() const
Definition: profiler.h:616
Sample * At(intptr_t idx) const
Definition: profiler.h:610
size_t length
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ capacity()

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

Definition at line 616 of file profiler.h.

616{ 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 570 of file profiler.h.

570 {
571 ASSERT(samples != nullptr);
572 ASSERT(capacity > 0);
573 samples_ = samples;
575 }

◆ Next()

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

Definition at line 1679 of file profiler.cc.

1679 {
1680 if (!sample->is_continuation_sample()) return nullptr;
1681 Sample* next_sample = sample->continuation_sample();
1682 // Sanity check.
1683 ASSERT(sample != next_sample);
1684 // Detect invalid chaining.
1685 if (sample->port() != next_sample->port()) {
1686 return nullptr;
1687 }
1688 if (sample->timestamp() != next_sample->timestamp()) {
1689 return nullptr;
1690 }
1691 if (sample->tid() != next_sample->tid()) {
1692 return nullptr;
1693 }
1694 return next_sample;
1695}

◆ 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 577 of file profiler.h.

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

Member Data Documentation

◆ capacity_

intptr_t dart::SampleBuffer::capacity_
protected

Definition at line 629 of file profiler.h.

◆ samples_

Sample* dart::SampleBuffer::samples_
protected

Definition at line 628 of file profiler.h.


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