Flutter Engine
The Flutter Engine
Public Member Functions | Public Attributes | List of all members
dart::ExceptionHandlerFinder Class Reference
Inheritance diagram for dart::ExceptionHandlerFinder:
dart::StackResource

Public Member Functions

 ExceptionHandlerFinder (Thread *thread)
 
bool Find ()
 
void PrepareFrameForCatchEntry ()
 
void ExecuteCatchEntryMoves (const CatchEntryMoves &moves)
 
void GetCatchEntryMovesFromDeopt (intptr_t num_vars, StackFrame *frame)
 
- Public Member Functions inherited from dart::StackResource
 StackResource (ThreadState *thread)
 
virtual ~StackResource ()
 
ThreadStatethread () const
 

Public Attributes

bool needs_stacktrace
 
uword handler_pc
 
uword handler_sp
 
uword handler_fp
 

Additional Inherited Members

- Static Public Member Functions inherited from dart::StackResource
static void Unwind (ThreadState *thread)
 
static void UnwindAbove (ThreadState *thread, StackResource *new_top)
 

Detailed Description

Definition at line 119 of file exceptions.cc.

Constructor & Destructor Documentation

◆ ExceptionHandlerFinder()

dart::ExceptionHandlerFinder::ExceptionHandlerFinder ( Thread thread)
inlineexplicit

Definition at line 121 of file exceptions.cc.

122 : StackResource(thread), thread_(thread) {}
ThreadState * thread() const
Definition: allocation.h:33
StackResource(ThreadState *thread)
Definition: allocation.h:25

Member Function Documentation

◆ ExecuteCatchEntryMoves()

void dart::ExceptionHandlerFinder::ExecuteCatchEntryMoves ( const CatchEntryMoves moves)
inline

Definition at line 218 of file exceptions.cc.

218 {
219 Zone* zone = Thread::Current()->zone();
220 auto& value = Object::Handle(zone);
221 GrowableArray<Object*> dst_values;
222
224 ObjectPool* pool = nullptr;
225 for (int j = 0; j < moves.count(); j++) {
226 const CatchEntryMove& move = moves.At(j);
227
228 switch (move.source_kind()) {
230 if (pool == nullptr) {
232 }
233 value = pool->ObjectAt(move.src_slot());
234 break;
235
237 value = *TaggedSlotAt(fp, move.src_slot());
238 break;
239
241 value = Double::New(*SlotAt<float>(fp, move.src_slot()));
242 break;
243
245 value = Double::New(*SlotAt<double>(fp, move.src_slot()));
246 break;
247
249 value = Float32x4::New(*SlotAt<simd128_value_t>(fp, move.src_slot()));
250 break;
251
253 value = Float64x2::New(*SlotAt<simd128_value_t>(fp, move.src_slot()));
254 break;
255
257 value = Int32x4::New(*SlotAt<simd128_value_t>(fp, move.src_slot()));
258 break;
259
262 Utils::LowHighTo64Bits(*SlotAt<uint32_t>(fp, move.src_lo_slot()),
263 *SlotAt<int32_t>(fp, move.src_hi_slot())));
264 break;
265
267 value = Integer::New(*SlotAt<int64_t>(fp, move.src_slot()));
268 break;
269
271 value = Integer::New(*SlotAt<int32_t>(fp, move.src_slot()));
272 break;
273
275 value = Integer::New(*SlotAt<uint32_t>(fp, move.src_slot()));
276 break;
277
278 default:
279 UNREACHABLE();
280 }
281
282 dst_values.Add(&Object::Handle(zone, value.ptr()));
283 }
284
285 {
286 Thread* thread = Thread::Current();
287 NoSafepointScope no_safepoint_scope(thread);
288
289 for (int j = 0; j < moves.count(); j++) {
290 const CatchEntryMove& move = moves.At(j);
291 *TaggedSlotAt(fp, move.dest_slot()) = dst_values[j]->ptr();
292 }
293
294 // Update the return address in the stack so the correct stack map is used
295 // for any stack walks that happen before we jump to the handler.
296 StackFrameIterator frames(ValidationPolicy::kDontValidateFrames, thread,
298 bool found = false;
299 for (StackFrame* frame = frames.NextFrame(); frame != nullptr;
300 frame = frames.NextFrame()) {
301 if (frame->fp() == handler_fp) {
302 ASSERT_EQUAL(frame->pc(), static_cast<uword>(pc_));
303 frame->set_pc(handler_pc);
304 found = true;
305 break;
306 }
307 }
308 ASSERT(found);
309 }
310 }
AutoreleasePool pool
#define UNREACHABLE()
Definition: assert.h:248
#define ASSERT_EQUAL(expected, actual)
Definition: assert.h:309
ObjectPoolPtr GetObjectPool() const
Definition: object.cc:17723
static DoublePtr New(double d, Heap::Space space=Heap::kNew)
Definition: object.cc:23402
static Float32x4Ptr New(float value0, float value1, float value2, float value3, Heap::Space space=Heap::kNew)
Definition: object.cc:25307
static Float64x2Ptr New(double value0, double value1, Heap::Space space=Heap::kNew)
Definition: object.cc:25475
static Int32x4Ptr New(int32_t value0, int32_t value1, int32_t value2, int32_t value3, Heap::Space space=Heap::kNew)
Definition: object.cc:25391
static IntegerPtr New(const String &str, Heap::Space space=Heap::kNew)
Definition: object.cc:22984
static Object & Handle()
Definition: object.h:407
Zone * zone() const
Definition: thread_state.h:37
static Thread * Current()
Definition: thread.h:362
static int64_t LowHighTo64Bits(uint32_t low, int32_t high)
Definition: utils.h:377
#define ASSERT(E)
double frame
Definition: examples.cpp:31
uint8_t value
uintptr_t uword
Definition: globals.h:501
const uint32_t fp

◆ Find()

bool dart::ExceptionHandlerFinder::Find ( )
inline

Definition at line 128 of file exceptions.cc.

128 {
129 StackFrameIterator frames(ValidationPolicy::kDontValidateFrames,
132 StackFrame* frame = frames.NextFrame();
133 if (frame == nullptr) return false; // No Dart frame.
134 handler_pc_set_ = false;
135 needs_stacktrace = false;
136 bool is_catch_all = false;
137 uword temp_handler_pc = kUwordMax;
138 bool is_optimized = false;
139 code_ = nullptr;
140 catch_entry_moves_cache_ = thread_->isolate()->catch_entry_moves_cache();
141
142 while (!frame->IsEntryFrame()) {
143 if (frame->IsDartFrame()) {
144 if (frame->FindExceptionHandler(thread_, &temp_handler_pc,
145 &needs_stacktrace, &is_catch_all,
146 &is_optimized)) {
147 if (!handler_pc_set_) {
148 handler_pc_set_ = true;
149 handler_pc = temp_handler_pc;
150 handler_sp = frame->sp();
151 handler_fp = frame->fp();
152 if (is_optimized &&
153 (handler_pc !=
154 StubCode::AsyncExceptionHandler().EntryPoint())) {
155 pc_ = frame->pc();
156 code_ = &Code::Handle(frame->LookupDartCode());
157 CatchEntryMovesRefPtr* cached_catch_entry_moves =
158 catch_entry_moves_cache_->Lookup(pc_);
159 if (cached_catch_entry_moves != nullptr) {
160 cached_catch_entry_moves_ = *cached_catch_entry_moves;
161 }
162 if (cached_catch_entry_moves_.IsEmpty()) {
163#if defined(DART_PRECOMPILED_RUNTIME)
164 // Only AOT mode is supported.
165 ReadCompressedCatchEntryMoves();
166#elif defined(DART_PRECOMPILER)
167 // Both AOT and JIT modes are supported.
168 if (FLAG_precompiled_mode) {
169 ReadCompressedCatchEntryMoves();
170 } else {
172 }
173#else
174 // Only JIT mode is supported.
175 ASSERT(!FLAG_precompiled_mode);
177#endif
178 }
179 }
180 }
181 if (needs_stacktrace || is_catch_all) {
182 return true;
183 }
184 }
185 } // if frame->IsDartFrame
186 frame = frames.NextFrame();
187 ASSERT(frame != nullptr);
188 } // while !frame->IsEntryFrame
189 ASSERT(frame->IsEntryFrame());
190 if (!handler_pc_set_) {
191 handler_pc = frame->pc();
192 handler_sp = frame->sp();
193 handler_fp = frame->fp();
194 }
195 // No catch-all encountered, needs stacktrace.
196 needs_stacktrace = true;
197 return handler_pc_set_;
198 }
intptr_t num_variables() const
Definition: object.cc:17672
void GetCatchEntryMovesFromDeopt(intptr_t num_vars, StackFrame *frame)
Definition: exceptions.cc:323
V * Lookup(K key)
Definition: fixed_cache.h:35
CatchEntryMovesCache * catch_entry_moves_cache()
Definition: isolate.h:1452
Isolate * isolate() const
Definition: thread.h:534
constexpr uword kUwordMax
Definition: globals.h:519

◆ GetCatchEntryMovesFromDeopt()

void dart::ExceptionHandlerFinder::GetCatchEntryMovesFromDeopt ( intptr_t  num_vars,
StackFrame frame 
)
inline

Definition at line 323 of file exceptions.cc.

323 {
324 Isolate* isolate = thread_->isolate();
325 DeoptContext* deopt_context =
326 new DeoptContext(frame, *code_, DeoptContext::kDestIsAllocated, nullptr,
327 nullptr, true, false /* deoptimizing_code */);
328 isolate->set_deopt_context(deopt_context);
329
330 catch_entry_moves_ = deopt_context->ToCatchEntryMoves(num_vars);
331
332 isolate->set_deopt_context(nullptr);
333 delete deopt_context;
334 }

◆ PrepareFrameForCatchEntry()

void dart::ExceptionHandlerFinder::PrepareFrameForCatchEntry ( )
inline

Definition at line 203 of file exceptions.cc.

203 {
204 if (code_ == nullptr || !code_->is_optimized()) {
205 return;
206 }
207
208 if (cached_catch_entry_moves_.IsEmpty()) {
209 catch_entry_moves_cache_->Insert(
210 pc_, CatchEntryMovesRefPtr(catch_entry_moves_));
211 } else {
212 catch_entry_moves_ = &cached_catch_entry_moves_.moves();
213 }
214
215 ExecuteCatchEntryMoves(*catch_entry_moves_);
216 }
const CatchEntryMoves & moves()
Definition: exceptions.h:331
bool is_optimized() const
Definition: object.h:6817
void ExecuteCatchEntryMoves(const CatchEntryMoves &moves)
Definition: exceptions.cc:218
void Insert(K key, V value)
Definition: fixed_cache.h:43

Member Data Documentation

◆ handler_fp

uword dart::ExceptionHandlerFinder::handler_fp

Definition at line 340 of file exceptions.cc.

◆ handler_pc

uword dart::ExceptionHandlerFinder::handler_pc

Definition at line 338 of file exceptions.cc.

◆ handler_sp

uword dart::ExceptionHandlerFinder::handler_sp

Definition at line 339 of file exceptions.cc.

◆ needs_stacktrace

bool dart::ExceptionHandlerFinder::needs_stacktrace

Definition at line 337 of file exceptions.cc.


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