v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
memory-chunk-inl.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_MEMORY_CHUNK_INL_H_
6#define V8_HEAP_MEMORY_CHUNK_INL_H_
7
9// Include the non-inl header before the rest of the headers.
10
12#include "src/sandbox/check.h"
13
14namespace v8 {
15namespace internal {
16
18 // If this changes, we also need to update
19 // CodeStubAssembler::PageMetadataFromMemoryChunk
20#ifdef V8_ENABLE_SANDBOX
21 DCHECK_LT(metadata_index_,
22 MemoryChunkConstants::kMetadataPointerTableSizeMask);
23 MemoryChunkMetadata** metadata_pointer_table =
24 IsolateGroup::current()->metadata_pointer_table();
25 MemoryChunkMetadata* metadata = metadata_pointer_table
26 [metadata_index_ & MemoryChunkConstants::kMetadataPointerTableSizeMask];
27 // Check that the Metadata belongs to this Chunk, since an attacker with write
28 // inside the sandbox could've swapped the index.
29 SBXCHECK_EQ(metadata->Chunk(), this);
30 return metadata;
31#else
32 return metadata_;
33#endif
34}
35
37 return const_cast<MemoryChunk*>(this)->Metadata();
38}
39
41
42} // namespace internal
43} // namespace v8
44
45#endif // V8_HEAP_MEMORY_CHUNK_INL_H_
#define SBXCHECK_EQ(lhs, rhs)
Definition check.h:62
static IsolateGroup * current()
V8_INLINE Heap * GetHeap()
V8_INLINE MemoryChunkMetadata * Metadata()
MemoryChunkMetadata * metadata_
#define DCHECK_LT(v1, v2)
Definition logging.h:489