@@ -1424,9 +1424,7 @@ class FieldSerializationCluster : public SerializationCluster {
1424
1424
}
1425
1425
// Write out either the initial static value or field offset.
1426
1426
if (Field::StaticBit::decode(field->untag()->kind_bits_)) {
1427
- const intptr_t field_id =
1428
- Smi::Value(field->untag()->host_offset_or_field_id());
1429
- s->Push(s->initial_field_table()->At(field_id));
1427
+ s->Push(field->untag()->host_offset_or_field_id());
1430
1428
} else {
1431
1429
s->Push(Smi::New(Field::TargetOffsetOf(field)));
1432
1430
}
@@ -1472,10 +1470,7 @@ class FieldSerializationCluster : public SerializationCluster {
1472
1470
1473
1471
// Write out either the initial static value or field offset.
1474
1472
if (Field::StaticBit::decode(field->untag()->kind_bits_)) {
1475
- const intptr_t field_id =
1476
- Smi::Value(field->untag()->host_offset_or_field_id());
1477
- WriteFieldValue("static value", s->initial_field_table()->At(field_id));
1478
- s->WriteUnsigned(field_id);
1473
+ WriteFieldValue("id", field->untag()->host_offset_or_field_id());
1479
1474
} else {
1480
1475
WriteFieldValue("offset", Smi::New(Field::TargetOffsetOf(field)));
1481
1476
}
@@ -1535,20 +1530,12 @@ class FieldDeserializationCluster : public DeserializationCluster {
1535
1530
#endif
1536
1531
field->untag()->kind_bits_ = d.Read<uint16_t>();
1537
1532
1538
- ObjectPtr value_or_offset = d.ReadRef();
1539
- if (Field::StaticBit::decode(field->untag()->kind_bits_)) {
1540
- const intptr_t field_id = d.ReadUnsigned();
1541
- d_->initial_field_table()->SetAt(
1542
- field_id, static_cast<InstancePtr>(value_or_offset));
1543
- field->untag()->host_offset_or_field_id_ = Smi::New(field_id);
1544
- } else {
1545
- field->untag()->host_offset_or_field_id_ =
1546
- Smi::RawCast(value_or_offset);
1533
+ field->untag()->host_offset_or_field_id_ =
1534
+ static_cast<SmiPtr>(d.ReadRef());
1547
1535
#if !defined(DART_PRECOMPILED_RUNTIME)
1548
- field->untag()->target_offset_ =
1549
- Smi::Value(field->untag()->host_offset_or_field_id());
1536
+ field->untag()->target_offset_ =
1537
+ Smi::Value(field->untag()->host_offset_or_field_id());
1550
1538
#endif // !defined(DART_PRECOMPILED_RUNTIME)
1551
- }
1552
1539
}
1553
1540
}
1554
1541
@@ -6019,6 +6006,12 @@ class ProgramSerializationRoots : public SerializationRoots {
6019
6006
s->Push(*p);
6020
6007
}
6021
6008
6009
+ FieldTable* initial_field_table =
6010
+ s->thread()->isolate_group()->initial_field_table();
6011
+ for (intptr_t i = 0, n = initial_field_table->NumFieldIds(); i < n; i++) {
6012
+ s->Push(initial_field_table->At(i));
6013
+ }
6014
+
6022
6015
dispatch_table_entries_ = object_store_->dispatch_table_code_entries();
6023
6016
// We should only have a dispatch table in precompiled mode.
6024
6017
ASSERT(dispatch_table_entries_.IsNull() || s->kind() == Snapshot::kFullAOT);
@@ -6043,6 +6036,14 @@ class ProgramSerializationRoots : public SerializationRoots {
6043
6036
s->WriteRootRef(*p, kObjectStoreFieldNames[p - from]);
6044
6037
}
6045
6038
6039
+ FieldTable* initial_field_table =
6040
+ s->thread()->isolate_group()->initial_field_table();
6041
+ intptr_t n = initial_field_table->NumFieldIds();
6042
+ s->WriteUnsigned(n);
6043
+ for (intptr_t i = 0; i < n; i++) {
6044
+ s->WriteRootRef(initial_field_table->At(i), "some-static-field");
6045
+ }
6046
+
6046
6047
// The dispatch table is serialized only for precompiled snapshots.
6047
6048
s->WriteDispatchTable(dispatch_table_entries_);
6048
6049
}
@@ -6087,6 +6088,14 @@ class ProgramDeserializationRoots : public DeserializationRoots {
6087
6088
*p = d->ReadRef();
6088
6089
}
6089
6090
6091
+ FieldTable* initial_field_table =
6092
+ d->thread()->isolate_group()->initial_field_table();
6093
+ intptr_t n = d->ReadUnsigned();
6094
+ initial_field_table->AllocateIndex(n - 1);
6095
+ for (intptr_t i = 0; i < n; i++) {
6096
+ initial_field_table->SetAt(i, d->ReadRef());
6097
+ }
6098
+
6090
6099
// Deserialize dispatch table (when applicable)
6091
6100
d->ReadDispatchTable();
6092
6101
}
@@ -6303,7 +6312,6 @@ Serializer::Serializer(Thread* thread,
6303
6312
num_base_objects_(0),
6304
6313
num_written_objects_(0),
6305
6314
next_ref_index_(kFirstReference),
6306
- initial_field_table_(thread->isolate_group()->initial_field_table()),
6307
6315
vm_(vm),
6308
6316
profile_writer_(profile_writer)
6309
6317
#if defined(SNAPSHOT_BACKTRACE)
@@ -7508,12 +7516,6 @@ ZoneGrowableArray<Object*>* Serializer::Serialize(SerializationRoots* roots) {
7508
7516
WriteUnsigned(num_base_objects_);
7509
7517
WriteUnsigned(num_objects);
7510
7518
WriteUnsigned(clusters.length());
7511
- // TODO(dartbug.com/36097): Not every snapshot carries the field table.
7512
- if (current_loading_unit_id_ <= LoadingUnit::kRootId) {
7513
- WriteUnsigned(initial_field_table_->NumFieldIds());
7514
- } else {
7515
- WriteUnsigned(0);
7516
- }
7517
7519
ASSERT((instructions_table_len_ == 0) || FLAG_precompiled_mode);
7518
7520
WriteUnsigned(instructions_table_len_);
7519
7521
WriteUnsigned(instructions_table_rodata_offset_);
@@ -7800,7 +7802,6 @@ Deserializer::Deserializer(Thread* thread,
7800
7802
refs_(nullptr),
7801
7803
next_ref_index_(kFirstReference),
7802
7804
clusters_(nullptr),
7803
- initial_field_table_(thread->isolate_group()->initial_field_table()),
7804
7805
is_non_root_unit_(is_non_root_unit),
7805
7806
instructions_table_(InstructionsTable::Handle(thread->zone())) {
7806
7807
if (Snapshot::IncludesCode(kind)) {
@@ -8316,17 +8317,12 @@ void Deserializer::Deserialize(DeserializationRoots* roots) {
8316
8317
num_base_objects_ = ReadUnsigned();
8317
8318
num_objects_ = ReadUnsigned();
8318
8319
num_clusters_ = ReadUnsigned();
8319
- const intptr_t initial_field_table_len = ReadUnsigned();
8320
8320
const intptr_t instructions_table_len = ReadUnsigned();
8321
8321
const uint32_t instruction_table_data_offset = ReadUnsigned();
8322
8322
USE(instruction_table_data_offset);
8323
8323
8324
8324
clusters_ = new DeserializationCluster*[num_clusters_];
8325
8325
refs = Array::New(num_objects_ + kFirstReference, Heap::kOld);
8326
- if (initial_field_table_len > 0) {
8327
- initial_field_table_->AllocateIndex(initial_field_table_len - 1);
8328
- ASSERT_EQUAL(initial_field_table_->NumFieldIds(), initial_field_table_len);
8329
- }
8330
8326
8331
8327
#if defined(DART_PRECOMPILED_RUNTIME)
8332
8328
if (instructions_table_len > 0) {
0 commit comments