@@ -144,6 +144,40 @@ void SerializationCluster::WriteAndMeasureFill(Serializer* serializer) {
144
144
size_ += (stop - start);
145
145
}
146
146
147
+ static UnboxedFieldBitmap CalculateTargetUnboxedFieldsBitmap (
148
+ Serializer* s,
149
+ intptr_t class_id) {
150
+ const auto unboxed_fields_bitmap_host =
151
+ s->isolate ()->group ()->shared_class_table ()->GetUnboxedFieldsMapAt (
152
+ class_id);
153
+
154
+ UnboxedFieldBitmap unboxed_fields_bitmap;
155
+ if (unboxed_fields_bitmap_host.IsEmpty () ||
156
+ kWordSize == compiler::target::kWordSize ) {
157
+ unboxed_fields_bitmap = unboxed_fields_bitmap_host;
158
+ } else {
159
+ ASSERT (kWordSize == 8 && compiler::target::kWordSize == 4 );
160
+ // A new bitmap is built if the word sizes in the target and
161
+ // host are different
162
+ unboxed_fields_bitmap.Reset ();
163
+ intptr_t target_i = 0 , host_i = 0 ;
164
+
165
+ while (host_i < UnboxedFieldBitmap::Length ()) {
166
+ // Each unboxed field has constant length, therefore the number of
167
+ // words used by it should double when compiling from 64-bit to 32-bit.
168
+ if (unboxed_fields_bitmap_host.Get (host_i++)) {
169
+ unboxed_fields_bitmap.Set (target_i++);
170
+ unboxed_fields_bitmap.Set (target_i++);
171
+ } else {
172
+ // For object pointers, the field is always one word length
173
+ target_i++;
174
+ }
175
+ }
176
+ }
177
+
178
+ return unboxed_fields_bitmap;
179
+ }
180
+
147
181
class ClassSerializationCluster : public SerializationCluster {
148
182
public:
149
183
explicit ClassSerializationCluster (intptr_t num_cids)
@@ -236,39 +270,6 @@ class ClassSerializationCluster : public SerializationCluster {
236
270
GrowableArray<ClassPtr> predefined_;
237
271
GrowableArray<ClassPtr> objects_;
238
272
239
- UnboxedFieldBitmap CalculateTargetUnboxedFieldsBitmap (Serializer* s,
240
- intptr_t class_id) {
241
- const auto unboxed_fields_bitmap_host =
242
- s->isolate ()->group ()->shared_class_table ()->GetUnboxedFieldsMapAt (
243
- class_id);
244
-
245
- UnboxedFieldBitmap unboxed_fields_bitmap;
246
- if (unboxed_fields_bitmap_host.IsEmpty () ||
247
- kWordSize == compiler::target::kWordSize ) {
248
- unboxed_fields_bitmap = unboxed_fields_bitmap_host;
249
- } else {
250
- ASSERT (kWordSize == 8 && compiler::target::kWordSize == 4 );
251
- // A new bitmap is built if the word sizes in the target and
252
- // host are different
253
- unboxed_fields_bitmap.Reset ();
254
- intptr_t target_i = 0 , host_i = 0 ;
255
-
256
- while (host_i < UnboxedFieldBitmap::Length ()) {
257
- // Each unboxed field has constant length, therefore the number of
258
- // words used by it should double when compiling from 64-bit to 32-bit.
259
- if (unboxed_fields_bitmap_host.Get (host_i++)) {
260
- unboxed_fields_bitmap.Set (target_i++);
261
- unboxed_fields_bitmap.Set (target_i++);
262
- } else {
263
- // For object pointers, the field is always one word length
264
- target_i++;
265
- }
266
- }
267
- }
268
-
269
- return unboxed_fields_bitmap;
270
- }
271
-
272
273
bool RequireLegacyErasureOfConstants (ClassPtr cls) {
273
274
// Do not generate a core snapshot containing constants that would require
274
275
// a legacy erasure of their types if loaded in an isolate running in weak
@@ -3349,9 +3350,11 @@ class InstanceSerializationCluster : public SerializationCluster {
3349
3350
intptr_t next_field_offset = host_next_field_offset_in_words_
3350
3351
<< kWordSizeLog2 ;
3351
3352
const intptr_t count = objects_.length ();
3353
+ s->WriteUnsigned64 (CalculateTargetUnboxedFieldsBitmap (s, cid_).Value ());
3352
3354
const auto unboxed_fields_bitmap =
3353
3355
s->isolate ()->group ()->shared_class_table ()->GetUnboxedFieldsMapAt (
3354
3356
cid_);
3357
+
3355
3358
for (intptr_t i = 0 ; i < count; i++) {
3356
3359
InstancePtr instance = objects_[i];
3357
3360
AutoTraceObject (instance);
@@ -3407,10 +3410,8 @@ class InstanceDeserializationCluster : public DeserializationCluster {
3407
3410
intptr_t next_field_offset = next_field_offset_in_words_ << kWordSizeLog2 ;
3408
3411
intptr_t instance_size =
3409
3412
Object::RoundedAllocationSize (instance_size_in_words_ * kWordSize );
3413
+ const UnboxedFieldBitmap unboxed_fields_bitmap (d->ReadUnsigned64 ());
3410
3414
3411
- const auto unboxed_fields_bitmap =
3412
- d->isolate ()->group ()->shared_class_table ()->GetUnboxedFieldsMapAt (
3413
- cid_);
3414
3415
for (intptr_t id = start_index_; id < stop_index_; id++) {
3415
3416
InstancePtr instance = static_cast <InstancePtr>(d->Ref (id));
3416
3417
bool is_canonical = d->Read <bool >();
0 commit comments