Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, 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 "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/assert.h" | 9 #include "vm/assert.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 Array; | |
| 21 class Class; | 22 class Class; |
| 23 class Context; | |
| 24 class Double; | |
| 25 class FourByteString; | |
| 22 class Heap; | 26 class Heap; |
| 27 class ImmutableArray; | |
| 23 class Library; | 28 class Library; |
| 29 class Mint; | |
| 24 class Object; | 30 class Object; |
| 25 class ObjectStore; | 31 class ObjectStore; |
| 32 class OneByteString; | |
| 26 class RawClass; | 33 class RawClass; |
| 34 class RawField; | |
| 35 class RawFunction; | |
| 36 class RawLibrary; | |
| 37 class RawLibraryPrefix; | |
| 27 class RawObject; | 38 class RawObject; |
| 39 class RawScript; | |
| 40 class RawType; | |
| 41 class RawTypeParameter; | |
| 42 class RawUnresolvedClass; | |
| 28 class String; | 43 class String; |
| 44 class TokenStream; | |
| 45 class TwoByteString; | |
| 46 class TypeArguments; | |
| 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: |
| 38 // - Smi: the Smi value is written as is (last bit is not tagged). | 56 // - Smi: the Smi value is written as is (last bit is not tagged). |
| (...skipping 273 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 void NewArray(Array* array, intptr_t len); | |
|
Ivan Posva
2012/01/16 19:30:33
RawArray* NewArray(intptr_t len);
siva
2012/01/18 00:00:24
Done.
| |
| 344 void NewImmutableArray(ImmutableArray* array, intptr_t len); | |
| 345 void NewOneByteString(OneByteString* str_obj, intptr_t len); | |
| 346 void NewTwoByteString(TwoByteString* str_obj, intptr_t len); | |
| 347 void NewFourByteString(FourByteString* str_obj, intptr_t len); | |
| 348 void NewTypeArguments(TypeArguments* obj, intptr_t len); | |
| 349 void NewTokenStream(TokenStream* obj, intptr_t len); | |
| 350 void NewContext(Context* obj, intptr_t num_variables); | |
| 351 void NewClass(Class* obj, int value); | |
| 352 void NewMint(Mint* obj, int64_t value); | |
| 353 void NewDouble(Double* obj, double value); | |
| 354 | |
| 355 RawUnresolvedClass* NewUnresolvedClass(); | |
| 356 RawType* NewType(); | |
| 357 RawTypeParameter* NewTypeParameter(); | |
| 358 RawFunction* NewFunction(); | |
| 359 RawField* NewField(); | |
| 360 RawLibrary* NewLibrary(); | |
| 361 RawLibraryPrefix* NewLibraryPrefix(); | |
| 362 RawScript* NewScript(); | |
| 363 | |
| 322 private: | 364 private: |
| 365 // Allocate uninitialized objects, this is used when reading a full snapshot. | |
| 366 RawObject* AllocateUninitialized(const Class& cls, intptr_t size); | |
| 367 | |
| 323 // Internal implementation of ReadObject once the header value is read. | 368 // Internal implementation of ReadObject once the header value is read. |
| 324 RawObject* ReadObjectImpl(intptr_t header); | 369 RawObject* ReadObjectImpl(intptr_t header); |
| 325 | 370 |
| 326 // Read an object that was serialized as an Id (singleton, object store, | 371 // Read an object that was serialized as an Id (singleton, object store, |
| 327 // or an object that was already serialized before). | 372 // or an object that was already serialized before). |
| 328 RawObject* ReadIndexedObject(intptr_t object_id); | 373 RawObject* ReadIndexedObject(intptr_t object_id); |
| 329 | 374 |
| 330 // Read an inlined object from the stream. | 375 // Read an inlined object from the stream. |
| 331 RawObject* ReadInlinedObject(intptr_t object_id); | 376 RawObject* ReadInlinedObject(intptr_t object_id); |
| 332 | 377 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 | 561 |
| 517 private: | 562 private: |
| 518 SnapshotWriter* writer_; | 563 SnapshotWriter* writer_; |
| 519 | 564 |
| 520 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); | 565 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); |
| 521 }; | 566 }; |
| 522 | 567 |
| 523 } // namespace dart | 568 } // namespace dart |
| 524 | 569 |
| 525 #endif // VM_SNAPSHOT_H_ | 570 #endif // VM_SNAPSHOT_H_ |
| OLD | NEW |