V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
bounded-page-allocator.h
1
// Copyright 2018 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_BASE_BOUNDED_PAGE_ALLOCATOR_H_
6
#define V8_BASE_BOUNDED_PAGE_ALLOCATOR_H_
7
8
#include "include/v8-platform.h"
9
#include "src/base/platform/mutex.h"
10
#include "src/base/region-allocator.h"
11
12
namespace
v8
{
13
namespace
base {
14
15
// This is a v8::PageAllocator implementation that allocates pages within the
16
// pre-reserved region of virtual space. This class requires the virtual space
17
// to be kept reserved during the lifetime of this object.
18
// The main application of bounded page allocator are
19
// - V8 heap pointer compression which requires the whole V8 heap to be
20
// allocated within a contiguous range of virtual address space,
21
// - executable page allocation, which allows to use PC-relative 32-bit code
22
// displacement on certain 64-bit platforms.
23
// Bounded page allocator uses other page allocator instance for doing actual
24
// page allocations.
25
// The implementation is thread-safe.
26
class
V8_BASE_EXPORT
BoundedPageAllocator
:
public
v8::PageAllocator
{
27
public
:
28
typedef
uintptr_t
Address
;
29
30
BoundedPageAllocator
(
v8::PageAllocator
* page_allocator,
Address
start,
31
size_t
size,
size_t
allocate_page_size);
32
~
BoundedPageAllocator
()
override
=
default
;
33
34
// These functions are not inlined to avoid https://crbug.com/v8/8275.
35
Address
begin()
const
;
36
size_t
size()
const
;
37
38
// Returns true if given address is in the range controlled by the bounded
39
// page allocator instance.
40
bool
contains(
Address
address)
const
{
41
return
region_allocator_.contains(address);
42
}
43
44
size_t
AllocatePageSize
()
override
{
return
allocate_page_size_; }
45
46
size_t
CommitPageSize
()
override
{
return
commit_page_size_; }
47
48
void
SetRandomMmapSeed
(
int64_t
seed)
override
{
49
page_allocator_->SetRandomMmapSeed(seed);
50
}
51
52
void
*
GetRandomMmapAddr
()
override
{
53
return
page_allocator_->GetRandomMmapAddr();
54
}
55
56
void
* AllocatePages(
void
* hint,
size_t
size,
size_t
alignment,
57
Permission access)
override
;
58
59
// Allocates pages at given address, returns true on success.
60
bool
AllocatePagesAt(Address address,
size_t
size, Permission access);
61
62
bool
FreePages(
void
* address,
size_t
size)
override
;
63
64
bool
ReleasePages(
void
* address,
size_t
size,
size_t
new_size)
override
;
65
66
bool
SetPermissions(
void
* address,
size_t
size, Permission access)
override
;
67
68
bool
DiscardSystemPages(
void
* address,
size_t
size)
override
;
69
70
private
:
71
v8::base::Mutex
mutex_;
72
const
size_t
allocate_page_size_;
73
const
size_t
commit_page_size_;
74
v8::PageAllocator
*
const
page_allocator_;
75
v8::base::RegionAllocator
region_allocator_;
76
77
DISALLOW_COPY_AND_ASSIGN(
BoundedPageAllocator
);
78
};
79
80
}
// namespace base
81
}
// namespace v8
82
83
#endif // V8_BASE_BOUNDED_PAGE_ALLOCATOR_H_
v8::base::BoundedPageAllocator
Definition:
bounded-page-allocator.h:26
v8::base::BoundedPageAllocator::GetRandomMmapAddr
void * GetRandomMmapAddr() override
Definition:
bounded-page-allocator.h:52
v8::base::RegionAllocator
Definition:
region-allocator.h:26
int64_t
v8::PageAllocator
Definition:
v8-platform.h:191
uintptr_t
v8
Definition:
libplatform.h:13
v8::base::BoundedPageAllocator::AllocatePageSize
size_t AllocatePageSize() override
Definition:
bounded-page-allocator.h:44
v8::base::Mutex
Definition:
mutex.h:37
v8::base::BoundedPageAllocator::CommitPageSize
size_t CommitPageSize() override
Definition:
bounded-page-allocator.h:46
v8::base::BoundedPageAllocator::SetRandomMmapSeed
void SetRandomMmapSeed(int64_t seed) override
Definition:
bounded-page-allocator.h:48
v8
src
base
bounded-page-allocator.h
Generated on Tue Dec 25 2018 14:38:14 by
1.8.14