15export namespace jam::detail {
16hint_cold hint_noreturn
17void heap_failure(
char const * operation,
int code = 0) noexcept;
21class generation_reservation {
25 generation_reservation(std::size_t old_maximum, std::size_t young_maximum)
noexcept;
26 generation_reservation(generation_reservation
const &) =
delete;
27 ~generation_reservation() noexcept;
28 std::
byte * data() const noexcept {
return base_; }
38 std::size_t begin, end;
40 std::shared_ptr<backing> section;
44 struct reservation {};
45 std::byte * address =
nullptr;
46 std::size_t capacity = 0;
47 std::size_t fixed_extent = 0;
49 std::vector<span> spans;
51 [[noreturn]]
static void system_failure(
char const * operation)
noexcept;
52 static void validate_size(std::size_t bytes)
noexcept;
53 explicit heap_mapping(reservation, std::size_t bytes)
noexcept;
55 static void alias(span
const & source, std::byte * target, std::size_t count,
56 std::size_t offset = 0) noexcept;
58 static void alias(std::byte * source, std::byte * target, std::size_t count)
noexcept;
60 void fresh(std::size_t begin, std::size_t count)
noexcept;
61 void map_arc(heap_mapping
const & source, std::size_t start, std::size_t target, std::size_t count)
noexcept;
62 void finish_aliases() noexcept;
63 void discard_gap(std::
size_t start, std::
size_t live) const noexcept;
65 void reset_fixed() noexcept;
69 explicit heap_mapping(std::
size_t bytes) noexcept;
70 heap_mapping(std::
size_t bytes, std::
byte * base, std::
size_t maximum) noexcept;
73 void replace(heap_mapping & staged) noexcept;
74 heap_mapping(heap_mapping const &) = delete;
75 heap_mapping & operator=(heap_mapping const &) = delete;
76 heap_mapping(heap_mapping && other) noexcept
77 : address(std::exchange(other.address,
nullptr)), capacity(std::exchange(other.capacity, 0)),
78 fixed_extent(std::exchange(other.fixed_extent, 0)), spans(std::move(other.spans)) {}
79 heap_mapping & operator=(heap_mapping && other)
noexcept { swap(other);
return *
this; }
81 ~heap_mapping() noexcept;
83 hint_inline hint_pure std::
byte * data() const noexcept {
return address; }
85 hint_inline hint_pure std::size_t bytes() const noexcept {
return capacity; }
87 static std::size_t page_size() noexcept;
91 void publish(std::
size_t start, std::
byte * target, std::
size_t count) const noexcept;
94 static
void unpublish(std::
byte * target, std::
size_t count) noexcept;
97 [[nodiscard]] heap_mapping alias_run(std::
size_t start, std::
size_t count) const noexcept;
100 void replace_pages(heap_mapping const & source, std::
size_t start,
101 std::
size_t target, std::
size_t count) noexcept;
103 void swap(heap_mapping & other) noexcept {
104 std::swap(address, other.address);
105 std::swap(capacity, other.capacity);
106 std::swap(fixed_extent, other.fixed_extent);
107 spans.swap(other.spans);
113 heap_mapping resized(std::size_t old_start_bytes, std::size_t live_bytes,
114 std::size_t new_bytes, std::size_t new_start_bytes)
const noexcept;