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

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

Issue 1412223018: [presubmit] Enabling readability/inheritance linter checking. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressing comments Created 5 years, 1 month 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 | « src/scanner-character-streams.h ('k') | 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 : isolate_(NULL), 360 : isolate_(NULL),
361 source_(data->Payload()), 361 source_(data->Payload()),
362 magic_number_(data->GetMagicNumber()), 362 magic_number_(data->GetMagicNumber()),
363 external_reference_table_(NULL), 363 external_reference_table_(NULL),
364 deserialized_large_objects_(0), 364 deserialized_large_objects_(0),
365 deserializing_user_code_(false), 365 deserializing_user_code_(false),
366 next_alignment_(kWordAligned) { 366 next_alignment_(kWordAligned) {
367 DecodeReservation(data->Reservations()); 367 DecodeReservation(data->Reservations());
368 } 368 }
369 369
370 virtual ~Deserializer(); 370 ~Deserializer() override;
371 371
372 // Deserialize the snapshot into an empty heap. 372 // Deserialize the snapshot into an empty heap.
373 void Deserialize(Isolate* isolate); 373 void Deserialize(Isolate* isolate);
374 374
375 // Deserialize a single object and the objects reachable from it. 375 // Deserialize a single object and the objects reachable from it.
376 MaybeHandle<Object> DeserializePartial( 376 MaybeHandle<Object> DeserializePartial(
377 Isolate* isolate, Handle<JSGlobalProxy> global_proxy, 377 Isolate* isolate, Handle<JSGlobalProxy> global_proxy,
378 Handle<FixedArray>* outdated_contexts_out); 378 Handle<FixedArray>* outdated_contexts_out);
379 379
380 // Deserialize a shared function info. Fail gracefully. 380 // Deserialize a shared function info. Fail gracefully.
381 MaybeHandle<SharedFunctionInfo> DeserializeCode(Isolate* isolate); 381 MaybeHandle<SharedFunctionInfo> DeserializeCode(Isolate* isolate);
382 382
383 // Pass a vector of externally-provided objects referenced by the snapshot. 383 // Pass a vector of externally-provided objects referenced by the snapshot.
384 // The ownership to its backing store is handed over as well. 384 // The ownership to its backing store is handed over as well.
385 void SetAttachedObjects(Vector<Handle<Object> > attached_objects) { 385 void SetAttachedObjects(Vector<Handle<Object> > attached_objects) {
386 attached_objects_ = attached_objects; 386 attached_objects_ = attached_objects;
387 } 387 }
388 388
389 private: 389 private:
390 virtual void VisitPointers(Object** start, Object** end); 390 void VisitPointers(Object** start, Object** end) override;
391 391
392 virtual void VisitRuntimeEntry(RelocInfo* rinfo) { 392 void VisitRuntimeEntry(RelocInfo* rinfo) override { UNREACHABLE(); }
393 UNREACHABLE();
394 }
395 393
396 void Initialize(Isolate* isolate); 394 void Initialize(Isolate* isolate);
397 395
398 bool deserializing_user_code() { return deserializing_user_code_; } 396 bool deserializing_user_code() { return deserializing_user_code_; }
399 397
400 void DecodeReservation(Vector<const SerializedData::Reservation> res); 398 void DecodeReservation(Vector<const SerializedData::Reservation> res);
401 399
402 bool ReserveSpace(); 400 bool ReserveSpace();
403 401
404 void UnalignedCopy(Object** dest, Object** src) { 402 void UnalignedCopy(Object** dest, Object** src) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 DISALLOW_COPY_AND_ASSIGN(Deserializer); 461 DISALLOW_COPY_AND_ASSIGN(Deserializer);
464 }; 462 };
465 463
466 464
467 class CodeAddressMap; 465 class CodeAddressMap;
468 466
469 // There can be only one serializer per V8 process. 467 // There can be only one serializer per V8 process.
470 class Serializer : public SerializerDeserializer { 468 class Serializer : public SerializerDeserializer {
471 public: 469 public:
472 Serializer(Isolate* isolate, SnapshotByteSink* sink); 470 Serializer(Isolate* isolate, SnapshotByteSink* sink);
473 ~Serializer(); 471 ~Serializer() override;
474 void VisitPointers(Object** start, Object** end) override; 472 void VisitPointers(Object** start, Object** end) override;
475 473
476 void EncodeReservations(List<SerializedData::Reservation>* out) const; 474 void EncodeReservations(List<SerializedData::Reservation>* out) const;
477 475
478 void SerializeDeferredObjects(); 476 void SerializeDeferredObjects();
479 477
480 Isolate* isolate() const { return isolate_; } 478 Isolate* isolate() const { return isolate_; }
481 479
482 BackReferenceMap* back_reference_map() { return &back_reference_map_; } 480 BackReferenceMap* back_reference_map() { return &back_reference_map_; }
483 RootIndexMap* root_index_map() { return &root_index_map_; } 481 RootIndexMap* root_index_map() { return &root_index_map_; }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 public: 608 public:
611 PartialSerializer(Isolate* isolate, Serializer* startup_snapshot_serializer, 609 PartialSerializer(Isolate* isolate, Serializer* startup_snapshot_serializer,
612 SnapshotByteSink* sink) 610 SnapshotByteSink* sink)
613 : Serializer(isolate, sink), 611 : Serializer(isolate, sink),
614 startup_serializer_(startup_snapshot_serializer), 612 startup_serializer_(startup_snapshot_serializer),
615 outdated_contexts_(0), 613 outdated_contexts_(0),
616 global_object_(NULL) { 614 global_object_(NULL) {
617 InitializeCodeAddressMap(); 615 InitializeCodeAddressMap();
618 } 616 }
619 617
620 ~PartialSerializer() { OutputStatistics("PartialSerializer"); } 618 ~PartialSerializer() override { OutputStatistics("PartialSerializer"); }
621 619
622 // Serialize the objects reachable from a single object pointer. 620 // Serialize the objects reachable from a single object pointer.
623 void Serialize(Object** o); 621 void Serialize(Object** o);
624 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, 622 void SerializeObject(HeapObject* o, HowToCode how_to_code,
625 WhereToPoint where_to_point, int skip) override; 623 WhereToPoint where_to_point, int skip) override;
626 624
627 private: 625 private:
628 int PartialSnapshotCacheIndex(HeapObject* o); 626 int PartialSnapshotCacheIndex(HeapObject* o);
629 bool ShouldBeInThePartialSnapshotCache(HeapObject* o); 627 bool ShouldBeInThePartialSnapshotCache(HeapObject* o);
630 628
631 void SerializeOutdatedContextsAsFixedArray(); 629 void SerializeOutdatedContextsAsFixedArray();
632 630
633 Serializer* startup_serializer_; 631 Serializer* startup_serializer_;
634 List<Context*> outdated_contexts_; 632 List<Context*> outdated_contexts_;
635 Object* global_object_; 633 Object* global_object_;
636 PartialCacheIndexMap partial_cache_index_map_; 634 PartialCacheIndexMap partial_cache_index_map_;
637 DISALLOW_COPY_AND_ASSIGN(PartialSerializer); 635 DISALLOW_COPY_AND_ASSIGN(PartialSerializer);
638 }; 636 };
639 637
640 638
641 class StartupSerializer : public Serializer { 639 class StartupSerializer : public Serializer {
642 public: 640 public:
643 StartupSerializer(Isolate* isolate, SnapshotByteSink* sink); 641 StartupSerializer(Isolate* isolate, SnapshotByteSink* sink);
644 ~StartupSerializer() { OutputStatistics("StartupSerializer"); } 642 ~StartupSerializer() override { OutputStatistics("StartupSerializer"); }
645 643
646 // The StartupSerializer has to serialize the root array, which is slightly 644 // The StartupSerializer has to serialize the root array, which is slightly
647 // different. 645 // different.
648 void VisitPointers(Object** start, Object** end) override; 646 void VisitPointers(Object** start, Object** end) override;
649 647
650 // Serialize the current state of the heap. The order is: 648 // Serialize the current state of the heap. The order is:
651 // 1) Strong references. 649 // 1) Strong references.
652 // 2) Partial snapshot cache. 650 // 2) Partial snapshot cache.
653 // 3) Weak references (e.g. the string table). 651 // 3) Weak references (e.g. the string table).
654 virtual void SerializeStrongReferences(); 652 virtual void SerializeStrongReferences();
655 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, 653 void SerializeObject(HeapObject* o, HowToCode how_to_code,
656 WhereToPoint where_to_point, int skip) override; 654 WhereToPoint where_to_point, int skip) override;
657 void SerializeWeakReferencesAndDeferred(); 655 void SerializeWeakReferencesAndDeferred();
658 void Serialize() { 656 void Serialize() {
659 SerializeStrongReferences(); 657 SerializeStrongReferences();
660 SerializeWeakReferencesAndDeferred(); 658 SerializeWeakReferencesAndDeferred();
661 } 659 }
662 660
663 private: 661 private:
664 intptr_t root_index_wave_front_; 662 intptr_t root_index_wave_front_;
665 DISALLOW_COPY_AND_ASSIGN(StartupSerializer); 663 DISALLOW_COPY_AND_ASSIGN(StartupSerializer);
666 }; 664 };
(...skipping 19 matching lines...) Expand all
686 } 684 }
687 685
688 const List<uint32_t>* stub_keys() const { return &stub_keys_; } 686 const List<uint32_t>* stub_keys() const { return &stub_keys_; }
689 687
690 private: 688 private:
691 CodeSerializer(Isolate* isolate, SnapshotByteSink* sink, String* source) 689 CodeSerializer(Isolate* isolate, SnapshotByteSink* sink, String* source)
692 : Serializer(isolate, sink), source_(source) { 690 : Serializer(isolate, sink), source_(source) {
693 back_reference_map_.AddSourceString(source); 691 back_reference_map_.AddSourceString(source);
694 } 692 }
695 693
696 ~CodeSerializer() { OutputStatistics("CodeSerializer"); } 694 ~CodeSerializer() override { OutputStatistics("CodeSerializer"); }
697 695
698 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, 696 void SerializeObject(HeapObject* o, HowToCode how_to_code,
699 WhereToPoint where_to_point, int skip) override; 697 WhereToPoint where_to_point, int skip) override;
700 698
701 void SerializeBuiltin(int builtin_index, HowToCode how_to_code, 699 void SerializeBuiltin(int builtin_index, HowToCode how_to_code,
702 WhereToPoint where_to_point); 700 WhereToPoint where_to_point);
703 void SerializeIC(Code* ic, HowToCode how_to_code, 701 void SerializeIC(Code* ic, HowToCode how_to_code,
704 WhereToPoint where_to_point); 702 WhereToPoint where_to_point);
705 void SerializeCodeStub(uint32_t stub_key, HowToCode how_to_code, 703 void SerializeCodeStub(uint32_t stub_key, HowToCode how_to_code,
706 WhereToPoint where_to_point); 704 WhereToPoint where_to_point);
707 void SerializeGeneric(HeapObject* heap_object, HowToCode how_to_code, 705 void SerializeGeneric(HeapObject* heap_object, HowToCode how_to_code,
708 WhereToPoint where_to_point); 706 WhereToPoint where_to_point);
709 int AddCodeStubKey(uint32_t stub_key); 707 int AddCodeStubKey(uint32_t stub_key);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; 807 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size;
810 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; 808 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size;
811 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; 809 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size;
812 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; 810 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size;
813 static const int kHeaderSize = kChecksum2Offset + kInt32Size; 811 static const int kHeaderSize = kChecksum2Offset + kInt32Size;
814 }; 812 };
815 } // namespace internal 813 } // namespace internal
816 } // namespace v8 814 } // namespace v8
817 815
818 #endif // V8_SNAPSHOT_SERIALIZE_H_ 816 #endif // V8_SNAPSHOT_SERIALIZE_H_
OLDNEW
« no previous file with comments | « src/scanner-character-streams.h ('k') | src/snapshot/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698