// Copyright 2020 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_HEAP_READ_ONLY_SPACES_H_ #define V8_HEAP_READ_ONLY_SPACES_H_ #include <memory> #include <optional> #include <utility> #include "include/v8-platform.h" #include "src/base/macros.h" #include "src/common/globals.h" #include "src/heap/allocation-result.h" #include "src/heap/allocation-stats.h" #include "src/heap/base-space.h" #include "src/heap/heap-verifier.h" #include "src/heap/list.h" #include "src/heap/memory-chunk-metadata.h" #include "src/heap/mutable-page-metadata.h" namespace v8 { namespace internal { class MemoryAllocator; class ReadOnlyHeap; class SnapshotByteSource; class ReadOnlyPageMetadata : public MemoryChunkMetadata { … }; // ----------------------------------------------------------------------------- // Artifacts used to construct a new SharedReadOnlySpace class ReadOnlyArtifacts { … }; // ----------------------------------------------------------------------------- // Artifacts used to construct a new SharedReadOnlySpace when pointer // compression is disabled and so there is a single ReadOnlySpace with one set // of pages shared between all Isolates. class SingleCopyReadOnlyArtifacts : public ReadOnlyArtifacts { … }; // ----------------------------------------------------------------------------- // Artifacts used to construct a new SharedReadOnlySpace when pointer // compression is enabled and so there is a ReadOnlySpace for each Isolate with // with its own set of pages mapped from the canonical set stored here. class PointerCompressedReadOnlyArtifacts : public ReadOnlyArtifacts { … }; // ----------------------------------------------------------------------------- // Read Only space for all Immortal Immovable and Immutable objects class ReadOnlySpace : public BaseSpace { … }; class SharedReadOnlySpace : public ReadOnlySpace { … }; } // namespace internal namespace base { // Define special hash function for page pointers, to be used with std data // structures, e.g. std::unordered_set<ReadOnlyPageMetadata*, // base::hash<ReadOnlyPageMetadata*> template <> struct hash<i::ReadOnlyPageMetadata*> : hash<i::MemoryChunkMetadata*> { … }; template <> struct hash<const i::ReadOnlyPageMetadata*> : hash<const i::MemoryChunkMetadata*> { … }; } // namespace base } // namespace v8 #endif // V8_HEAP_READ_ONLY_SPACES_H_