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

Side by Side Diff: src/snapshot/serialize.h

Issue 1667063002: [serializer] add synchronize codes to detect mismatch. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@snapshotignition
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | src/snapshot/serialize.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_SNAPSHOT_SERIALIZE_H_ 5 #ifndef V8_SNAPSHOT_SERIALIZE_H_
6 #define V8_SNAPSHOT_SERIALIZE_H_ 6 #define V8_SNAPSHOT_SERIALIZE_H_
7 7
8 #include "src/address-map.h" 8 #include "src/address-map.h"
9 #include "src/heap/heap.h" 9 #include "src/heap/heap.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 376
377 // Pass a vector of externally-provided objects referenced by the snapshot. 377 // Pass a vector of externally-provided objects referenced by the snapshot.
378 // The ownership to its backing store is handed over as well. 378 // The ownership to its backing store is handed over as well.
379 void SetAttachedObjects(Vector<Handle<Object> > attached_objects) { 379 void SetAttachedObjects(Vector<Handle<Object> > attached_objects) {
380 attached_objects_ = attached_objects; 380 attached_objects_ = attached_objects;
381 } 381 }
382 382
383 private: 383 private:
384 void VisitPointers(Object** start, Object** end) override; 384 void VisitPointers(Object** start, Object** end) override;
385 385
386 void Synchronize(VisitorSynchronization::SyncTag tag) override;
387
386 void VisitRuntimeEntry(RelocInfo* rinfo) override { UNREACHABLE(); } 388 void VisitRuntimeEntry(RelocInfo* rinfo) override { UNREACHABLE(); }
387 389
388 void Initialize(Isolate* isolate); 390 void Initialize(Isolate* isolate);
389 391
390 bool deserializing_user_code() { return deserializing_user_code_; } 392 bool deserializing_user_code() { return deserializing_user_code_; }
391 393
392 void DecodeReservation(Vector<const SerializedData::Reservation> res); 394 void DecodeReservation(Vector<const SerializedData::Reservation> res);
393 395
394 bool ReserveSpace(); 396 bool ReserveSpace();
395 397
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 }; 466 };
465 467
466 468
467 class CodeAddressMap; 469 class CodeAddressMap;
468 470
469 // There can be only one serializer per V8 process. 471 // There can be only one serializer per V8 process.
470 class Serializer : public SerializerDeserializer { 472 class Serializer : public SerializerDeserializer {
471 public: 473 public:
472 Serializer(Isolate* isolate, SnapshotByteSink* sink); 474 Serializer(Isolate* isolate, SnapshotByteSink* sink);
473 ~Serializer() override; 475 ~Serializer() override;
474 void VisitPointers(Object** start, Object** end) override;
475 476
476 void EncodeReservations(List<SerializedData::Reservation>* out) const; 477 void EncodeReservations(List<SerializedData::Reservation>* out) const;
477 478
478 void SerializeDeferredObjects(); 479 void SerializeDeferredObjects();
479 480
480 Isolate* isolate() const { return isolate_; } 481 Isolate* isolate() const { return isolate_; }
481 482
482 BackReferenceMap* back_reference_map() { return &back_reference_map_; } 483 BackReferenceMap* back_reference_map() { return &back_reference_map_; }
483 RootIndexMap* root_index_map() { return &root_index_map_; } 484 RootIndexMap* root_index_map() { return &root_index_map_; }
484 485
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 RootIndexMap root_index_map_; 572 RootIndexMap root_index_map_;
572 573
573 int recursion_depth_; 574 int recursion_depth_;
574 575
575 friend class Deserializer; 576 friend class Deserializer;
576 friend class ObjectSerializer; 577 friend class ObjectSerializer;
577 friend class RecursionScope; 578 friend class RecursionScope;
578 friend class SnapshotData; 579 friend class SnapshotData;
579 580
580 private: 581 private:
582 void VisitPointers(Object** start, Object** end) override;
583
581 CodeAddressMap* code_address_map_; 584 CodeAddressMap* code_address_map_;
582 // Objects from the same space are put into chunks for bulk-allocation 585 // Objects from the same space are put into chunks for bulk-allocation
583 // when deserializing. We have to make sure that each chunk fits into a 586 // when deserializing. We have to make sure that each chunk fits into a
584 // page. So we track the chunk size in pending_chunk_ of a space, but 587 // page. So we track the chunk size in pending_chunk_ of a space, but
585 // when it exceeds a page, we complete the current chunk and start a new one. 588 // when it exceeds a page, we complete the current chunk and start a new one.
586 uint32_t pending_chunk_[kNumberOfPreallocatedSpaces]; 589 uint32_t pending_chunk_[kNumberOfPreallocatedSpaces];
587 List<uint32_t> completed_chunks_[kNumberOfPreallocatedSpaces]; 590 List<uint32_t> completed_chunks_[kNumberOfPreallocatedSpaces];
588 uint32_t max_chunk_size_[kNumberOfPreallocatedSpaces]; 591 uint32_t max_chunk_size_[kNumberOfPreallocatedSpaces];
589 592
590 // We map serialized large objects to indexes for back-referencing. 593 // We map serialized large objects to indexes for back-referencing.
(...skipping 22 matching lines...) Expand all
613 : Serializer(isolate, sink), 616 : Serializer(isolate, sink),
614 startup_serializer_(startup_snapshot_serializer), 617 startup_serializer_(startup_snapshot_serializer),
615 global_object_(NULL) { 618 global_object_(NULL) {
616 InitializeCodeAddressMap(); 619 InitializeCodeAddressMap();
617 } 620 }
618 621
619 ~PartialSerializer() override { OutputStatistics("PartialSerializer"); } 622 ~PartialSerializer() override { OutputStatistics("PartialSerializer"); }
620 623
621 // Serialize the objects reachable from a single object pointer. 624 // Serialize the objects reachable from a single object pointer.
622 void Serialize(Object** o); 625 void Serialize(Object** o);
626
627 private:
623 void SerializeObject(HeapObject* o, HowToCode how_to_code, 628 void SerializeObject(HeapObject* o, HowToCode how_to_code,
624 WhereToPoint where_to_point, int skip) override; 629 WhereToPoint where_to_point, int skip) override;
625 630
626 private:
627 int PartialSnapshotCacheIndex(HeapObject* o); 631 int PartialSnapshotCacheIndex(HeapObject* o);
628 bool ShouldBeInThePartialSnapshotCache(HeapObject* o); 632 bool ShouldBeInThePartialSnapshotCache(HeapObject* o);
629 633
630 Serializer* startup_serializer_; 634 Serializer* startup_serializer_;
631 Object* global_object_; 635 Object* global_object_;
632 PartialCacheIndexMap partial_cache_index_map_; 636 PartialCacheIndexMap partial_cache_index_map_;
633 DISALLOW_COPY_AND_ASSIGN(PartialSerializer); 637 DISALLOW_COPY_AND_ASSIGN(PartialSerializer);
634 }; 638 };
635 639
636 640
637 class StartupSerializer : public Serializer { 641 class StartupSerializer : public Serializer {
638 public: 642 public:
639 StartupSerializer(Isolate* isolate, SnapshotByteSink* sink); 643 StartupSerializer(Isolate* isolate, SnapshotByteSink* sink);
640 ~StartupSerializer() override { OutputStatistics("StartupSerializer"); } 644 ~StartupSerializer() override { OutputStatistics("StartupSerializer"); }
641 645
642 // The StartupSerializer has to serialize the root array, which is slightly
643 // different.
644 void VisitPointers(Object** start, Object** end) override;
645
646 // Serialize the current state of the heap. The order is: 646 // Serialize the current state of the heap. The order is:
647 // 1) Strong references. 647 // 1) Strong references.
648 // 2) Partial snapshot cache. 648 // 2) Partial snapshot cache.
649 // 3) Weak references (e.g. the string table). 649 // 3) Weak references (e.g. the string table).
650 virtual void SerializeStrongReferences(); 650 void SerializeStrongReferences();
651 void SerializeWeakReferencesAndDeferred();
652
653 private:
654 // The StartupSerializer has to serialize the root array, which is slightly
655 // different.
656 void VisitPointers(Object** start, Object** end) override;
651 void SerializeObject(HeapObject* o, HowToCode how_to_code, 657 void SerializeObject(HeapObject* o, HowToCode how_to_code,
652 WhereToPoint where_to_point, int skip) override; 658 WhereToPoint where_to_point, int skip) override;
653 void SerializeWeakReferencesAndDeferred();
654
655 void Synchronize(VisitorSynchronization::SyncTag tag) override; 659 void Synchronize(VisitorSynchronization::SyncTag tag) override;
656 660
657 private:
658 intptr_t root_index_wave_front_; 661 intptr_t root_index_wave_front_;
659 bool serializing_builtins_; 662 bool serializing_builtins_;
660 DISALLOW_COPY_AND_ASSIGN(StartupSerializer); 663 DISALLOW_COPY_AND_ASSIGN(StartupSerializer);
661 }; 664 };
662 665
663 666
664 class CodeSerializer : public Serializer { 667 class CodeSerializer : public Serializer {
665 public: 668 public:
666 static ScriptData* Serialize(Isolate* isolate, 669 static ScriptData* Serialize(Isolate* isolate,
667 Handle<SharedFunctionInfo> info, 670 Handle<SharedFunctionInfo> info,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; 807 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size;
805 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; 808 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size;
806 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; 809 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size;
807 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; 810 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size;
808 static const int kHeaderSize = kChecksum2Offset + kInt32Size; 811 static const int kHeaderSize = kChecksum2Offset + kInt32Size;
809 }; 812 };
810 } // namespace internal 813 } // namespace internal
811 } // namespace v8 814 } // namespace v8
812 815
813 #endif // V8_SNAPSHOT_SERIALIZE_H_ 816 #endif // V8_SNAPSHOT_SERIALIZE_H_
OLDNEW
« no previous file with comments | « no previous file | src/snapshot/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698