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

Side by Side Diff: src/serialize.h

Issue 846023002: Update references to global object after deserializing context. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comments 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
« no previous file with comments | « src/bootstrapper.cc ('k') | src/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_SERIALIZE_H_ 5 #ifndef V8_SERIALIZE_H_
6 #define V8_SERIALIZE_H_ 6 #define V8_SERIALIZE_H_
7 7
8 #include "src/compiler.h" 8 #include "src/compiler.h"
9 #include "src/hashmap.h" 9 #include "src/hashmap.h"
10 #include "src/heap-profiler.h" 10 #include "src/heap-profiler.h"
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 external_reference_decoder_(NULL), 511 external_reference_decoder_(NULL),
512 deserialized_large_objects_(0) { 512 deserialized_large_objects_(0) {
513 DecodeReservation(data->Reservations()); 513 DecodeReservation(data->Reservations());
514 } 514 }
515 515
516 virtual ~Deserializer(); 516 virtual ~Deserializer();
517 517
518 // Deserialize the snapshot into an empty heap. 518 // Deserialize the snapshot into an empty heap.
519 void Deserialize(Isolate* isolate); 519 void Deserialize(Isolate* isolate);
520 520
521 enum OnOOM { FATAL_ON_OOM, NULL_ON_OOM };
522
523 // Deserialize a single object and the objects reachable from it. 521 // Deserialize a single object and the objects reachable from it.
524 // We may want to abort gracefully even if deserialization fails. 522 // We may want to abort gracefully even if deserialization fails.
525 void DeserializePartial(Isolate* isolate, Object** root, 523 MaybeHandle<Object> DeserializePartial(
526 OnOOM on_oom = FATAL_ON_OOM); 524 Isolate* isolate, Handle<FixedArray>* outdated_contexts_out);
525
526 MaybeHandle<SharedFunctionInfo> DeserializeCode(Isolate* isolate);
527 527
528 void FlushICacheForNewCodeObjects(); 528 void FlushICacheForNewCodeObjects();
529 529
530 // Serialized user code reference certain objects that are provided in a list 530 // Serialized user code reference certain objects that are provided in a list
531 // By calling this method, we assume that we are deserializing user code. 531 // By calling this method, we assume that we are deserializing user code.
532 void SetAttachedObjects(Vector<Handle<Object> >* attached_objects) { 532 void SetAttachedObjects(Vector<Handle<Object> >* attached_objects) {
533 attached_objects_ = attached_objects; 533 attached_objects_ = attached_objects;
534 } 534 }
535 535
536 bool deserializing_user_code() { return attached_objects_ != NULL; } 536 bool deserializing_user_code() { return attached_objects_ != NULL; }
537 537
538 private: 538 private:
539 virtual void VisitPointers(Object** start, Object** end); 539 virtual void VisitPointers(Object** start, Object** end);
540 540
541 virtual void VisitRuntimeEntry(RelocInfo* rinfo) { 541 virtual void VisitRuntimeEntry(RelocInfo* rinfo) {
542 UNREACHABLE(); 542 UNREACHABLE();
543 } 543 }
544 544
545 void Initialize(Isolate* isolate);
546
545 void DecodeReservation(Vector<const SerializedData::Reservation> res); 547 void DecodeReservation(Vector<const SerializedData::Reservation> res);
546 548
547 bool ReserveSpace(); 549 bool ReserveSpace();
548 550
549 void UnalignedCopy(Object** dest, Object** src) { 551 void UnalignedCopy(Object** dest, Object** src) {
550 memcpy(dest, src, sizeof(*src)); 552 memcpy(dest, src, sizeof(*src));
551 } 553 }
552 554
553 // Allocation sites are present in the snapshot, and must be linked into 555 // Allocation sites are present in the snapshot, and must be linked into
554 // a list at deserialization time. 556 // a list at deserialization time.
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 // We map serialized large objects to indexes for back-referencing. 733 // We map serialized large objects to indexes for back-referencing.
732 uint32_t large_objects_total_size_; 734 uint32_t large_objects_total_size_;
733 uint32_t seen_large_objects_index_; 735 uint32_t seen_large_objects_index_;
734 736
735 DISALLOW_COPY_AND_ASSIGN(Serializer); 737 DISALLOW_COPY_AND_ASSIGN(Serializer);
736 }; 738 };
737 739
738 740
739 class PartialSerializer : public Serializer { 741 class PartialSerializer : public Serializer {
740 public: 742 public:
741 PartialSerializer(Isolate* isolate, 743 PartialSerializer(Isolate* isolate, Serializer* startup_snapshot_serializer,
742 Serializer* startup_snapshot_serializer,
743 SnapshotByteSink* sink) 744 SnapshotByteSink* sink)
744 : Serializer(isolate, sink), 745 : Serializer(isolate, sink),
745 startup_serializer_(startup_snapshot_serializer) { 746 startup_serializer_(startup_snapshot_serializer),
747 outdated_contexts_(0),
748 global_object_(NULL) {
746 InitializeCodeAddressMap(); 749 InitializeCodeAddressMap();
747 } 750 }
748 751
749 // Serialize the objects reachable from a single object pointer. 752 // Serialize the objects reachable from a single object pointer.
750 void Serialize(Object** o); 753 void Serialize(Object** o);
751 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, 754 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code,
752 WhereToPoint where_to_point, int skip) OVERRIDE; 755 WhereToPoint where_to_point, int skip) OVERRIDE;
753 756
754 private: 757 private:
755 int PartialSnapshotCacheIndex(HeapObject* o); 758 int PartialSnapshotCacheIndex(HeapObject* o);
756 bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { 759 bool ShouldBeInThePartialSnapshotCache(HeapObject* o) {
757 // Scripts should be referred only through shared function infos. We can't 760 // Scripts should be referred only through shared function infos. We can't
758 // allow them to be part of the partial snapshot because they contain a 761 // allow them to be part of the partial snapshot because they contain a
759 // unique ID, and deserializing several partial snapshots containing script 762 // unique ID, and deserializing several partial snapshots containing script
760 // would cause dupes. 763 // would cause dupes.
761 DCHECK(!o->IsScript()); 764 DCHECK(!o->IsScript());
762 return o->IsName() || o->IsSharedFunctionInfo() || 765 return o->IsName() || o->IsSharedFunctionInfo() ||
763 o->IsHeapNumber() || o->IsCode() || 766 o->IsHeapNumber() || o->IsCode() ||
764 o->IsScopeInfo() || 767 o->IsScopeInfo() ||
765 o->map() == 768 o->map() ==
766 startup_serializer_->isolate()->heap()->fixed_cow_array_map(); 769 startup_serializer_->isolate()->heap()->fixed_cow_array_map();
767 } 770 }
768 771
772 void SerializeOutdatedContextsAsFixedArray();
769 773
770 Serializer* startup_serializer_; 774 Serializer* startup_serializer_;
775 List<BackReference> outdated_contexts_;
776 Object* global_object_;
771 DISALLOW_COPY_AND_ASSIGN(PartialSerializer); 777 DISALLOW_COPY_AND_ASSIGN(PartialSerializer);
772 }; 778 };
773 779
774 780
775 class StartupSerializer : public Serializer { 781 class StartupSerializer : public Serializer {
776 public: 782 public:
777 StartupSerializer(Isolate* isolate, SnapshotByteSink* sink) 783 StartupSerializer(Isolate* isolate, SnapshotByteSink* sink)
778 : Serializer(isolate, sink), root_index_wave_front_(0) { 784 : Serializer(isolate, sink), root_index_wave_front_(0) {
779 // Clear the cache of objects used by the partial snapshot. After the 785 // Clear the cache of objects used by the partial snapshot. After the
780 // strong roots have been serialized we can create a partial snapshot 786 // strong roots have been serialized we can create a partial snapshot
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 static const int kCheckSumOffset = 0; 945 static const int kCheckSumOffset = 0;
940 static const int kNumInternalizedStringsOffset = 1; 946 static const int kNumInternalizedStringsOffset = 1;
941 static const int kReservationsOffset = 2; 947 static const int kReservationsOffset = 2;
942 static const int kNumCodeStubKeysOffset = 3; 948 static const int kNumCodeStubKeysOffset = 3;
943 static const int kPayloadLengthOffset = 4; 949 static const int kPayloadLengthOffset = 4;
944 static const int kHeaderSize = (kPayloadLengthOffset + 1) * kIntSize; 950 static const int kHeaderSize = (kPayloadLengthOffset + 1) * kIntSize;
945 }; 951 };
946 } } // namespace v8::internal 952 } } // namespace v8::internal
947 953
948 #endif // V8_SERIALIZE_H_ 954 #endif // V8_SERIALIZE_H_
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698