v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
memory-chunk-metadata-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_METADATA_INL_H_
6
#define V8_HEAP_MEMORY_CHUNK_METADATA_INL_H_
7
8
#include "
src/heap/memory-chunk-metadata.h
"
9
// Include the non-inl header before the rest of the headers.
10
11
#include "
src/heap/memory-chunk-inl.h
"
12
13
namespace
v8
{
14
namespace
internal
{
15
16
// static
17
MemoryChunkMetadata
*
MemoryChunkMetadata::FromAddress
(
Address
a) {
18
return
MemoryChunk::FromAddress
(a)->
Metadata
();
19
}
20
21
// static
22
MemoryChunkMetadata
*
MemoryChunkMetadata::FromHeapObject
(
Tagged<HeapObject>
o) {
23
return
FromAddress
(o.
ptr
());
24
}
25
26
// static
27
MemoryChunkMetadata
*
MemoryChunkMetadata::FromHeapObject
(
28
const
HeapObjectLayout
* o) {
29
return
FromAddress
(
reinterpret_cast<
Address
>
(o));
30
}
31
32
// static
33
void
MemoryChunkMetadata::UpdateHighWaterMark
(
Address
mark) {
34
if
(mark ==
kNullAddress
)
return
;
35
// Need to subtract one from the mark because when a chunk is full the
36
// top points to the next address after the chunk, which effectively belongs
37
// to another chunk. See the comment to
38
// PageMetadata::FromAllocationAreaAddress.
39
MemoryChunkMetadata
* chunk =
MemoryChunkMetadata::FromAddress
(mark - 1);
40
intptr_t new_mark =
static_cast<
intptr_t
>
(mark - chunk->
ChunkAddress
());
41
intptr_t old_mark = chunk->
high_water_mark_
.load(std::memory_order_relaxed);
42
while
((new_mark > old_mark) &&
43
!chunk->
high_water_mark_
.compare_exchange_weak(
44
old_mark, new_mark, std::memory_order_acq_rel)) {
45
}
46
}
47
48
}
// namespace internal
49
}
// namespace v8
50
51
#endif
// V8_HEAP_MEMORY_CHUNK_METADATA_INL_H_
v8::internal::HeapObjectLayout
Definition
heap-object.h:31
v8::internal::MemoryChunkMetadata
Definition
memory-chunk-metadata.h:32
v8::internal::MemoryChunkMetadata::FromHeapObject
static V8_INLINE MemoryChunkMetadata * FromHeapObject(Tagged< HeapObject > o)
Definition
memory-chunk-metadata-inl.h:22
v8::internal::MemoryChunkMetadata::high_water_mark_
std::atomic< intptr_t > high_water_mark_
Definition
memory-chunk-metadata.h:149
v8::internal::MemoryChunkMetadata::FromAddress
static V8_INLINE MemoryChunkMetadata * FromAddress(Address a)
Definition
memory-chunk-metadata-inl.h:17
v8::internal::MemoryChunkMetadata::UpdateHighWaterMark
static V8_INLINE void UpdateHighWaterMark(Address mark)
Definition
memory-chunk-metadata-inl.h:33
v8::internal::MemoryChunkMetadata::ChunkAddress
Address ChunkAddress() const
Definition
memory-chunk-metadata.h:51
v8::internal::MemoryChunk::Metadata
V8_INLINE MemoryChunkMetadata * Metadata()
Definition
memory-chunk-inl.h:17
v8::internal::MemoryChunk::FromAddress
static V8_INLINE MemoryChunk * FromAddress(Address addr)
Definition
memory-chunk.h:175
v8::internal::TaggedImpl::ptr
V8_INLINE constexpr StorageType ptr() const
Definition
tagged-impl.h:114
v8::internal::Tagged
Definition
waiter-queue-node.h:21
memory-chunk-inl.h
memory-chunk-metadata.h
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8::internal::Address
Address
Definition
api-callbacks-inl.h:36
v8::internal::kNullAddress
static constexpr Address kNullAddress
Definition
v8-internal.h:53
v8
Definition
api-arguments-inl.h:19
src
heap
memory-chunk-metadata-inl.h
Generated on Sun Apr 6 2025 21:08:54 for v8 by
1.12.0