| 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/datastream.h" | 11 #include "vm/datastream.h" |
| 12 #include "vm/exceptions.h" | 12 #include "vm/exceptions.h" |
| 13 #include "vm/globals.h" | 13 #include "vm/globals.h" |
| 14 #include "vm/growable_array.h" | 14 #include "vm/growable_array.h" |
| 15 #include "vm/isolate.h" | 15 #include "vm/isolate.h" |
| 16 #include "vm/visitor.h" | 16 #include "vm/visitor.h" |
| 17 | 17 |
| 18 namespace dart { | 18 namespace dart { |
| 19 | 19 |
| 20 // Forward declarations. | 20 // Forward declarations. |
| 21 class AbstractType; | 21 class AbstractType; |
| 22 class AbstractTypeArguments; | |
| 23 class Array; | 22 class Array; |
| 24 class Class; | 23 class Class; |
| 25 class ClassTable; | 24 class ClassTable; |
| 26 class ExternalTypedData; | 25 class ExternalTypedData; |
| 27 class GrowableObjectArray; | 26 class GrowableObjectArray; |
| 28 class Heap; | 27 class Heap; |
| 29 class LanguageError; | 28 class LanguageError; |
| 30 class Library; | 29 class Library; |
| 31 class Object; | 30 class Object; |
| 32 class ObjectStore; | 31 class ObjectStore; |
| 33 class RawAbstractTypeArguments; | |
| 34 class RawApiError; | 32 class RawApiError; |
| 35 class RawArray; | 33 class RawArray; |
| 36 class RawBigint; | 34 class RawBigint; |
| 37 class RawBoundedType; | 35 class RawBoundedType; |
| 38 class RawMixinAppType; | 36 class RawMixinAppType; |
| 39 class RawClass; | 37 class RawClass; |
| 40 class RawContext; | 38 class RawContext; |
| 41 class RawDouble; | 39 class RawDouble; |
| 42 class RawField; | 40 class RawField; |
| 43 class RawClosureData; | 41 class RawClosureData; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 62 class RawStacktrace; | 60 class RawStacktrace; |
| 63 class RawTokenStream; | 61 class RawTokenStream; |
| 64 class RawType; | 62 class RawType; |
| 65 class RawTypeRef; | 63 class RawTypeRef; |
| 66 class RawTypeParameter; | 64 class RawTypeParameter; |
| 67 class RawTypeArguments; | 65 class RawTypeArguments; |
| 68 class RawTwoByteString; | 66 class RawTwoByteString; |
| 69 class RawUnresolvedClass; | 67 class RawUnresolvedClass; |
| 70 class String; | 68 class String; |
| 71 class TokenStream; | 69 class TokenStream; |
| 70 class TypeArguments; |
| 72 class UnhandledException; | 71 class UnhandledException; |
| 73 | 72 |
| 74 // Serialized object header encoding is as follows: | 73 // Serialized object header encoding is as follows: |
| 75 // - Smi: the Smi value is written as is (last bit is not tagged). | 74 // - Smi: the Smi value is written as is (last bit is not tagged). |
| 76 // - VM object (from VM isolate): (object id in vm isolate | 0x3) | 75 // - VM object (from VM isolate): (object id in vm isolate | 0x3) |
| 77 // This valus is serialized as a negative number. | 76 // This valus is serialized as a negative number. |
| 78 // (note VM objects are never serialized they are expected to be found | 77 // (note VM objects are never serialized they are expected to be found |
| 79 // using ths unique ID assigned to them). | 78 // using ths unique ID assigned to them). |
| 80 // - Reference to object that has already been written: (object id | 0x3) | 79 // - Reference to object that has already been written: (object id | 0x3) |
| 81 // This valus is serialized as a positive number. | 80 // This valus is serialized as a positive number. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 Isolate* isolate); | 216 Isolate* isolate); |
| 218 ~SnapshotReader() { } | 217 ~SnapshotReader() { } |
| 219 | 218 |
| 220 Isolate* isolate() const { return isolate_; } | 219 Isolate* isolate() const { return isolate_; } |
| 221 Heap* heap() const { return isolate_->heap(); } | 220 Heap* heap() const { return isolate_->heap(); } |
| 222 ObjectStore* object_store() const { return isolate_->object_store(); } | 221 ObjectStore* object_store() const { return isolate_->object_store(); } |
| 223 ClassTable* class_table() const { return isolate_->class_table(); } | 222 ClassTable* class_table() const { return isolate_->class_table(); } |
| 224 Object* ObjectHandle() { return &obj_; } | 223 Object* ObjectHandle() { return &obj_; } |
| 225 String* StringHandle() { return &str_; } | 224 String* StringHandle() { return &str_; } |
| 226 AbstractType* TypeHandle() { return &type_; } | 225 AbstractType* TypeHandle() { return &type_; } |
| 227 AbstractTypeArguments* TypeArgumentsHandle() { return &type_arguments_; } | 226 TypeArguments* TypeArgumentsHandle() { return &type_arguments_; } |
| 228 Array* TokensHandle() { return &tokens_; } | 227 Array* TokensHandle() { return &tokens_; } |
| 229 TokenStream* StreamHandle() { return &stream_; } | 228 TokenStream* StreamHandle() { return &stream_; } |
| 230 ExternalTypedData* DataHandle() { return &data_; } | 229 ExternalTypedData* DataHandle() { return &data_; } |
| 231 UnhandledException* ErrorHandle() { return &error_; } | 230 UnhandledException* ErrorHandle() { return &error_; } |
| 232 | 231 |
| 233 // Reads an object. | 232 // Reads an object. |
| 234 RawObject* ReadObject(); | 233 RawObject* ReadObject(); |
| 235 | 234 |
| 236 // Add object to backward references. | 235 // Add object to backward references. |
| 237 void AddBackRef(intptr_t id, Object* obj, DeserializeState state); | 236 void AddBackRef(intptr_t id, Object* obj, DeserializeState state); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 322 |
| 324 Snapshot::Kind kind_; // Indicates type of snapshot(full, script, message). | 323 Snapshot::Kind kind_; // Indicates type of snapshot(full, script, message). |
| 325 Isolate* isolate_; // Current isolate. | 324 Isolate* isolate_; // Current isolate. |
| 326 Class& cls_; // Temporary Class handle. | 325 Class& cls_; // Temporary Class handle. |
| 327 Object& obj_; // Temporary Object handle. | 326 Object& obj_; // Temporary Object handle. |
| 328 Array& array_; // Temporary Array handle. | 327 Array& array_; // Temporary Array handle. |
| 329 Field& field_; // Temporary Field handle. | 328 Field& field_; // Temporary Field handle. |
| 330 String& str_; // Temporary String handle. | 329 String& str_; // Temporary String handle. |
| 331 Library& library_; // Temporary library handle. | 330 Library& library_; // Temporary library handle. |
| 332 AbstractType& type_; // Temporary type handle. | 331 AbstractType& type_; // Temporary type handle. |
| 333 AbstractTypeArguments& type_arguments_; // Temporary type argument handle. | 332 TypeArguments& type_arguments_; // Temporary type argument handle. |
| 334 Array& tokens_; // Temporary tokens handle. | 333 Array& tokens_; // Temporary tokens handle. |
| 335 TokenStream& stream_; // Temporary token stream handle. | 334 TokenStream& stream_; // Temporary token stream handle. |
| 336 ExternalTypedData& data_; // Temporary stream data handle. | 335 ExternalTypedData& data_; // Temporary stream data handle. |
| 337 UnhandledException& error_; // Error handle. | 336 UnhandledException& error_; // Error handle. |
| 338 GrowableArray<BackRefNode*> backward_references_; | 337 GrowableArray<BackRefNode*> backward_references_; |
| 339 | 338 |
| 340 friend class ApiError; | 339 friend class ApiError; |
| 341 friend class Array; | 340 friend class Array; |
| 342 friend class BoundedType; | 341 friend class BoundedType; |
| 343 friend class MixinAppType; | 342 friend class MixinAppType; |
| 344 friend class Class; | 343 friend class Class; |
| 345 friend class Context; | 344 friend class Context; |
| 346 friend class ContextScope; | 345 friend class ContextScope; |
| 347 friend class Field; | 346 friend class Field; |
| 348 friend class ClosureData; | 347 friend class ClosureData; |
| 349 friend class RedirectionData; | 348 friend class RedirectionData; |
| 350 friend class Function; | 349 friend class Function; |
| 351 friend class GrowableObjectArray; | 350 friend class GrowableObjectArray; |
| 352 friend class ImmutableArray; | 351 friend class ImmutableArray; |
| 353 friend class InstantiatedTypeArguments; | |
| 354 friend class JSRegExp; | 352 friend class JSRegExp; |
| 355 friend class LanguageError; | 353 friend class LanguageError; |
| 356 friend class Library; | 354 friend class Library; |
| 357 friend class LibraryPrefix; | 355 friend class LibraryPrefix; |
| 358 friend class Namespace; | 356 friend class Namespace; |
| 359 friend class LiteralToken; | 357 friend class LiteralToken; |
| 360 friend class PatchClass; | 358 friend class PatchClass; |
| 361 friend class Script; | 359 friend class Script; |
| 362 friend class Stacktrace; | 360 friend class Stacktrace; |
| 363 friend class TokenStream; | 361 friend class TokenStream; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 | 501 |
| 504 void WriteObjectRef(RawObject* raw); | 502 void WriteObjectRef(RawObject* raw); |
| 505 void WriteClassId(RawClass* cls); | 503 void WriteClassId(RawClass* cls); |
| 506 void WriteObjectImpl(RawObject* raw); | 504 void WriteObjectImpl(RawObject* raw); |
| 507 void WriteInlinedObject(RawObject* raw); | 505 void WriteInlinedObject(RawObject* raw); |
| 508 void WriteForwardedObjects(); | 506 void WriteForwardedObjects(); |
| 509 void ArrayWriteTo(intptr_t object_id, | 507 void ArrayWriteTo(intptr_t object_id, |
| 510 intptr_t array_kind, | 508 intptr_t array_kind, |
| 511 intptr_t tags, | 509 intptr_t tags, |
| 512 RawSmi* length, | 510 RawSmi* length, |
| 513 RawAbstractTypeArguments* type_arguments, | 511 RawTypeArguments* type_arguments, |
| 514 RawObject* data[]); | 512 RawObject* data[]); |
| 515 void CheckIfSerializable(RawClass* cls); | 513 void CheckIfSerializable(RawClass* cls); |
| 516 void SetWriteException(Exceptions::ExceptionType type, const char* msg); | 514 void SetWriteException(Exceptions::ExceptionType type, const char* msg); |
| 517 void WriteInstance(intptr_t object_id, | 515 void WriteInstance(intptr_t object_id, |
| 518 RawObject* raw, | 516 RawObject* raw, |
| 519 RawClass* cls, | 517 RawClass* cls, |
| 520 intptr_t tags); | 518 intptr_t tags); |
| 521 void WriteInstanceRef(RawObject* raw, RawClass* cls); | 519 void WriteInstanceRef(RawObject* raw, RawClass* cls); |
| 522 | 520 |
| 523 ObjectStore* object_store() const { return object_store_; } | 521 ObjectStore* object_store() const { return object_store_; } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 private: | 618 private: |
| 621 SnapshotWriter* writer_; | 619 SnapshotWriter* writer_; |
| 622 bool as_references_; | 620 bool as_references_; |
| 623 | 621 |
| 624 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); | 622 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); |
| 625 }; | 623 }; |
| 626 | 624 |
| 627 } // namespace dart | 625 } // namespace dart |
| 628 | 626 |
| 629 #endif // VM_SNAPSHOT_H_ | 627 #endif // VM_SNAPSHOT_H_ |
| OLD | NEW |