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

#include <pending_deopts.h>

Public Types

enum  ClearReason { kClearDueToThrow , kClearDueToDeopt }
 

Public Member Functions

 PendingDeopts ()
 
 ~PendingDeopts ()
 
bool HasPendingDeopts ()
 
void AddPendingDeopt (uword fp, uword pc)
 
uword FindPendingDeopt (uword fp)
 
void ClearPendingDeoptsBelow (uword fp, ClearReason reason)
 
void ClearPendingDeoptsAtOrBelow (uword fp, ClearReason reason)
 
uword RemapExceptionPCForDeopt (uword program_counter, uword frame_pointer, bool *clear_deopt)
 

Detailed Description

Definition at line 28 of file pending_deopts.h.

Member Enumeration Documentation

◆ ClearReason

Enumerator
kClearDueToThrow 
kClearDueToDeopt 

Definition at line 30 of file pending_deopts.h.

Constructor & Destructor Documentation

◆ PendingDeopts()

dart::PendingDeopts::PendingDeopts ( )

Definition at line 14 of file pending_deopts.cc.

15 : pending_deopts_(new MallocGrowableArray<PendingLazyDeopt>()) {}

◆ ~PendingDeopts()

dart::PendingDeopts::~PendingDeopts ( )

Definition at line 16 of file pending_deopts.cc.

16 {
17 delete pending_deopts_;
18 pending_deopts_ = nullptr;
19}

Member Function Documentation

◆ AddPendingDeopt()

void dart::PendingDeopts::AddPendingDeopt ( uword  fp,
uword  pc 
)

Definition at line 21 of file pending_deopts.cc.

21 {
22 // GrowableArray::Add is not atomic and may be interrupted by a profiler
23 // stack walk.
24 MallocGrowableArray<PendingLazyDeopt>* old_pending_deopts = pending_deopts_;
25 MallocGrowableArray<PendingLazyDeopt>* new_pending_deopts =
26 new MallocGrowableArray<PendingLazyDeopt>(old_pending_deopts->length() +
27 1);
28 for (intptr_t i = 0; i < old_pending_deopts->length(); i++) {
29 ASSERT((*old_pending_deopts)[i].fp() != fp);
30 new_pending_deopts->Add((*old_pending_deopts)[i]);
31 }
32 PendingLazyDeopt deopt(fp, pc);
33 new_pending_deopts->Add(deopt);
34
35 pending_deopts_ = new_pending_deopts;
36 delete old_pending_deopts;
37}
#define ASSERT(E)
const uint32_t fp

◆ ClearPendingDeoptsAtOrBelow()

void dart::PendingDeopts::ClearPendingDeoptsAtOrBelow ( uword  fp,
ClearReason  reason 
)

Definition at line 79 of file pending_deopts.cc.

79 {
81}
void ClearPendingDeoptsBelow(uword fp, ClearReason reason)
constexpr intptr_t kWordSize
Definition globals.h:509

◆ ClearPendingDeoptsBelow()

void dart::PendingDeopts::ClearPendingDeoptsBelow ( uword  fp,
ClearReason  reason 
)

Definition at line 57 of file pending_deopts.cc.

57 {
58 for (intptr_t i = pending_deopts_->length() - 1; i >= 0; i--) {
59 if ((*pending_deopts_)[i].fp() < fp) {
60 if (FLAG_trace_deoptimization) {
61 switch (reason) {
64 "Lazy deopt skipped due to throw for "
65 "fp=%" Pp ", pc=%" Pp "\n",
66 (*pending_deopts_)[i].fp(), (*pending_deopts_)[i].pc());
67 break;
69 THR_Print("Lazy deopt fp=%" Pp " pc=%" Pp "\n",
70 (*pending_deopts_)[i].fp(), (*pending_deopts_)[i].pc());
71 break;
72 }
73 }
74 pending_deopts_->RemoveAt(i);
75 }
76 }
77}
#define THR_Print(format,...)
Definition log.h:20
#define Pp
Definition globals.h:425

◆ FindPendingDeopt()

uword dart::PendingDeopts::FindPendingDeopt ( uword  fp)

Definition at line 48 of file pending_deopts.cc.

48 {
49 auto record = FindPendingDeoptRecord(fp);
50 if (record != nullptr) {
51 return record->pc();
52 }
53 FATAL("Missing pending deopt entry");
54 return 0;
55}
#define FATAL(error)

◆ HasPendingDeopts()

bool dart::PendingDeopts::HasPendingDeopts ( )
inline

Definition at line 37 of file pending_deopts.h.

37{ return pending_deopts_->length() > 0; }

◆ RemapExceptionPCForDeopt()

uword dart::PendingDeopts::RemapExceptionPCForDeopt ( uword  program_counter,
uword  frame_pointer,
bool *  clear_deopt 
)

Definition at line 83 of file pending_deopts.cc.

85 {
86 *clear_deopt = false;
87
88 // Do not attempt to deopt at async exception handler as it doesn't
89 // belong to the function code. Async handler never continues execution
90 // in the same frame - it either rethrows exception to the caller or
91 // tail calls Dart handler, leaving the function frame before the call.
92 if (program_counter == StubCode::AsyncExceptionHandler().EntryPoint()) {
93 *clear_deopt = true;
94 return program_counter;
95 }
96
97 // Check if the target frame is scheduled for lazy deopt.
98 if (FindPendingDeoptRecord(frame_pointer) != nullptr) {
99#if defined(DEBUG)
100 // Ensure the frame references optimized code.
101 ObjectPtr pc_marker = *(reinterpret_cast<ObjectPtr*>(
102 frame_pointer + runtime_frame_layout.code_from_fp * kWordSize));
103 Code& code = Code::Handle(Code::RawCast(pc_marker));
104 ASSERT(code.is_optimized() && !code.is_force_optimized());
105#endif
106 if (FLAG_trace_deoptimization) {
107 THR_Print("Throwing to frame scheduled for lazy deopt fp=%" Pp "\n",
108 frame_pointer);
109 }
110 return StubCode::DeoptimizeLazyFromThrow().EntryPoint();
111 }
112
113 return program_counter;
114}
static Object & Handle()
Definition object.h:407
static ObjectPtr RawCast(ObjectPtr obj)
Definition object.h:325
FrameLayout runtime_frame_layout
intptr_t code_from_fp

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