@@ -33,6 +33,10 @@ static RawObject* AllocateUninitialized(PageSpace* old_space, intptr_t size) {
33
33
return RawObject::FromAddr (address);
34
34
}
35
35
36
+ static bool SnapshotContainsTypeTestingStubs (Snapshot::Kind kind) {
37
+ return kind == Snapshot::kFullAOT || kind == Snapshot::kFullJIT ;
38
+ }
39
+
36
40
void Deserializer::InitializeHeader (RawObject* raw,
37
41
intptr_t class_id,
38
42
intptr_t size,
@@ -3058,6 +3062,8 @@ class TypeSerializationCluster : public SerializationCluster {
3058
3062
3059
3063
void WriteFill (Serializer* s) {
3060
3064
const bool is_vm_isolate = s->isolate () == Dart::vm_isolate ();
3065
+ const bool should_write_type_testing_stub =
3066
+ SnapshotContainsTypeTestingStubs (s->kind ());
3061
3067
3062
3068
intptr_t count = canonical_objects_.length ();
3063
3069
for (intptr_t i = 0 ; i < count; i++) {
@@ -3069,7 +3075,7 @@ class TypeSerializationCluster : public SerializationCluster {
3069
3075
}
3070
3076
s->WriteTokenPosition (type->ptr ()->token_pos_ );
3071
3077
s->Write <int8_t >(type->ptr ()->type_state_ );
3072
- if (s-> kind () == Snapshot:: kFullAOT ) {
3078
+ if (should_write_type_testing_stub ) {
3073
3079
RawInstructions* instr = type_testing_stubs_.LookupByAddresss (
3074
3080
type->ptr ()->type_test_stub_entry_point_ );
3075
3081
s->WriteInstructions (instr, Code::null ());
@@ -3085,7 +3091,7 @@ class TypeSerializationCluster : public SerializationCluster {
3085
3091
}
3086
3092
s->WriteTokenPosition (type->ptr ()->token_pos_ );
3087
3093
s->Write <int8_t >(type->ptr ()->type_state_ );
3088
- if (s-> kind () == Snapshot:: kFullAOT ) {
3094
+ if (should_write_type_testing_stub ) {
3089
3095
RawInstructions* instr = type_testing_stubs_.LookupByAddresss (
3090
3096
type->ptr ()->type_test_stub_entry_point_ );
3091
3097
s->WriteInstructions (instr, Code::null ());
@@ -3094,7 +3100,7 @@ class TypeSerializationCluster : public SerializationCluster {
3094
3100
3095
3101
// The dynamic/void objects are not serialized, so we manually send
3096
3102
// the type testing stub for it.
3097
- if (s-> kind () == Snapshot:: kFullAOT && is_vm_isolate) {
3103
+ if (should_write_type_testing_stub && is_vm_isolate) {
3098
3104
RawInstructions* dynamic_instr = type_testing_stubs_.LookupByAddresss (
3099
3105
Type::dynamic_type ().type_test_stub_entry_point ());
3100
3106
s->WriteInstructions (dynamic_instr, Code::null ());
@@ -3137,6 +3143,8 @@ class TypeDeserializationCluster : public DeserializationCluster {
3137
3143
3138
3144
void ReadFill (Deserializer* d) {
3139
3145
const bool is_vm_isolate = d->isolate () == Dart::vm_isolate ();
3146
+ const bool should_read_type_testing_stub =
3147
+ SnapshotContainsTypeTestingStubs (d->kind ());
3140
3148
3141
3149
for (intptr_t id = canonical_start_index_; id < canonical_stop_index_;
3142
3150
id++) {
@@ -3150,7 +3158,7 @@ class TypeDeserializationCluster : public DeserializationCluster {
3150
3158
}
3151
3159
type->ptr ()->token_pos_ = d->ReadTokenPosition ();
3152
3160
type->ptr ()->type_state_ = d->Read <int8_t >();
3153
- if (d-> kind () == Snapshot:: kFullAOT ) {
3161
+ if (should_read_type_testing_stub ) {
3154
3162
instr_ = d->ReadInstructions ();
3155
3163
type_ = type;
3156
3164
type_.SetTypeTestingStub (instr_);
@@ -3168,7 +3176,7 @@ class TypeDeserializationCluster : public DeserializationCluster {
3168
3176
}
3169
3177
type->ptr ()->token_pos_ = d->ReadTokenPosition ();
3170
3178
type->ptr ()->type_state_ = d->Read <int8_t >();
3171
- if (d-> kind () == Snapshot:: kFullAOT ) {
3179
+ if (should_read_type_testing_stub ) {
3172
3180
instr_ = d->ReadInstructions ();
3173
3181
type_ = type;
3174
3182
type_.SetTypeTestingStub (instr_);
@@ -3177,7 +3185,7 @@ class TypeDeserializationCluster : public DeserializationCluster {
3177
3185
3178
3186
// The dynamic/void objects are not serialized, so we manually send
3179
3187
// the type testing stub for it.
3180
- if (d-> kind () == Snapshot:: kFullAOT && is_vm_isolate) {
3188
+ if (should_read_type_testing_stub && is_vm_isolate) {
3181
3189
instr_ = d->ReadInstructions ();
3182
3190
Type::dynamic_type ().SetTypeTestingStub (instr_);
3183
3191
instr_ = d->ReadInstructions ();
@@ -3186,7 +3194,7 @@ class TypeDeserializationCluster : public DeserializationCluster {
3186
3194
}
3187
3195
3188
3196
void PostLoad (const Array& refs, Snapshot::Kind kind, Zone* zone) {
3189
- if (kind != Snapshot:: kFullAOT ) {
3197
+ if (! SnapshotContainsTypeTestingStubs (kind) ) {
3190
3198
for (intptr_t id = canonical_start_index_; id < canonical_stop_index_;
3191
3199
id++) {
3192
3200
type_ ^= refs.At (id);
@@ -3237,6 +3245,9 @@ class TypeRefSerializationCluster : public SerializationCluster {
3237
3245
}
3238
3246
3239
3247
void WriteFill (Serializer* s) {
3248
+ const bool should_write_type_testing_stub =
3249
+ SnapshotContainsTypeTestingStubs (s->kind ());
3250
+
3240
3251
intptr_t count = objects_.length ();
3241
3252
for (intptr_t i = 0 ; i < count; i++) {
3242
3253
RawTypeRef* type = objects_[i];
@@ -3245,7 +3256,7 @@ class TypeRefSerializationCluster : public SerializationCluster {
3245
3256
for (RawObject** p = from; p <= to; p++) {
3246
3257
s->WriteRef (*p);
3247
3258
}
3248
- if (s-> kind () == Snapshot:: kFullAOT ) {
3259
+ if (should_write_type_testing_stub ) {
3249
3260
RawInstructions* instr = type_testing_stubs_.LookupByAddresss (
3250
3261
type->ptr ()->type_test_stub_entry_point_ );
3251
3262
s->WriteInstructions (instr, Code::null ());
@@ -3276,7 +3287,9 @@ class TypeRefDeserializationCluster : public DeserializationCluster {
3276
3287
}
3277
3288
3278
3289
void ReadFill (Deserializer* d) {
3279
- bool is_vm_object = d->isolate () == Dart::vm_isolate ();
3290
+ const bool is_vm_object = d->isolate () == Dart::vm_isolate ();
3291
+ const bool should_read_type_testing_stub =
3292
+ SnapshotContainsTypeTestingStubs (d->kind ());
3280
3293
3281
3294
for (intptr_t id = start_index_; id < stop_index_; id++) {
3282
3295
RawTypeRef* type = reinterpret_cast <RawTypeRef*>(d->Ref (id));
@@ -3287,14 +3300,24 @@ class TypeRefDeserializationCluster : public DeserializationCluster {
3287
3300
for (RawObject** p = from; p <= to; p++) {
3288
3301
*p = d->ReadRef ();
3289
3302
}
3290
- if (d-> kind () == Snapshot:: kFullAOT ) {
3303
+ if (should_read_type_testing_stub ) {
3291
3304
instr_ = d->ReadInstructions ();
3292
3305
type_ = type;
3293
3306
type_.SetTypeTestingStub (instr_);
3294
3307
}
3295
3308
}
3296
3309
}
3297
3310
3311
+ void PostLoad (const Array& refs, Snapshot::Kind kind, Zone* zone) {
3312
+ if (!SnapshotContainsTypeTestingStubs (kind)) {
3313
+ for (intptr_t id = start_index_; id < stop_index_; id++) {
3314
+ type_ ^= refs.At (id);
3315
+ instr_ = TypeTestingStubGenerator::DefaultCodeForType (type_);
3316
+ type_.SetTypeTestingStub (instr_);
3317
+ }
3318
+ }
3319
+ }
3320
+
3298
3321
private:
3299
3322
AbstractType& type_;
3300
3323
Instructions& instr_;
@@ -3331,6 +3354,9 @@ class TypeParameterSerializationCluster : public SerializationCluster {
3331
3354
}
3332
3355
3333
3356
void WriteFill (Serializer* s) {
3357
+ const bool should_write_type_testing_stub =
3358
+ SnapshotContainsTypeTestingStubs (s->kind ());
3359
+
3334
3360
intptr_t count = objects_.length ();
3335
3361
for (intptr_t i = 0 ; i < count; i++) {
3336
3362
RawTypeParameter* type = objects_[i];
@@ -3343,7 +3369,7 @@ class TypeParameterSerializationCluster : public SerializationCluster {
3343
3369
s->WriteTokenPosition (type->ptr ()->token_pos_ );
3344
3370
s->Write <int16_t >(type->ptr ()->index_ );
3345
3371
s->Write <int8_t >(type->ptr ()->type_state_ );
3346
- if (s-> kind () == Snapshot:: kFullAOT ) {
3372
+ if (should_write_type_testing_stub ) {
3347
3373
RawInstructions* instr = type_testing_stubs_.LookupByAddresss (
3348
3374
type->ptr ()->type_test_stub_entry_point_ );
3349
3375
s->WriteInstructions (instr, Code::null ());
@@ -3376,6 +3402,8 @@ class TypeParameterDeserializationCluster : public DeserializationCluster {
3376
3402
3377
3403
void ReadFill (Deserializer* d) {
3378
3404
bool is_vm_object = d->isolate () == Dart::vm_isolate ();
3405
+ const bool should_read_type_testing_stub =
3406
+ SnapshotContainsTypeTestingStubs (d->kind ());
3379
3407
3380
3408
for (intptr_t id = start_index_; id < stop_index_; id++) {
3381
3409
RawTypeParameter* type = reinterpret_cast <RawTypeParameter*>(d->Ref (id));
@@ -3390,7 +3418,7 @@ class TypeParameterDeserializationCluster : public DeserializationCluster {
3390
3418
type->ptr ()->token_pos_ = d->ReadTokenPosition ();
3391
3419
type->ptr ()->index_ = d->Read <int16_t >();
3392
3420
type->ptr ()->type_state_ = d->Read <int8_t >();
3393
- if (d-> kind () == Snapshot:: kFullAOT ) {
3421
+ if (should_read_type_testing_stub ) {
3394
3422
instr_ = d->ReadInstructions ();
3395
3423
type_ = type;
3396
3424
type_.SetTypeTestingStub (instr_);
@@ -3399,7 +3427,7 @@ class TypeParameterDeserializationCluster : public DeserializationCluster {
3399
3427
}
3400
3428
3401
3429
void PostLoad (const Array& refs, Snapshot::Kind kind, Zone* zone) {
3402
- if (kind != Snapshot:: kFullAOT ) {
3430
+ if (! SnapshotContainsTypeTestingStubs (kind) ) {
3403
3431
for (intptr_t id = start_index_; id < stop_index_; id++) {
3404
3432
type_ ^= refs.At (id);
3405
3433
instr_ = TypeTestingStubGenerator::DefaultCodeForType (type_);
0 commit comments