@@ -1424,9 +1424,7 @@ class FieldSerializationCluster : public SerializationCluster {
14241424 }
14251425 // Write out either the initial static value or field offset.
14261426 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 ());
14301428 } else {
14311429 s->Push (Smi::New (Field::TargetOffsetOf (field)));
14321430 }
@@ -1472,10 +1470,7 @@ class FieldSerializationCluster : public SerializationCluster {
14721470
14731471 // Write out either the initial static value or field offset.
14741472 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 ());
14791474 } else {
14801475 WriteFieldValue (" offset" , Smi::New (Field::TargetOffsetOf (field)));
14811476 }
@@ -1535,20 +1530,12 @@ class FieldDeserializationCluster : public DeserializationCluster {
15351530#endif
15361531 field->untag ()->kind_bits_ = d.Read <uint16_t >();
15371532
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 ());
15471535#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 ());
15501538#endif // !defined(DART_PRECOMPILED_RUNTIME)
1551- }
15521539 }
15531540 }
15541541
@@ -6019,6 +6006,12 @@ class ProgramSerializationRoots : public SerializationRoots {
60196006 s->Push (*p);
60206007 }
60216008
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+
60226015 dispatch_table_entries_ = object_store_->dispatch_table_code_entries ();
60236016 // We should only have a dispatch table in precompiled mode.
60246017 ASSERT (dispatch_table_entries_.IsNull () || s->kind () == Snapshot::kFullAOT );
@@ -6043,6 +6036,14 @@ class ProgramSerializationRoots : public SerializationRoots {
60436036 s->WriteRootRef (*p, kObjectStoreFieldNames [p - from]);
60446037 }
60456038
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+
60466047 // The dispatch table is serialized only for precompiled snapshots.
60476048 s->WriteDispatchTable (dispatch_table_entries_);
60486049 }
@@ -6087,6 +6088,14 @@ class ProgramDeserializationRoots : public DeserializationRoots {
60876088 *p = d->ReadRef ();
60886089 }
60896090
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+
60906099 // Deserialize dispatch table (when applicable)
60916100 d->ReadDispatchTable ();
60926101 }
@@ -6303,7 +6312,6 @@ Serializer::Serializer(Thread* thread,
63036312 num_base_objects_(0 ),
63046313 num_written_objects_(0 ),
63056314 next_ref_index_(kFirstReference ),
6306- initial_field_table_(thread->isolate_group ()->initial_field_table()),
63076315 vm_(vm),
63086316 profile_writer_(profile_writer)
63096317#if defined(SNAPSHOT_BACKTRACE)
@@ -7508,12 +7516,6 @@ ZoneGrowableArray<Object*>* Serializer::Serialize(SerializationRoots* roots) {
75087516 WriteUnsigned (num_base_objects_);
75097517 WriteUnsigned (num_objects);
75107518 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- }
75177519 ASSERT ((instructions_table_len_ == 0 ) || FLAG_precompiled_mode);
75187520 WriteUnsigned (instructions_table_len_);
75197521 WriteUnsigned (instructions_table_rodata_offset_);
@@ -7800,7 +7802,6 @@ Deserializer::Deserializer(Thread* thread,
78007802 refs_(nullptr ),
78017803 next_ref_index_(kFirstReference ),
78027804 clusters_(nullptr ),
7803- initial_field_table_(thread->isolate_group ()->initial_field_table()),
78047805 is_non_root_unit_(is_non_root_unit),
78057806 instructions_table_(InstructionsTable::Handle(thread->zone ())) {
78067807 if (Snapshot::IncludesCode (kind)) {
@@ -8316,17 +8317,12 @@ void Deserializer::Deserialize(DeserializationRoots* roots) {
83168317 num_base_objects_ = ReadUnsigned ();
83178318 num_objects_ = ReadUnsigned ();
83188319 num_clusters_ = ReadUnsigned ();
8319- const intptr_t initial_field_table_len = ReadUnsigned ();
83208320 const intptr_t instructions_table_len = ReadUnsigned ();
83218321 const uint32_t instruction_table_data_offset = ReadUnsigned ();
83228322 USE (instruction_table_data_offset);
83238323
83248324 clusters_ = new DeserializationCluster*[num_clusters_];
83258325 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- }
83308326
83318327#if defined(DART_PRECOMPILED_RUNTIME)
83328328 if (instructions_table_len > 0 ) {
0 commit comments