Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
dart::Profile Class Reference

#include <profiler_service.h>

Inheritance diagram for dart::Profile:
dart::ValueObject

Public Member Functions

 Profile ()
 
void Build (Thread *thread, Isolate *isolate, SampleFilter *filter, SampleBlockBuffer *sample_block_buffer)
 
int64_t min_time () const
 
int64_t max_time () const
 
int64_t GetTimeSpan () const
 
intptr_t sample_count () const
 
ProcessedSampleSampleAt (intptr_t index)
 
intptr_t NumFunctions () const
 
ProfileFunctionGetFunction (intptr_t index)
 
ProfileCodeGetCode (intptr_t index)
 
ProfileCodeGetCodeFromPC (uword pc, int64_t timestamp)
 
void PrintProfileJSON (JSONStream *stream, bool include_code_samples)
 
void PrintProfileJSON (JSONObject *obj, bool include_code_samples, bool is_event=false)
 
ProfileFunctionFindFunction (const Function &function)
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Friends

class ProfileBuilder
 

Detailed Description

Definition at line 370 of file profiler_service.h.

Constructor & Destructor Documentation

◆ Profile()

dart::Profile::Profile ( )

Definition at line 1484 of file profiler_service.cc.

1485 : zone_(Thread::Current()->zone()),
1486 samples_(nullptr),
1487 live_code_(nullptr),
1488 dead_code_(nullptr),
1489 tag_code_(nullptr),
1490 functions_(nullptr),
1491 dead_code_index_offset_(-1),
1492 tag_code_index_offset_(-1),
1493 min_time_(kMaxInt64),
1494 max_time_(0),
1495 sample_count_(0) {}
static Thread * Current()
Definition thread.h:361
constexpr int64_t kMaxInt64
Definition globals.h:486

Member Function Documentation

◆ Build()

void dart::Profile::Build ( Thread thread,
Isolate isolate,
SampleFilter filter,
SampleBlockBuffer sample_block_buffer 
)

Definition at line 1497 of file profiler_service.cc.

1500 {
1501 ASSERT(isolate != nullptr);
1502
1503 // Disable thread interrupts while processing the buffer.
1504 DisableThreadInterruptsScope dtis(thread);
1505 ProfileBuilder builder(thread, isolate, filter, sample_buffer, this);
1506 builder.Build();
1507}
friend class ProfileBuilder
#define ASSERT(E)

◆ FindFunction()

ProfileFunction * dart::Profile::FindFunction ( const Function function)

Definition at line 1870 of file profiler_service.cc.

1870 {
1871 return (functions_ != nullptr) ? functions_->Lookup(function) : nullptr;
1872}
ProfileFunction * Lookup(const Function &function)
Dart_NativeFunction function
Definition fuchsia.cc:51

◆ GetCode()

ProfileCode * dart::Profile::GetCode ( intptr_t  index)

Definition at line 1524 of file profiler_service.cc.

1524 {
1525 ASSERT(live_code_ != nullptr);
1526 ASSERT(dead_code_ != nullptr);
1527 ASSERT(tag_code_ != nullptr);
1528 ASSERT(dead_code_index_offset_ >= 0);
1529 ASSERT(tag_code_index_offset_ >= 0);
1530
1531 // Code indexes span three arrays.
1532 // 0 ... |live_code|
1533 // |live_code| ... |dead_code|
1534 // |dead_code| ... |tag_code|
1535
1536 if (index < dead_code_index_offset_) {
1537 return live_code_->At(index);
1538 }
1539
1540 if (index < tag_code_index_offset_) {
1541 index -= dead_code_index_offset_;
1542 return dead_code_->At(index);
1543 }
1544
1545 index -= tag_code_index_offset_;
1546 return tag_code_->At(index);
1547}
ProfileCode * At(intptr_t index) const

◆ GetCodeFromPC()

ProfileCode * dart::Profile::GetCodeFromPC ( uword  pc,
int64_t  timestamp 
)

Definition at line 1549 of file profiler_service.cc.

1549 {
1550 intptr_t index = live_code_->FindCodeIndexForPC(pc);
1551 ProfileCode* code = nullptr;
1552 if (index < 0) {
1553 index = dead_code_->FindCodeIndexForPC(pc);
1554 ASSERT(index >= 0);
1555 code = dead_code_->At(index);
1556 } else {
1557 code = live_code_->At(index);
1558 ASSERT(code != nullptr);
1559 if (code->compile_timestamp() > timestamp) {
1560 // Code is newer than sample. Fall back to dead code table.
1561 index = dead_code_->FindCodeIndexForPC(pc);
1562 ASSERT(index >= 0);
1563 code = dead_code_->At(index);
1564 }
1565 }
1566
1567 ASSERT(code != nullptr);
1568 ASSERT(code->Contains(pc));
1569 ASSERT(code->compile_timestamp() <= timestamp);
1570 return code;
1571}
intptr_t FindCodeIndexForPC(uword pc) const

◆ GetFunction()

ProfileFunction * dart::Profile::GetFunction ( intptr_t  index)

Definition at line 1519 of file profiler_service.cc.

1519 {
1520 ASSERT(functions_ != nullptr);
1521 return functions_->At(index);
1522}
ProfileFunction * At(intptr_t i) const

◆ GetTimeSpan()

int64_t dart::Profile::GetTimeSpan ( ) const
inline

Definition at line 383 of file profiler_service.h.

383{ return max_time() - min_time(); }
int64_t max_time() const
int64_t min_time() const

◆ max_time()

int64_t dart::Profile::max_time ( ) const
inline

Definition at line 382 of file profiler_service.h.

382{ return max_time_; }

◆ min_time()

int64_t dart::Profile::min_time ( ) const
inline

Definition at line 381 of file profiler_service.h.

381{ return min_time_; }

◆ NumFunctions()

intptr_t dart::Profile::NumFunctions ( ) const

Definition at line 1515 of file profiler_service.cc.

1515 {
1516 return functions_->length();
1517}

◆ PrintProfileJSON() [1/2]

void dart::Profile::PrintProfileJSON ( JSONObject obj,
bool  include_code_samples,
bool  is_event = false 
)

Definition at line 1879 of file profiler_service.cc.

1881 {
1882 ScopeTimer sw("Profile::PrintProfileJSON", FLAG_trace_profiler);
1883 Thread* thread = Thread::Current();
1884 if (is_event) {
1885 obj->AddProperty("type", "CpuSamplesEvent");
1886 } else {
1887 obj->AddProperty("type", "CpuSamples");
1888 }
1889 PrintHeaderJSON(obj);
1890 if (include_code_samples) {
1891 JSONArray codes(obj, "_codes");
1892 for (intptr_t i = 0; i < live_code_->length(); i++) {
1893 ProfileCode* code = live_code_->At(i);
1894 ASSERT(code != nullptr);
1895 code->PrintToJSONArray(&codes);
1896 thread->CheckForSafepoint();
1897 }
1898 for (intptr_t i = 0; i < dead_code_->length(); i++) {
1899 ProfileCode* code = dead_code_->At(i);
1900 ASSERT(code != nullptr);
1901 code->PrintToJSONArray(&codes);
1902 thread->CheckForSafepoint();
1903 }
1904 for (intptr_t i = 0; i < tag_code_->length(); i++) {
1905 ProfileCode* code = tag_code_->At(i);
1906 ASSERT(code != nullptr);
1907 code->PrintToJSONArray(&codes);
1908 thread->CheckForSafepoint();
1909 }
1910 }
1911
1912 {
1913 JSONArray functions(obj, "functions");
1914 for (intptr_t i = 0; i < functions_->length(); i++) {
1915 ProfileFunction* function = functions_->At(i);
1916 ASSERT(function != nullptr);
1917 function->PrintToJSONArray(&functions, is_event);
1918 thread->CheckForSafepoint();
1919 }
1920 }
1921 PrintSamplesJSON(obj, include_code_samples);
1922 thread->CheckForSafepoint();
1923}

◆ PrintProfileJSON() [2/2]

void dart::Profile::PrintProfileJSON ( JSONStream stream,
bool  include_code_samples 
)

Definition at line 1874 of file profiler_service.cc.

1874 {
1875 JSONObject obj(stream);
1876 PrintProfileJSON(&obj, include_code_samples);
1877}
void PrintProfileJSON(JSONStream *stream, bool include_code_samples)

◆ sample_count()

intptr_t dart::Profile::sample_count ( ) const
inline

Definition at line 384 of file profiler_service.h.

384{ return sample_count_; }

◆ SampleAt()

ProcessedSample * dart::Profile::SampleAt ( intptr_t  index)

Definition at line 1509 of file profiler_service.cc.

1509 {
1510 ASSERT(index >= 0);
1511 ASSERT(index < sample_count_);
1512 return samples_->At(index);
1513}
ProcessedSample * At(intptr_t index)
Definition profiler.h:898

Friends And Related Symbol Documentation

◆ ProfileBuilder

friend class ProfileBuilder
friend

Definition at line 448 of file profiler_service.h.


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