LCOV - code coverage report
Current view: top level - src - address-map.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 12 12 100.0 %
Date: 2017-10-20 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // Copyright 2015 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/address-map.h"
       6             : #include "src/heap/heap.h"
       7             : #include "src/isolate.h"
       8             : #include "src/objects-inl.h"
       9             : 
      10             : namespace v8 {
      11             : namespace internal {
      12             : 
      13      513467 : RootIndexMap::RootIndexMap(Isolate* isolate) {
      14      513467 :   map_ = isolate->root_index_map();
      15     1026934 :   if (map_ != nullptr) return;
      16       35960 :   map_ = new HeapObjectToIndexHashMap();
      17     7767360 :   for (uint32_t i = 0; i < Heap::kStrongRootListLength; i++) {
      18             :     Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i);
      19             :     Object* root = isolate->heap()->root(root_index);
      20     7749380 :     if (!root->IsHeapObject()) continue;
      21             :     // Omit root entries that can be written after initialization. They must
      22             :     // not be referenced through the root list in the snapshot.
      23             :     // Since we map the raw address of an root item to its root list index, the
      24             :     // raw address must be constant, i.e. the object must be immovable.
      25     7731307 :     if (isolate->heap()->RootCanBeTreatedAsConstant(root_index)) {
      26             :       HeapObject* heap_object = HeapObject::cast(root);
      27     7407667 :       Maybe<uint32_t> maybe_index = map_->Get(heap_object);
      28     7407667 :       if (maybe_index.IsJust()) {
      29             :         // Some are initialized to a previous value in the root list.
      30             :         DCHECK_LT(maybe_index.FromJust(), i);
      31             :       } else {
      32     7407667 :         map_->Set(heap_object, i);
      33             :       }
      34             :     } else {
      35             :       // Immortal immovable root objects are constant and allocated on the first
      36             :       // page of old space. Non-constant roots cannot be immortal immovable. The
      37             :       // root index map contains all immortal immmovable root objects.
      38      323640 :       CHECK(!Heap::RootIsImmortalImmovable(root_index));
      39             :     }
      40             :   }
      41       17980 :   isolate->set_root_index_map(map_);
      42             : }
      43             : 
      44             : }  // namespace internal
      45             : }  // namespace v8

Generated by: LCOV version 1.10