LCOV - code coverage report
Current view: top level - src/snapshot - startup-deserializer.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 28 29 96.6 %
Date: 2019-01-20 Functions: 5 5 100.0 %

          Line data    Source code
       1             : // Copyright 2017 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/startup-deserializer.h"
       6             : 
       7             : #include "src/api.h"
       8             : #include "src/assembler-inl.h"
       9             : #include "src/heap/heap-inl.h"
      10             : #include "src/snapshot/read-only-deserializer.h"
      11             : #include "src/snapshot/snapshot.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : 
      16       62827 : void StartupDeserializer::DeserializeInto(Isolate* isolate) {
      17      188481 :   Initialize(isolate);
      18             : 
      19       62827 :   ReadOnlyDeserializer read_only_deserializer(read_only_data_);
      20             :   read_only_deserializer.SetRehashability(can_rehash());
      21       62827 :   read_only_deserializer.DeserializeInto(isolate);
      22             : 
      23       62827 :   if (!allocator()->ReserveSpace()) {
      24           0 :     V8::FatalProcessOutOfMemory(isolate, "StartupDeserializer");
      25             :   }
      26             : 
      27             :   // No active threads.
      28             :   DCHECK_NULL(isolate->thread_manager()->FirstThreadStateInUse());
      29             :   // No active handles.
      30             :   DCHECK(isolate->handle_scope_implementer()->blocks()->empty());
      31             :   // Partial snapshot cache is not yet populated.
      32             :   DCHECK(isolate->partial_snapshot_cache()->empty());
      33             :   // Builtins are not yet created.
      34             :   DCHECK(!isolate->builtins()->is_initialized());
      35             : 
      36             :   {
      37             :     DisallowHeapAllocation no_gc;
      38       62827 :     isolate->heap()->IterateSmiRoots(this);
      39       62827 :     isolate->heap()->IterateStrongRoots(this, VISIT_FOR_SERIALIZATION);
      40       62827 :     Iterate(isolate, this);
      41       62827 :     isolate->heap()->IterateWeakRoots(this, VISIT_FOR_SERIALIZATION);
      42       62827 :     DeserializeDeferredObjects();
      43       62827 :     RestoreExternalReferenceRedirectors(accessor_infos());
      44       62827 :     RestoreExternalReferenceRedirectors(call_handler_infos());
      45             : 
      46             :     // Flush the instruction cache for the entire code-space. Must happen after
      47             :     // builtins deserialization.
      48       62827 :     FlushICache();
      49             :   }
      50             : 
      51             :   isolate->heap()->set_native_contexts_list(
      52             :       ReadOnlyRoots(isolate).undefined_value());
      53             :   // The allocation site list is build during root iteration, but if no sites
      54             :   // were encountered then it needs to be initialized to undefined.
      55       62827 :   if (isolate->heap()->allocation_sites_list() == Smi::kZero) {
      56             :     isolate->heap()->set_allocation_sites_list(
      57             :         ReadOnlyRoots(isolate).undefined_value());
      58             :   }
      59             : 
      60             : 
      61             :   isolate->builtins()->MarkInitialized();
      62             : 
      63       62827 :   LogNewMapEvents();
      64             : 
      65      125654 :   if (FLAG_rehash_snapshot && can_rehash()) {
      66       62767 :     isolate->heap()->InitializeHashSeed();
      67       62767 :     read_only_deserializer.RehashHeap();
      68       62767 :     Rehash();
      69             :   }
      70       62827 : }
      71             : 
      72       62827 : void StartupDeserializer::LogNewMapEvents() {
      73       62827 :   if (FLAG_trace_maps) LOG(isolate_, LogAllMaps());
      74       62827 : }
      75             : 
      76       62827 : void StartupDeserializer::FlushICache() {
      77             :   DCHECK(!deserializing_user_code());
      78             :   // The entire isolate is newly deserialized. Simply flush all code pages.
      79      188481 :   for (Page* p : *isolate()->heap()->code_space()) {
      80       62827 :     Assembler::FlushICache(p->area_start(), p->area_end() - p->area_start());
      81             :   }
      82       62827 : }
      83             : 
      84             : }  // namespace internal
      85      183867 : }  // namespace v8

Generated by: LCOV version 1.10