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" |
(...skipping 21 matching lines...) Expand all Loading... |
32 class ObjectStore; | 32 class ObjectStore; |
33 class PageSpace; | 33 class PageSpace; |
34 class RawApiError; | 34 class RawApiError; |
35 class RawArray; | 35 class RawArray; |
36 class RawBigint; | 36 class RawBigint; |
37 class RawBoundedType; | 37 class RawBoundedType; |
38 class RawCapability; | 38 class RawCapability; |
39 class RawClass; | 39 class RawClass; |
40 class RawClosureData; | 40 class RawClosureData; |
41 class RawContext; | 41 class RawContext; |
| 42 class RawContextScope; |
42 class RawDouble; | 43 class RawDouble; |
| 44 class RawExceptionHandlers; |
43 class RawField; | 45 class RawField; |
44 class RawFloat32x4; | 46 class RawFloat32x4; |
45 class RawFloat64x2; | 47 class RawFloat64x2; |
46 class RawFunction; | 48 class RawFunction; |
47 class RawGrowableObjectArray; | 49 class RawGrowableObjectArray; |
48 class RawICData; | 50 class RawICData; |
49 class RawImmutableArray; | 51 class RawImmutableArray; |
50 class RawInstructions; | 52 class RawInstructions; |
51 class RawInt32x4; | 53 class RawInt32x4; |
52 class RawLanguageError; | 54 class RawLanguageError; |
53 class RawLibrary; | 55 class RawLibrary; |
54 class RawLibraryPrefix; | 56 class RawLibraryPrefix; |
55 class RawLinkedHashMap; | 57 class RawLinkedHashMap; |
56 class RawLiteralToken; | 58 class RawLiteralToken; |
| 59 class RawLocalVarDescriptors; |
57 class RawMegamorphicCache; | 60 class RawMegamorphicCache; |
58 class RawMint; | 61 class RawMint; |
59 class RawMixinAppType; | 62 class RawMixinAppType; |
60 class RawBigint; | 63 class RawBigint; |
61 class RawNamespace; | 64 class RawNamespace; |
62 class RawObject; | 65 class RawObject; |
63 class RawObjectPool; | 66 class RawObjectPool; |
64 class RawOneByteString; | 67 class RawOneByteString; |
65 class RawPatchClass; | 68 class RawPatchClass; |
| 69 class RawPcDescriptors; |
66 class RawReceivePort; | 70 class RawReceivePort; |
67 class RawRedirectionData; | 71 class RawRedirectionData; |
68 class RawScript; | 72 class RawScript; |
69 class RawSendPort; | 73 class RawSendPort; |
70 class RawSmi; | 74 class RawSmi; |
| 75 class RawStackmap; |
71 class RawStacktrace; | 76 class RawStacktrace; |
72 class RawSubtypeTestCache; | 77 class RawSubtypeTestCache; |
73 class RawTokenStream; | 78 class RawTokenStream; |
74 class RawTwoByteString; | 79 class RawTwoByteString; |
75 class RawType; | 80 class RawType; |
76 class RawTypeArguments; | 81 class RawTypeArguments; |
77 class RawTypedData; | 82 class RawTypedData; |
78 class RawTypeParameter; | 83 class RawTypeParameter; |
79 class RawTypeRef; | 84 class RawTypeRef; |
80 class RawUnhandledException; | 85 class RawUnhandledException; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 } | 293 } |
289 | 294 |
290 private: | 295 private: |
291 Object* reference_; | 296 Object* reference_; |
292 DeserializeState state_; | 297 DeserializeState state_; |
293 bool defer_canonicalization_; | 298 bool defer_canonicalization_; |
294 ZoneGrowableArray<intptr_t>* patch_records_; | 299 ZoneGrowableArray<intptr_t>* patch_records_; |
295 }; | 300 }; |
296 | 301 |
297 | 302 |
| 303 class InstructionsReader : public ZoneAllocated { |
| 304 public: |
| 305 explicit InstructionsReader(const uint8_t* buffer) |
| 306 : buffer_(buffer) { |
| 307 ASSERT(buffer != NULL); |
| 308 ASSERT(Utils::IsAligned(reinterpret_cast<uword>(buffer), |
| 309 OS::PreferredCodeAlignment())); |
| 310 } |
| 311 |
| 312 RawInstructions* GetInstructionsAt(int32_t offset, uword expected_tags); |
| 313 |
| 314 private: |
| 315 const uint8_t* buffer_; |
| 316 |
| 317 DISALLOW_COPY_AND_ASSIGN(InstructionsReader); |
| 318 }; |
| 319 |
| 320 |
298 // Reads a snapshot into objects. | 321 // Reads a snapshot into objects. |
299 class SnapshotReader : public BaseReader { | 322 class SnapshotReader : public BaseReader { |
300 public: | 323 public: |
301 Thread* thread() const { return thread_; } | 324 Thread* thread() const { return thread_; } |
302 Zone* zone() const { return zone_; } | 325 Zone* zone() const { return zone_; } |
303 Isolate* isolate() const { return thread_->isolate(); } | 326 Isolate* isolate() const { return thread_->isolate(); } |
304 Heap* heap() const { return heap_; } | 327 Heap* heap() const { return heap_; } |
305 ObjectStore* object_store() const { return isolate()->object_store(); } | 328 ObjectStore* object_store() const { return isolate()->object_store(); } |
306 ClassTable* class_table() const { return isolate()->class_table(); } | 329 ClassTable* class_table() const { return isolate()->class_table(); } |
307 PassiveObject* PassiveObjectHandle() { return &pobj_; } | 330 PassiveObject* PassiveObjectHandle() { return &pobj_; } |
308 Array* ArrayHandle() { return &array_; } | 331 Array* ArrayHandle() { return &array_; } |
309 String* StringHandle() { return &str_; } | 332 String* StringHandle() { return &str_; } |
310 AbstractType* TypeHandle() { return &type_; } | 333 AbstractType* TypeHandle() { return &type_; } |
311 TypeArguments* TypeArgumentsHandle() { return &type_arguments_; } | 334 TypeArguments* TypeArgumentsHandle() { return &type_arguments_; } |
312 Array* TokensHandle() { return &tokens_; } | 335 Array* TokensHandle() { return &tokens_; } |
313 TokenStream* StreamHandle() { return &stream_; } | 336 TokenStream* StreamHandle() { return &stream_; } |
314 ExternalTypedData* DataHandle() { return &data_; } | 337 ExternalTypedData* DataHandle() { return &data_; } |
315 TypedData* TypedDataHandle() { return &typed_data_; } | 338 TypedData* TypedDataHandle() { return &typed_data_; } |
| 339 Code* CodeHandle() { return &code_; } |
316 Snapshot::Kind kind() const { return kind_; } | 340 Snapshot::Kind kind() const { return kind_; } |
317 bool snapshot_code() const { return snapshot_code_; } | 341 bool snapshot_code() const { return snapshot_code_; } |
318 | 342 |
319 // Reads an object. | 343 // Reads an object. |
320 RawObject* ReadObject(); | 344 RawObject* ReadObject(); |
321 | 345 |
322 // Add object to backward references. | 346 // Add object to backward references. |
323 void AddBackRef(intptr_t id, | 347 void AddBackRef(intptr_t id, |
324 Object* obj, | 348 Object* obj, |
325 DeserializeState state, | 349 DeserializeState state, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 RawTypeRef* NewTypeRef(); | 382 RawTypeRef* NewTypeRef(); |
359 RawTypeParameter* NewTypeParameter(); | 383 RawTypeParameter* NewTypeParameter(); |
360 RawBoundedType* NewBoundedType(); | 384 RawBoundedType* NewBoundedType(); |
361 RawMixinAppType* NewMixinAppType(); | 385 RawMixinAppType* NewMixinAppType(); |
362 RawPatchClass* NewPatchClass(); | 386 RawPatchClass* NewPatchClass(); |
363 RawClosureData* NewClosureData(); | 387 RawClosureData* NewClosureData(); |
364 RawRedirectionData* NewRedirectionData(); | 388 RawRedirectionData* NewRedirectionData(); |
365 RawFunction* NewFunction(); | 389 RawFunction* NewFunction(); |
366 RawCode* NewCode(intptr_t pointer_offsets_length); | 390 RawCode* NewCode(intptr_t pointer_offsets_length); |
367 RawObjectPool* NewObjectPool(intptr_t length); | 391 RawObjectPool* NewObjectPool(intptr_t length); |
| 392 RawPcDescriptors* NewPcDescriptors(intptr_t length); |
| 393 RawLocalVarDescriptors* NewLocalVarDescriptors(intptr_t num_entries); |
| 394 RawExceptionHandlers* NewExceptionHandlers(intptr_t num_entries); |
| 395 RawStackmap* NewStackmap(intptr_t length); |
| 396 RawContextScope* NewContextScope(intptr_t num_variables); |
368 RawICData* NewICData(); | 397 RawICData* NewICData(); |
369 RawMegamorphicCache* NewMegamorphicCache(); | 398 RawMegamorphicCache* NewMegamorphicCache(); |
370 RawSubtypeTestCache* NewSubtypeTestCache(); | 399 RawSubtypeTestCache* NewSubtypeTestCache(); |
| 400 RawLinkedHashMap* NewLinkedHashMap(); |
371 RawField* NewField(); | 401 RawField* NewField(); |
372 RawLibrary* NewLibrary(); | 402 RawLibrary* NewLibrary(); |
373 RawLibraryPrefix* NewLibraryPrefix(); | 403 RawLibraryPrefix* NewLibraryPrefix(); |
374 RawNamespace* NewNamespace(); | 404 RawNamespace* NewNamespace(); |
375 RawScript* NewScript(); | 405 RawScript* NewScript(); |
376 RawLiteralToken* NewLiteralToken(); | 406 RawLiteralToken* NewLiteralToken(); |
377 RawGrowableObjectArray* NewGrowableObjectArray(); | 407 RawGrowableObjectArray* NewGrowableObjectArray(); |
378 RawFloat32x4* NewFloat32x4(float v0, float v1, float v2, float v3); | 408 RawFloat32x4* NewFloat32x4(float v0, float v1, float v2, float v3); |
379 RawInt32x4* NewInt32x4(uint32_t v0, uint32_t v1, uint32_t v2, uint32_t v3); | 409 RawInt32x4* NewInt32x4(uint32_t v0, uint32_t v1, uint32_t v2, uint32_t v3); |
380 RawFloat64x2* NewFloat64x2(double v0, double v1); | 410 RawFloat64x2* NewFloat64x2(double v0, double v1); |
381 RawApiError* NewApiError(); | 411 RawApiError* NewApiError(); |
382 RawLanguageError* NewLanguageError(); | 412 RawLanguageError* NewLanguageError(); |
383 RawUnhandledException* NewUnhandledException(); | 413 RawUnhandledException* NewUnhandledException(); |
384 RawObject* NewInteger(int64_t value); | 414 RawObject* NewInteger(int64_t value); |
385 RawStacktrace* NewStacktrace(); | 415 RawStacktrace* NewStacktrace(); |
386 | 416 |
387 RawInstructions* GetInstructionsById(int32_t id); | 417 RawInstructions* GetInstructionsAt(int32_t offset, uword expected_tags) { |
| 418 return instructions_reader_->GetInstructionsAt(offset, expected_tags); |
| 419 } |
| 420 |
| 421 const uint8_t* instructions_buffer_; |
388 | 422 |
389 protected: | 423 protected: |
390 SnapshotReader(const uint8_t* buffer, | 424 SnapshotReader(const uint8_t* buffer, |
391 intptr_t size, | 425 intptr_t size, |
| 426 const uint8_t* instructions_buffer, |
392 Snapshot::Kind kind, | 427 Snapshot::Kind kind, |
393 ZoneGrowableArray<BackRefNode>* backward_references, | 428 ZoneGrowableArray<BackRefNode>* backward_references, |
394 Thread* thread); | 429 Thread* thread); |
395 ~SnapshotReader() { } | 430 ~SnapshotReader() { } |
396 | 431 |
397 ZoneGrowableArray<BackRefNode>* GetBackwardReferenceTable() const { | 432 ZoneGrowableArray<BackRefNode>* GetBackwardReferenceTable() const { |
398 return backward_references_; | 433 return backward_references_; |
399 } | 434 } |
400 void ResetBackwardReferenceTable() { backward_references_ = NULL; } | 435 void ResetBackwardReferenceTable() { backward_references_ = NULL; } |
401 PageSpace* old_space() const { return old_space_; } | 436 PageSpace* old_space() const { return old_space_; } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 Array& array_; // Temporary Array handle. | 511 Array& array_; // Temporary Array handle. |
477 Field& field_; // Temporary Field handle. | 512 Field& field_; // Temporary Field handle. |
478 String& str_; // Temporary String handle. | 513 String& str_; // Temporary String handle. |
479 Library& library_; // Temporary library handle. | 514 Library& library_; // Temporary library handle. |
480 AbstractType& type_; // Temporary type handle. | 515 AbstractType& type_; // Temporary type handle. |
481 TypeArguments& type_arguments_; // Temporary type argument handle. | 516 TypeArguments& type_arguments_; // Temporary type argument handle. |
482 Array& tokens_; // Temporary tokens handle. | 517 Array& tokens_; // Temporary tokens handle. |
483 TokenStream& stream_; // Temporary token stream handle. | 518 TokenStream& stream_; // Temporary token stream handle. |
484 ExternalTypedData& data_; // Temporary stream data handle. | 519 ExternalTypedData& data_; // Temporary stream data handle. |
485 TypedData& typed_data_; // Temporary typed data handle. | 520 TypedData& typed_data_; // Temporary typed data handle. |
| 521 Code& code_; // Temporary code handle. |
486 UnhandledException& error_; // Error handle. | 522 UnhandledException& error_; // Error handle. |
487 intptr_t max_vm_isolate_object_id_; | 523 intptr_t max_vm_isolate_object_id_; |
488 ZoneGrowableArray<BackRefNode>* backward_references_; | 524 ZoneGrowableArray<BackRefNode>* backward_references_; |
| 525 InstructionsReader* instructions_reader_; |
489 | 526 |
490 friend class ApiError; | 527 friend class ApiError; |
491 friend class Array; | 528 friend class Array; |
492 friend class Bigint; | 529 friend class Bigint; |
493 friend class BoundedType; | 530 friend class BoundedType; |
494 friend class Class; | 531 friend class Class; |
495 friend class ClosureData; | 532 friend class ClosureData; |
496 friend class Code; | 533 friend class Code; |
497 friend class Context; | 534 friend class Context; |
498 friend class ContextScope; | 535 friend class ContextScope; |
499 friend class ExceptionHandlers; | 536 friend class ExceptionHandlers; |
500 friend class Field; | 537 friend class Field; |
501 friend class Function; | 538 friend class Function; |
502 friend class GrowableObjectArray; | 539 friend class GrowableObjectArray; |
503 friend class ICData; | 540 friend class ICData; |
504 friend class ImmutableArray; | 541 friend class ImmutableArray; |
| 542 friend class Instructions; |
505 friend class JSRegExp; | 543 friend class JSRegExp; |
506 friend class LanguageError; | 544 friend class LanguageError; |
507 friend class Library; | 545 friend class Library; |
508 friend class LibraryPrefix; | 546 friend class LibraryPrefix; |
509 friend class LinkedHashMap; | 547 friend class LinkedHashMap; |
510 friend class LiteralToken; | 548 friend class LiteralToken; |
511 friend class LocalVarDescriptors; | 549 friend class LocalVarDescriptors; |
512 friend class MegamorphicCache; | 550 friend class MegamorphicCache; |
513 friend class MirrorReference; | 551 friend class MirrorReference; |
514 friend class MixinAppType; | 552 friend class MixinAppType; |
(...skipping 11 matching lines...) Expand all Loading... |
526 friend class TypeRef; | 564 friend class TypeRef; |
527 friend class UnhandledException; | 565 friend class UnhandledException; |
528 friend class UnresolvedClass; | 566 friend class UnresolvedClass; |
529 friend class WeakProperty; | 567 friend class WeakProperty; |
530 DISALLOW_COPY_AND_ASSIGN(SnapshotReader); | 568 DISALLOW_COPY_AND_ASSIGN(SnapshotReader); |
531 }; | 569 }; |
532 | 570 |
533 | 571 |
534 class VmIsolateSnapshotReader : public SnapshotReader { | 572 class VmIsolateSnapshotReader : public SnapshotReader { |
535 public: | 573 public: |
536 VmIsolateSnapshotReader(const uint8_t* buffer, intptr_t size, Thread* thread); | 574 VmIsolateSnapshotReader(const uint8_t* buffer, |
| 575 intptr_t size, |
| 576 const uint8_t* instructions_buffer, |
| 577 Thread* thread); |
537 ~VmIsolateSnapshotReader(); | 578 ~VmIsolateSnapshotReader(); |
538 | 579 |
539 RawApiError* ReadVmIsolateSnapshot(); | 580 RawApiError* ReadVmIsolateSnapshot(); |
540 | 581 |
541 private: | 582 private: |
542 DISALLOW_COPY_AND_ASSIGN(VmIsolateSnapshotReader); | 583 DISALLOW_COPY_AND_ASSIGN(VmIsolateSnapshotReader); |
543 }; | 584 }; |
544 | 585 |
545 | 586 |
546 class IsolateSnapshotReader : public SnapshotReader { | 587 class IsolateSnapshotReader : public SnapshotReader { |
547 public: | 588 public: |
548 IsolateSnapshotReader(const uint8_t* buffer, | 589 IsolateSnapshotReader(const uint8_t* buffer, |
549 intptr_t size, | 590 intptr_t size, |
| 591 const uint8_t* instructions_buffer, |
550 Thread* thread); | 592 Thread* thread); |
551 ~IsolateSnapshotReader(); | 593 ~IsolateSnapshotReader(); |
552 | 594 |
553 private: | 595 private: |
554 DISALLOW_COPY_AND_ASSIGN(IsolateSnapshotReader); | 596 DISALLOW_COPY_AND_ASSIGN(IsolateSnapshotReader); |
555 }; | 597 }; |
556 | 598 |
557 | 599 |
558 class ScriptSnapshotReader : public SnapshotReader { | 600 class ScriptSnapshotReader : public SnapshotReader { |
559 public: | 601 public: |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 | 765 |
724 const intptr_t first_object_id_; | 766 const intptr_t first_object_id_; |
725 GrowableArray<Node*> nodes_; | 767 GrowableArray<Node*> nodes_; |
726 intptr_t first_unprocessed_object_id_; | 768 intptr_t first_unprocessed_object_id_; |
727 | 769 |
728 friend class FullSnapshotWriter; | 770 friend class FullSnapshotWriter; |
729 DISALLOW_COPY_AND_ASSIGN(ForwardList); | 771 DISALLOW_COPY_AND_ASSIGN(ForwardList); |
730 }; | 772 }; |
731 | 773 |
732 | 774 |
| 775 class InstructionsWriter : public ZoneAllocated { |
| 776 public: |
| 777 InstructionsWriter(uint8_t** buffer, |
| 778 ReAlloc alloc, |
| 779 intptr_t initial_size) |
| 780 : stream_(buffer, alloc, initial_size) { |
| 781 ASSERT(buffer != NULL); |
| 782 ASSERT(alloc != NULL); |
| 783 } |
| 784 |
| 785 // Size of the snapshot. |
| 786 intptr_t BytesWritten() const { return stream_.bytes_written(); } |
| 787 |
| 788 int32_t GetOffsetFor(RawInstructions* instructions); |
| 789 |
| 790 private: |
| 791 WriteStream stream_; |
| 792 |
| 793 DISALLOW_COPY_AND_ASSIGN(InstructionsWriter); |
| 794 }; |
| 795 |
| 796 |
733 class SnapshotWriter : public BaseWriter { | 797 class SnapshotWriter : public BaseWriter { |
734 protected: | 798 protected: |
735 SnapshotWriter(Snapshot::Kind kind, | 799 SnapshotWriter(Snapshot::Kind kind, |
736 uint8_t** buffer, | 800 uint8_t** buffer, |
737 ReAlloc alloc, | 801 ReAlloc alloc, |
738 intptr_t initial_size, | 802 intptr_t initial_size, |
739 ForwardList* forward_list, | 803 ForwardList* forward_list, |
| 804 InstructionsWriter* instructions_writer, |
740 bool can_send_any_object, | 805 bool can_send_any_object, |
741 bool snapshot_code); | 806 bool snapshot_code, |
| 807 bool vm_isolate_is_symbolic); |
742 | 808 |
743 public: | 809 public: |
744 // Snapshot kind. | 810 // Snapshot kind. |
745 Snapshot::Kind kind() const { return kind_; } | 811 Snapshot::Kind kind() const { return kind_; } |
746 | 812 |
747 // Serialize an object into the buffer. | 813 // Serialize an object into the buffer. |
748 void WriteObject(RawObject* raw); | 814 void WriteObject(RawObject* raw); |
749 | 815 |
750 uword GetObjectTags(RawObject* raw); | 816 uword GetObjectTags(RawObject* raw); |
751 | 817 |
752 Exceptions::ExceptionType exception_type() const { | 818 Exceptions::ExceptionType exception_type() const { |
753 return exception_type_; | 819 return exception_type_; |
754 } | 820 } |
755 void set_exception_type(Exceptions::ExceptionType type) { | 821 void set_exception_type(Exceptions::ExceptionType type) { |
756 exception_type_ = type; | 822 exception_type_ = type; |
757 } | 823 } |
758 const char* exception_msg() const { return exception_msg_; } | 824 const char* exception_msg() const { return exception_msg_; } |
759 void set_exception_msg(const char* msg) { | 825 void set_exception_msg(const char* msg) { |
760 exception_msg_ = msg; | 826 exception_msg_ = msg; |
761 } | 827 } |
762 bool can_send_any_object() const { return can_send_any_object_; } | 828 bool can_send_any_object() const { return can_send_any_object_; } |
763 bool snapshot_code() const { return snapshot_code_; } | 829 bool snapshot_code() const { return snapshot_code_; } |
| 830 bool vm_isolate_is_symbolic() const { return vm_isolate_is_symbolic_; } |
764 void ThrowException(Exceptions::ExceptionType type, const char* msg); | 831 void ThrowException(Exceptions::ExceptionType type, const char* msg); |
765 | 832 |
766 // Write a version string for the snapshot. | 833 // Write a version string for the snapshot. |
767 void WriteVersion(); | 834 void WriteVersion(); |
768 | 835 |
769 static intptr_t FirstObjectId(); | 836 static intptr_t FirstObjectId(); |
770 | 837 |
771 int32_t GetInstructionsId(RawInstructions* instructions) { return 0; } | 838 int32_t GetInstructionsId(RawInstructions* instructions) { |
| 839 return instructions_writer_->GetOffsetFor(instructions); |
| 840 } |
772 | 841 |
773 protected: | 842 protected: |
774 void UnmarkAll() { | 843 void UnmarkAll() { |
775 if (!unmarked_objects_ && forward_list_ != NULL) { | 844 if (!unmarked_objects_ && forward_list_ != NULL) { |
776 forward_list_->UnmarkAll(); | 845 forward_list_->UnmarkAll(); |
777 unmarked_objects_ = true; | 846 unmarked_objects_ = true; |
778 } | 847 } |
779 } | 848 } |
780 | 849 |
781 bool CheckAndWritePredefinedObject(RawObject* raw); | 850 bool CheckAndWritePredefinedObject(RawObject* raw); |
782 void HandleVMIsolateObject(RawObject* raw); | 851 bool HandleVMIsolateObject(RawObject* raw); |
783 | 852 |
784 void WriteClassId(RawClass* cls); | 853 void WriteClassId(RawClass* cls); |
785 void WriteStaticImplicitClosure(intptr_t object_id, | 854 void WriteStaticImplicitClosure(intptr_t object_id, |
786 RawFunction* func, | 855 RawFunction* func, |
787 intptr_t tags); | 856 intptr_t tags); |
788 void WriteObjectImpl(RawObject* raw, bool as_reference); | 857 void WriteObjectImpl(RawObject* raw, bool as_reference); |
789 void WriteObjectRef(RawObject* raw); | 858 void WriteObjectRef(RawObject* raw); |
790 void WriteInlinedObject(RawObject* raw); | 859 void WriteInlinedObject(RawObject* raw); |
791 void WriteForwardedObjects(); | 860 void WriteForwardedObjects(); |
792 void ArrayWriteTo(intptr_t object_id, | 861 void ArrayWriteTo(intptr_t object_id, |
(...skipping 26 matching lines...) Expand all Loading... |
819 Thread* thread() const { return thread_; } | 888 Thread* thread() const { return thread_; } |
820 Isolate* isolate() const { return thread_->isolate(); } | 889 Isolate* isolate() const { return thread_->isolate(); } |
821 ObjectStore* object_store() const { return object_store_; } | 890 ObjectStore* object_store() const { return object_store_; } |
822 | 891 |
823 private: | 892 private: |
824 Snapshot::Kind kind_; | 893 Snapshot::Kind kind_; |
825 Thread* thread_; | 894 Thread* thread_; |
826 ObjectStore* object_store_; // Object store for common classes. | 895 ObjectStore* object_store_; // Object store for common classes. |
827 ClassTable* class_table_; // Class table for the class index to class lookup. | 896 ClassTable* class_table_; // Class table for the class index to class lookup. |
828 ForwardList* forward_list_; | 897 ForwardList* forward_list_; |
| 898 InstructionsWriter* instructions_writer_; |
829 Exceptions::ExceptionType exception_type_; // Exception type. | 899 Exceptions::ExceptionType exception_type_; // Exception type. |
830 const char* exception_msg_; // Message associated with exception. | 900 const char* exception_msg_; // Message associated with exception. |
831 bool unmarked_objects_; // True if marked objects have been unmarked. | 901 bool unmarked_objects_; // True if marked objects have been unmarked. |
832 bool can_send_any_object_; // True if any Dart instance can be sent. | 902 bool can_send_any_object_; // True if any Dart instance can be sent. |
833 bool snapshot_code_; | 903 bool snapshot_code_; |
| 904 bool vm_isolate_is_symbolic_; |
834 | 905 |
835 friend class FullSnapshotWriter; | 906 friend class FullSnapshotWriter; |
836 friend class RawArray; | 907 friend class RawArray; |
837 friend class RawClass; | 908 friend class RawClass; |
838 friend class RawClosureData; | 909 friend class RawClosureData; |
839 friend class RawContextScope; | 910 friend class RawContextScope; |
840 friend class RawExceptionHandlers; | 911 friend class RawExceptionHandlers; |
841 friend class RawGrowableObjectArray; | 912 friend class RawGrowableObjectArray; |
842 friend class RawImmutableArray; | 913 friend class RawImmutableArray; |
843 friend class RawInstructions; | 914 friend class RawInstructions; |
(...skipping 15 matching lines...) Expand all Loading... |
859 friend class WriteInlinedObjectVisitor; | 930 friend class WriteInlinedObjectVisitor; |
860 DISALLOW_COPY_AND_ASSIGN(SnapshotWriter); | 931 DISALLOW_COPY_AND_ASSIGN(SnapshotWriter); |
861 }; | 932 }; |
862 | 933 |
863 | 934 |
864 class FullSnapshotWriter { | 935 class FullSnapshotWriter { |
865 public: | 936 public: |
866 static const intptr_t kInitialSize = 64 * KB; | 937 static const intptr_t kInitialSize = 64 * KB; |
867 FullSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer, | 938 FullSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer, |
868 uint8_t** isolate_snapshot_buffer, | 939 uint8_t** isolate_snapshot_buffer, |
| 940 uint8_t** instructions_snapshot_buffer, |
869 ReAlloc alloc, | 941 ReAlloc alloc, |
870 bool snapshot_code); | 942 bool snapshot_code, |
| 943 bool vm_isolate_is_symbolic); |
871 ~FullSnapshotWriter(); | 944 ~FullSnapshotWriter(); |
872 | 945 |
873 uint8_t** vm_isolate_snapshot_buffer() { | 946 uint8_t** vm_isolate_snapshot_buffer() { |
874 return vm_isolate_snapshot_buffer_; | 947 return vm_isolate_snapshot_buffer_; |
875 } | 948 } |
876 | 949 |
877 uint8_t** isolate_snapshot_buffer() { | 950 uint8_t** isolate_snapshot_buffer() { |
878 return isolate_snapshot_buffer_; | 951 return isolate_snapshot_buffer_; |
879 } | 952 } |
880 | 953 |
881 // Writes a full snapshot of the Isolate. | 954 // Writes a full snapshot of the Isolate. |
882 void WriteFullSnapshot(); | 955 void WriteFullSnapshot(); |
883 | 956 |
884 intptr_t VmIsolateSnapshotSize() const { | 957 intptr_t VmIsolateSnapshotSize() const { |
885 return vm_isolate_snapshot_size_; | 958 return vm_isolate_snapshot_size_; |
886 } | 959 } |
887 intptr_t IsolateSnapshotSize() const { | 960 intptr_t IsolateSnapshotSize() const { |
888 return isolate_snapshot_size_; | 961 return isolate_snapshot_size_; |
889 } | 962 } |
| 963 intptr_t InstructionsSnapshotSize() const { |
| 964 return instructions_snapshot_size_; |
| 965 } |
890 | 966 |
891 private: | 967 private: |
892 // Writes a snapshot of the VM Isolate. | 968 // Writes a snapshot of the VM Isolate. |
893 void WriteVmIsolateSnapshot(); | 969 void WriteVmIsolateSnapshot(); |
894 | 970 |
895 // Writes a full snapshot of a regular Dart Isolate. | 971 // Writes a full snapshot of a regular Dart Isolate. |
896 void WriteIsolateFullSnapshot(); | 972 void WriteIsolateFullSnapshot(); |
897 | 973 |
898 Isolate* isolate_; | 974 Isolate* isolate_; |
899 uint8_t** vm_isolate_snapshot_buffer_; | 975 uint8_t** vm_isolate_snapshot_buffer_; |
900 uint8_t** isolate_snapshot_buffer_; | 976 uint8_t** isolate_snapshot_buffer_; |
| 977 uint8_t** instructions_snapshot_buffer_; |
901 ReAlloc alloc_; | 978 ReAlloc alloc_; |
902 intptr_t vm_isolate_snapshot_size_; | 979 intptr_t vm_isolate_snapshot_size_; |
903 intptr_t isolate_snapshot_size_; | 980 intptr_t isolate_snapshot_size_; |
| 981 intptr_t instructions_snapshot_size_; |
904 ForwardList* forward_list_; | 982 ForwardList* forward_list_; |
| 983 InstructionsWriter* instructions_writer_; |
905 Array& scripts_; | 984 Array& scripts_; |
906 Array& symbol_table_; | 985 Array& symbol_table_; |
907 bool snapshot_code_; | 986 bool snapshot_code_; |
| 987 bool vm_isolate_is_symbolic_; |
908 | 988 |
909 DISALLOW_COPY_AND_ASSIGN(FullSnapshotWriter); | 989 DISALLOW_COPY_AND_ASSIGN(FullSnapshotWriter); |
910 }; | 990 }; |
911 | 991 |
912 | 992 |
913 class PrecompiledSnapshotWriter : public FullSnapshotWriter { | 993 class PrecompiledSnapshotWriter : public FullSnapshotWriter { |
914 public: | 994 public: |
915 PrecompiledSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer, | 995 PrecompiledSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer, |
916 uint8_t** isolate_snapshot_buffer, | 996 uint8_t** isolate_snapshot_buffer, |
| 997 uint8_t** instructions_snapshot_buffer, |
917 ReAlloc alloc); | 998 ReAlloc alloc); |
918 ~PrecompiledSnapshotWriter(); | 999 ~PrecompiledSnapshotWriter(); |
919 }; | 1000 }; |
920 | 1001 |
921 | 1002 |
922 class ScriptSnapshotWriter : public SnapshotWriter { | 1003 class ScriptSnapshotWriter : public SnapshotWriter { |
923 public: | 1004 public: |
924 static const intptr_t kInitialSize = 64 * KB; | 1005 static const intptr_t kInitialSize = 64 * KB; |
925 ScriptSnapshotWriter(uint8_t** buffer, ReAlloc alloc); | 1006 ScriptSnapshotWriter(uint8_t** buffer, ReAlloc alloc); |
926 ~ScriptSnapshotWriter() { } | 1007 ~ScriptSnapshotWriter() { } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 private: | 1050 private: |
970 SnapshotWriter* writer_; | 1051 SnapshotWriter* writer_; |
971 bool as_references_; | 1052 bool as_references_; |
972 | 1053 |
973 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); | 1054 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); |
974 }; | 1055 }; |
975 | 1056 |
976 } // namespace dart | 1057 } // namespace dart |
977 | 1058 |
978 #endif // VM_SNAPSHOT_H_ | 1059 #endif // VM_SNAPSHOT_H_ |
OLD | NEW |