v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
heap-layout.h
Go to the documentation of this file.
1// Copyright 2024 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_HEAP_LAYOUT_H_
6#define V8_HEAP_HEAP_LAYOUT_H_
7
8// Clients of this interface shouldn't depend on lots of heap internals.
9// Do not include anything from src/heap here!
10
11#include "src/base/macros.h"
12#include "src/common/globals.h"
13#include "src/objects/objects.h"
14#include "src/objects/tagged.h"
15
16namespace v8::internal {
17
18class MemoryChunk;
19
20// Checks for heap layouts. The checks generally use Heap infrastructure (heap,
21// space, page, mark bits, etc) and do not rely on instance types.
22class HeapLayout final : public AllStatic {
23 public:
24 // Returns whether `object` is part of a read-only space.
26
27 static V8_INLINE bool InYoungGeneration(Tagged<Object> object);
30 static V8_INLINE bool InYoungGeneration(const HeapObjectLayout* object);
31 static V8_INLINE bool InYoungGeneration(const MemoryChunk* chunk,
32 Tagged<HeapObject> object);
33
34 // Returns whether `object` is in a writable shared space. The is agnostic to
35 // how the shared space itself is managed.
37 // Returns whether `object` is in a shared space.
39
40 // Returns whether `object` is in code space. Note that there's various kinds
41 // of different code spaces (regular, external, large object) which are all
42 // covered by this check.
43 static V8_INLINE bool InCodeSpace(Tagged<HeapObject> object);
44
45 // Returns whether `object` is allocated in trusted space. See
46 // src/sandbox/GLOSSARY.md for details.
48
49 // Returns whether `object` is allocated on a black page (during
50 // incremental/concurrent marking).
52
53 // Returns whether `object` is allocated on a page which is owned by some Heap
54 // instance. This is equivalent to !InReadOnlySpace except during
55 // serialization.
57
58 // Returns whether the map word of `object` is a self forwarding address.
59 // This represents pinned objects and live large objects in Scavenger.
60 static bool IsSelfForwarded(Tagged<HeapObject> object);
61 static bool IsSelfForwarded(Tagged<HeapObject> object,
62 PtrComprCageBase cage_base);
63 static bool IsSelfForwarded(Tagged<HeapObject> object, MapWord map_word);
64
65 private:
67 const MemoryChunk* chunk, Tagged<HeapObject> object);
68
70 const MemoryChunk* chunk);
71};
72
73} // namespace v8::internal
74
75#endif // V8_HEAP_HEAP_LAYOUT_H_
static V8_INLINE bool InYoungGeneration(Tagged< Object > object)
static V8_EXPORT bool InYoungGenerationForStickyMarkbits(const MemoryChunk *chunk, Tagged< HeapObject > object)
static V8_INLINE bool InWritableSharedSpace(Tagged< HeapObject > object)
static V8_INLINE bool IsOwnedByAnyHeap(Tagged< HeapObject > object)
static V8_EXPORT void CheckYoungGenerationConsistency(const MemoryChunk *chunk)
static V8_INLINE bool InTrustedSpace(Tagged< HeapObject > object)
static V8_INLINE bool InReadOnlySpace(Tagged< HeapObject > object)
static bool IsSelfForwarded(Tagged< HeapObject > object)
static V8_INLINE bool InBlackAllocatedPage(Tagged< HeapObject > object)
static V8_INLINE bool InAnySharedSpace(Tagged< HeapObject > object)
static V8_INLINE bool InCodeSpace(Tagged< HeapObject > object)
#define V8_EXPORT
Definition v8config.h:800
#define V8_INLINE
Definition v8config.h:500