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

Side by Side Diff: src/snapshot/serializer.cc

Issue 1811913002: [serializer] ensure that immortal immovable roots are correctly deserialized. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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/snapshot/serializer.h ('k') | src/snapshot/startup-serializer.h » ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 #include "src/snapshot/serializer.h" 5 #include "src/snapshot/serializer.h"
6 6
7 #include "src/macro-assembler.h" 7 #include "src/macro-assembler.h"
8 #include "src/snapshot/natives.h" 8 #include "src/snapshot/natives.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 void Serializer::SerializeDeferredObjects() { 90 void Serializer::SerializeDeferredObjects() {
91 while (deferred_objects_.length() > 0) { 91 while (deferred_objects_.length() > 0) {
92 HeapObject* obj = deferred_objects_.RemoveLast(); 92 HeapObject* obj = deferred_objects_.RemoveLast();
93 ObjectSerializer obj_serializer(this, obj, sink_, kPlain, kStartOfObject); 93 ObjectSerializer obj_serializer(this, obj, sink_, kPlain, kStartOfObject);
94 obj_serializer.SerializeDeferred(); 94 obj_serializer.SerializeDeferred();
95 } 95 }
96 sink_->Put(kSynchronize, "Finished with deferred objects"); 96 sink_->Put(kSynchronize, "Finished with deferred objects");
97 } 97 }
98 98
99 bool Serializer::ShouldBeSkipped(Object** current) {
100 Object** roots = isolate()->heap()->roots_array_start();
Michael Starzinger 2016/03/17 12:27:29 Woot! I love this, this was one of the last remain
101 return current == &roots[Heap::kStoreBufferTopRootIndex] ||
102 current == &roots[Heap::kStackLimitRootIndex] ||
103 current == &roots[Heap::kRealStackLimitRootIndex];
104 }
105
106 void Serializer::VisitPointers(Object** start, Object** end) { 99 void Serializer::VisitPointers(Object** start, Object** end) {
107 for (Object** current = start; current < end; current++) { 100 for (Object** current = start; current < end; current++) {
108 if ((*current)->IsSmi()) { 101 if ((*current)->IsSmi()) {
109 sink_->Put(kOnePointerRawData, "Smi"); 102 PutSmi(Smi::cast(*current));
110 for (int i = 0; i < kPointerSize; i++) {
111 sink_->Put(reinterpret_cast<byte*>(current)[i], "Byte");
112 }
113 } else { 103 } else {
114 SerializeObject(HeapObject::cast(*current), kPlain, kStartOfObject, 0); 104 SerializeObject(HeapObject::cast(*current), kPlain, kStartOfObject, 0);
115 } 105 }
116 } 106 }
117 } 107 }
118 108
119 void Serializer::EncodeReservations( 109 void Serializer::EncodeReservations(
120 List<SerializedData::Reservation>* out) const { 110 List<SerializedData::Reservation>* out) const {
121 for (int i = 0; i < kNumberOfPreallocatedSpaces; i++) { 111 for (int i = 0; i < kNumberOfPreallocatedSpaces; i++) {
122 for (int j = 0; j < completed_chunks_[i].length(); j++) { 112 for (int j = 0; j < completed_chunks_[i].length(); j++) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 sink_->Put(kRootArrayConstantsWithSkip + root_index, "RootConstant"); 223 sink_->Put(kRootArrayConstantsWithSkip + root_index, "RootConstant");
234 sink_->PutInt(skip, "SkipInPutRoot"); 224 sink_->PutInt(skip, "SkipInPutRoot");
235 } 225 }
236 } else { 226 } else {
237 FlushSkip(skip); 227 FlushSkip(skip);
238 sink_->Put(kRootArray + how_to_code + where_to_point, "RootSerialization"); 228 sink_->Put(kRootArray + how_to_code + where_to_point, "RootSerialization");
239 sink_->PutInt(root_index, "root_index"); 229 sink_->PutInt(root_index, "root_index");
240 } 230 }
241 } 231 }
242 232
233 void Serializer::PutSmi(Smi* smi) {
234 sink_->Put(kOnePointerRawData, "Smi");
235 byte* bytes = reinterpret_cast<byte*>(&smi);
236 for (int i = 0; i < kPointerSize; i++) sink_->Put(bytes[i], "Byte");
237 }
238
243 void Serializer::PutBackReference(HeapObject* object, BackReference reference) { 239 void Serializer::PutBackReference(HeapObject* object, BackReference reference) {
244 DCHECK(BackReferenceIsAlreadyAllocated(reference)); 240 DCHECK(BackReferenceIsAlreadyAllocated(reference));
245 sink_->PutInt(reference.reference(), "BackRefValue"); 241 sink_->PutInt(reference.reference(), "BackRefValue");
246 hot_objects_.Add(object); 242 hot_objects_.Add(object);
247 } 243 }
248 244
249 int Serializer::PutAlignmentPrefix(HeapObject* object) { 245 int Serializer::PutAlignmentPrefix(HeapObject* object) {
250 AllocationAlignment alignment = object->RequiredAlignment(); 246 AllocationAlignment alignment = object->RequiredAlignment();
251 if (alignment != kWordAligned) { 247 if (alignment != kWordAligned) {
252 DCHECK(1 <= alignment && alignment <= 3); 248 DCHECK(1 <= alignment && alignment <= 3);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 code_address_map_ = new CodeAddressMap(isolate_); 297 code_address_map_ = new CodeAddressMap(isolate_);
302 } 298 }
303 299
304 Code* Serializer::CopyCode(Code* code) { 300 Code* Serializer::CopyCode(Code* code) {
305 code_buffer_.Rewind(0); // Clear buffer without deleting backing store. 301 code_buffer_.Rewind(0); // Clear buffer without deleting backing store.
306 int size = code->CodeSize(); 302 int size = code->CodeSize();
307 code_buffer_.AddAll(Vector<byte>(code->address(), size)); 303 code_buffer_.AddAll(Vector<byte>(code->address(), size));
308 return Code::cast(HeapObject::FromAddress(&code_buffer_.first())); 304 return Code::cast(HeapObject::FromAddress(&code_buffer_.first()));
309 } 305 }
310 306
307 bool Serializer::HasNotExceededFirstPageOfEachSpace() {
308 for (int i = 0; i < kNumberOfPreallocatedSpaces; i++) {
309 if (!completed_chunks_[i].is_empty()) return false;
310 }
311 return true;
312 }
313
311 void Serializer::ObjectSerializer::SerializePrologue(AllocationSpace space, 314 void Serializer::ObjectSerializer::SerializePrologue(AllocationSpace space,
312 int size, Map* map) { 315 int size, Map* map) {
313 if (serializer_->code_address_map_) { 316 if (serializer_->code_address_map_) {
314 const char* code_name = 317 const char* code_name =
315 serializer_->code_address_map_->Lookup(object_->address()); 318 serializer_->code_address_map_->Lookup(object_->address());
316 LOG(serializer_->isolate_, 319 LOG(serializer_->isolate_,
317 CodeNameEvent(object_->address(), sink_->Position(), code_name)); 320 CodeNameEvent(object_->address(), sink_->Position(), code_name));
318 LOG(serializer_->isolate_, 321 LOG(serializer_->isolate_,
319 SnapshotPositionEvent(object_, sink_->Position())); 322 SnapshotPositionEvent(object_, sink_->Position()));
320 } 323 }
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 if (to_skip != 0 && return_skip == kIgnoringReturn) { 763 if (to_skip != 0 && return_skip == kIgnoringReturn) {
761 sink_->Put(kSkip, "Skip"); 764 sink_->Put(kSkip, "Skip");
762 sink_->PutInt(to_skip, "SkipDistance"); 765 sink_->PutInt(to_skip, "SkipDistance");
763 to_skip = 0; 766 to_skip = 0;
764 } 767 }
765 return to_skip; 768 return to_skip;
766 } 769 }
767 770
768 } // namespace internal 771 } // namespace internal
769 } // namespace v8 772 } // namespace v8
OLDNEW
« no previous file with comments | « src/snapshot/serializer.h ('k') | src/snapshot/startup-serializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698