Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: runtime/vm/snapshot.h

Issue 834233003: Fix for issue 21398 (only send "literal like" objects across isolates spawned using spawnURI (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/service.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 561
562 DISALLOW_COPY_AND_ASSIGN(ForwardList); 562 DISALLOW_COPY_AND_ASSIGN(ForwardList);
563 }; 563 };
564 564
565 565
566 class SnapshotWriter : public BaseWriter { 566 class SnapshotWriter : public BaseWriter {
567 protected: 567 protected:
568 SnapshotWriter(Snapshot::Kind kind, 568 SnapshotWriter(Snapshot::Kind kind,
569 uint8_t** buffer, 569 uint8_t** buffer,
570 ReAlloc alloc, 570 ReAlloc alloc,
571 intptr_t initial_size); 571 intptr_t initial_size,
572 bool can_send_any_object);
572 573
573 public: 574 public:
574 // Snapshot kind. 575 // Snapshot kind.
575 Snapshot::Kind kind() const { return kind_; } 576 Snapshot::Kind kind() const { return kind_; }
576 577
577 // Serialize an object into the buffer. 578 // Serialize an object into the buffer.
578 void WriteObject(RawObject* raw); 579 void WriteObject(RawObject* raw);
579 580
580 uword GetObjectTags(RawObject* raw); 581 uword GetObjectTags(RawObject* raw);
581 582
582 Exceptions::ExceptionType exception_type() const { 583 Exceptions::ExceptionType exception_type() const {
583 return exception_type_; 584 return exception_type_;
584 } 585 }
585 void set_exception_type(Exceptions::ExceptionType type) { 586 void set_exception_type(Exceptions::ExceptionType type) {
586 exception_type_ = type; 587 exception_type_ = type;
587 } 588 }
588 const char* exception_msg() const { return exception_msg_; } 589 const char* exception_msg() const { return exception_msg_; }
589 void set_exception_msg(const char* msg) { 590 void set_exception_msg(const char* msg) {
590 exception_msg_ = msg; 591 exception_msg_ = msg;
591 } 592 }
593 bool can_send_any_object() const { return can_send_any_object_; }
592 void ThrowException(Exceptions::ExceptionType type, const char* msg); 594 void ThrowException(Exceptions::ExceptionType type, const char* msg);
593 595
594 // Write a version string for the snapshot. 596 // Write a version string for the snapshot.
595 void WriteVersion(); 597 void WriteVersion();
596 598
597 protected: 599 protected:
598 void UnmarkAll() { 600 void UnmarkAll() {
599 if (!unmarked_objects_) { 601 if (!unmarked_objects_) {
600 forward_list_.UnmarkAll(); 602 forward_list_.UnmarkAll();
601 unmarked_objects_ = true; 603 unmarked_objects_ = true;
(...skipping 14 matching lines...) Expand all
616 RawSmi* length, 618 RawSmi* length,
617 RawTypeArguments* type_arguments, 619 RawTypeArguments* type_arguments,
618 RawObject* data[]); 620 RawObject* data[]);
619 void CheckIfSerializable(RawClass* cls); 621 void CheckIfSerializable(RawClass* cls);
620 void SetWriteException(Exceptions::ExceptionType type, const char* msg); 622 void SetWriteException(Exceptions::ExceptionType type, const char* msg);
621 void WriteInstance(intptr_t object_id, 623 void WriteInstance(intptr_t object_id,
622 RawObject* raw, 624 RawObject* raw,
623 RawClass* cls, 625 RawClass* cls,
624 intptr_t tags); 626 intptr_t tags);
625 void WriteInstanceRef(RawObject* raw, RawClass* cls); 627 void WriteInstanceRef(RawObject* raw, RawClass* cls);
628 bool AllowObjectsInDartLibrary(RawLibrary* library);
626 629
627 Isolate* isolate() const { return isolate_; } 630 Isolate* isolate() const { return isolate_; }
628 ObjectStore* object_store() const { return object_store_; } 631 ObjectStore* object_store() const { return object_store_; }
629 632
630 private: 633 private:
631 Snapshot::Kind kind_; 634 Snapshot::Kind kind_;
632 Isolate* isolate_; 635 Isolate* isolate_;
633 ObjectStore* object_store_; // Object store for common classes. 636 ObjectStore* object_store_; // Object store for common classes.
634 ClassTable* class_table_; // Class table for the class index to class lookup. 637 ClassTable* class_table_; // Class table for the class index to class lookup.
635 ForwardList forward_list_; 638 ForwardList forward_list_;
636 Exceptions::ExceptionType exception_type_; // Exception type. 639 Exceptions::ExceptionType exception_type_; // Exception type.
637 const char* exception_msg_; // Message associated with exception. 640 const char* exception_msg_; // Message associated with exception.
638 bool unmarked_objects_; // True if marked objects have been unmarked. 641 bool unmarked_objects_; // True if marked objects have been unmarked.
642 bool can_send_any_object_; // True if any Dart instance can be sent.
639 643
640 friend class RawArray; 644 friend class RawArray;
641 friend class RawClass; 645 friend class RawClass;
642 friend class RawClosureData; 646 friend class RawClosureData;
643 friend class RawGrowableObjectArray; 647 friend class RawGrowableObjectArray;
644 friend class RawLinkedHashMap; 648 friend class RawLinkedHashMap;
645 friend class RawImmutableArray; 649 friend class RawImmutableArray;
646 friend class RawJSRegExp; 650 friend class RawJSRegExp;
647 friend class RawLibrary; 651 friend class RawLibrary;
648 friend class RawLiteralToken; 652 friend class RawLiteralToken;
649 friend class RawMirrorReference; 653 friend class RawMirrorReference;
650 friend class RawReceivePort; 654 friend class RawReceivePort;
651 friend class RawScript; 655 friend class RawScript;
652 friend class RawStacktrace; 656 friend class RawStacktrace;
653 friend class RawTokenStream; 657 friend class RawTokenStream;
654 friend class RawTypeArguments; 658 friend class RawTypeArguments;
655 friend class RawUserTag; 659 friend class RawUserTag;
656 friend class SnapshotWriterVisitor; 660 friend class SnapshotWriterVisitor;
657 friend class WriteInlinedObjectVisitor; 661 friend class WriteInlinedObjectVisitor;
658 DISALLOW_COPY_AND_ASSIGN(SnapshotWriter); 662 DISALLOW_COPY_AND_ASSIGN(SnapshotWriter);
659 }; 663 };
660 664
661 665
662 class FullSnapshotWriter : public SnapshotWriter { 666 class FullSnapshotWriter : public SnapshotWriter {
663 public: 667 public:
664 static const intptr_t kInitialSize = 64 * KB; 668 static const intptr_t kInitialSize = 64 * KB;
665 FullSnapshotWriter(uint8_t** buffer, ReAlloc alloc) 669 FullSnapshotWriter(uint8_t** buffer, ReAlloc alloc)
666 : SnapshotWriter(Snapshot::kFull, buffer, alloc, kInitialSize) { 670 : SnapshotWriter(Snapshot::kFull, buffer, alloc, kInitialSize, true) {
667 ASSERT(buffer != NULL); 671 ASSERT(buffer != NULL);
668 ASSERT(alloc != NULL); 672 ASSERT(alloc != NULL);
669 } 673 }
670 ~FullSnapshotWriter() { } 674 ~FullSnapshotWriter() { }
671 675
672 // Writes a full snapshot of the Isolate. 676 // Writes a full snapshot of the Isolate.
673 void WriteFullSnapshot(); 677 void WriteFullSnapshot();
674 678
675 private: 679 private:
676 DISALLOW_COPY_AND_ASSIGN(FullSnapshotWriter); 680 DISALLOW_COPY_AND_ASSIGN(FullSnapshotWriter);
677 }; 681 };
678 682
679 683
680 class ScriptSnapshotWriter : public SnapshotWriter { 684 class ScriptSnapshotWriter : public SnapshotWriter {
681 public: 685 public:
682 static const intptr_t kInitialSize = 64 * KB; 686 static const intptr_t kInitialSize = 64 * KB;
683 ScriptSnapshotWriter(uint8_t** buffer, ReAlloc alloc) 687 ScriptSnapshotWriter(uint8_t** buffer, ReAlloc alloc)
684 : SnapshotWriter(Snapshot::kScript, buffer, alloc, kInitialSize) { 688 : SnapshotWriter(Snapshot::kScript, buffer, alloc, kInitialSize, true) {
685 ASSERT(buffer != NULL); 689 ASSERT(buffer != NULL);
686 ASSERT(alloc != NULL); 690 ASSERT(alloc != NULL);
687 } 691 }
688 ~ScriptSnapshotWriter() { } 692 ~ScriptSnapshotWriter() { }
689 693
690 // Writes a partial snapshot of the script. 694 // Writes a partial snapshot of the script.
691 void WriteScriptSnapshot(const Library& lib); 695 void WriteScriptSnapshot(const Library& lib);
692 696
693 private: 697 private:
694 DISALLOW_COPY_AND_ASSIGN(ScriptSnapshotWriter); 698 DISALLOW_COPY_AND_ASSIGN(ScriptSnapshotWriter);
695 }; 699 };
696 700
697 701
698 class MessageWriter : public SnapshotWriter { 702 class MessageWriter : public SnapshotWriter {
699 public: 703 public:
700 static const intptr_t kInitialSize = 512; 704 static const intptr_t kInitialSize = 512;
701 MessageWriter(uint8_t** buffer, ReAlloc alloc) 705 MessageWriter(uint8_t** buffer, ReAlloc alloc, bool can_send_any_object)
702 : SnapshotWriter(Snapshot::kMessage, buffer, alloc, kInitialSize) { 706 : SnapshotWriter(Snapshot::kMessage,
707 buffer,
708 alloc,
709 kInitialSize,
710 can_send_any_object) {
703 ASSERT(buffer != NULL); 711 ASSERT(buffer != NULL);
704 ASSERT(alloc != NULL); 712 ASSERT(alloc != NULL);
705 } 713 }
706 ~MessageWriter() { } 714 ~MessageWriter() { }
707 715
708 void WriteMessage(const Object& obj); 716 void WriteMessage(const Object& obj);
709 717
710 private: 718 private:
711 DISALLOW_COPY_AND_ASSIGN(MessageWriter); 719 DISALLOW_COPY_AND_ASSIGN(MessageWriter);
712 }; 720 };
(...skipping 18 matching lines...) Expand all
731 private: 739 private:
732 SnapshotWriter* writer_; 740 SnapshotWriter* writer_;
733 bool as_references_; 741 bool as_references_;
734 742
735 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); 743 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor);
736 }; 744 };
737 745
738 } // namespace dart 746 } // namespace dart
739 747
740 #endif // VM_SNAPSHOT_H_ 748 #endif // VM_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « runtime/vm/service.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698