OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/clustered_snapshot.h" | 5 #include "vm/clustered_snapshot.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/bootstrap.h" | 8 #include "vm/bootstrap.h" |
9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
(...skipping 3260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3271 RawObject** from = bigint->from(); | 3271 RawObject** from = bigint->from(); |
3272 RawObject** to = bigint->to(); | 3272 RawObject** to = bigint->to(); |
3273 for (RawObject** p = from; p <= to; p++) { | 3273 for (RawObject** p = from; p <= to; p++) { |
3274 *p = d->ReadRef(); | 3274 *p = d->ReadRef(); |
3275 } | 3275 } |
3276 } | 3276 } |
3277 } | 3277 } |
3278 }; | 3278 }; |
3279 | 3279 |
3280 | 3280 |
| 3281 class FractionSerializationCluster : public SerializationCluster { |
| 3282 public: |
| 3283 FractionSerializationCluster() { } |
| 3284 virtual ~FractionSerializationCluster() { } |
| 3285 |
| 3286 void Trace(Serializer* s, RawObject* object) { |
| 3287 RawFraction* fraction = Fraction::RawCast(object); |
| 3288 objects_.Add(fraction); |
| 3289 |
| 3290 RawObject** from = fraction->from(); |
| 3291 RawObject** to = fraction->to(); |
| 3292 for (RawObject** p = from; p <= to; p++) { |
| 3293 s->Push(*p); |
| 3294 } |
| 3295 } |
| 3296 |
| 3297 void WriteAlloc(Serializer* s) { |
| 3298 s->WriteCid(kFractionCid); |
| 3299 intptr_t count = objects_.length(); |
| 3300 s->Write<intptr_t>(count); |
| 3301 for (intptr_t i = 0; i < count; i++) { |
| 3302 RawFraction* fraction = objects_[i]; |
| 3303 s->AssignRef(fraction); |
| 3304 } |
| 3305 } |
| 3306 |
| 3307 void WriteFill(Serializer* s) { |
| 3308 intptr_t count = objects_.length(); |
| 3309 for (intptr_t i = 0; i < count; i++) { |
| 3310 RawFraction* fraction = objects_[i]; |
| 3311 s->Write<bool>(fraction->IsCanonical()); |
| 3312 RawObject** from = fraction->from(); |
| 3313 RawObject** to = fraction->to(); |
| 3314 for (RawObject** p = from; p <= to; p++) { |
| 3315 s->WriteRef(*p); |
| 3316 } |
| 3317 } |
| 3318 } |
| 3319 |
| 3320 private: |
| 3321 GrowableArray<RawFraction*> objects_; |
| 3322 }; |
| 3323 |
| 3324 |
| 3325 class FractionDeserializationCluster : public DeserializationCluster { |
| 3326 public: |
| 3327 FractionDeserializationCluster() { } |
| 3328 virtual ~FractionDeserializationCluster() { } |
| 3329 |
| 3330 void ReadAlloc(Deserializer* d) { |
| 3331 start_index_ = d->next_index(); |
| 3332 PageSpace* old_space = d->heap()->old_space(); |
| 3333 intptr_t count = d->Read<intptr_t>(); |
| 3334 for (intptr_t i = 0; i < count; i++) { |
| 3335 d->AssignRef(AllocateUninitialized(old_space, Fraction::InstanceSize())); |
| 3336 } |
| 3337 stop_index_ = d->next_index(); |
| 3338 } |
| 3339 |
| 3340 void ReadFill(Deserializer* d) { |
| 3341 bool is_vm_object = d->isolate() == Dart::vm_isolate(); |
| 3342 |
| 3343 for (intptr_t id = start_index_; id < stop_index_; id++) { |
| 3344 RawFraction* fraction = reinterpret_cast<RawFraction*>(d->Ref(id)); |
| 3345 bool is_canonical = d->Read<bool>(); |
| 3346 Deserializer::InitializeHeader(fraction, kFractionCid, |
| 3347 Fraction::InstanceSize(), |
| 3348 is_vm_object, is_canonical); |
| 3349 RawObject** from = fraction->from(); |
| 3350 RawObject** to = fraction->to(); |
| 3351 for (RawObject** p = from; p <= to; p++) { |
| 3352 *p = d->ReadRef(); |
| 3353 } |
| 3354 } |
| 3355 } |
| 3356 }; |
| 3357 |
| 3358 |
3281 class DoubleSerializationCluster : public SerializationCluster { | 3359 class DoubleSerializationCluster : public SerializationCluster { |
3282 public: | 3360 public: |
3283 DoubleSerializationCluster() { } | 3361 DoubleSerializationCluster() { } |
3284 virtual ~DoubleSerializationCluster() { } | 3362 virtual ~DoubleSerializationCluster() { } |
3285 | 3363 |
3286 void Trace(Serializer* s, RawObject* object) { | 3364 void Trace(Serializer* s, RawObject* object) { |
3287 RawDouble* dbl = Double::RawCast(object); | 3365 RawDouble* dbl = Double::RawCast(object); |
3288 objects_.Add(dbl); | 3366 objects_.Add(dbl); |
3289 } | 3367 } |
3290 | 3368 |
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4191 case kUnhandledExceptionCid: | 4269 case kUnhandledExceptionCid: |
4192 return new (Z) UnhandledExceptionSerializationCluster(); | 4270 return new (Z) UnhandledExceptionSerializationCluster(); |
4193 case kLibraryPrefixCid: return new (Z) LibraryPrefixSerializationCluster(); | 4271 case kLibraryPrefixCid: return new (Z) LibraryPrefixSerializationCluster(); |
4194 case kTypeCid: return new (Z) TypeSerializationCluster(); | 4272 case kTypeCid: return new (Z) TypeSerializationCluster(); |
4195 case kTypeRefCid: return new (Z) TypeRefSerializationCluster(); | 4273 case kTypeRefCid: return new (Z) TypeRefSerializationCluster(); |
4196 case kTypeParameterCid: return new (Z) TypeParameterSerializationCluster(); | 4274 case kTypeParameterCid: return new (Z) TypeParameterSerializationCluster(); |
4197 case kBoundedTypeCid: return new (Z) BoundedTypeSerializationCluster(); | 4275 case kBoundedTypeCid: return new (Z) BoundedTypeSerializationCluster(); |
4198 case kClosureCid: return new (Z) ClosureSerializationCluster(); | 4276 case kClosureCid: return new (Z) ClosureSerializationCluster(); |
4199 case kMintCid: return new (Z) MintSerializationCluster(); | 4277 case kMintCid: return new (Z) MintSerializationCluster(); |
4200 case kBigintCid: return new (Z) BigintSerializationCluster(); | 4278 case kBigintCid: return new (Z) BigintSerializationCluster(); |
| 4279 case kFractionCid: return new (Z) FractionSerializationCluster(); |
4201 case kDoubleCid: return new (Z) DoubleSerializationCluster(); | 4280 case kDoubleCid: return new (Z) DoubleSerializationCluster(); |
4202 case kGrowableObjectArrayCid: | 4281 case kGrowableObjectArrayCid: |
4203 return new (Z) GrowableObjectArraySerializationCluster(); | 4282 return new (Z) GrowableObjectArraySerializationCluster(); |
4204 case kStacktraceCid: return new (Z) StacktraceSerializationCluster(); | 4283 case kStacktraceCid: return new (Z) StacktraceSerializationCluster(); |
4205 case kRegExpCid: return new (Z) RegExpSerializationCluster(); | 4284 case kRegExpCid: return new (Z) RegExpSerializationCluster(); |
4206 case kLinkedHashMapCid: return new (Z) LinkedHashMapSerializationCluster(); | 4285 case kLinkedHashMapCid: return new (Z) LinkedHashMapSerializationCluster(); |
4207 case kArrayCid: | 4286 case kArrayCid: |
4208 return new (Z) ArraySerializationCluster(kArrayCid); | 4287 return new (Z) ArraySerializationCluster(kArrayCid); |
4209 case kImmutableArrayCid: | 4288 case kImmutableArrayCid: |
4210 return new (Z) ArraySerializationCluster(kImmutableArrayCid); | 4289 return new (Z) ArraySerializationCluster(kImmutableArrayCid); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4514 case kLibraryPrefixCid: | 4593 case kLibraryPrefixCid: |
4515 return new (Z) LibraryPrefixDeserializationCluster(); | 4594 return new (Z) LibraryPrefixDeserializationCluster(); |
4516 case kTypeCid: return new (Z) TypeDeserializationCluster(); | 4595 case kTypeCid: return new (Z) TypeDeserializationCluster(); |
4517 case kTypeRefCid: return new (Z) TypeRefDeserializationCluster(); | 4596 case kTypeRefCid: return new (Z) TypeRefDeserializationCluster(); |
4518 case kTypeParameterCid: | 4597 case kTypeParameterCid: |
4519 return new (Z) TypeParameterDeserializationCluster(); | 4598 return new (Z) TypeParameterDeserializationCluster(); |
4520 case kBoundedTypeCid: return new (Z) BoundedTypeDeserializationCluster(); | 4599 case kBoundedTypeCid: return new (Z) BoundedTypeDeserializationCluster(); |
4521 case kClosureCid: return new (Z) ClosureDeserializationCluster(); | 4600 case kClosureCid: return new (Z) ClosureDeserializationCluster(); |
4522 case kMintCid: return new (Z) MintDeserializationCluster(); | 4601 case kMintCid: return new (Z) MintDeserializationCluster(); |
4523 case kBigintCid: return new (Z) BigintDeserializationCluster(); | 4602 case kBigintCid: return new (Z) BigintDeserializationCluster(); |
| 4603 case kFractionCid: return new (Z) FractionDeserializationCluster(); |
4524 case kDoubleCid: return new (Z) DoubleDeserializationCluster(); | 4604 case kDoubleCid: return new (Z) DoubleDeserializationCluster(); |
4525 case kGrowableObjectArrayCid: | 4605 case kGrowableObjectArrayCid: |
4526 return new (Z) GrowableObjectArrayDeserializationCluster(); | 4606 return new (Z) GrowableObjectArrayDeserializationCluster(); |
4527 case kStacktraceCid: return new (Z) StacktraceDeserializationCluster(); | 4607 case kStacktraceCid: return new (Z) StacktraceDeserializationCluster(); |
4528 case kRegExpCid: return new (Z) RegExpDeserializationCluster(); | 4608 case kRegExpCid: return new (Z) RegExpDeserializationCluster(); |
4529 case kLinkedHashMapCid: | 4609 case kLinkedHashMapCid: |
4530 return new (Z) LinkedHashMapDeserializationCluster(); | 4610 return new (Z) LinkedHashMapDeserializationCluster(); |
4531 case kArrayCid: | 4611 case kArrayCid: |
4532 return new (Z) ArrayDeserializationCluster(kArrayCid); | 4612 return new (Z) ArrayDeserializationCluster(kArrayCid); |
4533 case kImmutableArrayCid: | 4613 case kImmutableArrayCid: |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5033 | 5113 |
5034 deserializer.ReadVMSnapshot(); | 5114 deserializer.ReadVMSnapshot(); |
5035 | 5115 |
5036 Dart::set_instructions_snapshot_buffer(instructions_buffer_); | 5116 Dart::set_instructions_snapshot_buffer(instructions_buffer_); |
5037 Dart::set_data_snapshot_buffer(data_buffer_); | 5117 Dart::set_data_snapshot_buffer(data_buffer_); |
5038 | 5118 |
5039 return ApiError::null(); | 5119 return ApiError::null(); |
5040 } | 5120 } |
5041 | 5121 |
5042 } // namespace dart | 5122 } // namespace dart |
OLD | NEW |