Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::ProfilerDartStackWalker Class Reference
Inheritance diagram for dart::ProfilerDartStackWalker:
dart::ProfilerStackWalker dart::ValueObject

Public Member Functions

 ProfilerDartStackWalker (Thread *thread, Sample *sample, SampleBuffer *sample_buffer, uword pc, uword fp, uword sp, uword lr, bool allocation_sample, intptr_t skip_count=0)
 
void walk ()
 
- Public Member Functions inherited from dart::ProfilerStackWalker
 ProfilerStackWalker (Dart_Port port_id, Sample *head_sample, SampleBuffer *sample_buffer, intptr_t skip_count=0)
 
bool Append (uword pc, uword fp)
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Additional Inherited Members

- Protected Attributes inherited from dart::ProfilerStackWalker
Dart_Port port_id_
 
Samplesample_
 
SampleBuffersample_buffer_
 
intptr_t skip_count_
 
intptr_t frames_skipped_
 
intptr_t frame_index_
 
intptr_t total_frames_
 

Detailed Description

Definition at line 1001 of file profiler.cc.

Constructor & Destructor Documentation

◆ ProfilerDartStackWalker()

dart::ProfilerDartStackWalker::ProfilerDartStackWalker ( Thread thread,
Sample sample,
SampleBuffer sample_buffer,
uword  pc,
uword  fp,
uword  sp,
uword  lr,
bool  allocation_sample,
intptr_t  skip_count = 0 
)
inline

Definition at line 1003 of file profiler.cc.

1012 : ProfilerStackWalker((thread->isolate() != nullptr)
1013 ? thread->isolate()->main_port()
1014 : ILLEGAL_PORT,
1015 sample,
1016 sample_buffer,
1017 skip_count),
1018 thread_(thread),
1019 pc_(reinterpret_cast<uword*>(pc)),
1020 fp_(reinterpret_cast<uword*>(fp)),
1021 sp_(reinterpret_cast<uword*>(sp)),
1022 lr_(reinterpret_cast<uword*>(lr)) {}
ProfilerStackWalker(Dart_Port port_id, Sample *head_sample, SampleBuffer *sample_buffer, intptr_t skip_count=0)
Definition: profiler.cc:126
#define ILLEGAL_PORT
Definition: dart_api.h:1535
uintptr_t uword
Definition: globals.h:501
const uint32_t fp

Member Function Documentation

◆ walk()

void dart::ProfilerDartStackWalker::walk ( )
inline

Definition at line 1024 of file profiler.cc.

1024 {
1026 if (thread_->isolate()->IsDeoptimizing()) {
1028 return;
1029 }
1030
1031 uword* exit_fp = reinterpret_cast<uword*>(thread_->top_exit_frame_info());
1032 bool has_exit_frame = exit_fp != nullptr;
1033 if (has_exit_frame) {
1034 // Exited from compiled code.
1035 pc_ = nullptr;
1036 fp_ = exit_fp;
1037
1038 // Skip exit frame.
1039 pc_ = CallerPC();
1040 fp_ = CallerFP();
1041 } else {
1042 if (thread_->vm_tag() == VMTag::kDartTagId) {
1043 // Running compiled code.
1044 // Use the FP and PC from the thread interrupt or simulator; already set
1045 // in the constructor.
1046 } else {
1047 // No Dart on the stack; caller shouldn't use this walker.
1048 UNREACHABLE();
1049 }
1050
1051 const bool is_entry_frame =
1052#if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
1053 StubCode::InInvocationStub(Stack(0)) ||
1055#else
1056 StubCode::InInvocationStub(reinterpret_cast<uword>(lr_));
1057#endif
1058 if (is_entry_frame) {
1059 // During the prologue of a function, CallerPC will return the caller's
1060 // caller. For most frames, the missing PC will be added during profile
1061 // processing. However, during this stack walk, it can cause us to fail
1062 // to identify the entry frame and lead the stack walk into the weeds.
1063 // Do not continue the stalk walk since this might be a false positive
1064 // from a Smi or unboxed value.
1066 return;
1067 }
1068 }
1069
1070 sample_->set_exit_frame_sample(has_exit_frame);
1071
1072 for (;;) {
1073 // Skip entry frame.
1074 if (StubCode::InInvocationStub(reinterpret_cast<uword>(pc_))) {
1075 pc_ = nullptr;
1076 fp_ = ExitLink();
1077 if (fp_ == nullptr) {
1078 break; // End of Dart stack.
1079 }
1080
1081 // Skip exit frame.
1082 pc_ = CallerPC();
1083 fp_ = CallerFP();
1084
1085 // At least one frame between exit and next entry frame.
1087 !StubCode::InInvocationStub(reinterpret_cast<uword>(pc_)));
1088 }
1089
1090 if (!Append(reinterpret_cast<uword>(pc_), reinterpret_cast<uword>(fp_))) {
1091 break; // Sample is full.
1092 }
1093
1094 pc_ = CallerPC();
1095 fp_ = CallerFP();
1096 }
1097 }
#define UNREACHABLE()
Definition: assert.h:248
#define RELEASE_ASSERT(cond)
Definition: assert.h:327
bool IsDeoptimizing() const
Definition: isolate.h:1254
bool Append(uword pc, uword fp)
Definition: profiler.cc:145
void set_ignore_sample(bool ignore_sample)
Definition: profiler.h:282
void set_exit_frame_sample(bool exit_frame_sample)
Definition: profiler.h:288
static bool HasBeenInitialized()
Definition: stub_code.h:41
static bool InInvocationStub(uword pc)
Definition: stub_code.cc:132
uword vm_tag() const
Definition: thread.h:821
uword top_exit_frame_info() const
Definition: thread.h:691
Isolate * isolate() const
Definition: thread.h:534

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