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];
86 ASSERT(fpu_registers_ != NULL);
89 return *
reinterpret_cast<float*
>(&fpu_registers_[reg]);
93 ASSERT(fpu_registers_ !=
nullptr);
96 return *
reinterpret_cast<double*
>(&fpu_registers_[reg]);
101 ASSERT(fpu_registers_ !=
nullptr);
104 const float* address =
reinterpret_cast<float*
>(&fpu_registers_[reg]);
118 return reinterpret_cast<intptr_t*
>(
frame->sp() -
123 ASSERT(
frame !=
nullptr && dest_frame_ ==
nullptr);
133 CodePtr
code()
const {
return code_; }
141 return (deopt_flags_ &
flag) != 0;
165 idx,
reinterpret_cast<ObjectPtr*
>(slot), deferred_slots_);
202 index, deopt_id,
reinterpret_cast<ObjectPtr*
>(slot), deferred_slots_);
207 index,
reinterpret_cast<ObjectPtr*
>(slot), deferred_slots_);
211 deferred_slots_ =
new DeferredPp(index, slot, deferred_slots_);
215 return deferred_objects_[idx];
221 intptr_t* GetDestFrameAddressAt(intptr_t index)
const {
222 ASSERT(dest_frame_ !=
nullptr);
223 ASSERT((0 <= index) && (index < dest_frame_size_));
224 return &dest_frame_[index];
227 void PrepareForDeferredMaterialization(intptr_t
count) {
229 deferred_objects_ =
new DeferredObject*[
count];
230 deferred_objects_count_ =
count;
237 void SetDeferredObjectAt(intptr_t idx, DeferredObject*
object) {
238 deferred_objects_[idx] = object;
241 intptr_t DeferredObjectsCount()
const {
return deferred_objects_count_; }
244 ObjectPoolPtr object_pool_;
245 TypedDataPtr deopt_info_;
246 bool dest_frame_is_allocated_;
247 intptr_t* dest_frame_;
248 intptr_t dest_frame_size_;
249 bool source_frame_is_allocated_;
250 intptr_t* source_frame_;
251 intptr_t source_frame_size_;
252 intptr_t* cpu_registers_;
256 uint32_t deopt_flags_;
259 int64_t deopt_start_micros_;
261 DeferredSlot* deferred_slots_;
263 intptr_t deferred_objects_count_;
264 DeferredObject** deferred_objects_;
266 const bool is_lazy_deopt_;
267 const bool deoptimizing_code_;
310 if (
args !=
nullptr) {
312 "%s(%s)", KindToCString(
kind()),
args);
314 return KindToCString(
kind());
321 intptr_t dest_slot) {
353 static const char* KindToCString(
Kind kind);
362template <
typename RegisterType,
typename DestinationType>
396template <
typename RegisterType>
410 : source_index_(KindField::
encode(kind) |
411 UntaggedIndexField::
encode(index)) {}
413 template <
typename T>
416 return static_cast<T>(
419 return *
reinterpret_cast<T*
>(
440 class KindField :
public BitField<intptr_t, intptr_t, 0, 1> {};
441 class UntaggedIndexField
442 :
public BitField<intptr_t, intptr_t, 1, kBitsPerWord - 1> {};
444 bool is_register()
const {
447 intptr_t raw_index()
const {
451 RegisterType reg()
const {
return static_cast<RegisterType
>(raw_index()); }
453 static const char* Name(
Register reg) {
461 const intptr_t source_index_;
475 const intptr_t num_args,
481 intptr_t dest_index);
510 ASSERT(frame_start_ == -1);
511 frame_start_ = instructions_.length();
524 intptr_t FindOrAddObjectInTable(
const Object& obj)
const;
526 intptr_t CalculateStackIndex(
const Location& source_loc)
const;
528 intptr_t FrameSize()
const {
529 ASSERT(frame_start_ != -1);
530 const intptr_t frame_size = instructions_.length() - frame_start_;
535 void AddConstant(
const Object& obj, intptr_t dest_index);
537 Zone* zone()
const {
return zone_; }
541 GrowableArray<DeoptInstr*> instructions_;
542 const intptr_t num_args_;
543 compiler::Assembler* assembler_;
547 intptr_t current_info_number_;
549 intptr_t frame_start_;
550 GrowableArray<MaterializeObjectInstr*> materializations_;
571 const Smi& reason_and_flags);
582 Smi* reason_and_flags);
593 static constexpr intptr_t kEntrySize = 3;
629 const Array& deopt_table,
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static void encode(uint8_t output[16], const uint32_t input[4])
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
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)
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
DeoptInfoBuilder(Zone *zone, const intptr_t num_args, compiler::Assembler *assembler)
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)
static DeoptInstr * Create(intptr_t kind_as_int, intptr_t source_index)
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 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
SK_API bool Read(SkStreamSeekable *src, SkDocumentPage *dstArray, int dstArrayCount, const SkDeserialProcs *=nullptr)
static constexpr int kDartFrameFixedSize
RegisterSource< Register > CpuRegisterSource
const int kNumberOfFpuRegisters
constexpr intptr_t kWordSize
simd128_value_t fpu_register_t
RegisterSource< FpuRegister > FpuRegisterSource
AsciiTrie::TrieNode TrieNode
static DecodeResult decode(std::string path)
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)