LCOV - code coverage report
Current view: top level - src/heap - read-only-heap.h (source / functions) Hit Total Coverage
Test: app.info Lines: 3 3 100.0 %
Date: 2019-03-21 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2019 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             : #ifndef V8_HEAP_READ_ONLY_HEAP_H_
       6             : #define V8_HEAP_READ_ONLY_HEAP_H_
       7             : 
       8             : #include "src/base/macros.h"
       9             : #include "src/heap/heap.h"
      10             : #include "src/objects.h"
      11             : #include "src/roots.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : 
      16             : class ReadOnlySpace;
      17             : class ReadOnlyDeserializer;
      18             : 
      19             : // This class transparently manages read-only space, roots and cache creation
      20             : // and destruction.
      21       61519 : class ReadOnlyHeap final {
      22             :  public:
      23             :   static constexpr size_t kEntriesCount =
      24             :       static_cast<size_t>(RootIndex::kReadOnlyRootsCount);
      25             : 
      26             :   // If necessary create read-only heap and initialize its artifacts (if the
      27             :   // deserializer is provided).
      28             :   // TODO(goszczycki): Ideally we'd create this without needing a heap.
      29             :   static void SetUp(Isolate* isolate, ReadOnlyDeserializer* des);
      30             :   // Indicate that all read-only space objects have been created and will not
      31             :   // be written to. This is not thread safe, and should really only be used as
      32             :   // part of mksnapshot or when read-only heap sharing is disabled.
      33             :   void OnCreateHeapObjectsComplete();
      34             :   // Indicate that the current isolate no longer requires the read-only heap and
      35             :   // it may be safely disposed of.
      36             :   void OnHeapTearDown();
      37             : 
      38             :   // Returns whether the object resides in the read-only space.
      39             :   static bool Contains(Object object);
      40             : 
      41             :   std::vector<Object>* read_only_object_cache() {
      42       61478 :     return &read_only_object_cache_;
      43             :   }
      44             :   ReadOnlySpace* read_only_space() const { return read_only_space_; }
      45             : 
      46             :  private:
      47             :   static ReadOnlyHeap* Init(Isolate* isolate, ReadOnlyDeserializer* des);
      48             : 
      49             :   bool deserializing_ = false;
      50             :   ReadOnlySpace* read_only_space_ = nullptr;
      51             :   std::vector<Object> read_only_object_cache_;
      52             : 
      53             : #ifdef V8_SHARED_RO_HEAP
      54             :   Address read_only_roots_[kEntriesCount];
      55             : #endif
      56             : 
      57       61534 :   explicit ReadOnlyHeap(ReadOnlySpace* ro_space) : read_only_space_(ro_space) {}
      58             :   DISALLOW_COPY_AND_ASSIGN(ReadOnlyHeap);
      59             : };
      60             : 
      61             : }  // namespace internal
      62             : }  // namespace v8
      63             : 
      64             : #endif  // V8_HEAP_READ_ONLY_HEAP_H_

Generated by: LCOV version 1.10