2106 { \
2107 s->Write<
const Object&>(
x); \
2108 } \
2109 template <> \
2110 const handle& FlowGraphDeserializer::ReadTrait<const handle&>::Read( \
2111 FlowGraphDeserializer*
d) { \
2112 const Object&
result =
d->Read<
const Object&>(); \
2114 return null_handle; \
2115 } \
2116 return handle::Cast(
result); \
2117 }
2118
2120#undef SERIALIZE_HANDLE_AS_OBJECT
2121#undef HANDLES_SERIALIZABLE_AS_OBJECT
2122
2123void OsrEntryInstr::WriteTo(FlowGraphSerializer*
s) {
2124 BlockEntryWithInitialDefs::WriteTo(
s);
2125}
2126
2127OsrEntryInstr::OsrEntryInstr(FlowGraphDeserializer*
d)
2128 : BlockEntryWithInitialDefs(
d), graph_entry_(
d->graph_entry()) {}
2129
2130void ParallelMoveInstr::WriteExtra(FlowGraphSerializer*
s) {
2131 Instruction::WriteExtra(
s);
2132 s->Write<GrowableArray<MoveOperands*>>(moves_);
2133 s->Write<
const MoveSchedule*>(move_schedule_);
2134}
2135
2136void ParallelMoveInstr::ReadExtra(FlowGraphDeserializer*
d) {
2137 Instruction::ReadExtra(
d);
2138 moves_ =
d->Read<GrowableArray<MoveOperands*>>();
2139 move_schedule_ =
d->Read<
const MoveSchedule*>();
2140}
2141
2142void ParameterInstr::WriteExtra(FlowGraphSerializer*
s) {
2143 TemplateDefinition::WriteExtra(
s);
2145}
2146
2147void ParameterInstr::ReadExtra(FlowGraphDeserializer*
d) {
2148 TemplateDefinition::ReadExtra(
d);
2149 location_ = Location::Read(
d);
2150}
2151
2152void PhiInstr::WriteTo(FlowGraphSerializer*
s) {
2153 VariadicDefinition::WriteTo(
s);
2155 s->Write<
bool>(is_alive_);
2156 s->Write<int8_t>(is_receiver_);
2157}
2158
2159PhiInstr::PhiInstr(FlowGraphDeserializer*
d)
2160 : VariadicDefinition(
d),
2161 block_(
d->current_block()->AsJoinEntry()),
2163 is_alive_(
d->
Read<bool>()),
2164 is_receiver_(
d->
Read<int8_t>()) {}
2165
2166void LeafRuntimeCallInstr::WriteTo(FlowGraphSerializer*
s) {
2167 VariadicDefinition::WriteTo(
s);
2169 s->Write<
const ZoneGrowableArray<Representation>&>(argument_representations_);
2170}
2171
2172LeafRuntimeCallInstr::LeafRuntimeCallInstr(FlowGraphDeserializer*
d)
2173 : VariadicDefinition(
d),
2175 argument_representations_(
2177 native_calling_convention_(
2178 compiler::ffi::NativeCallingConvention::FromSignature(
2180 *
compiler::ffi::NativeFunctionType::FromRepresentations(
2182 return_representation_,
2183 argument_representations_))) {}
2184
2185template <>
2186void FlowGraphSerializer::WriteTrait<Range*>::Write(FlowGraphSerializer*
s,
2189 s->Write<
bool>(
false);
2190 } else {
2191 s->Write<
bool>(
true);
2193 }
2194}
2195
2196template <>
2197Range* FlowGraphDeserializer::ReadTrait<Range*>::Read(
2198 FlowGraphDeserializer*
d) {
2199 if (!
d->Read<
bool>()) {
2200 return nullptr;
2201 }
2202 return new (
d->zone()) Range(
d);
2203}
2204
2205void Range::Write(FlowGraphSerializer*
s)
const {
2208}
2209
2210Range::Range(FlowGraphDeserializer*
d)
2211 :
min_(RangeBoundary(
d)),
max_(RangeBoundary(
d)) {}
2212
2213void RangeBoundary::Write(FlowGraphSerializer*
s)
const {
2214 s->Write<int8_t>(kind_);
2215 s->Write<int64_t>(value_);
2216 s->Write<int64_t>(offset_);
2217}
2218
2219RangeBoundary::RangeBoundary(FlowGraphDeserializer*
d)
2220 : kind_(static_cast<
Kind>(
d->
Read<int8_t>())),
2221 value_(
d->
Read<int64_t>()),
2222 offset_(
d->
Read<int64_t>()) {}
2223
2224template <>
2225void FlowGraphSerializer::WriteTrait<RecordShape>::Write(FlowGraphSerializer*
s,
2227 s->Write<intptr_t>(
x.num_fields());
2228 s->Write<
const Array&>(
2229 Array::Handle(
s->zone(),
x.GetFieldNames(
s->thread())));
2230}
2231
2232template <>
2233RecordShape FlowGraphDeserializer::ReadTrait<RecordShape>::Read(
2234 FlowGraphDeserializer*
d) {
2235 const intptr_t num_fields =
d->Read<intptr_t>();
2236 const auto& field_names =
d->Read<
const Array&>();
2237 return RecordShape::Register(
d->thread(), num_fields, field_names);
2238}
2239
2240void RegisterSet::Write(FlowGraphSerializer*
s)
const {
2241 s->Write<uintptr_t>(cpu_registers_.data());
2242 s->Write<uintptr_t>(untagged_cpu_registers_.data());
2243 s->Write<uintptr_t>(fpu_registers_.data());
2244}
2245
2246RegisterSet::RegisterSet(FlowGraphDeserializer*
d)
2247 : cpu_registers_(
d->
Read<uintptr_t>()),
2248 untagged_cpu_registers_(
d->
Read<uintptr_t>()),
2249 fpu_registers_(
d->
Read<uintptr_t>()) {}
2250
2251template <>
2252void FlowGraphSerializer::WriteTrait<Representation>::Write(
2253 FlowGraphSerializer*
s,
2255 s->Write<uint8_t>(
x);
2256}
2257
2258template <>
2259Representation FlowGraphDeserializer::ReadTrait<Representation>::Read(
2260 FlowGraphDeserializer*
d) {
2262}
2263
2264template <>
2265void FlowGraphSerializer::WriteTrait<const Slot&>::Write(FlowGraphSerializer*
s,
2268}
2269
2270template <>
2271const Slot& FlowGraphDeserializer::ReadTrait<const Slot&>::Read(
2272 FlowGraphDeserializer*
d) {
2273 return Slot::Read(
d);
2274}
2275
2276template <>
2277void FlowGraphSerializer::WriteTrait<const Slot*>::Write(FlowGraphSerializer*
s,
2280 s->Write<
bool>(
false);
2281 return;
2282 }
2283 s->Write<
bool>(
true);
2285}
2286
2287template <>
2288const Slot* FlowGraphDeserializer::ReadTrait<const Slot*>::Read(
2289 FlowGraphDeserializer*
d) {
2290 if (!
d->Read<
bool>()) {
2291 return nullptr;
2292 }
2293 return &Slot::Read(
d);
2294}
2295
2296void Slot::Write(FlowGraphSerializer*
s)
const {
2297 s->Write<serializable_type_t<Kind>>(
2298 static_cast<serializable_type_t<Kind>>(kind_));
2299
2300 switch (kind_) {
2301 case Kind::kTypeArguments:
2302 s->Write<int8_t>(flags_);
2303 s->Write<intptr_t>(offset_in_bytes_);
2304 break;
2305 case Kind::kTypeArgumentsIndex:
2306 s->Write<intptr_t>(offset_in_bytes_);
2307 break;
2308 case Kind::kArrayElement:
2309 s->Write<intptr_t>(offset_in_bytes_);
2310 break;
2311 case Kind::kRecordField:
2312 s->Write<intptr_t>(offset_in_bytes_);
2313 break;
2314 case Kind::kCapturedVariable:
2315 s->Write<int8_t>(flags_);
2316 s->Write<intptr_t>(offset_in_bytes_);
2317 s->Write<
const String&>(*DataAs<const String>());
2319 break;
2320 case Kind::kDartField:
2321 s->Write<
const Field&>(field());
2322 break;
2323 default:
2324 break;
2325 }
2326}
2327
2328const Slot& Slot::Read(FlowGraphDeserializer*
d) {
2329 const Kind kind =
static_cast<Kind>(
d->Read<serializable_type_t<Kind>>());
2332 const void*
data =
nullptr;
2333 CompileType
type = CompileType::None();
2335
2336 switch (kind) {
2337 case Kind::kTypeArguments:
2338 flags =
d->Read<int8_t>();
2340 data =
":type_arguments";
2341 type = CompileType::FromCid(kTypeArgumentsCid);
2342 break;
2343 case Kind::kTypeArgumentsIndex:
2345 IsImmutableBit::encode(true) |
2346 IsCompressedBit::encode(TypeArguments::ContainsCompressedPointers());
2349 type = CompileType(CompileType::kCannotBeNull,
2350 CompileType::kCannotBeSentinel, kDynamicCid, nullptr);
2351 break;
2352 case Kind::kArrayElement:
2353 flags = IsCompressedBit::encode(Array::ContainsCompressedPointers());
2355 data =
":array_element";
2356 type = CompileType::Dynamic();
2357 break;
2358 case Kind::kRecordField:
2359 flags = IsCompressedBit::encode(Record::ContainsCompressedPointers());
2361 data =
":record_field";
2362 type = CompileType::Dynamic();
2363 break;
2364 case Kind::kCapturedVariable:
2365 flags =
d->Read<int8_t>();
2367 data = &
d->Read<
const String&>();
2368 type = CompileType(
d);
2369 break;
2370 case Kind::kDartField: {
2371 const Field& field =
d->Read<
const Field&>();
2372 return Slot::Get(field, &
d->parsed_function());
2373 }
2374 default:
2375 return Slot::GetNativeSlot(kind);
2376 }
2377
2379 representation);
2380}
2381
2382template <>
2383void FlowGraphSerializer::WriteTrait<const compiler::TableSelector*>::Write(
2384 FlowGraphSerializer*
s,
2385 const compiler::TableSelector*
x) {
2386#if defined(DART_PRECOMPILER)
2388 s->Write<int32_t>(
x->id);
2389#else
2391#endif
2392}
2393
2394template <>
2395const compiler::TableSelector*
2396FlowGraphDeserializer::ReadTrait<const compiler::TableSelector*>::Read(
2397 FlowGraphDeserializer*
d) {
2398#if defined(DART_PRECOMPILER)
2399 const int32_t
id =
d->Read<int32_t>();
2400 const compiler::TableSelector* selector =
2401 Precompiler::Instance()->selector_map()->GetSelector(id);
2402 ASSERT(selector !=
nullptr);
2403 return selector;
2404#else
2406#endif
2407}
2408
2409template <intptr_t kExtraInputs>
2410void TemplateDartCall<kExtraInputs>::WriteTo(FlowGraphSerializer*
s) {
2411 VariadicDefinition::WriteTo(
s);
2412 s->Write<intptr_t>(type_args_len_);
2413 s->Write<
const Array&>(argument_names_);
2414 s->Write<TokenPosition>(token_pos_);
2415 if (move_arguments_ == nullptr) {
2416 s->Write<intptr_t>(-1);
2417 } else {
2418 s->Write<intptr_t>(move_arguments_->length());
2419
2420 for (auto move_arg : *move_arguments_) {
2421 if (move_arg->next() == nullptr) {
2422 s->Write<
bool>(
true);
2423 s->Write<Instruction*>(move_arg);
2424 } else {
2425 s->Write<
bool>(
false);
2426 }
2427 }
2428 }
2429}
2430
2431template <intptr_t kExtraInputs>
2432TemplateDartCall<kExtraInputs>::TemplateDartCall(FlowGraphDeserializer*
d)
2433 : VariadicDefinition(
d),
2434 type_args_len_(
d->
Read<intptr_t>()),
2435 argument_names_(
d->
Read<const Array&>()),
2436 token_pos_(
d->
Read<TokenPosition>()) {
2437 const intptr_t num_move_args =
d->Read<intptr_t>();
2438 if (num_move_args >= 0) {
2439 move_arguments_ =
2441 move_arguments_->EnsureLength(num_move_args, nullptr);
2442 for (intptr_t i = 0; i < num_move_args; i++) {
2443 if (
d->Read<
bool>()) {
2444 auto move_arg =
d->Read<Instruction*>()->AsMoveArgument();
2445 ASSERT(move_arg !=
nullptr);
2446 (*move_arguments_)[i] = move_arg;
2447 }
2448 }
2449 }
2450}
2451
2452template <intptr_t kExtraInputs>
2453void TemplateDartCall<kExtraInputs>::WriteExtra(FlowGraphSerializer*
s) {
2454 VariadicDefinition::WriteExtra(
s);
2455 if (move_arguments_ != nullptr) {
2456
2457
2458 for (intptr_t i = move_arguments_->length() - 1; i >= 0; --i) {
2459 auto move_arg = move_arguments_->At(i);
2460 if (move_arg->next() == nullptr) {
2461 move_arg->WriteExtra(
s);
2462 }
2463 }
2464 }
2465}
2466
2467template <intptr_t kExtraInputs>
2468void TemplateDartCall<kExtraInputs>::ReadExtra(FlowGraphDeserializer*
d) {
2469 VariadicDefinition::ReadExtra(
d);
2470 if (move_arguments_ != nullptr) {
2471 Instruction* cursor = this;
2472 for (intptr_t i = move_arguments_->length() - 1; i >= 0; --i) {
2473 if ((*move_arguments_)[i] != nullptr) {
2474 (*move_arguments_)[i]->ReadExtra(
d);
2475 } else {
2476
2477
2478 do {
2479 cursor = cursor->previous();
2480 } while (!cursor->IsMoveArgument());
2481 (*move_arguments_)[i] = cursor->AsMoveArgument();
2482 }
2483 }
2484 if (
env() !=
nullptr) {
2485 RepairArgumentUsesInEnvironment();
2486 }
2487 }
2488}
2489
2490
2491template class TemplateDartCall<0>;
2492template class TemplateDartCall<1>;
2493
2494void MoveArgumentInstr::WriteExtra(FlowGraphSerializer*
s) {
2495 TemplateDefinition::WriteExtra(
s);
2497}
2498
2499void MoveArgumentInstr::ReadExtra(FlowGraphDeserializer*
d) {
2500 TemplateDefinition::ReadExtra(
d);
2501 location_ = Location::Read(
d);
2502}
2503
2504template <>
2505void FlowGraphSerializer::WriteTrait<TokenPosition>::Write(
2506 FlowGraphSerializer*
s,
2508 s->Write<int32_t>(
x.Serialize());
2509}
2510
2511template <>
2512TokenPosition FlowGraphDeserializer::ReadTrait<TokenPosition>::Read(
2513 FlowGraphDeserializer*
d) {
2514 return TokenPosition::Deserialize(
d->Read<int32_t>());
2515}
2516
2517template <>
2518void FlowGraphSerializer::WriteTrait<uint8_t>::Write(FlowGraphSerializer*
s,
2520 s->stream()->Write<uint8_t>(
x);
2521}
2522
2523template <>
2524uint8_t FlowGraphDeserializer::ReadTrait<uint8_t>::Read(
2525 FlowGraphDeserializer*
d) {
2526 return d->stream()->Read<uint8_t>();
2527}
2528
2529template <>
2530void FlowGraphSerializer::WriteTrait<uint16_t>::Write(FlowGraphSerializer*
s,
2532 s->stream()->Write<uint16_t>(
x);
2533}
2534
2535template <>
2536uint16_t FlowGraphDeserializer::ReadTrait<uint16_t>::Read(
2537 FlowGraphDeserializer*
d) {
2538 return d->stream()->Read<uint16_t>();
2539}
2540
2541template <>
2542void FlowGraphSerializer::WriteTrait<uint32_t>::Write(FlowGraphSerializer*
s,
2544 s->stream()->Write<int32_t>(
static_cast<int32_t
>(
x));
2545}
2546
2547template <>
2548uint32_t FlowGraphDeserializer::ReadTrait<uint32_t>::Read(
2549 FlowGraphDeserializer*
d) {
2550 return static_cast<uint32_t
>(
d->stream()->Read<int32_t>());
2551}
2552
2553template <>
2554void FlowGraphSerializer::WriteTrait<uint64_t>::Write(FlowGraphSerializer*
s,
2556 s->stream()->Write<int64_t>(
static_cast<int64_t
>(
x));
2557}
2558
2559template <>
2560uint64_t FlowGraphDeserializer::ReadTrait<uint64_t>::Read(
2561 FlowGraphDeserializer*
d) {
2562 return static_cast<uint64_t
>(
d->stream()->Read<int64_t>());
2563}
2564
2565void UnboxedConstantInstr::WriteTo(FlowGraphSerializer*
s) {
2566 ConstantInstr::WriteTo(
s);
2568
2569}
2570
2571UnboxedConstantInstr::UnboxedConstantInstr(FlowGraphDeserializer*
d)
2574 constant_address_(0) {
2575 if (representation_ == kUnboxedDouble) {
2578 }
2579}
2580
2581template <>
2582void FlowGraphSerializer::WriteTrait<Value*>::Write(FlowGraphSerializer*
s,
2585 CompileType* reaching_type =
x->reaching_type();
2586 Definition* def =
x->definition();
2587
2588 if ((reaching_type != nullptr) && def->HasType() &&
2589 (reaching_type == def->Type())) {
2590 reaching_type = nullptr;
2591 }
2592 s->Write<CompileType*>(reaching_type);
2593 s->WriteRef<Definition*>(def);
2594}
2595
2596template <>
2597Value* FlowGraphDeserializer::ReadTrait<Value*>::Read(
2598 FlowGraphDeserializer*
d) {
2599 CompileType*
type =
d->Read<CompileType*>();
2600 Definition* def =
d->ReadRef<Definition*>();
2604}
2605
2606void VariadicDefinition::WriteTo(FlowGraphSerializer*
s) {
2607 Definition::WriteTo(
s);
2608 s->Write<intptr_t>(inputs_.length());
2609}
2610
2611VariadicDefinition::VariadicDefinition(FlowGraphDeserializer*
d)
2612 : Definition(
d), inputs_(
d->zone(), 0) {
2613 const intptr_t num_inputs =
d->Read<intptr_t>();
2614 inputs_.EnsureLength(num_inputs, nullptr);
2615}
2616
2617}
FlutterSemanticsFlag flags
#define HANDLES_SERIALIZABLE_AS_OBJECT(V)
#define SERIALIZE_HANDLE_AS_OBJECT(handle, null_handle)
SK_API bool Read(SkStreamSeekable *src, SkDocumentPage *dstArray, int dstArrayCount, const SkDeserialProcs *=nullptr)
bool IsDouble(const dart::Object &a)
uword FindDoubleConstant(double value)
ZoneGrowableArray< MoveArgumentInstr * > MoveArgumentsArray
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data