v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
memory-chunk-metadata.cc
Go to the documentation of this file.
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
6
7#include <cstdlib>
8
13
14namespace v8::internal {
15
17 size_t chunk_size, Address area_start,
18 Address area_end,
19 VirtualMemory reservation)
20 : reservation_(std::move(reservation)),
21 allocated_bytes_(area_end - area_start),
22 high_water_mark_(area_start -
23 MemoryChunk::FromAddress(area_start)->address()),
24 size_(chunk_size),
25 area_end_(area_end),
26 heap_(heap),
27 area_start_(area_start),
28 owner_(space) {}
29
31#ifdef V8_ENABLE_SANDBOX
32 MemoryChunk::ClearMetadataPointer(this);
33#endif
34}
35
37 return IsAnySharedSpace(owner()->identity());
38}
39
41 return IsAnyTrustedSpace(owner()->identity());
42}
43
44#ifdef THREAD_SANITIZER
45void MemoryChunkMetadata::SynchronizedHeapLoad() const {
46 CHECK(reinterpret_cast<Heap*>(
47 base::Acquire_Load(reinterpret_cast<base::AtomicWord*>(&(
48 const_cast<MemoryChunkMetadata*>(this)->heap_)))) != nullptr ||
50}
51
52void MemoryChunkMetadata::SynchronizedHeapStore() {
53 // Since TSAN does not process memory fences, we use the following annotation
54 // to tell TSAN that there is no data race when emitting a
55 // InitializationMemoryFence. Note that the other thread still needs to
56 // perform MutablePageMetadata::synchronized_heap().
57 base::Release_Store(reinterpret_cast<base::AtomicWord*>(&heap_),
58 reinterpret_cast<base::AtomicWord>(heap_));
59}
60#endif
61
62} // namespace v8::internal
MemoryChunkMetadata(Heap *heap, BaseSpace *space, size_t chunk_size, Address area_start, Address area_end, VirtualMemory reservation)
const int size_
Definition assembler.cc:132
const MapRef owner_
STL namespace.
Atomic32 AtomicWord
Definition atomicops.h:76
Atomic8 Acquire_Load(volatile const Atomic8 *ptr)
Definition atomicops.h:249
void Release_Store(volatile Atomic8 *ptr, Atomic8 value)
Definition atomicops.h:204
constexpr bool IsAnyTrustedSpace(AllocationSpace space)
Definition globals.h:1337
constexpr bool IsAnySharedSpace(AllocationSpace space)
Definition globals.h:1341
#define CHECK(condition)
Definition logging.h:124
Heap * heap_