1// Copyright 2018 the V8 project authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "src/snapshot/read-only-deserializer.h" 6 7#include "src/api/api.h" 8#include "src/execution/v8threads.h" 9#include "src/heap/heap-inl.h" // crbug.com/v8/8499 10#include "src/heap/read-only-heap.h" 11#include "src/objects/slots.h" 12#include "src/snapshot/snapshot.h" 13 14namespace v8 { 15namespace internal { 16 17void ReadOnlyDeserializer::DeserializeIntoIsolate() { 18 HandleScope scope(isolate()); 19 20 ReadOnlyHeap* ro_heap = isolate()->read_only_heap(); 21 22 // No active threads. 23 DCHECK_NULL(isolate()->thread_manager()->FirstThreadStateInUse()); 24 // No active handles. 25 DCHECK(isolate()->handle_scope_implementer()->blocks()->empty()); 26 // Read-only object cache is not yet populated. 27 DCHECK(!ro_heap->read_only_object_cache_is_initialized()); 28 // Startup object cache is not yet populated. 29 DCHECK(isolate()->startup_object_cache()->empty()); 30 // Builtins are not yet created. 31 DCHECK(!isolate()->builtins()->is_initialized()); 32 33 { 34 ReadOnlyRoots roots(isolate()); 35 36 roots.Iterate(this); 37 ro_heap->read_only_space()->RepairFreeSpacesAfterDeserialization(); 38 39 // Deserialize the Read-only Object Cache. 40 for (;;) { 41 Object* object = ro_heap->ExtendReadOnlyObjectCache(); 42 // During deserialization, the visitor populates the read-only object 43 // cache and eventually terminates the cache with undefined. 44 VisitRootPointer(Root::kReadOnlyObjectCache, nullptr, 45 FullObjectSlot(object)); 46 if (object->IsUndefined(roots)) break; 47 } 48 DeserializeDeferredObjects(); 49 CheckNoArrayBufferBackingStores(); 50 } 51 52 if (should_rehash()) { 53 isolate()->heap()->InitializeHashSeed(); 54 Rehash(); 55 } 56} 57 58} // namespace internal 59} // namespace v8 60