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

#include <profiler.h>

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

Public Member Functions

 SampleBlock ()=default
 
virtual ~SampleBlock ()=default
 
intptr_t capacity () const
 
Isolateowner () const
 
void set_owner (Isolate *isolate)
 
virtual SampleReserveSample ()
 
virtual SampleReserveSampleAndLink (Sample *previous)
 
bool TryAllocateFree ()
 
bool TryAllocateCompleted ()
 
void MarkCompleted ()
 
bool TryAcquireStreaming (Isolate *isolate)
 
void StreamingToCompleted ()
 
void StreamingToFree ()
 
void FreeCompleted ()
 
- Public Member Functions inherited from dart::SampleBuffer
 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)
 

Static Public Attributes

static constexpr intptr_t kSamplesPerBlock = 100
 

Protected Types

enum  State : uint32_t { kFree , kSampling , kCompleted , kStreaming }
 

Protected Member Functions

bool HasStreamableSamples (const GrowableObjectArray &tag_table, UserTag *tag)
 
- Protected Member Functions inherited from dart::SampleBuffer
SampleNext (Sample *sample)
 
ProcessedSampleBuildProcessedSample (Sample *sample, const CodeLookupTable &clt)
 
 DISALLOW_COPY_AND_ASSIGN (SampleBuffer)
 

Protected Attributes

std::atomic< Statestate_ = kFree
 
RelaxedAtomic< uint32_t > cursor_ = 0
 
Isolateowner_ = nullptr
 
- Protected Attributes inherited from dart::SampleBuffer
Samplesamples_
 
intptr_t capacity_
 

Friends

class SampleBlockListProcessor
 
class SampleBlockBuffer
 

Detailed Description

Definition at line 634 of file profiler.h.

Member Enumeration Documentation

◆ State

enum dart::SampleBlock::State : uint32_t
protected
Enumerator
kFree 
kSampling 
kCompleted 
kStreaming 

Definition at line 711 of file profiler.h.

711 : uint32_t {
712 kFree,
713 kSampling, // I.e., writing.
715 kStreaming, // I.e., reading.
716 };

Constructor & Destructor Documentation

◆ SampleBlock()

dart::SampleBlock::SampleBlock ( )
default

◆ ~SampleBlock()

virtual dart::SampleBlock::~SampleBlock ( )
virtualdefault

Member Function Documentation

◆ capacity()

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

Definition at line 643 of file profiler.h.

643{ return capacity_; }
intptr_t capacity_
Definition: profiler.h:629

◆ FreeCompleted()

void dart::SampleBlock::FreeCompleted ( )
inline

Definition at line 697 of file profiler.h.

697 {
698 State expected = kCompleted;
699 State desired = kStreaming;
700 std::memory_order success_order = std::memory_order_acquire;
701 std::memory_order failure_order = std::memory_order_relaxed;
702 if (state_.compare_exchange_strong(expected, desired, success_order,
703 failure_order)) {
705 }
706 }
void StreamingToFree()
Definition: profiler.h:691
std::atomic< State > state_
Definition: profiler.h:717

◆ HasStreamableSamples()

bool dart::SampleBlock::HasStreamableSamples ( const GrowableObjectArray tag_table,
UserTag tag 
)
protected

Definition at line 730 of file profiler.cc.

731 {
732 for (intptr_t i = 0; i < capacity_; ++i) {
733 Sample* sample = At(i);
734 uword sample_tag = sample->user_tag();
735 for (intptr_t j = 0; j < tag_table.Length(); ++j) {
736 *tag ^= tag_table.At(j);
737 if (tag->tag() == sample_tag && tag->streamable()) {
738 return true;
739 }
740 }
741 }
742 return false;
743}
Sample * At(intptr_t idx) const
Definition: profiler.h:610
uintptr_t uword
Definition: globals.h:501

◆ MarkCompleted()

void dart::SampleBlock::MarkCompleted ( )
inline

Definition at line 672 of file profiler.h.

672 {
673 ASSERT(state_.load(std::memory_order_relaxed) == kSampling);
674 state_.store(kCompleted, std::memory_order_release);
675 }
#define ASSERT(E)

◆ owner()

Isolate * dart::SampleBlock::owner ( ) const
inline

Definition at line 645 of file profiler.h.

645{ return owner_; }
Isolate * owner_
Definition: profiler.h:719

◆ ReserveSample()

Sample * dart::SampleBlock::ReserveSample ( )
virtual

Implements dart::SampleBuffer.

Definition at line 791 of file profiler.cc.

791 {
792 intptr_t slot = cursor_.fetch_add(1u);
793 if (slot < capacity_) {
794 return At(slot);
795 }
796 return nullptr;
797}
T fetch_add(T arg, std::memory_order order=std::memory_order_relaxed)
Definition: atomic.h:35
RelaxedAtomic< uint32_t > cursor_
Definition: profiler.h:718

◆ ReserveSampleAndLink()

Sample * dart::SampleBlock::ReserveSampleAndLink ( Sample previous)
virtual

Implements dart::SampleBuffer.

Definition at line 799 of file profiler.cc.

799 {
800 ASSERT(previous != nullptr);
802 Isolate* isolate = owner_;
803 ASSERT(isolate != nullptr);
804 Sample* next = previous->is_allocation_sample()
805 ? buffer->ReserveAllocationSample(isolate)
806 : buffer->ReserveCPUSample(isolate);
807 if (next == nullptr) {
808 return nullptr; // No blocks left, so drop sample.
809 }
810 next->Init(previous->port(), previous->timestamp(), previous->tid());
811 next->set_head_sample(false);
812 // Mark that previous continues at next.
813 previous->SetContinuation(next);
814 return next;
815}
static float next(float f)
static SampleBlockBuffer * sample_block_buffer()
Definition: profiler.h:67
friend class SampleBlockBuffer
Definition: profiler.h:723
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

◆ set_owner()

void dart::SampleBlock::set_owner ( Isolate isolate)
inline

Definition at line 646 of file profiler.h.

646{ owner_ = isolate; }

◆ StreamingToCompleted()

void dart::SampleBlock::StreamingToCompleted ( )
inline

Definition at line 687 of file profiler.h.

687 {
688 ASSERT(state_.load(std::memory_order_relaxed) == kStreaming);
689 state_.store(kCompleted, std::memory_order_relaxed);
690 }

◆ StreamingToFree()

void dart::SampleBlock::StreamingToFree ( )
inline

Definition at line 691 of file profiler.h.

691 {
692 ASSERT(state_.load(std::memory_order_relaxed) == kStreaming);
693 owner_ = nullptr;
694 cursor_ = 0;
695 state_.store(kFree, std::memory_order_release);
696 }

◆ TryAcquireStreaming()

bool dart::SampleBlock::TryAcquireStreaming ( Isolate isolate)
inline

Definition at line 676 of file profiler.h.

676 {
677 if (state_.load(std::memory_order_relaxed) != kCompleted) return false;
678 if (owner_ != isolate) return false;
679
680 State expected = kCompleted;
681 State desired = kStreaming;
682 std::memory_order success_order = std::memory_order_acquire;
683 std::memory_order failure_order = std::memory_order_relaxed;
684 return state_.compare_exchange_strong(expected, desired, success_order,
685 failure_order);
686 }

◆ TryAllocateCompleted()

bool dart::SampleBlock::TryAllocateCompleted ( )
inline

Definition at line 659 of file profiler.h.

659 {
660 State expected = kCompleted;
661 State desired = kSampling;
662 std::memory_order success_order = std::memory_order_acquire;
663 std::memory_order failure_order = std::memory_order_relaxed;
664 if (state_.compare_exchange_strong(expected, desired, success_order,
665 failure_order)) {
666 owner_ = nullptr;
667 cursor_ = 0;
668 return true;
669 }
670 return false;
671 }

◆ TryAllocateFree()

bool dart::SampleBlock::TryAllocateFree ( )
inline

Definition at line 651 of file profiler.h.

651 {
652 State expected = kFree;
653 State desired = kSampling;
654 std::memory_order success_order = std::memory_order_acquire;
655 std::memory_order failure_order = std::memory_order_relaxed;
656 return state_.compare_exchange_strong(expected, desired, success_order,
657 failure_order);
658 }

Friends And Related Function Documentation

◆ SampleBlockBuffer

friend class SampleBlockBuffer
friend

Definition at line 723 of file profiler.h.

◆ SampleBlockListProcessor

friend class SampleBlockListProcessor
friend

Definition at line 722 of file profiler.h.

Member Data Documentation

◆ cursor_

RelaxedAtomic<uint32_t> dart::SampleBlock::cursor_ = 0
protected

Definition at line 718 of file profiler.h.

◆ kSamplesPerBlock

constexpr intptr_t dart::SampleBlock::kSamplesPerBlock = 100
staticconstexpr

Definition at line 637 of file profiler.h.

◆ owner_

Isolate* dart::SampleBlock::owner_ = nullptr
protected

Definition at line 719 of file profiler.h.

◆ state_

std::atomic<State> dart::SampleBlock::state_ = kFree
protected

Definition at line 717 of file profiler.h.


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