2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
+ #include < memory>
6
+
5
7
#include " vm/clustered_snapshot.h"
6
8
7
9
#include " platform/assert.h"
@@ -231,7 +233,8 @@ class ClassSerializationCluster : public SerializationCluster {
231
233
UnboxedFieldBitmap CalculateTargetUnboxedFieldsBitmap (Serializer* s,
232
234
intptr_t class_id) {
233
235
const auto unboxed_fields_bitmap_host =
234
- s->isolate ()->group ()->class_table ()->GetUnboxedFieldsMapAt (class_id);
236
+ s->isolate ()->group ()->shared_class_table ()->GetUnboxedFieldsMapAt (
237
+ class_id);
235
238
236
239
UnboxedFieldBitmap unboxed_fields_bitmap;
237
240
if (unboxed_fields_bitmap_host.IsEmpty () ||
@@ -349,7 +352,7 @@ class ClassDeserializationCluster : public DeserializationCluster {
349
352
}
350
353
}
351
354
352
- auto shared_class_table = d->isolate ()->group ()->class_table ();
355
+ auto shared_class_table = d->isolate ()->group ()->shared_class_table ();
353
356
for (intptr_t id = start_index_; id < stop_index_; id++) {
354
357
RawClass* cls = reinterpret_cast <RawClass*>(d->Ref (id));
355
358
Deserializer::InitializeHeader (cls, kClassCid , Class::InstanceSize ());
@@ -1201,6 +1204,10 @@ class FieldDeserializationCluster : public DeserializationCluster {
1201
1204
field.InitializeGuardedListLengthInObjectOffset ();
1202
1205
}
1203
1206
}
1207
+
1208
+ Isolate* isolate = Isolate::Current ();
1209
+ isolate->set_saved_initial_field_table (
1210
+ std::shared_ptr<FieldTable>(isolate->field_table ()->Clone ()));
1204
1211
}
1205
1212
};
1206
1213
@@ -3022,7 +3029,8 @@ class InstanceSerializationCluster : public SerializationCluster {
3022
3029
const intptr_t next_field_offset = host_next_field_offset_in_words_
3023
3030
<< kWordSizeLog2 ;
3024
3031
const auto unboxed_fields_bitmap =
3025
- s->isolate ()->group ()->class_table ()->GetUnboxedFieldsMapAt (cid_);
3032
+ s->isolate ()->group ()->shared_class_table ()->GetUnboxedFieldsMapAt (
3033
+ cid_);
3026
3034
intptr_t offset = Instance::NextFieldOffset ();
3027
3035
while (offset < next_field_offset) {
3028
3036
// Skips unboxed fields
@@ -3058,7 +3066,8 @@ class InstanceSerializationCluster : public SerializationCluster {
3058
3066
<< kWordSizeLog2 ;
3059
3067
const intptr_t count = objects_.length ();
3060
3068
const auto unboxed_fields_bitmap =
3061
- s->isolate ()->group ()->class_table ()->GetUnboxedFieldsMapAt (cid_);
3069
+ s->isolate ()->group ()->shared_class_table ()->GetUnboxedFieldsMapAt (
3070
+ cid_);
3062
3071
for (intptr_t i = 0 ; i < count; i++) {
3063
3072
RawInstance* instance = objects_[i];
3064
3073
AutoTraceObject (instance);
@@ -3116,7 +3125,8 @@ class InstanceDeserializationCluster : public DeserializationCluster {
3116
3125
Object::RoundedAllocationSize (instance_size_in_words_ * kWordSize );
3117
3126
3118
3127
const auto unboxed_fields_bitmap =
3119
- d->isolate ()->group ()->class_table ()->GetUnboxedFieldsMapAt (cid_);
3128
+ d->isolate ()->group ()->shared_class_table ()->GetUnboxedFieldsMapAt (
3129
+ cid_);
3120
3130
for (intptr_t id = start_index_; id < stop_index_; id++) {
3121
3131
RawInstance* instance = reinterpret_cast <RawInstance*>(d->Ref (id));
3122
3132
bool is_canonical = d->Read <bool >();
@@ -5521,7 +5531,7 @@ static const char* kObjectStoreFieldNames[] = {
5521
5531
#undef DECLARE_OBJECT_STORE_FIELD
5522
5532
};
5523
5533
5524
- void Serializer::WriteIsolateSnapshot (intptr_t num_base_objects,
5534
+ void Serializer::WriteProgramSnapshot (intptr_t num_base_objects,
5525
5535
ObjectStore* object_store) {
5526
5536
NoSafepointScope no_safepoint;
5527
5537
@@ -5532,7 +5542,7 @@ void Serializer::WriteIsolateSnapshot(intptr_t num_base_objects,
5532
5542
AddBaseObject (base_objects.At (i));
5533
5543
}
5534
5544
} else {
5535
- // Base objects carried over from WriteVMIsolateSnapshot .
5545
+ // Base objects carried over from WriteVMSnapshot .
5536
5546
num_base_objects_ += num_base_objects;
5537
5547
next_ref_index_ += num_base_objects;
5538
5548
}
@@ -5813,7 +5823,7 @@ void Deserializer::ReadDispatchTable() {
5813
5823
}
5814
5824
ASSERT (repeat_count == 0 );
5815
5825
5816
- I->set_dispatch_table (table);
5826
+ I->group ()-> set_dispatch_table (table);
5817
5827
#endif
5818
5828
}
5819
5829
@@ -6196,7 +6206,7 @@ void Deserializer::ReadVMSnapshot() {
6196
6206
}
6197
6207
}
6198
6208
6199
- void Deserializer::ReadIsolateSnapshot (ObjectStore* object_store) {
6209
+ void Deserializer::ReadProgramSnapshot (ObjectStore* object_store) {
6200
6210
Array& refs = Array::Handle ();
6201
6211
Prepare ();
6202
6212
@@ -6234,22 +6244,21 @@ void Deserializer::ReadIsolateSnapshot(ObjectStore* object_store) {
6234
6244
thread ()->isolate ()->class_table ()->CopySizesFromClassObjects ();
6235
6245
heap_->old_space ()->EvaluateAfterLoading ();
6236
6246
6237
- #if defined(DEBUG)
6238
6247
Isolate* isolate = thread ()->isolate ();
6248
+ #if defined(DEBUG)
6239
6249
isolate->ValidateClassTable ();
6240
6250
isolate->heap ()->Verify ();
6241
6251
#endif
6242
6252
6243
6253
for (intptr_t i = 0 ; i < num_clusters_; i++) {
6244
6254
clusters_[i]->PostLoad (refs, kind_, zone_);
6245
6255
}
6246
- object_store-> PostLoad ();
6256
+ isolate-> isolate_object_store ()-> PreallocateObjects ();
6247
6257
6248
6258
// Setup native resolver for bootstrap impl.
6249
6259
Bootstrap::SetupNativeResolver ();
6250
6260
}
6251
6261
6252
-
6253
6262
#if !defined(DART_PRECOMPILED_RUNTIME)
6254
6263
FullSnapshotWriter::FullSnapshotWriter (Snapshot::Kind kind,
6255
6264
uint8_t ** vm_snapshot_data_buffer,
@@ -6324,8 +6333,8 @@ intptr_t FullSnapshotWriter::WriteVMSnapshot() {
6324
6333
return num_objects;
6325
6334
}
6326
6335
6327
- void FullSnapshotWriter::WriteIsolateSnapshot (intptr_t num_base_objects) {
6328
- TIMELINE_DURATION (thread (), Isolate, " WriteIsolateSnapshot " );
6336
+ void FullSnapshotWriter::WriteProgramSnapshot (intptr_t num_base_objects) {
6337
+ TIMELINE_DURATION (thread (), Isolate, " WriteProgramSnapshot " );
6329
6338
6330
6339
Serializer serializer (thread (), kind_, isolate_snapshot_data_buffer_, alloc_,
6331
6340
kInitialSize , isolate_image_writer_, /* vm=*/ false ,
@@ -6344,7 +6353,7 @@ void FullSnapshotWriter::WriteIsolateSnapshot(intptr_t num_base_objects) {
6344
6353
serializer.WriteVersionAndFeatures (false );
6345
6354
// Isolate snapshot roots are:
6346
6355
// - the object store
6347
- serializer.WriteIsolateSnapshot (num_base_objects, object_store);
6356
+ serializer.WriteProgramSnapshot (num_base_objects, object_store);
6348
6357
serializer.FillHeader (serializer.kind ());
6349
6358
clustered_isolate_size_ = serializer.bytes_written ();
6350
6359
@@ -6375,7 +6384,7 @@ void FullSnapshotWriter::WriteFullSnapshot() {
6375
6384
}
6376
6385
6377
6386
if (isolate_snapshot_data_buffer () != NULL ) {
6378
- WriteIsolateSnapshot (num_base_objects);
6387
+ WriteProgramSnapshot (num_base_objects);
6379
6388
}
6380
6389
6381
6390
if (FLAG_print_snapshot_sizes) {
@@ -6538,7 +6547,7 @@ RawApiError* FullSnapshotReader::ReadVMSnapshot() {
6538
6547
return ApiError::null ();
6539
6548
}
6540
6549
6541
- RawApiError* FullSnapshotReader::ReadIsolateSnapshot () {
6550
+ RawApiError* FullSnapshotReader::ReadProgramSnapshot () {
6542
6551
SnapshotHeaderReader header_reader (kind_, buffer_, size_);
6543
6552
intptr_t offset = 0 ;
6544
6553
char * error =
@@ -6564,7 +6573,7 @@ RawApiError* FullSnapshotReader::ReadIsolateSnapshot() {
6564
6573
}
6565
6574
6566
6575
auto object_store = thread_->isolate ()->object_store ();
6567
- deserializer.ReadIsolateSnapshot (object_store);
6576
+ deserializer.ReadProgramSnapshot (object_store);
6568
6577
6569
6578
#if defined(DART_PRECOMPILED_RUNTIME)
6570
6579
if (FLAG_use_bare_instructions) {
0 commit comments