LCOV - code coverage report
Current view: top level - src/snapshot - read-only-deserializer.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 16 17 94.1 %
Date: 2019-04-18 Functions: 2 2 100.0 %

          Line data    Source code
       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.h"
       8             : #include "src/heap/heap-inl.h"  // crbug.com/v8/8499
       9             : #include "src/heap/read-only-heap.h"
      10             : #include "src/objects/slots.h"
      11             : #include "src/snapshot/snapshot.h"
      12             : #include "src/v8threads.h"
      13             : 
      14             : namespace v8 {
      15             : namespace internal {
      16             : 
      17       62386 : void ReadOnlyDeserializer::DeserializeInto(Isolate* isolate) {
      18       62386 :   Initialize(isolate);
      19             : 
      20       62386 :   if (!allocator()->ReserveSpace()) {
      21           0 :     V8::FatalProcessOutOfMemory(isolate, "ReadOnlyDeserializer");
      22             :   }
      23             : 
      24             :   // No active threads.
      25             :   DCHECK_NULL(isolate->thread_manager()->FirstThreadStateInUse());
      26             :   // No active handles.
      27             :   DCHECK(isolate->handle_scope_implementer()->blocks()->empty());
      28             :   // Partial snapshot cache is not yet populated.
      29             :   DCHECK(isolate->heap()->read_only_heap()->read_only_object_cache()->empty());
      30             :   DCHECK(isolate->partial_snapshot_cache()->empty());
      31             :   // Builtins are not yet created.
      32             :   DCHECK(!isolate->builtins()->is_initialized());
      33             : 
      34             :   {
      35             :     DisallowHeapAllocation no_gc;
      36             :     ReadOnlyRoots roots(isolate);
      37             : 
      38       62386 :     roots.Iterate(this);
      39             :     isolate->heap()
      40             :         ->read_only_heap()
      41             :         ->read_only_space()
      42       62386 :         ->RepairFreeListsAfterDeserialization();
      43             : 
      44             :     // Deserialize the Read-only Object Cache.
      45             :     std::vector<Object>* cache =
      46             :         isolate->heap()->read_only_heap()->read_only_object_cache();
      47    14036701 :     for (size_t i = 0;; ++i) {
      48             :       // Extend the array ready to get a value when deserializing.
      49    14099086 :       if (cache->size() <= i) cache->push_back(Smi::kZero);
      50             :       // During deserialization, the visitor populates the read-only object
      51             :       // cache and eventually terminates the cache with undefined.
      52    14099087 :       VisitRootPointer(Root::kReadOnlyObjectCache, nullptr,
      53    14099086 :                        FullObjectSlot(&cache->at(i)));
      54    14099087 :       if (cache->at(i)->IsUndefined(roots)) break;
      55             :     }
      56       62386 :     DeserializeDeferredObjects();
      57             :   }
      58             : 
      59       62386 :   if (FLAG_rehash_snapshot && can_rehash()) {
      60      124652 :     isolate_->heap()->InitializeHashSeed();
      61       62326 :     Rehash();
      62             :   }
      63       62386 : }
      64             : 
      65             : }  // namespace internal
      66      122036 : }  // namespace v8

Generated by: LCOV version 1.10