Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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)
 
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 641 of file profiler.h.

Member Enumeration Documentation

◆ State

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

Definition at line 718 of file profiler.h.

718 : uint32_t {
719 kFree,
720 kSampling, // I.e., writing.
722 kStreaming, // I.e., reading.
723 };

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

650{ return capacity_; }
intptr_t capacity_
Definition profiler.h:636

◆ FreeCompleted()

void dart::SampleBlock::FreeCompleted ( )
inline

Definition at line 704 of file profiler.h.

704 {
705 State expected = kCompleted;
706 State desired = kStreaming;
707 std::memory_order success_order = std::memory_order_acquire;
708 std::memory_order failure_order = std::memory_order_relaxed;
709 if (state_.compare_exchange_strong(expected, desired, success_order,
710 failure_order)) {
712 }
713 }
void StreamingToFree()
Definition profiler.h:698
std::atomic< State > state_
Definition profiler.h:724

◆ HasStreamableSamples()

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

Definition at line 724 of file profiler.cc.

725 {
726 for (intptr_t i = 0; i < capacity_; ++i) {
727 Sample* sample = At(i);
728 uword sample_tag = sample->user_tag();
729 for (intptr_t j = 0; j < tag_table.Length(); ++j) {
730 *tag ^= tag_table.At(j);
731 if (tag->tag() == sample_tag && tag->streamable()) {
732 return true;
733 }
734 }
735 }
736 return false;
737}
Sample * At(intptr_t idx) const
Definition profiler.h:617
uintptr_t uword
Definition globals.h:501

◆ MarkCompleted()

void dart::SampleBlock::MarkCompleted ( )
inline

Definition at line 679 of file profiler.h.

679 {
680 ASSERT(state_.load(std::memory_order_relaxed) == kSampling);
681 state_.store(kCompleted, std::memory_order_release);
682 }
#define ASSERT(E)

◆ owner()

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

Definition at line 652 of file profiler.h.

652{ return owner_; }
Isolate * owner_
Definition profiler.h:726

◆ ReserveSample()

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

Implements dart::SampleBuffer.

Definition at line 785 of file profiler.cc.

785 {
786 intptr_t slot = cursor_.fetch_add(1u);
787 if (slot < capacity_) {
788 return At(slot);
789 }
790 return nullptr;
791}
T fetch_add(T arg, std::memory_order order=std::memory_order_relaxed)
Definition atomic.h:35
RelaxedAtomic< uint32_t > cursor_
Definition profiler.h:725

◆ ReserveSampleAndLink()

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

Implements dart::SampleBuffer.

Definition at line 793 of file profiler.cc.

793 {
794 ASSERT(previous != nullptr);
796 Isolate* isolate = owner_;
797 ASSERT(isolate != nullptr);
798 Sample* next = previous->is_allocation_sample()
799 ? buffer->ReserveAllocationSample(isolate)
800 : buffer->ReserveCPUSample(isolate);
801 if (next == nullptr) {
802 return nullptr; // No blocks left, so drop sample.
803 }
804 next->Init(previous->port(), previous->timestamp(), previous->tid());
805 next->set_head_sample(false);
806 // Mark that previous continues at next.
807 previous->SetContinuation(next);
808 return next;
809}
static float next(float f)
static SampleBlockBuffer * sample_block_buffer()
Definition profiler.h:67
friend class SampleBlockBuffer
Definition profiler.h:730
static const uint8_t buffer[]

◆ set_owner()

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

Definition at line 653 of file profiler.h.

653{ owner_ = isolate; }

◆ StreamingToCompleted()

void dart::SampleBlock::StreamingToCompleted ( )
inline

Definition at line 694 of file profiler.h.

694 {
695 ASSERT(state_.load(std::memory_order_relaxed) == kStreaming);
696 state_.store(kCompleted, std::memory_order_relaxed);
697 }

◆ StreamingToFree()

void dart::SampleBlock::StreamingToFree ( )
inline

Definition at line 698 of file profiler.h.

698 {
699 ASSERT(state_.load(std::memory_order_relaxed) == kStreaming);
700 owner_ = nullptr;
701 cursor_ = 0;
702 state_.store(kFree, std::memory_order_release);
703 }
void store(T arg, std::memory_order order=std::memory_order_relaxed)
Definition atomic.h:27

◆ TryAcquireStreaming()

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

Definition at line 683 of file profiler.h.

683 {
684 if (state_.load(std::memory_order_relaxed) != kCompleted) return false;
685 if (owner_ != isolate) return false;
686
687 State expected = kCompleted;
688 State desired = kStreaming;
689 std::memory_order success_order = std::memory_order_acquire;
690 std::memory_order failure_order = std::memory_order_relaxed;
691 return state_.compare_exchange_strong(expected, desired, success_order,
692 failure_order);
693 }

◆ TryAllocateCompleted()

bool dart::SampleBlock::TryAllocateCompleted ( )
inline

Definition at line 666 of file profiler.h.

666 {
667 State expected = kCompleted;
668 State desired = kSampling;
669 std::memory_order success_order = std::memory_order_acquire;
670 std::memory_order failure_order = std::memory_order_relaxed;
671 if (state_.compare_exchange_strong(expected, desired, success_order,
672 failure_order)) {
673 owner_ = nullptr;
674 cursor_ = 0;
675 return true;
676 }
677 return false;
678 }

◆ TryAllocateFree()

bool dart::SampleBlock::TryAllocateFree ( )
inline

Definition at line 658 of file profiler.h.

658 {
659 State expected = kFree;
660 State desired = kSampling;
661 std::memory_order success_order = std::memory_order_acquire;
662 std::memory_order failure_order = std::memory_order_relaxed;
663 return state_.compare_exchange_strong(expected, desired, success_order,
664 failure_order);
665 }

Friends And Related Symbol Documentation

◆ SampleBlockBuffer

friend class SampleBlockBuffer
friend

Definition at line 730 of file profiler.h.

◆ SampleBlockListProcessor

friend class SampleBlockListProcessor
friend

Definition at line 729 of file profiler.h.

Member Data Documentation

◆ cursor_

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

Definition at line 725 of file profiler.h.

◆ kSamplesPerBlock

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

Definition at line 644 of file profiler.h.

◆ owner_

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

Definition at line 726 of file profiler.h.

◆ state_

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

Definition at line 724 of file profiler.h.


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