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

#include <deopt_instructions.h>

Inheritance diagram for dart::DeoptContext:
dart::MallocAllocated

Public Types

enum  DestFrameOptions { kDestIsOriginalFrame , kDestIsAllocated }
 

Public Member Functions

 DeoptContext (const StackFrame *frame, const Code &code, DestFrameOptions dest_options, fpu_register_t *fpu_registers, intptr_t *cpu_registers, bool is_lazy_deopt, bool deoptimizing_code)
 
virtual ~DeoptContext ()
 
intptr_t DestStackAdjustment () const
 
intptr_t * GetSourceFrameAddressAt (intptr_t index) const
 
intptr_t GetStackSlot (intptr_t index) const
 
intptr_t GetSourceFp () const
 
intptr_t GetSourcePp () const
 
intptr_t GetSourcePc () const
 
intptr_t GetCallerFp () const
 
void SetCallerFp (intptr_t callers_fp)
 
ObjectPtr ObjectAt (intptr_t index) const
 
intptr_t RegisterValue (Register reg) const
 
float FpuRegisterValueAsFloat (FpuRegister reg) const
 
double FpuRegisterValueAsDouble (FpuRegister reg) const
 
simd128_value_t FpuRegisterValueAsSimd128 (FpuRegister reg) const
 
intptr_t * FrameBase (const StackFrame *frame)
 
void set_dest_frame (const StackFrame *frame)
 
Threadthread () const
 
Zonezone () const
 
intptr_t source_frame_size () const
 
intptr_t dest_frame_size () const
 
CodePtr code () const
 
bool is_lazy_deopt () const
 
bool deoptimizing_code () const
 
ICData::DeoptReasonId deopt_reason () const
 
bool HasDeoptFlag (ICData::DeoptFlags flag)
 
TypedDataPtr deopt_info () const
 
void FillDestFrame ()
 
const CatchEntryMovesToCatchEntryMoves (intptr_t num_vars)
 
intptr_t MaterializeDeferredObjects ()
 
ArrayPtr DestFrameAsArray ()
 
void VisitObjectPointers (ObjectPointerVisitor *visitor)
 
void DeferMaterializedObjectRef (intptr_t idx, intptr_t *slot)
 
void DeferMaterialization (float value, DoublePtr *slot)
 
void DeferMaterialization (double value, DoublePtr *slot)
 
void DeferMintMaterialization (int64_t value, MintPtr *slot)
 
void DeferMaterialization (simd128_value_t value, Float32x4Ptr *slot)
 
void DeferMaterialization (simd128_value_t value, Float64x2Ptr *slot)
 
void DeferMaterialization (simd128_value_t value, Int32x4Ptr *slot)
 
void DeferRetAddrMaterialization (intptr_t index, intptr_t deopt_id, intptr_t *slot)
 
void DeferPcMarkerMaterialization (intptr_t index, intptr_t *slot)
 
void DeferPpMaterialization (intptr_t index, ObjectPtr *slot)
 
DeferredObjectGetDeferredObject (intptr_t idx) const
 
intptr_t num_args () const
 
- Public Member Functions inherited from dart::MallocAllocated
 MallocAllocated ()
 
void * operator new (size_t size)
 
void * operator new[] (size_t size)
 
void operator delete (void *pointer)
 
void operator delete[] (void *pointer)
 

Detailed Description

Definition at line 30 of file deopt_instructions.h.

Member Enumeration Documentation

◆ DestFrameOptions

Enumerator
kDestIsOriginalFrame 
kDestIsAllocated 

Definition at line 32 of file deopt_instructions.h.

32 {
33 kDestIsOriginalFrame, // Replace the original frame with deopt frame.
34 kDestIsAllocated // Write deopt frame to a buffer.
35 };

Constructor & Destructor Documentation

◆ DeoptContext()

dart::DeoptContext::DeoptContext ( const StackFrame frame,
const Code code,
DestFrameOptions  dest_options,
fpu_register_t fpu_registers,
intptr_t *  cpu_registers,
bool  is_lazy_deopt,
bool  deoptimizing_code 
)

Definition at line 29 of file deopt_instructions.cc.

36 : code_(code.ptr()),
37 object_pool_(code.GetObjectPool()),
38 deopt_info_(TypedData::null()),
39 dest_frame_is_allocated_(false),
40 dest_frame_(nullptr),
41 dest_frame_size_(0),
42 source_frame_is_allocated_(false),
43 source_frame_(nullptr),
44 source_frame_size_(0),
45 cpu_registers_(cpu_registers),
46 fpu_registers_(fpu_registers),
47 num_args_(0),
48 deopt_reason_(ICData::kDeoptUnknown),
49 deopt_flags_(0),
50 thread_(Thread::Current()),
51 deopt_start_micros_(0),
52 deferred_slots_(nullptr),
53 deferred_objects_count_(0),
54 deferred_objects_(nullptr),
55 is_lazy_deopt_(is_lazy_deopt),
56 deoptimizing_code_(deoptimizing_code) {
57 const TypedData& deopt_info = TypedData::Handle(
58 code.GetDeoptInfoAtPc(frame->pc(), &deopt_reason_, &deopt_flags_));
59#if defined(DEBUG)
60 if (deopt_info.IsNull()) {
61 OS::PrintErr("Missing deopt info for pc %" Px "\n", frame->pc());
62 DisassembleToStdout formatter;
63 code.Disassemble(&formatter);
64 }
65#endif
66 ASSERT(!deopt_info.IsNull());
67 deopt_info_ = deopt_info.ptr();
68
69 const Function& function = Function::Handle(code.function());
70
71 // Do not include incoming arguments if there are optional arguments
72 // (they are copied into local space at method entry).
73 num_args_ =
74 function.MakesCopyOfParameters() ? 0 : function.num_fixed_parameters();
75
76 // The fixed size section of the (fake) Dart frame called via a stub by the
77 // optimized function contains FP, PP (ARM only), PC-marker and
78 // return-address. This section is copied as well, so that its contained
79 // values can be updated before returning to the deoptimized function.
80 ASSERT(frame->fp() >= frame->sp());
81 const intptr_t frame_size = (frame->fp() - frame->sp()) / kWordSize;
82
83 source_frame_size_ = +kDartFrameFixedSize // For saved values below sp.
84 + frame_size // For frame size incl. sp.
85 + 1 // For fp.
86 + kParamEndSlotFromFp // For saved values above fp.
87 + num_args_; // For arguments.
88
89 source_frame_ = FrameBase(frame);
90
91 if (dest_options == kDestIsOriginalFrame) {
92 // Work from a copy of the source frame.
93 intptr_t* original_frame = source_frame_;
94 source_frame_ = new intptr_t[source_frame_size_];
95 ASSERT(source_frame_ != nullptr);
96 for (intptr_t i = 0; i < source_frame_size_; i++) {
97 source_frame_[i] = original_frame[i];
98 }
99 source_frame_is_allocated_ = true;
100 }
101 caller_fp_ = GetSourceFp();
102
103 dest_frame_size_ = DeoptInfo::FrameSize(deopt_info);
104
105 if (dest_options == kDestIsAllocated) {
106 dest_frame_ = new intptr_t[dest_frame_size_];
107 ASSERT(source_frame_ != nullptr);
108 for (intptr_t i = 0; i < dest_frame_size_; i++) {
109 dest_frame_[i] = 0;
110 }
111 dest_frame_is_allocated_ = true;
112 }
113
114 if (dest_options != kDestIsAllocated) {
115 // kDestIsAllocated is used by the debugger to generate a stack trace
116 // and does not signal a real deopt.
117 deopt_start_micros_ = OS::GetCurrentMonotonicMicros();
118 }
119
120 if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) {
121 THR_Print(
122 "Deoptimizing (reason %d '%s') at "
123 "pc=%" Pp " fp=%" Pp " '%s' (count %d)\n",
125 frame->fp(), function.ToFullyQualifiedCString(),
126 function.deoptimization_counter());
127 }
128}
intptr_t GetSourceFp() const
bool deoptimizing_code() const
ICData::DeoptReasonId deopt_reason() const
intptr_t * FrameBase(const StackFrame *frame)
TypedDataPtr deopt_info() const
static intptr_t FrameSize(const TypedData &packed)
static int64_t GetCurrentMonotonicMicros()
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static ObjectPtr null()
Definition object.h:433
static Object & Handle()
Definition object.h:407
static Thread * Current()
Definition thread.h:361
#define THR_Print(format,...)
Definition log.h:20
#define ASSERT(E)
double frame
Definition examples.cpp:31
Dart_NativeFunction function
Definition fuchsia.cc:51
static constexpr int kDartFrameFixedSize
static constexpr int kParamEndSlotFromFp
constexpr intptr_t kWordSize
Definition globals.h:509
const char * DeoptReasonToCString(ICData::DeoptReasonId deopt_reason)
#define Pp
Definition globals.h:425
#define Px
Definition globals.h:410

◆ ~DeoptContext()

dart::DeoptContext::~DeoptContext ( )
virtual

Definition at line 130 of file deopt_instructions.cc.

130 {
131 // Delete memory for source frame and registers.
132 if (source_frame_is_allocated_) {
133 delete[] source_frame_;
134 }
135 source_frame_ = nullptr;
136 delete[] fpu_registers_;
137 delete[] cpu_registers_;
138 fpu_registers_ = nullptr;
139 cpu_registers_ = nullptr;
140 if (dest_frame_is_allocated_) {
141 delete[] dest_frame_;
142 }
143 dest_frame_ = nullptr;
144
145 // Delete all deferred objects.
146 for (intptr_t i = 0; i < deferred_objects_count_; i++) {
147 delete deferred_objects_[i];
148 }
149 delete[] deferred_objects_;
150 deferred_objects_ = nullptr;
151 deferred_objects_count_ = 0;
152
153#if defined(SUPPORT_TIMELINE)
154 if (deopt_start_micros_ != 0) {
155 TimelineStream* compiler_stream = Timeline::GetCompilerStream();
156 ASSERT(compiler_stream != nullptr);
157 if (compiler_stream->enabled()) {
158 // Allocate all Dart objects needed before calling StartEvent,
159 // which blocks safe points until Complete is called.
160 const Code& code = Code::Handle(zone(), code_);
161 const Function& function = Function::Handle(zone(), code.function());
162 const String& function_name =
163 String::Handle(zone(), function.QualifiedScrubbedName());
164 const char* reason = DeoptReasonToCString(deopt_reason());
165 const int counter = function.deoptimization_counter();
166 TimelineEvent* timeline_event = compiler_stream->StartEvent();
167 if (timeline_event != nullptr) {
168 timeline_event->Duration("Deoptimize", deopt_start_micros_,
170 timeline_event->SetNumArguments(3);
171 timeline_event->CopyArgument(0, "function", function_name.ToCString());
172 timeline_event->CopyArgument(1, "reason", reason);
173 timeline_event->FormatArgument(2, "deoptimizationCount", "%d", counter);
174 timeline_event->Complete();
175 }
176 }
177 }
178#endif // !PRODUCT
179}
const char *const function_name

Member Function Documentation

◆ code()

CodePtr dart::DeoptContext::code ( ) const
inline

Definition at line 135 of file deopt_instructions.h.

135{ return code_; }

◆ DeferMaterialization() [1/5]

void dart::DeoptContext::DeferMaterialization ( double  value,
DoublePtr *  slot 
)
inline

Definition at line 175 of file deopt_instructions.h.

175 {
176 deferred_slots_ = new DeferredDouble(
177 value, reinterpret_cast<ObjectPtr*>(slot), deferred_slots_);
178 }

◆ DeferMaterialization() [2/5]

void dart::DeoptContext::DeferMaterialization ( float  value,
DoublePtr *  slot 
)
inline

Definition at line 170 of file deopt_instructions.h.

170 {
171 deferred_slots_ = new DeferredDouble(
172 value, reinterpret_cast<ObjectPtr*>(slot), deferred_slots_);
173 }

◆ DeferMaterialization() [3/5]

void dart::DeoptContext::DeferMaterialization ( simd128_value_t  value,
Float32x4Ptr *  slot 
)
inline

Definition at line 185 of file deopt_instructions.h.

185 {
186 deferred_slots_ = new DeferredFloat32x4(
187 value, reinterpret_cast<ObjectPtr*>(slot), deferred_slots_);
188 }

◆ DeferMaterialization() [4/5]

void dart::DeoptContext::DeferMaterialization ( simd128_value_t  value,
Float64x2Ptr *  slot 
)
inline

Definition at line 190 of file deopt_instructions.h.

190 {
191 deferred_slots_ = new DeferredFloat64x2(
192 value, reinterpret_cast<ObjectPtr*>(slot), deferred_slots_);
193 }

◆ DeferMaterialization() [5/5]

void dart::DeoptContext::DeferMaterialization ( simd128_value_t  value,
Int32x4Ptr *  slot 
)
inline

Definition at line 195 of file deopt_instructions.h.

195 {
196 deferred_slots_ = new DeferredInt32x4(
197 value, reinterpret_cast<ObjectPtr*>(slot), deferred_slots_);
198 }

◆ DeferMaterializedObjectRef()

void dart::DeoptContext::DeferMaterializedObjectRef ( intptr_t  idx,
intptr_t *  slot 
)
inline

Definition at line 165 of file deopt_instructions.h.

165 {
166 deferred_slots_ = new DeferredObjectRef(
167 idx, reinterpret_cast<ObjectPtr*>(slot), deferred_slots_);
168 }

◆ DeferMintMaterialization()

void dart::DeoptContext::DeferMintMaterialization ( int64_t  value,
MintPtr *  slot 
)
inline

Definition at line 180 of file deopt_instructions.h.

180 {
181 deferred_slots_ = new DeferredMint(
182 value, reinterpret_cast<ObjectPtr*>(slot), deferred_slots_);
183 }

◆ DeferPcMarkerMaterialization()

void dart::DeoptContext::DeferPcMarkerMaterialization ( intptr_t  index,
intptr_t *  slot 
)
inline

Definition at line 207 of file deopt_instructions.h.

207 {
208 deferred_slots_ = new DeferredPcMarker(
209 index, reinterpret_cast<ObjectPtr*>(slot), deferred_slots_);
210 }

◆ DeferPpMaterialization()

void dart::DeoptContext::DeferPpMaterialization ( intptr_t  index,
ObjectPtr slot 
)
inline

Definition at line 212 of file deopt_instructions.h.

212 {
213 deferred_slots_ = new DeferredPp(index, slot, deferred_slots_);
214 }

◆ DeferRetAddrMaterialization()

void dart::DeoptContext::DeferRetAddrMaterialization ( intptr_t  index,
intptr_t  deopt_id,
intptr_t *  slot 
)
inline

Definition at line 200 of file deopt_instructions.h.

202 {
203 deferred_slots_ = new DeferredRetAddr(
204 index, deopt_id, reinterpret_cast<ObjectPtr*>(slot), deferred_slots_);
205 }

◆ deopt_info()

TypedDataPtr dart::DeoptContext::deopt_info ( ) const
inline

Definition at line 146 of file deopt_instructions.h.

146{ return deopt_info_; }

◆ deopt_reason()

ICData::DeoptReasonId dart::DeoptContext::deopt_reason ( ) const
inline

Definition at line 141 of file deopt_instructions.h.

141{ return deopt_reason_; }

◆ deoptimizing_code()

bool dart::DeoptContext::deoptimizing_code ( ) const
inline

Definition at line 139 of file deopt_instructions.h.

139{ return deoptimizing_code_; }

◆ dest_frame_size()

intptr_t dart::DeoptContext::dest_frame_size ( ) const
inline

Definition at line 133 of file deopt_instructions.h.

133{ return dest_frame_size_; }

◆ DestFrameAsArray()

ArrayPtr dart::DeoptContext::DestFrameAsArray ( )

Definition at line 400 of file deopt_instructions.cc.

400 {
401 ASSERT(dest_frame_ != nullptr && dest_frame_is_allocated_);
402 const Array& dest_array = Array::Handle(zone(), Array::New(dest_frame_size_));
403 PassiveObject& obj = PassiveObject::Handle(zone());
404 for (intptr_t i = 0; i < dest_frame_size_; i++) {
405 obj = static_cast<ObjectPtr>(dest_frame_[i]);
406 dest_array.SetAt(i, obj);
407 }
408 return dest_array.ptr();
409}
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition object.h:10933
static PassiveObject & Handle()
Definition object.h:1077

◆ DestStackAdjustment()

intptr_t dart::DeoptContext::DestStackAdjustment ( ) const

Definition at line 196 of file deopt_instructions.cc.

196 {
197 return dest_frame_size_ - kDartFrameFixedSize - num_args_ - 1 // For fp.
199}

◆ FillDestFrame()

void dart::DeoptContext::FillDestFrame ( )

Definition at line 258 of file deopt_instructions.cc.

258 {
259 const Code& code = Code::Handle(code_);
260 const TypedData& deopt_info = TypedData::Handle(deopt_info_);
261
262 GrowableArray<DeoptInstr*> deopt_instructions;
263 const Array& deopt_table = Array::Handle(code.deopt_info_array());
264 ASSERT(!deopt_table.IsNull());
265 DeoptInfo::Unpack(deopt_table, deopt_info, &deopt_instructions);
266
267 const intptr_t len = deopt_instructions.length();
268 const intptr_t frame_size = dest_frame_size_;
269
270 // For now, we never place non-objects in the deoptimized frame if
271 // the destination frame is a copy. This allows us to copy the
272 // deoptimized frame into an Array.
273 const bool objects_only = dest_frame_is_allocated_;
274
275 // All kMaterializeObject instructions are emitted before the instructions
276 // that describe stack frames. Skip them and defer materialization of
277 // objects until the frame is fully reconstructed and it is safe to perform
278 // GC.
279 // Arguments (class of the instance to allocate and field-value pairs) are
280 // described as part of the expression stack for the bottom-most deoptimized
281 // frame. They will be used during materialization and removed from the stack
282 // right before control switches to the unoptimized code.
283 const intptr_t num_materializations =
284 DeoptInfo::NumMaterializations(deopt_instructions);
285 PrepareForDeferredMaterialization(num_materializations);
286 for (intptr_t from_index = 0, to_index = kDartFrameFixedSize;
287 from_index < num_materializations; from_index++) {
288 const intptr_t field_count =
289 DeoptInstr::GetFieldCount(deopt_instructions[from_index]);
290 intptr_t* args = GetDestFrameAddressAt(to_index);
291 DeferredObject* obj = new DeferredObject(field_count, args);
292 SetDeferredObjectAt(from_index, obj);
293 to_index += obj->ArgumentCount();
294 }
295
296 // Populate stack frames.
297 for (intptr_t to_index = frame_size - 1, from_index = len - 1; to_index >= 0;
298 to_index--, from_index--) {
299 intptr_t* to_addr = GetDestFrameAddressAt(to_index);
300 DeoptInstr* instr = deopt_instructions[from_index];
301 if (!objects_only || IsObjectInstruction(instr->kind())) {
302 instr->Execute(this, to_addr);
303 } else {
304 *reinterpret_cast<ObjectPtr*>(to_addr) = Object::null();
305 }
306 }
307
308 if (FLAG_trace_deoptimization_verbose) {
309 for (intptr_t i = 0; i < frame_size; i++) {
310 intptr_t* to_addr = GetDestFrameAddressAt(i);
311 THR_Print("*%" Pd ". [%p] 0x%" Px " [%s]\n", i, to_addr, *to_addr,
312 deopt_instructions[i + (len - frame_size)]->ToCString());
313 }
314 }
315}
static intptr_t NumMaterializations(const GrowableArray< DeoptInstr * > &)
static void Unpack(const Array &table, const TypedData &packed, GrowableArray< DeoptInstr * > *instructions)
static intptr_t GetFieldCount(DeoptInstr *instr)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
static bool IsObjectInstruction(DeoptInstr::Kind kind)
#define Pd
Definition globals.h:408

◆ FpuRegisterValueAsDouble()

double dart::DeoptContext::FpuRegisterValueAsDouble ( FpuRegister  reg) const
inline

Definition at line 93 of file deopt_instructions.h.

93 {
95 ASSERT(fpu_registers_ != nullptr);
96 ASSERT(reg >= 0);
98 return *reinterpret_cast<double*>(&fpu_registers_[reg]);
99 }
static bool SupportsUnboxedDoubles()
const int kNumberOfFpuRegisters

◆ FpuRegisterValueAsFloat()

float dart::DeoptContext::FpuRegisterValueAsFloat ( FpuRegister  reg) const
inline

Definition at line 85 of file deopt_instructions.h.

85 {
87 ASSERT(fpu_registers_ != NULL);
88 ASSERT(reg >= 0);
90 return *reinterpret_cast<float*>(&fpu_registers_[reg]);
91 }

◆ FpuRegisterValueAsSimd128()

simd128_value_t dart::DeoptContext::FpuRegisterValueAsSimd128 ( FpuRegister  reg) const
inline

Definition at line 101 of file deopt_instructions.h.

101 {
103 ASSERT(fpu_registers_ != nullptr);
104 ASSERT(reg >= 0);
106 const float* address = reinterpret_cast<float*>(&fpu_registers_[reg]);
107 return simd128_value_t().readFrom(address);
108 }
static bool SupportsUnboxedSimd128()

◆ FrameBase()

intptr_t * dart::DeoptContext::FrameBase ( const StackFrame frame)
inline

Definition at line 117 of file deopt_instructions.h.

117 {
118 // SP of the deoptimization frame is the lowest slot because
119 // stack is growing downwards.
120 return reinterpret_cast<intptr_t*>(frame->sp() -
122 }

◆ GetCallerFp()

intptr_t dart::DeoptContext::GetCallerFp ( ) const

Definition at line 216 of file deopt_instructions.cc.

216 {
217 return caller_fp_;
218}

◆ GetDeferredObject()

DeferredObject * dart::DeoptContext::GetDeferredObject ( intptr_t  idx) const
inline

Definition at line 216 of file deopt_instructions.h.

216 {
217 return deferred_objects_[idx];
218 }

◆ GetSourceFp()

intptr_t dart::DeoptContext::GetSourceFp ( ) const

Definition at line 201 of file deopt_instructions.cc.

201 {
202 return source_frame_[source_frame_size_ - 1 - num_args_ -
204}
static constexpr int kSavedCallerFpSlotFromFp

◆ GetSourceFrameAddressAt()

intptr_t * dart::DeoptContext::GetSourceFrameAddressAt ( intptr_t  index) const
inline

Definition at line 51 of file deopt_instructions.h.

51 {
52 ASSERT(source_frame_ != nullptr);
53 ASSERT((0 <= index) && (index < source_frame_size_));
54 // Convert FP relative index to SP relative one.
55 index = source_frame_size_ - 1 - index;
56 return &source_frame_[index];
57 }

◆ GetSourcePc()

intptr_t dart::DeoptContext::GetSourcePc ( ) const

Definition at line 212 of file deopt_instructions.cc.

212 {
213 return source_frame_[source_frame_size_ - num_args_ + kSavedPcSlotFromSp];
214}
static constexpr int kSavedPcSlotFromSp

◆ GetSourcePp()

intptr_t dart::DeoptContext::GetSourcePp ( ) const

Definition at line 206 of file deopt_instructions.cc.

206 {
207 return source_frame_[source_frame_size_ - 1 - num_args_ -
210}
static int SavedCallerPpSlotFromFp()
Definition stack_frame.h:46

◆ GetStackSlot()

intptr_t dart::DeoptContext::GetStackSlot ( intptr_t  index) const
inline

Definition at line 60 of file deopt_instructions.h.

60 {
61 ASSERT((0 <= index) && (index < source_frame_size_));
62 index -= num_args_;
63 return index < 0 ? index : index - kDartFrameFixedSize;
64 }

◆ HasDeoptFlag()

bool dart::DeoptContext::HasDeoptFlag ( ICData::DeoptFlags  flag)
inline

Definition at line 142 of file deopt_instructions.h.

142 {
143 return (deopt_flags_ & flag) != 0;
144 }
FlutterSemanticsFlag flag

◆ is_lazy_deopt()

bool dart::DeoptContext::is_lazy_deopt ( ) const
inline

Definition at line 137 of file deopt_instructions.h.

137{ return is_lazy_deopt_; }

◆ MaterializeDeferredObjects()

intptr_t dart::DeoptContext::MaterializeDeferredObjects ( )

Definition at line 360 of file deopt_instructions.cc.

360 {
361 // Populate slots with references to all unboxed "primitive" values (doubles,
362 // mints, simd) and deferred objects. Deferred objects are only allocated
363 // but not filled with data. This is done later because deferred objects
364 // can references each other.
365 FillDeferredSlots(this, &deferred_slots_);
366
367 // Compute total number of artificial arguments used during deoptimization.
368 intptr_t deopt_arg_count = 0;
369 for (intptr_t i = 0; i < DeferredObjectsCount(); i++) {
371 deopt_arg_count += GetDeferredObject(i)->ArgumentCount();
372 }
373
374 // Since this is the only step where GC can occur during deoptimization,
375 // use it to report the source line where deoptimization occurred.
376 if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) {
377 DartFrameIterator iterator(Thread::Current(),
379 StackFrame* top_frame = iterator.NextFrame();
380 ASSERT(top_frame != nullptr);
381 const Code& code = Code::Handle(top_frame->LookupDartCode());
382 const Function& top_function = Function::Handle(code.function());
383 const Script& script = Script::Handle(top_function.script());
384 const TokenPosition token_pos = code.GetTokenIndexOfPC(top_frame->pc());
385 THR_Print(" Function: %s\n", top_function.ToFullyQualifiedCString());
386 intptr_t line;
387 if (script.GetTokenLocation(token_pos, &line)) {
388 String& line_string = String::Handle(script.GetLine(line));
389 char line_buffer[80];
390 Utils::SNPrint(line_buffer, sizeof(line_buffer), " Line %" Pd ": '%s'",
391 line, line_string.ToCString());
392 THR_Print("%s\n", line_buffer);
393 }
394 THR_Print(" Deopt args: %" Pd "\n", deopt_arg_count);
395 }
396
397 return deopt_arg_count;
398}
intptr_t ArgumentCount() const
DeferredObject * GetDeferredObject(intptr_t idx) const
static int SNPrint(char *str, size_t size, const char *format,...) PRINTF_ATTRIBUTE(3
static void FillDeferredSlots(DeoptContext *deopt_context, DeferredSlot **slot_list)

◆ num_args()

intptr_t dart::DeoptContext::num_args ( ) const
inline

Definition at line 220 of file deopt_instructions.h.

220{ return num_args_; }

◆ ObjectAt()

ObjectPtr dart::DeoptContext::ObjectAt ( intptr_t  index) const
inline

Definition at line 73 of file deopt_instructions.h.

73 {
74 const ObjectPool& object_pool = ObjectPool::Handle(object_pool_);
75 return object_pool.ObjectAt(index);
76 }

◆ RegisterValue()

intptr_t dart::DeoptContext::RegisterValue ( Register  reg) const
inline

Definition at line 78 of file deopt_instructions.h.

78 {
79 ASSERT(reg >= 0);
81 ASSERT(cpu_registers_ != nullptr);
82 return cpu_registers_[reg];
83 }
@ kNumberOfCpuRegisters

◆ set_dest_frame()

void dart::DeoptContext::set_dest_frame ( const StackFrame frame)
inline

Definition at line 124 of file deopt_instructions.h.

124 {
125 ASSERT(frame != nullptr && dest_frame_ == nullptr);
126 dest_frame_ = FrameBase(frame);
127 }

◆ SetCallerFp()

void dart::DeoptContext::SetCallerFp ( intptr_t  callers_fp)

Definition at line 220 of file deopt_instructions.cc.

220 {
221 caller_fp_ = caller_fp;
222}

◆ source_frame_size()

intptr_t dart::DeoptContext::source_frame_size ( ) const
inline

Definition at line 132 of file deopt_instructions.h.

132{ return source_frame_size_; }

◆ thread()

Thread * dart::DeoptContext::thread ( ) const
inline

Definition at line 129 of file deopt_instructions.h.

129{ return thread_; }

◆ ToCatchEntryMoves()

const CatchEntryMoves * dart::DeoptContext::ToCatchEntryMoves ( intptr_t  num_vars)

Definition at line 317 of file deopt_instructions.cc.

317 {
318 const Code& code = Code::Handle(code_);
319 const TypedData& deopt_info = TypedData::Handle(deopt_info_);
320 GrowableArray<DeoptInstr*> deopt_instructions;
321 const Array& deopt_table = Array::Handle(code.deopt_info_array());
322 ASSERT(!deopt_table.IsNull());
323 DeoptInfo::Unpack(deopt_table, deopt_info, &deopt_instructions);
324
325 CatchEntryMoves* moves = CatchEntryMoves::Allocate(num_vars);
326
327 Function& function = Function::Handle(zone(), code.function());
328 intptr_t params =
329 function.MakesCopyOfParameters() ? 0 : function.num_fixed_parameters();
330 for (intptr_t i = 0; i < num_vars; i++) {
331 const intptr_t len = deopt_instructions.length();
332 intptr_t slot = i < params ? i
333 : i + kParamEndSlotFromFp -
335 DeoptInstr* instr = deopt_instructions[len - 1 - slot];
336 intptr_t dest_index = i - params;
337 moves->At(i) = instr->ToCatchEntryMove(this, dest_index);
338 }
339
340 return moves;
341}
static CatchEntryMoves * Allocate(intptr_t num_moves)
Definition exceptions.h:254
const EmbeddedViewParams * params
FrameLayout runtime_frame_layout
intptr_t first_local_from_fp

◆ VisitObjectPointers()

void dart::DeoptContext::VisitObjectPointers ( ObjectPointerVisitor visitor)

Definition at line 181 of file deopt_instructions.cc.

181 {
182 visitor->VisitPointer(reinterpret_cast<ObjectPtr*>(&code_));
183 visitor->VisitPointer(reinterpret_cast<ObjectPtr*>(&object_pool_));
184 visitor->VisitPointer(reinterpret_cast<ObjectPtr*>(&deopt_info_));
185
186 // Visit any object pointers on the destination stack.
187 if (dest_frame_is_allocated_) {
188 for (intptr_t i = 0; i < dest_frame_size_; i++) {
189 if (dest_frame_[i] != 0) {
190 visitor->VisitPointer(reinterpret_cast<ObjectPtr*>(&dest_frame_[i]));
191 }
192 }
193 }
194}

◆ zone()

Zone * dart::DeoptContext::zone ( ) const
inline

Definition at line 130 of file deopt_instructions.h.

130{ return thread_->zone(); }
Zone * zone() const

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