| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #ifndef VM_SNAPSHOT_H_ | 5 #ifndef VM_SNAPSHOT_H_ |
| 6 #define VM_SNAPSHOT_H_ | 6 #define VM_SNAPSHOT_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
| 10 #include "vm/bitfield.h" | 10 #include "vm/bitfield.h" |
| 11 #include "vm/globals.h" | 11 #include "vm/globals.h" |
| 12 #include "vm/growable_array.h" | 12 #include "vm/growable_array.h" |
| 13 #include "vm/isolate.h" | 13 #include "vm/isolate.h" |
| 14 #include "vm/visitor.h" | 14 #include "vm/visitor.h" |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 | 17 |
| 18 // Forward declarations. | 18 // Forward declarations. |
| 19 class AbstractType; | 19 class AbstractType; |
| 20 class AbstractTypeArguments; | 20 class AbstractTypeArguments; |
| 21 class Class; | 21 class Class; |
| 22 class Heap; | 22 class Heap; |
| 23 class Library; | 23 class Library; |
| 24 class Object; | 24 class Object; |
| 25 class ObjectStore; | 25 class ObjectStore; |
| 26 class RawArray; |
| 26 class RawClass; | 27 class RawClass; |
| 28 class RawContext; |
| 29 class RawDouble; |
| 30 class RawField; |
| 31 class RawFourByteString; |
| 32 class RawFunction; |
| 33 class RawImmutableArray; |
| 34 class RawLibrary; |
| 35 class RawLibraryPrefix; |
| 36 class RawMint; |
| 27 class RawObject; | 37 class RawObject; |
| 38 class RawOneByteString; |
| 39 class RawScript; |
| 40 class RawTokenStream; |
| 41 class RawType; |
| 42 class RawTypeParameter; |
| 43 class RawTypeArguments; |
| 44 class RawTwoByteString; |
| 45 class RawUnresolvedClass; |
| 28 class String; | 46 class String; |
| 29 | 47 |
| 30 static const int8_t kSerializedBitsPerByte = 7; | 48 static const int8_t kSerializedBitsPerByte = 7; |
| 31 static const int8_t kMaxSerializedUnsignedValuePerByte = 127; | 49 static const int8_t kMaxSerializedUnsignedValuePerByte = 127; |
| 32 static const int8_t kMaxSerializedValuePerByte = 63; | 50 static const int8_t kMaxSerializedValuePerByte = 63; |
| 33 static const int8_t kMinSerializedValuePerByte = -64; | 51 static const int8_t kMinSerializedValuePerByte = -64; |
| 34 static const uint8_t kEndByteMarker = (255 - kMaxSerializedValuePerByte); | 52 static const uint8_t kEndByteMarker = (255 - kMaxSerializedValuePerByte); |
| 35 static const int8_t kSerializedByteMask = (1 << kSerializedBitsPerByte) - 1; | 53 static const int8_t kSerializedByteMask = (1 << kSerializedBitsPerByte) - 1; |
| 36 | 54 |
| 37 // Serialized object header encoding is as follows: | 55 // Serialized object header encoding is as follows: |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 RawObject* ReadObject(); | 330 RawObject* ReadObject(); |
| 313 | 331 |
| 314 RawClass* ReadClassId(intptr_t object_id); | 332 RawClass* ReadClassId(intptr_t object_id); |
| 315 | 333 |
| 316 // Add object to backward references. | 334 // Add object to backward references. |
| 317 void AddBackwardReference(intptr_t id, Object* obj); | 335 void AddBackwardReference(intptr_t id, Object* obj); |
| 318 | 336 |
| 319 // Read a full snap shot. | 337 // Read a full snap shot. |
| 320 void ReadFullSnapshot(); | 338 void ReadFullSnapshot(); |
| 321 | 339 |
| 340 // Helper functions for creating uninitialized versions |
| 341 // of various object types. These are used when reading a |
| 342 // full snapshot. |
| 343 RawArray* NewArray(intptr_t len); |
| 344 RawImmutableArray* NewImmutableArray(intptr_t len); |
| 345 RawOneByteString* NewOneByteString(intptr_t len); |
| 346 RawTwoByteString* NewTwoByteString(intptr_t len); |
| 347 RawFourByteString* NewFourByteString(intptr_t len); |
| 348 RawTypeArguments* NewTypeArguments(intptr_t len); |
| 349 RawTokenStream* NewTokenStream(intptr_t len); |
| 350 RawContext* NewContext(intptr_t num_variables); |
| 351 RawClass* NewClass(int value); |
| 352 RawMint* NewMint(int64_t value); |
| 353 RawDouble* NewDouble(double value); |
| 354 RawUnresolvedClass* NewUnresolvedClass(); |
| 355 RawType* NewType(); |
| 356 RawTypeParameter* NewTypeParameter(); |
| 357 RawFunction* NewFunction(); |
| 358 RawField* NewField(); |
| 359 RawLibrary* NewLibrary(); |
| 360 RawLibraryPrefix* NewLibraryPrefix(); |
| 361 RawScript* NewScript(); |
| 362 |
| 322 private: | 363 private: |
| 364 // Allocate uninitialized objects, this is used when reading a full snapshot. |
| 365 RawObject* AllocateUninitialized(const Class& cls, intptr_t size); |
| 366 |
| 323 // Internal implementation of ReadObject once the header value is read. | 367 // Internal implementation of ReadObject once the header value is read. |
| 324 RawObject* ReadObjectImpl(intptr_t header); | 368 RawObject* ReadObjectImpl(intptr_t header); |
| 325 | 369 |
| 326 // Read an object that was serialized as an Id (singleton, object store, | 370 // Read an object that was serialized as an Id (singleton, object store, |
| 327 // or an object that was already serialized before). | 371 // or an object that was already serialized before). |
| 328 RawObject* ReadIndexedObject(intptr_t object_id); | 372 RawObject* ReadIndexedObject(intptr_t object_id); |
| 329 | 373 |
| 330 // Read an inlined object from the stream. | 374 // Read an inlined object from the stream. |
| 331 RawObject* ReadInlinedObject(intptr_t object_id); | 375 RawObject* ReadInlinedObject(intptr_t object_id); |
| 332 | 376 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 | 560 |
| 517 private: | 561 private: |
| 518 SnapshotWriter* writer_; | 562 SnapshotWriter* writer_; |
| 519 | 563 |
| 520 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); | 564 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); |
| 521 }; | 565 }; |
| 522 | 566 |
| 523 } // namespace dart | 567 } // namespace dart |
| 524 | 568 |
| 525 #endif // VM_SNAPSHOT_H_ | 569 #endif // VM_SNAPSHOT_H_ |
| OLD | NEW |