Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | List of all members
dart::FlowGraphSerializer::WriteTrait< T, class > Struct Template Reference

#include <il_serializer.h>

Public Types

using ArgType = T
 

Public Member Functions

void Write (FlowGraphSerializer *s, const AbstractType *x)
 
void Write (FlowGraphSerializer *s, AliasIdentity x)
 
void Write (FlowGraphSerializer *s, bool x)
 
void Write (FlowGraphSerializer *s, const compiler::ffi::CallbackMarshaller &x)
 
void Write (FlowGraphSerializer *s, const compiler::ffi::CallMarshaller &x)
 
void Write (FlowGraphSerializer *s, const CallTargets &x)
 
void Write (FlowGraphSerializer *s, const char *x)
 
void Write (FlowGraphSerializer *s, CidRangeValue x)
 
void Write (FlowGraphSerializer *s, const Cids &x)
 
void Write (FlowGraphSerializer *s, const Class &x)
 
void Write (FlowGraphSerializer *s, const Code &x)
 
void Write (FlowGraphSerializer *s, CompileType *x)
 
void Write (FlowGraphSerializer *s, double x)
 
void Write (FlowGraphSerializer *s, Environment *x)
 
void Write (FlowGraphSerializer *s, const Function &x)
 
void Write (FlowGraphSerializer *s, const ICData *x)
 
void Write (FlowGraphSerializer *s, Instruction *x)
 
void Write (FlowGraphSerializer *s, int8_t x)
 
void Write (FlowGraphSerializer *s, int16_t x)
 
void Write (FlowGraphSerializer *s, int32_t x)
 
void Write (FlowGraphSerializer *s, int64_t x)
 
void Write (FlowGraphSerializer *s, const LocalVariable &x)
 
void Write (FlowGraphSerializer *s, LocationSummary *x)
 
void Write (FlowGraphSerializer *s, MoveOperands *x)
 
void Write (FlowGraphSerializer *s, const Object &x)
 
void Write (FlowGraphSerializer *s, Range *x)
 
void Write (FlowGraphSerializer *s, RecordShape x)
 
void Write (FlowGraphSerializer *s, Representation x)
 
void Write (FlowGraphSerializer *s, const Slot &x)
 
void Write (FlowGraphSerializer *s, const Slot *x)
 
void Write (FlowGraphSerializer *s, const compiler::TableSelector *x)
 
void Write (FlowGraphSerializer *s, TokenPosition x)
 
void Write (FlowGraphSerializer *s, uint8_t x)
 
void Write (FlowGraphSerializer *s, uint16_t x)
 
void Write (FlowGraphSerializer *s, uint32_t x)
 
void Write (FlowGraphSerializer *s, uint64_t x)
 
void Write (FlowGraphSerializer *s, Value *x)
 
void Write (FlowGraphSerializer *s, const MoveSchedule *schedule)
 

Detailed Description

template<typename T, class = void>
struct dart::FlowGraphSerializer::WriteTrait< T, class >

Definition at line 170 of file il_serializer.h.

Member Typedef Documentation

◆ ArgType

template<typename T , class = void>
using dart::FlowGraphSerializer::WriteTrait< T, class >::ArgType = T

Definition at line 171 of file il_serializer.h.

Member Function Documentation

◆ Write() [1/38]

Definition at line 74 of file il_serializer.cc.

76 {
77 x.Write(s);
78}
struct MyStruct s
double x

◆ Write() [2/38]

void dart::FlowGraphSerializer::WriteTrait< bool >::Write ( FlowGraphSerializer s,
bool  x 
)

Definition at line 211 of file il_serializer.cc.

212 {
213 s->stream()->Write<uint8_t>(x ? 1 : 0);
214}

◆ Write() [3/38]

Definition at line 378 of file il_serializer.cc.

380 {
381 s->Write<intptr_t>(x.cid_start);
382 s->Write<intptr_t>(x.cid_end);
383}

◆ Write() [4/38]

Definition at line 495 of file il_serializer.cc.

497 {
498 if (x == nullptr) {
499 s->Write<bool>(false);
500 } else {
501 s->Write<bool>(true);
502 x->Write(s);
503 }
504}

◆ Write() [5/38]

void dart::FlowGraphSerializer::WriteTrait< constAbstractType * >::Write ( FlowGraphSerializer s,
const AbstractType x 
)

Definition at line 53 of file il_serializer.cc.

55 {
56 if (x == nullptr) {
57 s->Write<bool>(false);
58 } else {
59 s->Write<bool>(true);
60 s->Write<const AbstractType&>(*x);
61 }
62}

◆ Write() [6/38]

void dart::FlowGraphSerializer::WriteTrait< constCallTargets & >::Write ( FlowGraphSerializer s,
const CallTargets x 
)

Definition at line 280 of file il_serializer.cc.

282 {
283 x.Write(s);
284}

◆ Write() [7/38]

void dart::FlowGraphSerializer::WriteTrait< constchar * >::Write ( FlowGraphSerializer s,
const char *  x 
)

Definition at line 343 of file il_serializer.cc.

344 {
345 ASSERT(x != nullptr);
346 const intptr_t len = strlen(x);
347 s->Write<intptr_t>(len);
348 s->stream()->WriteBytes(x, len);
349}
#define ASSERT(E)

◆ Write() [8/38]

void dart::FlowGraphSerializer::WriteTrait< constCids & >::Write ( FlowGraphSerializer s,
const Cids x 
)

Definition at line 394 of file il_serializer.cc.

395 {
396 const intptr_t len = x.length();
397 s->Write<intptr_t>(len);
398 for (intptr_t i = 0; i < len; ++i) {
399 const CidRange* r = x.At(i);
400 s->Write<intptr_t>(r->cid_start);
401 s->Write<intptr_t>(r->cid_end);
402 }
403}

◆ Write() [9/38]

void dart::FlowGraphSerializer::WriteTrait< constClass & >::Write ( FlowGraphSerializer s,
const Class x 
)

Definition at line 421 of file il_serializer.cc.

423 {
424 if (x.IsNull()) {
425 s->Write<classid_t>(kIllegalCid);
426 return;
427 }
428 s->Write<classid_t>(x.id());
429}
int32_t classid_t
Definition: globals.h:524
@ kIllegalCid
Definition: class_id.h:214

◆ Write() [10/38]

void dart::FlowGraphSerializer::WriteTrait< constCode & >::Write ( FlowGraphSerializer s,
const Code x 
)

Definition at line 452 of file il_serializer.cc.

453 {
454 ASSERT(!x.IsNull());
455 ASSERT(x.IsStubCode());
456 for (intptr_t i = 0, n = StubCode::NumEntries(); i < n; ++i) {
457 if (StubCode::EntryAt(i).ptr() == x.ptr()) {
458 s->Write<intptr_t>(i);
459 return;
460 }
461 }
462 intptr_t index = StubCode::NumEntries();
463 ObjectStore* object_store = s->isolate_group()->object_store();
464#define MATCH(member, name) \
465 if (object_store->member() == x.ptr()) { \
466 s->Write<intptr_t>(index); \
467 return; \
468 } \
469 ++index;
471#undef MATCH
473}
static const Code & EntryAt(intptr_t index)
Definition: stub_code.h:101
static intptr_t NumEntries()
Definition: stub_code.h:107
#define UNIMPLEMENTED
#define MATCH(member, name)
#define OBJECT_STORE_STUB_CODE_LIST(DO)
Definition: object_store.h:296

◆ Write() [11/38]

void dart::FlowGraphSerializer::WriteTrait< constcompiler::ffi::CallbackMarshaller & >::Write ( FlowGraphSerializer s,
const compiler::ffi::CallbackMarshaller x 
)

Definition at line 244 of file il_serializer.cc.

245 {
246 s->Write<const Function&>(x.dart_signature());
247}

◆ Write() [12/38]

void dart::FlowGraphSerializer::WriteTrait< constcompiler::ffi::CallMarshaller & >::Write ( FlowGraphSerializer s,
const compiler::ffi::CallMarshaller x 
)

Definition at line 259 of file il_serializer.cc.

260 {
261 s->Write<const Function&>(x.dart_signature());
262 s->Write<int8_t>(x.dart_signature_params_start_at());
263 s->Write<const FunctionType&>(x.c_signature());
264}

◆ Write() [13/38]

void dart::FlowGraphSerializer::WriteTrait< constcompiler::TableSelector * >::Write ( FlowGraphSerializer s,
const compiler::TableSelector x 
)

Definition at line 2384 of file il_serializer.cc.

2386 {
2387#if defined(DART_PRECOMPILER)
2388 ASSERT(x != nullptr);
2389 s->Write<int32_t>(x->id);
2390#else
2391 UNREACHABLE();
2392#endif
2393}
#define UNREACHABLE()
Definition: assert.h:248

◆ Write() [14/38]

void dart::FlowGraphSerializer::WriteTrait< constFunction & >::Write ( FlowGraphSerializer s,
const Function x 
)

Definition at line 778 of file il_serializer.cc.

780 {
781 if (x.IsNull()) {
782 s->Write<int8_t>(-1);
783 return;
784 }
785 Zone* zone = s->zone();
786 s->Write<int8_t>(x.kind());
787 switch (x.kind()) {
788 case UntaggedFunction::kRegularFunction:
789 case UntaggedFunction::kGetterFunction:
790 case UntaggedFunction::kSetterFunction:
791 case UntaggedFunction::kImplicitGetter:
792 case UntaggedFunction::kImplicitSetter:
793 case UntaggedFunction::kImplicitStaticGetter:
794 case UntaggedFunction::kConstructor: {
795 const auto& owner = Class::Handle(zone, x.Owner());
796 s->Write<classid_t>(owner.id());
797 const intptr_t function_index = owner.FindFunctionIndex(x);
798 ASSERT(function_index >= 0);
799 s->Write<intptr_t>(function_index);
800 return;
801 }
802 case UntaggedFunction::kImplicitClosureFunction: {
803 const auto& parent = Function::Handle(zone, x.parent_function());
804 s->Write<const Function&>(parent);
805 return;
806 }
807 case UntaggedFunction::kFieldInitializer: {
808 const auto& field = Field::Handle(zone, x.accessor_field());
809 s->Write<const Field&>(field);
810 return;
811 }
812 case UntaggedFunction::kClosureFunction:
813 // TODO(alexmarkov): we cannot rely on ClosureFunctionsCache
814 // as it is lazily populated when compiling functions.
815 // We need to serialize kernel offset and re-create
816 // closure functions when reading as needed.
818 return;
819 case UntaggedFunction::kMethodExtractor: {
820 Function& function = Function::Handle(zone, x.extracted_method_closure());
821 ASSERT(function.IsImplicitClosureFunction());
822 function = function.parent_function();
823 s->Write<const Function&>(function);
824 s->Write<const String&>(String::Handle(zone, x.name()));
825 return;
826 }
827 case UntaggedFunction::kInvokeFieldDispatcher: {
828 s->Write<const Class&>(Class::Handle(zone, x.Owner()));
829 s->Write<const String&>(String::Handle(zone, x.name()));
830 s->Write<const Array&>(Array::Handle(zone, x.saved_args_desc()));
831 return;
832 }
833 case UntaggedFunction::kDynamicInvocationForwarder: {
834 const auto& target = Function::Handle(zone, x.ForwardingTarget());
835 s->Write<const Function&>(target);
836 return;
837 }
838 case UntaggedFunction::kFfiTrampoline: {
839 s->Write<uint8_t>(static_cast<uint8_t>(x.GetFfiCallbackKind()));
840 s->Write<const FunctionType&>(
841 FunctionType::Handle(zone, x.FfiCSignature()));
842 s->Write<const Function&>(Function::Handle(zone, x.FfiCallbackTarget()));
843 s->Write<const Instance&>(
844 Instance::Handle(zone, x.FfiCallbackExceptionalReturn()));
845 return;
846 }
847 default:
848 break;
849 }
850 switch (x.kind()) {
851#define UNIMPLEMENTED_FUNCTION_KIND(kind) \
852 case UntaggedFunction::k##kind: \
853 FATAL("Unimplemented WriteTrait<const Function&>::Write for " #kind);
855#undef UNIMPLEMENTED_FUNCTION_KIND
856 }
857 UNREACHABLE();
858}
static intptr_t FindClosureIndex(const Function &needle)
static Object & Handle()
Definition: object.h:407
uint32_t * target
Dart_NativeFunction function
Definition: fuchsia.cc:51
#define UNIMPLEMENTED_FUNCTION_KIND(kind)
#define FOR_EACH_RAW_FUNCTION_KIND(V)
Definition: raw_object.h:1240

◆ Write() [15/38]

void dart::FlowGraphSerializer::WriteTrait< constICData * >::Write ( FlowGraphSerializer s,
const ICData x 
)

Definition at line 998 of file il_serializer.cc.

1000 {
1001 if (x == nullptr) {
1002 s->Write<bool>(false);
1003 } else {
1004 s->Write<bool>(true);
1005 ASSERT(!x->IsNull());
1006 s->Write<const Object&>(*x);
1007 }
1008}

◆ Write() [16/38]

void dart::FlowGraphSerializer::WriteTrait< constLocalVariable & >::Write ( FlowGraphSerializer s,
const LocalVariable x 
)

Definition at line 1215 of file il_serializer.cc.

1217 {
1218 UNIMPLEMENTED();
1219}

◆ Write() [17/38]

void dart::FlowGraphSerializer::WriteTrait< constMoveSchedule * >::Write ( FlowGraphSerializer s,
const MoveSchedule schedule 
)

Definition at line 392 of file parallel_move_resolver.cc.

394 {
395 ASSERT(schedule != nullptr);
396 const intptr_t len = schedule->length();
397 s->Write<intptr_t>(len);
398 for (intptr_t i = 0; i < len; ++i) {
399 const auto& op = (*schedule)[i];
400 s->Write<uint8_t>(static_cast<uint8_t>(op.kind));
401 op.operands.Write(s);
402 }
403}

◆ Write() [18/38]

void dart::FlowGraphSerializer::WriteTrait< constObject & >::Write ( FlowGraphSerializer s,
const Object x 
)

Definition at line 1381 of file il_serializer.cc.

1383 {
1384 const intptr_t cid = x.GetClassId();
1386 // Do not write objects repeatedly.
1387 const intptr_t object_id = s->heap()->GetObjectId(x.ptr());
1388 if (object_id > 0) {
1389 const intptr_t object_index = object_id - 1;
1390 s->Write<intptr_t>(kIllegalCid);
1391 s->Write<intptr_t>(object_index);
1392 return;
1393 }
1394 const intptr_t object_index = s->object_counter_++;
1395 s->heap()->SetObjectId(x.ptr(), object_index + 1);
1396 s->Write<intptr_t>(cid);
1397 s->WriteObjectImpl(x, cid, object_index);
1398}
const intptr_t cid

◆ Write() [19/38]

void dart::FlowGraphSerializer::WriteTrait< constSlot & >::Write ( FlowGraphSerializer s,
const Slot x 
)

Definition at line 2266 of file il_serializer.cc.

2267 {
2268 x.Write(s);
2269}

◆ Write() [20/38]

void dart::FlowGraphSerializer::WriteTrait< constSlot * >::Write ( FlowGraphSerializer s,
const Slot x 
)

Definition at line 2278 of file il_serializer.cc.

2279 {
2280 if (x == nullptr) {
2281 s->Write<bool>(false);
2282 return;
2283 }
2284 s->Write<bool>(true);
2285 x->Write(s);
2286}

◆ Write() [21/38]

void dart::FlowGraphSerializer::WriteTrait< double >::Write ( FlowGraphSerializer s,
double  x 
)

Definition at line 586 of file il_serializer.cc.

587 {
588 s->stream()->Write<int64_t>(bit_cast<int64_t>(x));
589}

◆ Write() [22/38]

Definition at line 598 of file il_serializer.cc.

600 {
601 ASSERT(s->can_write_refs());
602 if (x == nullptr) {
603 s->Write<bool>(false);
604 } else {
605 s->Write<bool>(true);
606 x->Write(s);
607 }
608}

◆ Write() [23/38]

Definition at line 1058 of file il_serializer.cc.

1060 {
1061 if (x == nullptr) {
1062 s->Write<uint8_t>(Instruction::kNumInstructions);
1063 } else {
1064 s->Write<uint8_t>(static_cast<uint8_t>(x->tag()));
1065 x->WriteTo(s);
1066 }
1067}

◆ Write() [24/38]

void dart::FlowGraphSerializer::WriteTrait< int16_t >::Write ( FlowGraphSerializer s,
int16_t  x 
)

Definition at line 1161 of file il_serializer.cc.

1162 {
1163 s->stream()->Write<int16_t>(x);
1164}

◆ Write() [25/38]

void dart::FlowGraphSerializer::WriteTrait< int32_t >::Write ( FlowGraphSerializer s,
int32_t  x 
)

Definition at line 1173 of file il_serializer.cc.

1174 {
1175 s->stream()->Write<int32_t>(x);
1176}

◆ Write() [26/38]

void dart::FlowGraphSerializer::WriteTrait< int64_t >::Write ( FlowGraphSerializer s,
int64_t  x 
)

Definition at line 1185 of file il_serializer.cc.

1186 {
1187 s->stream()->Write<int64_t>(x);
1188}

◆ Write() [27/38]

void dart::FlowGraphSerializer::WriteTrait< int8_t >::Write ( FlowGraphSerializer s,
int8_t  x 
)

Definition at line 1149 of file il_serializer.cc.

1150 {
1151 s->stream()->Write<int8_t>(x);
1152}

◆ Write() [28/38]

Definition at line 1260 of file il_serializer.cc.

1262 {
1263 ASSERT(s->can_write_refs());
1264 if (x == nullptr) {
1265 s->Write<bool>(false);
1266 } else {
1267 s->Write<bool>(true);
1268 x->Write(s);
1269 }
1270}

◆ Write() [29/38]

Definition at line 1360 of file il_serializer.cc.

1362 {
1363 x->Write(s);
1364}

◆ Write() [30/38]

Definition at line 2187 of file il_serializer.cc.

2188 {
2189 if (x == nullptr) {
2190 s->Write<bool>(false);
2191 } else {
2192 s->Write<bool>(true);
2193 x->Write(s);
2194 }
2195}

◆ Write() [31/38]

Definition at line 2226 of file il_serializer.cc.

2227 {
2228 s->Write<intptr_t>(x.num_fields());
2229 s->Write<const Array&>(
2230 Array::Handle(s->zone(), x.GetFieldNames(s->thread())));
2231}

◆ Write() [32/38]

Definition at line 2253 of file il_serializer.cc.

2255 {
2256 s->Write<uint8_t>(x);
2257}

◆ Write() [33/38]

Definition at line 2506 of file il_serializer.cc.

2508 {
2509 s->Write<int32_t>(x.Serialize());
2510}

◆ Write() [34/38]

void dart::FlowGraphSerializer::WriteTrait< uint16_t >::Write ( FlowGraphSerializer s,
uint16_t  x 
)

Definition at line 2531 of file il_serializer.cc.

2532 {
2533 s->stream()->Write<uint16_t>(x);
2534}

◆ Write() [35/38]

void dart::FlowGraphSerializer::WriteTrait< uint32_t >::Write ( FlowGraphSerializer s,
uint32_t  x 
)

Definition at line 2543 of file il_serializer.cc.

2544 {
2545 s->stream()->Write<int32_t>(static_cast<int32_t>(x));
2546}

◆ Write() [36/38]

void dart::FlowGraphSerializer::WriteTrait< uint64_t >::Write ( FlowGraphSerializer s,
uint64_t  x 
)

Definition at line 2555 of file il_serializer.cc.

2556 {
2557 s->stream()->Write<int64_t>(static_cast<int64_t>(x));
2558}

◆ Write() [37/38]

void dart::FlowGraphSerializer::WriteTrait< uint8_t >::Write ( FlowGraphSerializer s,
uint8_t  x 
)

Definition at line 2519 of file il_serializer.cc.

2520 {
2521 s->stream()->Write<uint8_t>(x);
2522}

◆ Write() [38/38]

Definition at line 2583 of file il_serializer.cc.

2584 {
2585 ASSERT(s->can_write_refs());
2586 CompileType* reaching_type = x->reaching_type();
2587 Definition* def = x->definition();
2588 // Omit reaching type if it is the same as definition type.
2589 if ((reaching_type != nullptr) && def->HasType() &&
2590 (reaching_type == def->Type())) {
2591 reaching_type = nullptr;
2592 }
2593 s->Write<CompileType*>(reaching_type);
2594 s->WriteRef<Definition*>(def);
2595}

The documentation for this struct was generated from the following file: