5#ifndef RUNTIME_VM_DEOPT_INSTRUCTIONS_H_
6#define RUNTIME_VM_DEOPT_INSTRUCTIONS_H_
7#if !defined(DART_PRECOMPILED_RUNTIME)
24class MaterializeObjectInstr;
42 intptr_t* cpu_registers,
52 ASSERT(source_frame_ !=
nullptr);
53 ASSERT((0 <= index) && (index < source_frame_size_));
55 index = source_frame_size_ - 1 - index;
56 return &source_frame_[index];
61 ASSERT((0 <= index) && (index < source_frame_size_));
81 ASSERT(cpu_registers_ !=
nullptr);
82 return cpu_registers_[reg];
87 ASSERT(fpu_registers_ != NULL);
90 return *
reinterpret_cast<float*
>(&fpu_registers_[reg]);
95 ASSERT(fpu_registers_ !=
nullptr);
98 return *
reinterpret_cast<double*
>(&fpu_registers_[reg]);
103 ASSERT(fpu_registers_ !=
nullptr);
106 const float* address =
reinterpret_cast<float*
>(&fpu_registers_[reg]);
120 return reinterpret_cast<intptr_t*
>(
frame->sp() -
125 ASSERT(
frame !=
nullptr && dest_frame_ ==
nullptr);
135 CodePtr
code()
const {
return code_; }
143 return (deopt_flags_ &
flag) != 0;
167 idx,
reinterpret_cast<ObjectPtr*
>(slot), deferred_slots_);
204 index, deopt_id,
reinterpret_cast<ObjectPtr*
>(slot), deferred_slots_);
209 index,
reinterpret_cast<ObjectPtr*
>(slot), deferred_slots_);
213 deferred_slots_ =
new DeferredPp(index, slot, deferred_slots_);
217 return deferred_objects_[idx];
223 intptr_t* GetDestFrameAddressAt(intptr_t index)
const {
224 ASSERT(dest_frame_ !=
nullptr);
225 ASSERT((0 <= index) && (index < dest_frame_size_));
226 return &dest_frame_[index];
229 void PrepareForDeferredMaterialization(intptr_t
count) {
231 deferred_objects_ =
new DeferredObject*[
count];
232 deferred_objects_count_ =
count;
239 void SetDeferredObjectAt(intptr_t idx, DeferredObject*
object) {
240 deferred_objects_[idx] = object;
243 intptr_t DeferredObjectsCount()
const {
return deferred_objects_count_; }
246 ObjectPoolPtr object_pool_;
247 TypedDataPtr deopt_info_;
248 bool dest_frame_is_allocated_;
249 intptr_t* dest_frame_;
250 intptr_t dest_frame_size_;
251 bool source_frame_is_allocated_;
252 intptr_t* source_frame_;
253 intptr_t source_frame_size_;
254 intptr_t* cpu_registers_;
258 uint32_t deopt_flags_;
261 int64_t deopt_start_micros_;
263 DeferredSlot* deferred_slots_;
265 intptr_t deferred_objects_count_;
266 DeferredObject** deferred_objects_;
268 const bool is_lazy_deopt_;
269 const bool deoptimizing_code_;
312 if (
args !=
nullptr) {
314 "%s(%s)", KindToCString(
kind()),
args);
316 return KindToCString(
kind());
323 intptr_t dest_slot) {
355 static const char* KindToCString(
Kind kind);
364template <
typename RegisterType,
typename DestinationType>
398template <
typename RegisterType>
412 : source_index_(KindField::
encode(kind) |
413 UntaggedIndexField::
encode(index)) {}
415 template <
typename T>
418 return static_cast<T>(
421 return *
reinterpret_cast<T*
>(
442 class KindField :
public BitField<intptr_t, intptr_t, 0, 1> {};
443 class UntaggedIndexField
444 :
public BitField<intptr_t, intptr_t, 1, kBitsPerWord - 1> {};
446 bool is_register()
const {
449 intptr_t raw_index()
const {
453 RegisterType reg()
const {
return static_cast<RegisterType
>(raw_index()); }
455 static const char* Name(
Register reg) {
463 const intptr_t source_index_;
477 const intptr_t num_args,
483 intptr_t dest_index);
512 ASSERT(frame_start_ == -1);
513 frame_start_ = instructions_.length();
526 intptr_t FindOrAddObjectInTable(
const Object& obj)
const;
528 intptr_t CalculateStackIndex(
const Location& source_loc)
const;
530 intptr_t FrameSize()
const {
531 ASSERT(frame_start_ != -1);
532 const intptr_t frame_size = instructions_.length() - frame_start_;
537 void AddConstant(
const Object& obj, intptr_t dest_index);
539 Zone* zone()
const {
return zone_; }
543 GrowableArray<DeoptInstr*> instructions_;
544 const intptr_t num_args_;
545 compiler::Assembler* assembler_;
548 TrieNode* trie_root_;
549 intptr_t current_info_number_;
551 intptr_t frame_start_;
552 GrowableArray<MaterializeObjectInstr*> materializations_;
573 const Smi& reason_and_flags);
584 Smi* reason_and_flags);
595 static constexpr intptr_t kEntrySize = 3;
631 const Array& deopt_table,
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static sk_sp< Effect > Create()
static void encode(uint8_t output[16], const uint32_t input[4])
static constexpr intptr_t decode(intptr_t value)
static constexpr intptr_t encode(ICData::DeoptReasonId value)
intptr_t num_args() const
intptr_t GetSourceFp() const
intptr_t RegisterValue(Register reg) const
intptr_t MaterializeDeferredObjects()
intptr_t * GetSourceFrameAddressAt(intptr_t index) const
double FpuRegisterValueAsDouble(FpuRegister reg) const
bool deoptimizing_code() const
simd128_value_t FpuRegisterValueAsSimd128(FpuRegister reg) const
bool HasDeoptFlag(ICData::DeoptFlags flag)
intptr_t dest_frame_size() const
intptr_t source_frame_size() const
bool is_lazy_deopt() const
intptr_t GetSourcePp() const
intptr_t GetCallerFp() const
void DeferMaterialization(double value, DoublePtr *slot)
ObjectPtr ObjectAt(intptr_t index) const
void DeferRetAddrMaterialization(intptr_t index, intptr_t deopt_id, intptr_t *slot)
void DeferMaterialization(float value, DoublePtr *slot)
ICData::DeoptReasonId deopt_reason() const
void set_dest_frame(const StackFrame *frame)
intptr_t GetSourcePc() const
intptr_t GetStackSlot(intptr_t index) const
void DeferMaterialization(simd128_value_t value, Float32x4Ptr *slot)
float FpuRegisterValueAsFloat(FpuRegister reg) const
intptr_t * FrameBase(const StackFrame *frame)
void DeferMaterialization(simd128_value_t value, Float64x2Ptr *slot)
void DeferPcMarkerMaterialization(intptr_t index, intptr_t *slot)
void VisitObjectPointers(ObjectPointerVisitor *visitor)
void DeferMaterialization(simd128_value_t value, Int32x4Ptr *slot)
void DeferPpMaterialization(intptr_t index, ObjectPtr *slot)
const CatchEntryMoves * ToCatchEntryMoves(intptr_t num_vars)
TypedDataPtr deopt_info() const
intptr_t DestStackAdjustment() const
void SetCallerFp(intptr_t callers_fp)
void DeferMaterializedObjectRef(intptr_t idx, intptr_t *slot)
void DeferMintMaterialization(int64_t value, MintPtr *slot)
ArrayPtr DestFrameAsArray()
DeferredObject * GetDeferredObject(intptr_t idx) const
void AddCopy(Value *value, const Location &source_loc, intptr_t dest_index)
TypedDataPtr CreateDeoptInfo(const Array &deopt_table)
void AddMaterialization(MaterializeObjectInstr *mat)
void AddPcMarker(const Function &function, intptr_t dest_index)
void AddReturnAddress(const Function &function, intptr_t deopt_id, intptr_t dest_index)
void AddCallerFp(intptr_t dest_index)
void AddCallerPp(intptr_t dest_index)
intptr_t EmitMaterializationArguments(intptr_t dest_index)
void AddPp(const Function &function, intptr_t dest_index)
void AddCallerPc(intptr_t dest_index)
static intptr_t NumMaterializations(const GrowableArray< DeoptInstr * > &)
static void Unpack(const Array &table, const TypedData &packed, GrowableArray< DeoptInstr * > *instructions)
static const char * ToCString(const Array &table, const TypedData &packed)
static intptr_t FrameSize(const TypedData &packed)
static bool VerifyDecompression(const GrowableArray< DeoptInstr * > &original, const Array &deopt_table, const TypedData &packed)
virtual const char * ArgumentsToCString() const
virtual void Execute(DeoptContext *deopt_context, intptr_t *dest_addr)=0
virtual DeoptInstr::Kind kind() const =0
virtual intptr_t source_index() const =0
static intptr_t GetFieldCount(DeoptInstr *instr)
bool Equals(const DeoptInstr &other) const
virtual CatchEntryMove ToCatchEntryMove(DeoptContext *deopt_context, intptr_t dest_slot)
static uword GetRetAddress(DeoptInstr *instr, const ObjectPool &object_pool, Code *code)
virtual const char * ToCString() const
static void GetEntry(const Array &table, intptr_t index, Smi *offset, TypedData *info, Smi *reason_and_flags)
static intptr_t GetLength(const Array &table)
static SmiPtr EncodeReasonAndFlags(ICData::DeoptReasonId reason, uint32_t flags)
static intptr_t SizeFor(intptr_t length)
static void SetEntry(const Array &table, intptr_t index, const Smi &offset, const TypedData &info, const Smi &reason_and_flags)
static bool SupportsUnboxedDoubles()
static bool SupportsUnboxedSimd128()
ObjectPtr ObjectAt(intptr_t index) const
static const char * FpuRegisterName(FpuRegister reg)
static const char * RegisterName(Register reg)
T Value(DeoptContext *context) const
intptr_t source_index() const
RegisterSource(Kind kind, intptr_t index)
intptr_t StackSlot(DeoptContext *context) const
const char * ToCString() const
RegisterSource(intptr_t source_index)
static SmiPtr New(intptr_t value)
static Thread * Current()
char * PrintToString(const char *format,...) PRINTF_ATTRIBUTE(2
FlutterSemanticsFlag flag
FlutterSemanticsFlag flags
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Dart_NativeFunction function
static constexpr int kDartFrameFixedSize
RegisterSource< Register > CpuRegisterSource
const int kNumberOfFpuRegisters
constexpr intptr_t kWordSize
simd128_value_t fpu_register_t
RegisterSource< FpuRegister > FpuRegisterSource
static double Read(DeoptContext *context, FpuRegister reg)
static double Read(DeoptContext *context, FpuRegister reg)
static simd128_value_t Read(DeoptContext *context, FpuRegister reg)
static intptr_t Read(DeoptContext *context, Register reg)
simd128_value_t & readFrom(const float *v)