Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Friends | List of all members
dart::DeoptInfoBuilder Class Reference

#include <deopt_instructions.h>

Inheritance diagram for dart::DeoptInfoBuilder:
dart::ValueObject

Classes

class  TrieNode
 

Public Member Functions

 DeoptInfoBuilder (Zone *zone, const intptr_t num_args, compiler::Assembler *assembler)
 
void AddReturnAddress (const Function &function, intptr_t deopt_id, intptr_t dest_index)
 
void AddCopy (Value *value, const Location &source_loc, intptr_t dest_index)
 
void AddPcMarker (const Function &function, intptr_t dest_index)
 
void AddPp (const Function &function, intptr_t dest_index)
 
void AddCallerFp (intptr_t dest_index)
 
void AddCallerPp (intptr_t dest_index)
 
void AddCallerPc (intptr_t dest_index)
 
void AddMaterialization (MaterializeObjectInstr *mat)
 
intptr_t EmitMaterializationArguments (intptr_t dest_index)
 
TypedDataPtr CreateDeoptInfo (const Array &deopt_table)
 
void MarkFrameStart ()
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Friends

class CompilerDeoptInfo
 

Detailed Description

Definition at line 472 of file deopt_instructions.h.

Constructor & Destructor Documentation

◆ DeoptInfoBuilder()

dart::DeoptInfoBuilder::DeoptInfoBuilder ( Zone zone,
const intptr_t  num_args,
compiler::Assembler assembler 
)

Definition at line 1024 of file deopt_instructions.cc.

1027 : zone_(zone),
1028 instructions_(),
1029 num_args_(num_args),
1030 assembler_(assembler),
1031 trie_root_(new(zone) TrieNode()),
1032 current_info_number_(0),
1033 frame_start_(-1),
1034 materializations_() {}
AsciiTrie::TrieNode TrieNode
Definition: ascii_trie.cc:10

Member Function Documentation

◆ AddCallerFp()

void dart::DeoptInfoBuilder::AddCallerFp ( intptr_t  dest_index)

Definition at line 1172 of file deopt_instructions.cc.

1172 {
1173 ASSERT(dest_index == FrameSize());
1174 instructions_.Add(new (zone()) DeoptCallerFpInstr());
1175}
#define ASSERT(E)

◆ AddCallerPc()

void dart::DeoptInfoBuilder::AddCallerPc ( intptr_t  dest_index)

Definition at line 1182 of file deopt_instructions.cc.

1182 {
1183 ASSERT(dest_index == FrameSize());
1184 instructions_.Add(new (zone()) DeoptCallerPcInstr());
1185}

◆ AddCallerPp()

void dart::DeoptInfoBuilder::AddCallerPp ( intptr_t  dest_index)

Definition at line 1177 of file deopt_instructions.cc.

1177 {
1178 ASSERT(dest_index == FrameSize());
1179 instructions_.Add(new (zone()) DeoptCallerPpInstr());
1180}

◆ AddCopy()

void dart::DeoptInfoBuilder::AddCopy ( Value value,
const Location source_loc,
intptr_t  dest_index 
)

Definition at line 1094 of file deopt_instructions.cc.

1096 {
1097 DeoptInstr* deopt_instr = nullptr;
1098 if (source_loc.IsConstant()) {
1099 intptr_t object_table_index = FindOrAddObjectInTable(source_loc.constant());
1100 deopt_instr = new (zone()) DeoptConstantInstr(object_table_index);
1101 } else if (source_loc.IsInvalid() &&
1102 value->definition()->IsMaterializeObject()) {
1103 const intptr_t index =
1104 FindMaterialization(value->definition()->AsMaterializeObject());
1105 ASSERT(index >= 0);
1106 deopt_instr = new (zone()) DeoptMaterializedObjectRefInstr(index);
1107 } else {
1108 ASSERT(!source_loc.IsInvalid());
1109 Representation rep = value->definition()->representation();
1110 switch (rep) {
1111 case kTagged:
1112 deopt_instr =
1113 new (zone()) DeoptWordInstr(ToCpuRegisterSource(source_loc));
1114 break;
1115#if defined(TARGET_ARCH_IS_64_BIT)
1116 case kUntagged:
1117#endif
1118 case kUnboxedInt64: {
1119 if (source_loc.IsPairLocation()) {
1120 PairLocation* pair = source_loc.AsPairLocation();
1121 deopt_instr =
1122 new (zone()) DeoptMintPairInstr(ToCpuRegisterSource(pair->At(0)),
1123 ToCpuRegisterSource(pair->At(1)));
1124 } else {
1125 ASSERT(!source_loc.IsPairLocation());
1126 deopt_instr =
1127 new (zone()) DeoptMintInstr(ToCpuRegisterSource(source_loc));
1128 }
1129 break;
1130 }
1131#if defined(TARGET_ARCH_IS_32_BIT)
1132 case kUntagged:
1133#endif
1134 case kUnboxedInt32:
1135 deopt_instr =
1136 new (zone()) DeoptInt32Instr(ToCpuRegisterSource(source_loc));
1137 break;
1138 case kUnboxedUint32:
1139 deopt_instr =
1140 new (zone()) DeoptUint32Instr(ToCpuRegisterSource(source_loc));
1141 break;
1142 case kUnboxedFloat:
1143 deopt_instr = new (zone()) DeoptFloatInstr(
1144 ToFpuRegisterSource(source_loc, Location::kDoubleStackSlot));
1145 break;
1146 case kUnboxedDouble:
1147 deopt_instr = new (zone()) DeoptDoubleInstr(
1148 ToFpuRegisterSource(source_loc, Location::kDoubleStackSlot));
1149 break;
1150 case kUnboxedFloat32x4:
1151 deopt_instr = new (zone()) DeoptFloat32x4Instr(
1152 ToFpuRegisterSource(source_loc, Location::kQuadStackSlot));
1153 break;
1154 case kUnboxedFloat64x2:
1155 deopt_instr = new (zone()) DeoptFloat64x2Instr(
1156 ToFpuRegisterSource(source_loc, Location::kQuadStackSlot));
1157 break;
1158 case kUnboxedInt32x4:
1159 deopt_instr = new (zone()) DeoptInt32x4Instr(
1160 ToFpuRegisterSource(source_loc, Location::kQuadStackSlot));
1161 break;
1162 default:
1163 UNREACHABLE();
1164 break;
1165 }
1166 }
1167 ASSERT(dest_index == FrameSize());
1168 ASSERT(deopt_instr != nullptr);
1169 instructions_.Add(deopt_instr);
1170}
#define UNREACHABLE()
Definition: assert.h:248
uint8_t value
DeoptFpuInstr< DeoptInstr::kInt32x4, CatchEntryMove::SourceKind::kInt32x4Slot, simd128_value_t, Int32x4Ptr > DeoptInt32x4Instr
DeoptFpuInstr< DeoptInstr::kFloat64x2, CatchEntryMove::SourceKind::kFloat64x2Slot, simd128_value_t, Float64x2Ptr > DeoptFloat64x2Instr
DeoptIntInstr< DeoptInstr::kUint32, CatchEntryMove::SourceKind::kUint32Slot, uint32_t > DeoptUint32Instr
Representation
Definition: locations.h:66
DeoptIntInstr< DeoptInstr::kInt32, CatchEntryMove::SourceKind::kInt32Slot, int32_t > DeoptInt32Instr
DeoptFpuInstr< DeoptInstr::kFloat32x4, CatchEntryMove::SourceKind::kFloat32x4Slot, simd128_value_t, Float32x4Ptr > DeoptFloat32x4Instr
DeoptFpuInstr< DeoptInstr::kDouble, CatchEntryMove::SourceKind::kDoubleSlot, double, DoublePtr > DeoptDoubleInstr
DeoptIntInstr< DeoptInstr::kMint, CatchEntryMove::SourceKind::kInt64Slot, int64_t > DeoptMintInstr
DeoptFpuInstr< DeoptInstr::kFloat, CatchEntryMove::SourceKind::kFloatSlot, float, DoublePtr > DeoptFloatInstr

◆ AddMaterialization()

void dart::DeoptInfoBuilder::AddMaterialization ( MaterializeObjectInstr mat)

Definition at line 1193 of file deopt_instructions.cc.

1193 {
1194 const intptr_t index = FindMaterialization(mat);
1195 if (index >= 0) {
1196 return; // Already added.
1197 }
1198 materializations_.Add(mat);
1199
1200 // Count initialized fields and emit kMaterializeObject instruction.
1201 // There is no need to write nulls into fields because object is null
1202 // initialized by default.
1203 intptr_t non_null_fields = 0;
1204 for (intptr_t i = 0; i < mat->InputCount(); i++) {
1205 if (!mat->InputAt(i)->BindsToConstantNull()) {
1206 non_null_fields++;
1207 }
1208 }
1209
1210 instructions_.Add(new (zone()) DeoptMaterializeObjectInstr(non_null_fields));
1211
1212 for (intptr_t i = 0; i < mat->InputCount(); i++) {
1213 MaterializeObjectInstr* nested_mat =
1214 mat->InputAt(i)->definition()->AsMaterializeObject();
1215 if (nested_mat != nullptr) {
1216 AddMaterialization(nested_mat);
1217 }
1218 }
1219}
void AddMaterialization(MaterializeObjectInstr *mat)

◆ AddPcMarker()

void dart::DeoptInfoBuilder::AddPcMarker ( const Function function,
intptr_t  dest_index 
)

Definition at line 1081 of file deopt_instructions.cc.

1082 {
1083 intptr_t object_table_index = FindOrAddObjectInTable(function);
1084 ASSERT(dest_index == FrameSize());
1085 instructions_.Add(new (zone()) DeoptPcMarkerInstr(object_table_index));
1086}
Dart_NativeFunction function
Definition: fuchsia.cc:51

◆ AddPp()

void dart::DeoptInfoBuilder::AddPp ( const Function function,
intptr_t  dest_index 
)

Definition at line 1088 of file deopt_instructions.cc.

1088 {
1089 intptr_t object_table_index = FindOrAddObjectInTable(function);
1090 ASSERT(dest_index == FrameSize());
1091 instructions_.Add(new (zone()) DeoptPpInstr(object_table_index));
1092}

◆ AddReturnAddress()

void dart::DeoptInfoBuilder::AddReturnAddress ( const Function function,
intptr_t  deopt_id,
intptr_t  dest_index 
)

Definition at line 1072 of file deopt_instructions.cc.

1074 {
1075 const intptr_t object_table_index = FindOrAddObjectInTable(function);
1076 ASSERT(dest_index == FrameSize());
1077 instructions_.Add(new (zone())
1078 DeoptRetAddressInstr(object_table_index, deopt_id));
1079}

◆ CreateDeoptInfo()

TypedDataPtr dart::DeoptInfoBuilder::CreateDeoptInfo ( const Array deopt_table)

Definition at line 1251 of file deopt_instructions.cc.

1251 {
1252 intptr_t length = instructions_.length();
1253
1254 // Count the number of instructions that are a shared suffix of some deopt
1255 // info already written.
1256 TrieNode* suffix = trie_root_;
1257 intptr_t suffix_length = 0;
1258 if (FLAG_compress_deopt_info) {
1259 for (intptr_t i = length - 1; i >= 0; --i) {
1260 TrieNode* node = suffix->FindChild(*instructions_[i]);
1261 if (node == nullptr) break;
1262 suffix = node;
1263 ++suffix_length;
1264 }
1265 }
1266
1267 // Allocate space for the translation. If the shared suffix is longer
1268 // than one instruction, we replace it with a single suffix instruction.
1269 const bool use_suffix = suffix_length > 1;
1270 if (use_suffix) {
1271 length -= (suffix_length - 1);
1272 }
1273
1274 typedef ZoneWriteStream::Raw<sizeof(intptr_t), intptr_t> Writer;
1275 ZoneWriteStream stream(zone(), 2 * length * kWordSize);
1276
1277 Writer::Write(&stream, FrameSize());
1278
1279 if (use_suffix) {
1280 Writer::Write(&stream, suffix_length);
1281 Writer::Write(&stream, suffix->info_number());
1282 } else {
1283 Writer::Write(&stream, 0);
1284 }
1285
1286 // Write the unshared instructions and build their sub-tree.
1287 TrieNode* node = use_suffix ? suffix : trie_root_;
1288 const intptr_t write_count = use_suffix ? length - 1 : length;
1289 for (intptr_t i = write_count - 1; i >= 0; --i) {
1290 DeoptInstr* instr = instructions_[i];
1291 Writer::Write(&stream, instr->kind());
1292 Writer::Write(&stream, instr->source_index());
1293
1294 TrieNode* child = new (zone()) TrieNode(instr, current_info_number_);
1295 node->AddChild(child);
1296 node = child;
1297 }
1298
1299 const TypedData& deopt_info = TypedData::Handle(
1300 zone(), TypedData::New(kTypedDataUint8ArrayCid, stream.bytes_written(),
1301 Heap::kOld));
1302 {
1303 NoSafepointScope no_safepoint;
1304 memmove(deopt_info.DataAddr(0), stream.buffer(), stream.bytes_written());
1305 }
1306
1307 ASSERT(
1308 DeoptInfo::VerifyDecompression(instructions_, deopt_table, deopt_info));
1309 instructions_.Clear();
1310 materializations_.Clear();
1311 frame_start_ = -1;
1312
1313 ++current_info_number_;
1314 return deopt_info.ptr();
1315}
static bool VerifyDecompression(const GrowableArray< DeoptInstr * > &original, const Array &deopt_table, const TypedData &packed)
@ kOld
Definition: heap.h:39
static Object & Handle()
Definition: object.h:407
static TypedDataPtr New(intptr_t class_id, intptr_t len, Heap::Space space=Heap::kNew)
Definition: object.cc:25587
size_t length
constexpr intptr_t kWordSize
Definition: globals.h:509

◆ EmitMaterializationArguments()

intptr_t dart::DeoptInfoBuilder::EmitMaterializationArguments ( intptr_t  dest_index)

Definition at line 1221 of file deopt_instructions.cc.

1221 {
1222 ASSERT(dest_index == kDartFrameFixedSize);
1223 for (intptr_t i = 0; i < materializations_.length(); i++) {
1224 MaterializeObjectInstr* mat = materializations_[i];
1225 // Class of the instance to allocate.
1226 AddConstant(mat->cls(), dest_index++);
1227 AddConstant(Smi::ZoneHandle(Smi::New(mat->length_or_shape())),
1228 dest_index++);
1229 for (intptr_t i = 0; i < mat->InputCount(); i++) {
1230 if (!mat->InputAt(i)->BindsToConstantNull()) {
1231 // Emit offset-value pair.
1232 AddConstant(Smi::ZoneHandle(Smi::New(mat->FieldOffsetAt(i))),
1233 dest_index++);
1234 AddCopy(mat->InputAt(i), mat->LocationAt(i), dest_index++);
1235 }
1236 }
1237 }
1238 return dest_index;
1239}
void AddCopy(Value *value, const Location &source_loc, intptr_t dest_index)
static Object & ZoneHandle()
Definition: object.h:419
static SmiPtr New(intptr_t value)
Definition: object.h:10006
static constexpr int kDartFrameFixedSize

◆ MarkFrameStart()

void dart::DeoptInfoBuilder::MarkFrameStart ( )
inline

Definition at line 509 of file deopt_instructions.h.

509 {
510 ASSERT(frame_start_ == -1);
511 frame_start_ = instructions_.length();
512 }

Friends And Related Function Documentation

◆ CompilerDeoptInfo

friend class CompilerDeoptInfo
friend

Definition at line 515 of file deopt_instructions.h.


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