v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
virtual-memory.h
Go to the documentation of this file.
1
// Copyright 2020 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_CPPGC_VIRTUAL_MEMORY_H_
6
#define V8_HEAP_CPPGC_VIRTUAL_MEMORY_H_
7
8
#include <cstdint>
9
10
#include "
include/cppgc/platform.h
"
11
#include "
src/base/macros.h
"
12
13
namespace
cppgc
{
14
namespace
internal
{
15
16
// Represents and controls an area of reserved memory.
17
class
V8_EXPORT_PRIVATE
VirtualMemory
{
18
public
:
19
// Empty VirtualMemory object, controlling no reserved memory.
20
VirtualMemory
() =
default
;
21
22
// Reserves virtual memory containing an area of the given size that is
23
// aligned per |alignment| rounded up to the |page_allocator|'s allocate page
24
// size. The |size| is aligned with |page_allocator|'s commit page size.
25
VirtualMemory
(
PageAllocator
*,
size_t
size,
size_t
alignment,
26
void
* hint =
nullptr
);
27
28
// Releases the reserved memory, if any, controlled by this VirtualMemory
29
// object.
30
~VirtualMemory
()
V8_NOEXCEPT
;
31
32
VirtualMemory
(
VirtualMemory
&&)
V8_NOEXCEPT
;
33
VirtualMemory
& operator=(
VirtualMemory
&&)
V8_NOEXCEPT
;
34
35
// Returns whether the memory has been reserved.
36
bool
IsReserved()
const
{
return
start_
!=
nullptr
; }
37
38
void
*
address
()
const
{
39
DCHECK
(IsReserved());
40
return
start_
;
41
}
42
43
size_t
size
()
const
{
44
DCHECK
(IsReserved());
45
return
size_
;
46
}
47
48
private
:
49
// Resets to the default state.
50
void
Reset();
51
52
PageAllocator
*
page_allocator_
=
nullptr
;
53
void
*
start_
=
nullptr
;
54
size_t
size_
= 0;
55
};
56
57
}
// namespace internal
58
}
// namespace cppgc
59
60
#endif
// V8_HEAP_CPPGC_VIRTUAL_MEMORY_H_
cppgc::internal::VirtualMemory
Definition
virtual-memory.h:17
cppgc::internal::VirtualMemory::size
size_t size() const
Definition
virtual-memory.h:43
cppgc::internal::VirtualMemory::VirtualMemory
VirtualMemory()=default
cppgc::internal::VirtualMemory::address
void * address() const
Definition
virtual-memory.h:38
v8::PageAllocator
Definition
v8-platform.h:455
size_
const int size_
Definition
assembler.cc:132
start_
uint8_t *const start_
Definition
assembler.cc:131
page_allocator_
cppgc::PageAllocator * page_allocator_
Definition
cpp-heap.cc:194
platform.h
cppgc
Definition
cross-heap-remembered-set.h:14
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
V8_NOEXCEPT
#define V8_NOEXCEPT
Definition
compiler-specific.h:105
DCHECK
#define DCHECK(condition)
Definition
logging.h:482
macros.h
V8_EXPORT_PRIVATE
#define V8_EXPORT_PRIVATE
Definition
macros.h:460
src
heap
cppgc
virtual-memory.h
Generated on Sun Apr 6 2025 21:08:54 for v8 by
1.12.0