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

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

Issue 1992723002: [serializer] prepare attached references for general use. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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
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/deserializer.h" 5 #include "src/snapshot/deserializer.h"
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/external-reference-table.h" 8 #include "src/external-reference-table.h"
9 #include "src/heap/heap.h" 9 #include "src/heap/heap.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 113
114 MaybeHandle<Object> Deserializer::DeserializePartial( 114 MaybeHandle<Object> Deserializer::DeserializePartial(
115 Isolate* isolate, Handle<JSGlobalProxy> global_proxy) { 115 Isolate* isolate, Handle<JSGlobalProxy> global_proxy) {
116 Initialize(isolate); 116 Initialize(isolate);
117 if (!ReserveSpace()) { 117 if (!ReserveSpace()) {
118 V8::FatalProcessOutOfMemory("deserialize context"); 118 V8::FatalProcessOutOfMemory("deserialize context");
119 return MaybeHandle<Object>(); 119 return MaybeHandle<Object>();
120 } 120 }
121 121
122 Vector<Handle<Object> > attached_objects = Vector<Handle<Object> >::New(1); 122 AddAttachedObject(global_proxy);
123 attached_objects[kGlobalProxyReference] = global_proxy;
124 SetAttachedObjects(attached_objects);
125 123
126 DisallowHeapAllocation no_gc; 124 DisallowHeapAllocation no_gc;
127 // Keep track of the code space start and end pointers in case new 125 // Keep track of the code space start and end pointers in case new
128 // code objects were unserialized 126 // code objects were unserialized
129 OldSpace* code_space = isolate_->heap()->code_space(); 127 OldSpace* code_space = isolate_->heap()->code_space();
130 Address start_address = code_space->top(); 128 Address start_address = code_space->top();
131 Object* root; 129 Object* root;
132 VisitPointer(&root); 130 VisitPointer(&root);
133 DeserializeDeferredObjects(); 131 DeserializeDeferredObjects();
134 132
(...skipping 25 matching lines...) Expand all
160 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_); 158 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_);
161 } 159 }
162 CommitPostProcessedObjects(isolate); 160 CommitPostProcessedObjects(isolate);
163 return scope.CloseAndEscape(result); 161 return scope.CloseAndEscape(result);
164 } 162 }
165 } 163 }
166 164
167 Deserializer::~Deserializer() { 165 Deserializer::~Deserializer() {
168 // TODO(svenpanne) Re-enable this assertion when v8 initialization is fixed. 166 // TODO(svenpanne) Re-enable this assertion when v8 initialization is fixed.
169 // DCHECK(source_.AtEOF()); 167 // DCHECK(source_.AtEOF());
170 attached_objects_.Dispose();
171 } 168 }
172 169
173 // This is called on the roots. It is the driver of the deserialization 170 // This is called on the roots. It is the driver of the deserialization
174 // process. It is also called on the body of each function. 171 // process. It is also called on the body of each function.
175 void Deserializer::VisitPointers(Object** start, Object** end) { 172 void Deserializer::VisitPointers(Object** start, Object** end) {
176 // The space must be new space. Any other space would cause ReadChunk to try 173 // The space must be new space. Any other space would cause ReadChunk to try
177 // to update the remembered using NULL as the address. 174 // to update the remembered using NULL as the address.
178 ReadData(start, end, NEW_SPACE, NULL); 175 ReadData(start, end, NEW_SPACE, NULL);
179 } 176 }
180 177
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // Assign a new script id to avoid collision. 305 // Assign a new script id to avoid collision.
309 script->set_id(isolate_->heap()->NextScriptId()); 306 script->set_id(isolate_->heap()->NextScriptId());
310 // Add script to list. 307 // Add script to list.
311 Handle<Object> list = WeakFixedArray::Add(factory->script_list(), script); 308 Handle<Object> list = WeakFixedArray::Add(factory->script_list(), script);
312 heap->SetRootScriptList(*list); 309 heap->SetRootScriptList(*list);
313 } 310 }
314 } 311 }
315 312
316 HeapObject* Deserializer::GetBackReferencedObject(int space) { 313 HeapObject* Deserializer::GetBackReferencedObject(int space) {
317 HeapObject* obj; 314 HeapObject* obj;
318 BackReference back_reference(source_.GetInt()); 315 SerializerReference back_reference(source_.GetInt());
319 if (space == LO_SPACE) { 316 if (space == LO_SPACE) {
320 CHECK(back_reference.chunk_index() == 0); 317 CHECK(back_reference.chunk_index() == 0);
321 uint32_t index = back_reference.large_object_index(); 318 uint32_t index = back_reference.large_object_index();
322 obj = deserialized_large_objects_[index]; 319 obj = deserialized_large_objects_[index];
323 } else { 320 } else {
324 DCHECK(space < kNumberOfPreallocatedSpaces); 321 DCHECK(space < kNumberOfPreallocatedSpaces);
325 uint32_t chunk_index = back_reference.chunk_index(); 322 uint32_t chunk_index = back_reference.chunk_index();
326 DCHECK_LE(chunk_index, current_chunk_[space]); 323 DCHECK_LE(chunk_index, current_chunk_[space]);
327 uint32_t chunk_offset = back_reference.chunk_offset(); 324 uint32_t chunk_offset = back_reference.chunk_offset();
328 Address address = reservations_[space][chunk_index].start + chunk_offset; 325 Address address = reservations_[space][chunk_index].start + chunk_offset;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 emit_write_barrier = isolate->heap()->InNewSpace(new_object); \ 486 emit_write_barrier = isolate->heap()->InNewSpace(new_object); \
490 } else if (where == kExternalReference) { \ 487 } else if (where == kExternalReference) { \
491 int skip = source_.GetInt(); \ 488 int skip = source_.GetInt(); \
492 current = reinterpret_cast<Object**>( \ 489 current = reinterpret_cast<Object**>( \
493 reinterpret_cast<Address>(current) + skip); \ 490 reinterpret_cast<Address>(current) + skip); \
494 int reference_id = source_.GetInt(); \ 491 int reference_id = source_.GetInt(); \
495 Address address = external_reference_table_->address(reference_id); \ 492 Address address = external_reference_table_->address(reference_id); \
496 new_object = reinterpret_cast<Object*>(address); \ 493 new_object = reinterpret_cast<Object*>(address); \
497 } else if (where == kAttachedReference) { \ 494 } else if (where == kAttachedReference) { \
498 int index = source_.GetInt(); \ 495 int index = source_.GetInt(); \
499 DCHECK(deserializing_user_code() || index == kGlobalProxyReference); \
500 new_object = *attached_objects_[index]; \ 496 new_object = *attached_objects_[index]; \
501 emit_write_barrier = isolate->heap()->InNewSpace(new_object); \ 497 emit_write_barrier = isolate->heap()->InNewSpace(new_object); \
502 } else { \ 498 } else { \
503 DCHECK(where == kBuiltin); \ 499 DCHECK(where == kBuiltin); \
504 DCHECK(deserializing_user_code()); \ 500 DCHECK(deserializing_user_code()); \
505 int builtin_id = source_.GetInt(); \ 501 int builtin_id = source_.GetInt(); \
506 DCHECK_LE(0, builtin_id); \ 502 DCHECK_LE(0, builtin_id); \
507 DCHECK_LT(builtin_id, Builtins::builtin_count); \ 503 DCHECK_LT(builtin_id, Builtins::builtin_count); \
508 Builtins::Name name = static_cast<Builtins::Name>(builtin_id); \ 504 Builtins::Name name = static_cast<Builtins::Name>(builtin_id); \
509 new_object = isolate->builtins()->builtin(name); \ 505 new_object = isolate->builtins()->builtin(name); \
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 805
810 default: 806 default:
811 CHECK(false); 807 CHECK(false);
812 } 808 }
813 } 809 }
814 CHECK_EQ(limit, current); 810 CHECK_EQ(limit, current);
815 return true; 811 return true;
816 } 812 }
817 } // namespace internal 813 } // namespace internal
818 } // namespace v8 814 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698