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

Public Member Functions

 PreallocatedStackTraceBuilder (const Instance &stacktrace)
 
 ~PreallocatedStackTraceBuilder ()
 
void AddFrame (const Object &code, uword pc_offset) override
 
- Public Member Functions inherited from dart::StackTraceBuilder
 StackTraceBuilder ()
 
virtual ~StackTraceBuilder ()
 
virtual void AddFrame (const Object &code, uword pc_offset)=0
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Detailed Description

Definition at line 44 of file exceptions.cc.

Constructor & Destructor Documentation

◆ PreallocatedStackTraceBuilder()

dart::PreallocatedStackTraceBuilder::PreallocatedStackTraceBuilder ( const Instance stacktrace)
inlineexplicit

Definition at line 46 of file exceptions.cc.

47 : stacktrace_(StackTrace::Cast(stacktrace)),
48 cur_index_(0),
49 dropped_frames_(0) {
50 ASSERT(
51 stacktrace_.ptr() ==
52 Isolate::Current()->isolate_object_store()->preallocated_stack_trace());
53 }
static Isolate * Current()
Definition: isolate.h:986
IsolateObjectStore * isolate_object_store() const
Definition: isolate.h:1007
ObjectPtr ptr() const
Definition: object.h:332
#define ASSERT(E)

◆ ~PreallocatedStackTraceBuilder()

dart::PreallocatedStackTraceBuilder::~PreallocatedStackTraceBuilder ( )
inline

Definition at line 54 of file exceptions.cc.

54{}

Member Function Documentation

◆ AddFrame()

void dart::PreallocatedStackTraceBuilder::AddFrame ( const Object code,
uword  pc_offset 
)
overridevirtual

Implements dart::StackTraceBuilder.

Definition at line 68 of file exceptions.cc.

69 {
70 if (cur_index_ >= StackTrace::kPreallocatedStackdepth) {
71 // The number of frames is overflowing the preallocated stack trace object.
72 Object& frame_code = Object::Handle();
73 intptr_t start = StackTrace::kPreallocatedStackdepth - (kNumTopframes - 1);
74 intptr_t null_slot = start - 2;
75 // We are going to drop one frame.
76 dropped_frames_++;
77 // Add an empty slot to indicate the overflow so that the toString
78 // method can account for the overflow.
79 if (stacktrace_.CodeAtFrame(null_slot) != Code::null()) {
80 stacktrace_.SetCodeAtFrame(null_slot, frame_code);
81 // We drop an extra frame here too.
82 dropped_frames_++;
83 }
84 // Encode the number of dropped frames into the pc offset.
85 stacktrace_.SetPcOffsetAtFrame(null_slot, dropped_frames_);
86 // Move frames one slot down so that we can accommodate the new frame.
87 for (intptr_t i = start; i < StackTrace::kPreallocatedStackdepth; i++) {
88 intptr_t prev = (i - 1);
89 frame_code = stacktrace_.CodeAtFrame(i);
90 const uword frame_offset = stacktrace_.PcOffsetAtFrame(i);
91 stacktrace_.SetCodeAtFrame(prev, frame_code);
92 stacktrace_.SetPcOffsetAtFrame(prev, frame_offset);
93 }
94 cur_index_ = (StackTrace::kPreallocatedStackdepth - 1);
95 }
96 stacktrace_.SetCodeAtFrame(cur_index_, code);
97 stacktrace_.SetPcOffsetAtFrame(cur_index_, pc_offset);
98 cur_index_ += 1;
99}
static float prev(float f)
static ObjectPtr null()
Definition: object.h:433
static Object & Handle()
Definition: object.h:407
void SetPcOffsetAtFrame(intptr_t frame_index, uword pc_offset) const
Definition: object.cc:26042
void SetCodeAtFrame(intptr_t frame_index, const Object &code) const
Definition: object.cc:26030
static constexpr int kPreallocatedStackdepth
Definition: object.h:12558
uword PcOffsetAtFrame(intptr_t frame_index) const
Definition: object.cc:26036
ObjectPtr CodeAtFrame(intptr_t frame_index) const
Definition: object.cc:26025
uintptr_t uword
Definition: globals.h:501

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