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

#include <code_descriptors.h>

Inheritance diagram for dart::ExceptionHandlerList:
dart::ZoneAllocated

Classes

struct  HandlerDesc
 

Public Member Functions

 ExceptionHandlerList (const Function &function)
 
intptr_t Length () const
 
void AddPlaceHolder ()
 
void AddHandler (intptr_t try_index, intptr_t outer_try_index, intptr_t pc_offset, bool is_generated, const Array &handler_types, bool needs_stacktrace)
 
void SetNeedsStackTrace (intptr_t try_index)
 
ExceptionHandlersPtr FinalizeExceptionHandlers (uword entry_point) const
 
- Public Member Functions inherited from dart::ZoneAllocated
 ZoneAllocated ()
 
void * operator new (size_t size)
 
void * operator new (size_t size, Zone *zone)
 
void operator delete (void *pointer)
 

Static Public Member Functions

static bool ContainsCatchAllType (const Array &array)
 

Detailed Description

Definition at line 69 of file code_descriptors.h.

Constructor & Destructor Documentation

◆ ExceptionHandlerList()

dart::ExceptionHandlerList::ExceptionHandlerList ( const Function function)
inlineexplicit

Definition at line 79 of file code_descriptors.h.

80 : list_(),
81 has_async_handler_(function.IsAsyncFunction() ||
82 function.IsAsyncGenerator()) {}
Dart_NativeFunction function
Definition fuchsia.cc:51

Member Function Documentation

◆ AddHandler()

void dart::ExceptionHandlerList::AddHandler ( intptr_t  try_index,
intptr_t  outer_try_index,
intptr_t  pc_offset,
bool  is_generated,
const Array handler_types,
bool  needs_stacktrace 
)
inline

Definition at line 96 of file code_descriptors.h.

101 {
102 ASSERT(try_index >= 0);
103 while (Length() <= try_index) {
105 }
106 list_[try_index].outer_try_index = outer_try_index;
107 ASSERT(list_[try_index].pc_offset == ExceptionHandlers::kInvalidPcOffset);
108 list_[try_index].pc_offset = pc_offset;
109 list_[try_index].is_generated = is_generated;
110 DEBUG_ASSERT(handler_types.IsNotTemporaryScopedHandle());
111 list_[try_index].handler_types = &handler_types;
112 list_[try_index].needs_stacktrace |= needs_stacktrace;
113 }
#define DEBUG_ASSERT(cond)
Definition assert.h:321
static constexpr intptr_t kInvalidPcOffset
Definition object.h:6547
#define ASSERT(E)

◆ AddPlaceHolder()

void dart::ExceptionHandlerList::AddPlaceHolder ( )
inline

Definition at line 86 of file code_descriptors.h.

86 {
87 struct HandlerDesc data;
88 data.outer_try_index = -1;
90 data.is_generated = true;
91 data.handler_types = nullptr;
92 data.needs_stacktrace = false;
93 list_.Add(data);
94 }
static int8_t data[kExtLength]

◆ ContainsCatchAllType()

static bool dart::ExceptionHandlerList::ContainsCatchAllType ( const Array array)
inlinestatic

Definition at line 128 of file code_descriptors.h.

128 {
129 auto& type = AbstractType::Handle();
130 for (intptr_t i = 0; i < array.Length(); i++) {
131 type ^= array.At(i);
132 if (type.IsCatchAllType()) {
133 return true;
134 }
135 }
136 return false;
137 }
static Object & Handle()
Definition object.h:407

◆ FinalizeExceptionHandlers()

ExceptionHandlersPtr dart::ExceptionHandlerList::FinalizeExceptionHandlers ( uword  entry_point) const

Definition at line 124 of file code_descriptors.cc.

125 {
126 intptr_t num_handlers = Length();
127 if (num_handlers == 0) {
128 return has_async_handler_ ? Object::empty_async_exception_handlers().ptr()
129 : Object::empty_exception_handlers().ptr();
130 }
131 const ExceptionHandlers& handlers =
133 handlers.set_has_async_handler(has_async_handler_);
134 for (intptr_t i = 0; i < num_handlers; i++) {
135 // Assert that every element in the array has been initialized.
136 if (list_[i].handler_types == nullptr) {
137 // Unreachable handler, entry not computed.
138 // Initialize it to some meaningful value.
139 const bool has_catch_all = false;
140 // Check it is uninitialized.
141 ASSERT((list_[i].outer_try_index == -1) &&
142 (list_[i].pc_offset == ExceptionHandlers::kInvalidPcOffset));
143 handlers.SetHandlerInfo(i, list_[i].outer_try_index, list_[i].pc_offset,
144 list_[i].needs_stacktrace, has_catch_all,
145 list_[i].is_generated);
146 handlers.SetHandledTypes(i, Array::empty_array());
147 } else {
148 const bool has_catch_all = ContainsCatchAllType(*list_[i].handler_types);
149 handlers.SetHandlerInfo(i, list_[i].outer_try_index, list_[i].pc_offset,
150 list_[i].needs_stacktrace, has_catch_all,
151 list_[i].is_generated);
152 handlers.SetHandledTypes(i, *list_[i].handler_types);
153 }
154 }
155 return handlers.ptr();
156}
static bool ContainsCatchAllType(const Array &array)
static ExceptionHandlersPtr New(intptr_t num_handlers)
Definition object.cc:16288

◆ Length()

intptr_t dart::ExceptionHandlerList::Length ( ) const
inline

Definition at line 84 of file code_descriptors.h.

84{ return list_.length(); }

◆ SetNeedsStackTrace()

void dart::ExceptionHandlerList::SetNeedsStackTrace ( intptr_t  try_index)
inline

Definition at line 116 of file code_descriptors.h.

116 {
117 // Rethrows can be generated outside a try by the compiler.
118 if (try_index == kInvalidTryIndex) {
119 return;
120 }
121 ASSERT(try_index >= 0);
122 while (Length() <= try_index) {
124 }
125 list_[try_index].needs_stacktrace = true;
126 }
static constexpr intptr_t kInvalidTryIndex

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