v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
active-system-pages.h
Go to the documentation of this file.
1// Copyright 2022 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_BASE_ACTIVE_SYSTEM_PAGES_H_
6#define V8_HEAP_BASE_ACTIVE_SYSTEM_PAGES_H_
7
8#include <bitset>
9#include <cstdint>
10
11#include "src/base/macros.h"
12
13namespace heap {
14namespace base {
15
16// Class implements a bitset of system pages on a heap page.
17class ActiveSystemPages final {
18 public:
19 // Defines the maximum number of system pages that can be tracked in one
20 // instance.
21 static constexpr size_t kMaxPages = 64;
22
23 // Initializes the set of active pages to the system pages for the header.
24 V8_EXPORT_PRIVATE size_t Init(size_t header_size, size_t page_size_bits,
25 size_t user_page_size);
26
27 // Adds the pages for this memory range. Returns the number of freshly added
28 // pages.
29 V8_EXPORT_PRIVATE size_t Add(size_t start, size_t end, size_t page_size_bits);
30
31 // Replaces the current bitset with the given argument. The new bitset needs
32 // to be a proper subset of the current pages, which means this operation
33 // can't add pages. Returns the number of removed pages.
34 V8_EXPORT_PRIVATE size_t Reduce(ActiveSystemPages updated_value);
35
36 // Removes all pages. Returns the number of removed pages.
37 V8_EXPORT_PRIVATE size_t Clear();
38
39 // Returns the memory used with the given page size.
40 V8_EXPORT_PRIVATE size_t Size(size_t page_size_bits) const;
41
42 private:
43 using bitset_t = std::bitset<kMaxPages>;
44
46};
47
48} // namespace base
49} // namespace heap
50
51#endif // V8_HEAP_BASE_ACTIVE_SYSTEM_PAGES_H_
V8_EXPORT_PRIVATE size_t Add(size_t start, size_t end, size_t page_size_bits)
static constexpr size_t kMaxPages
std::bitset< kMaxPages > bitset_t
V8_EXPORT_PRIVATE size_t Reduce(ActiveSystemPages updated_value)
V8_EXPORT_PRIVATE size_t Init(size_t header_size, size_t page_size_bits, size_t user_page_size)
V8_EXPORT_PRIVATE size_t Clear()
V8_EXPORT_PRIVATE size_t Size(size_t page_size_bits) const
int start
int end
#define V8_EXPORT_PRIVATE
Definition macros.h:460