Skip to content

Commit 69371bd

Browse files
author
Mark Lam
committed
Push guard page de/allocation down into OSAllocator.
https://bugs.webkit.org/show_bug.cgi?id=297841 rdar://159065710 Reviewed by Yusuke Suzuki. Previously, PageReservation can increase the allocation size by 2 pages to include guard pages. It then tells OSAllocator that there are guard pages included by passing a includesGuardPages bool. Based on this includesGuardPages bool, OSAllocator also assumes that the allocation size includes exactly 2 page sized guard regions on each end. Unfortunately, this treatment is not applied consistents everywhere. For example, 1. OSAllocator::tryReserveUncommitted() calls tryReserveAndCommit() with includesGuardPages being true. tryReserveAndCommit() allocates the buffer including the guard pages, and maps the guard pages to be PROT_NONE. Then, tryReserveUncommitted() fails to account for the Guard pages and madvise() the whole range as MADV_FREE_REUSABLE (including guard pages). This madvise fails, because it's not allowed to do this to the PROT_NONE guard pages. 2. PageReservation::deallocate() calls OSAllocator::releaseDecommitted() on its base() for size() bytes. base() is not the base of the allocation, but just the start of the usable section after the guard page at the start. releaseDecommitted() munmaps that memory range. However, if there are guard regions on each end, the pages for the guard regions are never munmapped. This change makes the division of labor and responsibility clearer: 1. PageReservation just specifies how many guard pages it wants on each end, if any. 2. OSAllocator takes care of allocation / deallocation, including for guard pages. So, PageReservation will now pass in the number of pages it wants as guard on each end. OSAllocator takes care of the rest. Similarly. PageReservation::deallocate() also passes in the number of pages it requested as guard on each end, and OSAllocator::releaseDecommitted() does the right thing to munmap the actual memory range including any guard regions. This approach simplifies the logic significantly, and makes it easier to get right: 1. PageBlock::m_realBase was initialized but never used. It can not be removed. It also makes it clear that PageBlock is not responsible for dealing with guard regions. 2. PageReservation can now think of its buffer size request without needing to do any padding math to account for guard regions. 3. PageReservation can now think of its addressHint without needing to do any padding math to account for guard regions. PageReservation no longer needs to do any padding math for the guard regions. OSAllocator will take care of that as needed. This is also fine from a performance angle. OSAllocator calls are already dominated by the mmap and munmap calls. The extra arithmetic for the padding math is not going to move the needle in terms of perf impact. Two additional changes: 4. Change addressHints to be specified using a void* instead of a std::optional. There's no value add with using a std::optional for it. An addressHint of nullptr would indicated that no hint is specified. This is already consistent with the convention mmap and munmap expects. 5. Change Linux's OSAllocator::tryReserveUncommitted() to also forward to OSAllocator::tryReserveAndCommit() to do the mapping just like for OS(DARWIN), instead of rolling its own. There were only 2 differences between the 2 implementations to begin with: a. Linux's OSAllocator::tryReserveUncommitted() sets the MAP_NORESERVE flag for its call to mmap(). We now achieve this by repurposing the unused usage parameter to pass a new OSAllocator::UncommittedPages value. This value tells OSAllocator::tryReserveAndCommit() to add the MAP_NORESERVE flag for Linux. b. After the mmap call, Linux's OSAllocator::tryReserveUncommitted() does a madvise() with MADV_DONTNEED instead of MADV_FREE_REUSABLE. We retain this behavior by keeping different madvise() calls for the 2 ports. * Source/JavaScriptCore/jit/ExecutableAllocator.cpp: (JSC::initializeJITPageReservation): * Source/WTF/wtf/OSAllocator.h: (WTF::OSAllocator::decommitAndRelease): * Source/WTF/wtf/PageAllocation.h: (WTF::PageAllocation::PageAllocation): * Source/WTF/wtf/PageBlock.h: (WTF::PageBlock::operator bool const): (WTF::PageBlock::PageBlock): * Source/WTF/wtf/PageReservation.h: (WTF::PageReservation::reserve): (WTF::PageReservation::tryReserve): (WTF::PageReservation::reserveWithGuardPages): (WTF::PageReservation::tryReserveWithGuardPages): (WTF::PageReservation::deallocate): (WTF::PageReservation::PageReservation): * Source/WTF/wtf/playstation/OSAllocatorPlayStation.cpp: (WTF::OSAllocator::tryReserveAndCommit): (WTF::OSAllocator::tryReserveUncommitted): (WTF::OSAllocator::reserveUncommitted): (WTF::OSAllocator::tryReserveUncommittedAligned): (WTF::OSAllocator::reserveAndCommit): (WTF::OSAllocator::releaseDecommitted): * Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp: (WTF::OSAllocator::tryReserveAndCommit): (WTF::OSAllocator::tryReserveUncommitted): (WTF::OSAllocator::reserveUncommitted): (WTF::OSAllocator::tryReserveUncommittedAligned): (WTF::OSAllocator::reserveAndCommit): (WTF::OSAllocator::releaseDecommitted): * Source/WTF/wtf/win/OSAllocatorWin.cpp: (WTF::OSAllocator::tryReserveUncommitted): (WTF::OSAllocator::reserveUncommitted): (WTF::OSAllocator::tryReserveUncommittedAligned): (WTF::OSAllocator::tryReserveAndCommit): (WTF::OSAllocator::reserveAndCommit): (WTF::OSAllocator::releaseDecommitted): Canonical link: https://commits.webkit.org/299145@main
1 parent 93d1c5a commit 69371bd

8 files changed

Lines changed: 115 additions & 102 deletions

File tree

‎Source/JavaScriptCore/jit/ExecutableAllocator.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2008-2024 Apple Inc. All rights reserved.
2+
* Copyright (C) 2008-2025 Apple Inc. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -389,7 +389,7 @@ static ALWAYS_INLINE JITReservation initializeJITPageReservation()
389389
jit_heap_runtime_config.max_segregated_object_size = 0;
390390
#endif
391391

392-
auto tryCreatePageReservation = [] (size_t reservationSize, uintptr_t hintAddress) {
392+
auto tryCreatePageReservation = [] (size_t reservationSize, void* hintAddress) {
393393
#if OS(LINUX)
394394
// On Linux, if we use uncommitted reservation, mmap operation is recorded with small page size in perf command's output.
395395
// This makes the following JIT code logging broken and some of JIT code is not recorded correctly.
@@ -402,10 +402,10 @@ static ALWAYS_INLINE JITReservation initializeJITPageReservation()
402402
return PageReservation::tryReserveWithGuardPages(reservationSize, OSAllocator::JSJITCodePages, hintAddress, EXECUTABLE_POOL_WRITABLE, true, false, false);
403403
};
404404

405-
406-
reservation.pageReservation = tryCreatePageReservation(reservation.size, Options::jitMemoryReservationAddress());
407-
if (Options::jitMemoryReservationAddress())
408-
RELEASE_ASSERT(std::bit_cast<uintptr_t>(reservation.pageReservation.base()) == Options::jitMemoryReservationAddress() && "Failed to accomodate JSC_jitMemoryReservationAddress");
405+
void* addressHint = reinterpret_cast<void*>(Options::jitMemoryReservationAddress());
406+
reservation.pageReservation = tryCreatePageReservation(reservation.size, addressHint);
407+
if (addressHint)
408+
RELEASE_ASSERT(reservation.pageReservation.base() == addressHint && "Failed to accomodate JSC_jitMemoryReservationAddress");
409409

410410
if (Options::verboseExecutablePoolAllocation())
411411
dataLog(getpid(), ": Got executable pool reservation at ", RawPointer(reservation.pageReservation.base()), "...", RawPointer(reservation.pageReservation.end()), ", while I'm at ", RawPointer(reinterpret_cast<void*>(initializeJITPageReservation)), "\n");

‎Source/WTF/wtf/OSAllocator.h‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2010 Apple Inc. All rights reserved.
2+
* Copyright (C) 2010-2025 Apple Inc. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -37,21 +37,24 @@ class OSAllocator {
3737
UnknownUsage = -1,
3838
FastMallocPages = VM_TAG_FOR_TCMALLOC_MEMORY,
3939
JSJITCodePages = VM_TAG_FOR_EXECUTABLEALLOCATOR_MEMORY,
40+
#if OS(LINUX) || OS(HAIKU)
41+
UncommittedPages = -2,
42+
#endif
4043
};
4144

4245
// The requested alignment must be a power of two and greater than the system page size.
4346
// The memory returned by this cannot be released as on Windows there's no guaranteed API to
4447
// get an aligned address and the size + alignment then rounding trick cannot release the unused parts
4548
// due to how the Windows syscalls work.
46-
WTF_EXPORT_PRIVATE static void* tryReserveUncommittedAligned(size_t, size_t alignment, Usage = UnknownUsage, void* address = nullptr, bool writable = true, bool executable = false, bool jitCageEnabled = false, bool includesGuardPages = false);
49+
WTF_EXPORT_PRIVATE static void* tryReserveUncommittedAligned(size_t, size_t alignment, Usage = UnknownUsage, void* address = nullptr, bool writable = true, bool executable = false, bool jitCageEnabled = false, unsigned numGuardPagesToAddOnEachEnd = 0);
4750

4851
// These methods are symmetric; reserveUncommitted allocates VM in an uncommitted state,
4952
// releaseDecommitted should be called on a region of VM allocated by a single reservation,
5053
// the memory must all currently be in a decommitted state. reserveUncommitted returns to
5154
// you memory that is zeroed.
52-
WTF_EXPORT_PRIVATE static void* reserveUncommitted(size_t, Usage = UnknownUsage, void* address = nullptr, bool writable = true, bool executable = false, bool jitCageEnabled = false, bool includesGuardPages = false);
53-
WTF_EXPORT_PRIVATE static void* tryReserveUncommitted(size_t, Usage = UnknownUsage, void* address = nullptr, bool writable = true, bool executable = false, bool jitCageEnabled = false, bool includesGuardPages = false);
54-
WTF_EXPORT_PRIVATE static void releaseDecommitted(void*, size_t);
55+
WTF_EXPORT_PRIVATE static void* reserveUncommitted(size_t, Usage = UnknownUsage, void* address = nullptr, bool writable = true, bool executable = false, bool jitCageEnabled = false, unsigned numGuardPagesToAddOnEachEnd = 0);
56+
WTF_EXPORT_PRIVATE static void* tryReserveUncommitted(size_t, Usage = UnknownUsage, void* address = nullptr, bool writable = true, bool executable = false, bool jitCageEnabled = false, unsigned numGuardPagesToAddOnEachEnd = 0);
57+
WTF_EXPORT_PRIVATE static void releaseDecommitted(void*, size_t, unsigned numberOfGuardPagesOnEachEnd);
5558

5659
// These methods are symmetric; they commit or decommit a region of VM (uncommitted VM should
5760
// never be accessed, since the OS may not have attached physical memory for these regions).
@@ -62,8 +65,8 @@ class OSAllocator {
6265
// These methods are symmetric; reserveAndCommit allocates VM in an committed state,
6366
// decommitAndRelease should be called on a region of VM allocated by a single reservation,
6467
// the memory must all currently be in a committed state.
65-
WTF_EXPORT_PRIVATE static void* reserveAndCommit(size_t, Usage = UnknownUsage, void* address = nullptr, bool writable = true, bool executable = false, bool jitCageEnabled = false, bool includesGuardPages = false);
66-
WTF_EXPORT_PRIVATE static void* tryReserveAndCommit(size_t, Usage = UnknownUsage, void* address = nullptr, bool writable = true, bool executable = false, bool jitCageEnabled = false, bool includesGuardPages = false);
68+
WTF_EXPORT_PRIVATE static void* reserveAndCommit(size_t, Usage = UnknownUsage, void* address = nullptr, bool writable = true, bool executable = false, bool jitCageEnabled = false, unsigned numGuardPagesToAddOnEachEnd = 0);
69+
WTF_EXPORT_PRIVATE static void* tryReserveAndCommit(size_t, Usage = UnknownUsage, void* address = nullptr, bool writable = true, bool executable = false, bool jitCageEnabled = false, unsigned numGuardPagesToAddOnEachEnd = 0);
6770
static void decommitAndRelease(void* base, size_t size);
6871

6972
// These methods are akin to reserveAndCommit/decommitAndRelease, above - however rather than
@@ -93,7 +96,7 @@ inline void* OSAllocator::reserveAndCommit(size_t reserveSize, size_t commitSize
9396

9497
inline void OSAllocator::decommitAndRelease(void* releaseBase, size_t releaseSize)
9598
{
96-
releaseDecommitted(releaseBase, releaseSize);
99+
releaseDecommitted(releaseBase, releaseSize, 0);
97100
}
98101

99102
template<typename T>

‎Source/WTF/wtf/PageAllocation.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2010 Apple Inc. All rights reserved.
2+
* Copyright (C) 2010-2025 Apple Inc. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -102,7 +102,7 @@ class PageAllocation : private PageBlock {
102102

103103
private:
104104
PageAllocation(void* base, size_t size)
105-
: PageBlock(base, size, false)
105+
: PageBlock(base, size)
106106
{
107107
}
108108
};

‎Source/WTF/wtf/PageBlock.h‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2010-2022 Apple Inc. All rights reserved.
2+
* Copyright (C) 2010-2025 Apple Inc. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -74,13 +74,13 @@ class PageBlock {
7474
WTF_DEPRECATED_MAKE_FAST_ALLOCATED(PageBlock);
7575
public:
7676
PageBlock() = default;
77-
PageBlock(void*, size_t, bool hasGuardPages);
77+
PageBlock(void*, size_t);
7878

7979
void* base() const { return m_base; }
8080
void* end() const { return static_cast<uint8_t*>(m_base) + size(); }
8181
size_t size() const { return m_size; }
8282

83-
operator bool() const { return !!m_realBase; }
83+
operator bool() const { return !!m_base; }
8484

8585
bool contains(void* containedBase, size_t containedSize)
8686
{
@@ -89,14 +89,12 @@ class PageBlock {
8989
}
9090

9191
private:
92-
void* m_realBase { nullptr };
9392
void* m_base { nullptr };
9493
size_t m_size { 0 };
9594
};
9695

97-
inline PageBlock::PageBlock(void* base, size_t size, bool hasGuardPages)
98-
: m_realBase(base)
99-
, m_base(static_cast<char*>(base) + ((base && hasGuardPages) ? pageSize() : 0))
96+
inline PageBlock::PageBlock(void* base, size_t size)
97+
: m_base(base)
10098
, m_size(size)
10199
{
102100
}

‎Source/WTF/wtf/PageReservation.h‎

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2010-2022 Apple Inc. All rights reserved.
2+
* Copyright (C) 2010-2025 Apple Inc. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -89,46 +89,40 @@ class PageReservation : private PageBlock {
8989
return m_committed;
9090
}
9191

92-
static PageReservation reserve(size_t size, OSAllocator::Usage usage = OSAllocator::UnknownUsage, std::optional<uintptr_t> address = { }, bool writable = true, bool executable = false, bool commit = false, bool jitCageEnabled = false)
92+
static PageReservation reserve(size_t size, OSAllocator::Usage usage = OSAllocator::UnknownUsage, void* addressHint = nullptr, bool writable = true, bool executable = false, bool commit = false, bool jitCageEnabled = false)
9393
{
9494
ASSERT(isPageAligned(size));
95-
ASSERT(isPageAligned(address.value_or(0)));
95+
ASSERT(isPageAligned(addressHint));
9696
if (commit)
97-
return PageReservation(OSAllocator::reserveAndCommit(size, usage, std::bit_cast<void*>(address.value_or(0)), writable, executable, jitCageEnabled, false), size, writable, executable, jitCageEnabled, false);
98-
return PageReservation(OSAllocator::reserveUncommitted(size, usage, std::bit_cast<void*>(address.value_or(0)), writable, executable, jitCageEnabled, false), size, writable, executable, jitCageEnabled, false);
97+
return PageReservation(OSAllocator::reserveAndCommit(size, usage, addressHint, writable, executable, jitCageEnabled), size, writable, executable, jitCageEnabled);
98+
return PageReservation(OSAllocator::reserveUncommitted(size, usage, addressHint, writable, executable, jitCageEnabled), size, writable, executable, jitCageEnabled);
9999
}
100100

101-
static PageReservation tryReserve(size_t size, OSAllocator::Usage usage = OSAllocator::UnknownUsage, std::optional<uintptr_t> address = { }, bool writable = true, bool executable = false, bool commit = false, bool jitCageEnabled = false)
101+
static PageReservation tryReserve(size_t size, OSAllocator::Usage usage = OSAllocator::UnknownUsage, void* addressHint = nullptr, bool writable = true, bool executable = false, bool commit = false, bool jitCageEnabled = false)
102102
{
103103
ASSERT(isPageAligned(size));
104-
ASSERT(isPageAligned(address.value_or(0)));
104+
ASSERT(isPageAligned(addressHint));
105105
if (commit)
106-
return PageReservation(OSAllocator::tryReserveAndCommit(size, usage, std::bit_cast<void*>(address.value_or(0)), writable, executable, jitCageEnabled, false), size, writable, executable, jitCageEnabled, false);
107-
return PageReservation(OSAllocator::tryReserveUncommitted(size, usage, std::bit_cast<void*>(address.value_or(0)), writable, executable, jitCageEnabled, false), size, writable, executable, jitCageEnabled, false);
106+
return PageReservation(OSAllocator::tryReserveAndCommit(size, usage, addressHint, writable, executable, jitCageEnabled), size, writable, executable, jitCageEnabled);
107+
return PageReservation(OSAllocator::tryReserveUncommitted(size, usage, addressHint, writable, executable, jitCageEnabled), size, writable, executable, jitCageEnabled);
108108
}
109109

110-
static PageReservation reserveWithGuardPages(size_t size, OSAllocator::Usage usage = OSAllocator::UnknownUsage, std::optional<uintptr_t> address = { }, bool writable = true, bool executable = false, bool commit = false, bool jitCageEnabled = false)
110+
static PageReservation reserveWithGuardPages(size_t size, OSAllocator::Usage usage = OSAllocator::UnknownUsage, void* addressHint = nullptr, bool writable = true, bool executable = false, bool commit = false, bool jitCageEnabled = false)
111111
{
112112
ASSERT(isPageAligned(size));
113-
ASSERT(isPageAligned(address.value_or(0)));
114-
// Account for guard pages
115-
if (address.has_value() && address.value() >= pageSize())
116-
address.value() -= pageSize();
113+
ASSERT(isPageAligned(addressHint));
117114
if (commit)
118-
return PageReservation(OSAllocator::reserveAndCommit(size + pageSize() * 2, usage, std::bit_cast<void*>(address.value_or(0)), writable, executable, jitCageEnabled, true), size, writable, executable, jitCageEnabled, true);
119-
return PageReservation(OSAllocator::reserveUncommitted(size + pageSize() * 2, usage, std::bit_cast<void*>(address.value_or(0)), writable, executable, jitCageEnabled, true), size, writable, executable, jitCageEnabled, true);
115+
return PageReservation(OSAllocator::reserveAndCommit(size, usage, addressHint, writable, executable, jitCageEnabled, 1), size, writable, executable, jitCageEnabled, 1);
116+
return PageReservation(OSAllocator::reserveUncommitted(size, usage, addressHint, writable, executable, jitCageEnabled, 1), size, writable, executable, jitCageEnabled, 1);
120117
}
121118

122-
static PageReservation tryReserveWithGuardPages(size_t size, OSAllocator::Usage usage = OSAllocator::UnknownUsage, std::optional<uintptr_t> address = { }, bool writable = true, bool executable = false, bool commit = false, bool jitCageEnabled = false)
119+
static PageReservation tryReserveWithGuardPages(size_t size, OSAllocator::Usage usage = OSAllocator::UnknownUsage, void* addressHint = nullptr, bool writable = true, bool executable = false, bool commit = false, bool jitCageEnabled = false)
123120
{
124121
ASSERT(isPageAligned(size));
125-
ASSERT(isPageAligned(address.value_or(0)));
126-
// Account for guard pages
127-
if (address.has_value() && address.value() >= pageSize())
128-
address.value() -= pageSize();
122+
ASSERT(isPageAligned(addressHint));
129123
if (commit)
130-
return PageReservation(OSAllocator::tryReserveAndCommit(size + pageSize() * 2, usage, std::bit_cast<void*>(address.value_or(0)), writable, executable, jitCageEnabled, true), size, writable, executable, jitCageEnabled, true);
131-
return PageReservation(OSAllocator::tryReserveUncommitted(size + pageSize() * 2, usage, std::bit_cast<void*>(address.value_or(0)), writable, executable, jitCageEnabled, true), size, writable, executable, jitCageEnabled, true);
124+
return PageReservation(OSAllocator::tryReserveAndCommit(size, usage, addressHint, writable, executable, jitCageEnabled, 1), size, writable, executable, jitCageEnabled, 1);
125+
return PageReservation(OSAllocator::tryReserveUncommitted(size, usage, addressHint, writable, executable, jitCageEnabled, 1), size, writable, executable, jitCageEnabled, 1);
132126
}
133127

134128

@@ -144,21 +138,23 @@ class PageReservation : private PageBlock {
144138
ASSERT(tmp);
145139
ASSERT(!*this);
146140

147-
OSAllocator::releaseDecommitted(tmp.base(), tmp.size());
141+
OSAllocator::releaseDecommitted(tmp.base(), tmp.size(), tmp.m_numberOfGuardPagesOnEachEnd);
148142
}
149143

150144
private:
151-
PageReservation(void* base, size_t size, bool writable, bool executable, bool, bool hasGuardPages)
152-
: PageBlock(base, size, hasGuardPages)
145+
PageReservation(void* base, size_t size, bool writable, bool executable, bool, unsigned numberOfGuardPagesOnEachEnd = 0)
146+
: PageBlock(base, size)
153147
, m_committed(0)
154148
, m_writable(writable)
155149
, m_executable(executable)
150+
, m_numberOfGuardPagesOnEachEnd(numberOfGuardPagesOnEachEnd)
156151
{
157152
}
158153

159154
size_t m_committed { 0 };
160155
bool m_writable { false };
161156
bool m_executable { false };
157+
unsigned m_numberOfGuardPagesOnEachEnd { 0 };
162158
};
163159

164160
}

‎Source/WTF/wtf/playstation/OSAllocatorPlayStation.cpp‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838

3939
namespace WTF {
4040

41-
void* OSAllocator::tryReserveAndCommit(size_t bytes, Usage usage, void* address, bool writable, bool executable, bool jitCageEnabled, bool includesGuardPages)
41+
void* OSAllocator::tryReserveAndCommit(size_t bytes, Usage usage, void* address, bool writable, bool executable, bool jitCageEnabled, unsigned numGuardPagesToAddOnEachEnd)
4242
{
43-
ASSERT_UNUSED(includesGuardPages, !includesGuardPages);
43+
UNUSED_PARAM(numGuardPagesToAddOnEachEnd); // Guard pages not supported, and will be ignored.
4444
ASSERT_UNUSED(jitCageEnabled, !jitCageEnabled);
4545
ASSERT_UNUSED(executable, !executable);
4646
ASSERT_UNUSED(address, !address);
@@ -58,11 +58,11 @@ void* OSAllocator::tryReserveAndCommit(size_t bytes, Usage usage, void* address,
5858
return result;
5959
}
6060

61-
void* OSAllocator::tryReserveUncommitted(size_t bytes, Usage usage, void* address, bool writable, bool executable, bool jitCageEnabled, bool includesGuardPages)
61+
void* OSAllocator::tryReserveUncommitted(size_t bytes, Usage usage, void* address, bool writable, bool executable, bool jitCageEnabled, unsigned numGuardPagesToAddOnEachEnd)
6262
{
6363
UNUSED_PARAM(usage);
6464
UNUSED_PARAM(writable);
65-
ASSERT_UNUSED(includesGuardPages, !includesGuardPages);
65+
UNUSED_PARAM(numGuardPagesToAddOnEachEnd); // Guard pages not supported, and will be ignored.
6666
ASSERT_UNUSED(jitCageEnabled, !jitCageEnabled);
6767
ASSERT_UNUSED(executable, !executable);
6868
ASSERT_UNUSED(address, !address);
@@ -74,16 +74,16 @@ void* OSAllocator::tryReserveUncommitted(size_t bytes, Usage usage, void* addres
7474
return result;
7575
}
7676

77-
void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, void* address, bool writable, bool executable, bool jitCageEnabled, bool includesGuardPages)
77+
void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, void* address, bool writable, bool executable, bool jitCageEnabled, unsigned numGuardPagesToAddOnEachEnd)
7878
{
79-
void* result = tryReserveUncommitted(bytes, usage, address, writable, executable, jitCageEnabled, includesGuardPages);
79+
void* result = tryReserveUncommitted(bytes, usage, address, writable, executable, jitCageEnabled, numGuardPagesToAddOnEachEnd);
8080
RELEASE_ASSERT(result);
8181
return result;
8282
}
8383

84-
void* OSAllocator::tryReserveUncommittedAligned(size_t bytes, size_t alignment, Usage usage, void* address, bool writable, bool executable, bool jitCageEnabled, bool includesGuardPages)
84+
void* OSAllocator::tryReserveUncommittedAligned(size_t bytes, size_t alignment, Usage usage, void* address, bool writable, bool executable, bool jitCageEnabled, unsigned numGuardPagesToAddOnEachEnd)
8585
{
86-
ASSERT_UNUSED(includesGuardPages, !includesGuardPages);
86+
ASSERT_UNUSED(numGuardPagesToAddOnEachEnd, !numGuardPagesToAddOnEachEnd);
8787
ASSERT_UNUSED(jitCageEnabled, !jitCageEnabled);
8888
ASSERT_UNUSED(executable, !executable);
8989
ASSERT_UNUSED(address, !address);
@@ -98,9 +98,9 @@ void* OSAllocator::tryReserveUncommittedAligned(size_t bytes, size_t alignment,
9898
return result;
9999
}
100100

101-
void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, void* address, bool writable, bool executable, bool jitCageEnabled, bool includesGuardPages)
101+
void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, void* address, bool writable, bool executable, bool jitCageEnabled, unsigned numGuardPagesToAddOnEachEnd)
102102
{
103-
void* result = tryReserveAndCommit(bytes, usage, address, writable, executable, jitCageEnabled, includesGuardPages);
103+
void* result = tryReserveAndCommit(bytes, usage, address, writable, executable, jitCageEnabled, numGuardPagesToAddOnEachEnd);
104104
RELEASE_ASSERT(result);
105105
return result;
106106
}
@@ -124,8 +124,9 @@ void OSAllocator::hintMemoryNotNeededSoon(void* address, size_t bytes)
124124
UNUSED_PARAM(bytes);
125125
}
126126

127-
void OSAllocator::releaseDecommitted(void* address, size_t bytes)
127+
void OSAllocator::releaseDecommitted(void* address, size_t bytes, unsigned numGuardPagesToAddOnEachEnd)
128128
{
129+
UNUSED_PARAM(numGuardPagesToAddOnEachEnd); // Guard pages not supported, and will be ignored.
129130
bool success = memory_extra::vss::release(address, bytes);
130131
RELEASE_ASSERT(success);
131132
}

0 commit comments

Comments
 (0)