-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace OSAllocator implementation with memory-extra private library
https://bugs.webkit.org/show_bug.cgi?id=274221 Reviewed by Don Olmstead. To reserve large address space, our platform requires precise control of virtual address space and commiti/decommit management is not enough for this purpose. In this patch, I've introduced new memory-extra private library for that purpose and add platform specific OSAllocator implementation. Also replace showmap library with embedded one inside memory-extra and use clever way to collect memory information. * Source/JavaScriptCore/PlatformPlayStation.cmake: * Source/JavaScriptCore/shell/PlatformPlayStation.cmake: * Source/JavaScriptCore/testmem/PlatformPlayStation.cmake: * Source/JavaScriptCore/testmem/testmem.cpp: (Footprint::now): * Source/WTF/wtf/PlatformPlayStation.cmake: * Source/WTF/wtf/playstation/OSAllocatorPlayStation.cpp: Added. (WTF::OSAllocator::tryReserveAndCommit): (WTF::OSAllocator::tryReserveUncommitted): (WTF::OSAllocator::reserveUncommitted): (WTF::OSAllocator::tryReserveUncommittedAligned): (WTF::OSAllocator::reserveAndCommit): (WTF::OSAllocator::commit): (WTF::OSAllocator::decommit): (WTF::OSAllocator::hintMemoryNotNeededSoon): (WTF::OSAllocator::releaseDecommitted): (WTF::OSAllocator::protect): * Source/WebCore/PlatformPlayStation.cmake: * Source/WebCore/page/playstation/ResourceUsageThreadPlayStation.cpp: (WebCore::ResourceUsageThread::platformCollectMemoryData): * Source/cmake/OptionsPlayStation.cmake: * Tools/TestWebKitAPI/PlatformPlayStation.cmake: Canonical link: https://commits.webkit.org/278920@main
- Loading branch information
Showing
10 changed files
with
183 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/* | ||
* Copyright (C) 2010-2022 Apple Inc. All rights reserved. | ||
* Copyright (C) 2024 SONY Interactive Entertainment Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "config.h" | ||
#include <wtf/OSAllocator.h> | ||
|
||
#include <errno.h> | ||
#include <memory-extra/vss.h> | ||
#include <wtf/Assertions.h> | ||
#include <wtf/MathExtras.h> | ||
#include <wtf/PageBlock.h> | ||
|
||
namespace WTF { | ||
|
||
void* OSAllocator::tryReserveAndCommit(size_t bytes, Usage usage, bool writable, bool executable, bool jitCageEnabled, bool includesGuardPages) | ||
{ | ||
ASSERT_UNUSED(includesGuardPages, !includesGuardPages); | ||
ASSERT_UNUSED(jitCageEnabled, !jitCageEnabled); | ||
ASSERT_UNUSED(executable, !executable); | ||
|
||
void* result = memory_extra::vss::reserve(bytes); | ||
if (!result) | ||
return nullptr; | ||
|
||
bool success = memory_extra::vss::commit(result, bytes, writable, usage); | ||
if (!success) { | ||
memory_extra::vss::release(result, bytes); | ||
return nullptr; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
void* OSAllocator::tryReserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable, bool jitCageEnabled, bool includesGuardPages) | ||
{ | ||
UNUSED_PARAM(usage); | ||
UNUSED_PARAM(writable); | ||
ASSERT_UNUSED(includesGuardPages, !includesGuardPages); | ||
ASSERT_UNUSED(jitCageEnabled, !jitCageEnabled); | ||
ASSERT_UNUSED(executable, !executable); | ||
|
||
void* result = memory_extra::vss::reserve(bytes); | ||
if (!result) | ||
return nullptr; | ||
|
||
return result; | ||
} | ||
|
||
void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable, bool jitCageEnabled, bool includesGuardPages) | ||
{ | ||
void* result = tryReserveUncommitted(bytes, usage, writable, executable, jitCageEnabled, includesGuardPages); | ||
RELEASE_ASSERT(result); | ||
return result; | ||
} | ||
|
||
void* OSAllocator::tryReserveUncommittedAligned(size_t bytes, size_t alignment, Usage usage, bool writable, bool executable, bool jitCageEnabled, bool includesGuardPages) | ||
{ | ||
ASSERT_UNUSED(includesGuardPages, !includesGuardPages); | ||
ASSERT_UNUSED(jitCageEnabled, !jitCageEnabled); | ||
ASSERT_UNUSED(executable, !executable); | ||
UNUSED_PARAM(usage); | ||
UNUSED_PARAM(writable); | ||
ASSERT(hasOneBitSet(alignment) && alignment >= pageSize()); | ||
|
||
void* result = memory_extra::vss::reserve(bytes, alignment); | ||
if (!result) | ||
return nullptr; | ||
|
||
return result; | ||
} | ||
|
||
void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bool executable, bool jitCageEnabled, bool includesGuardPages) | ||
{ | ||
void* result = tryReserveAndCommit(bytes, usage, writable, executable, jitCageEnabled, includesGuardPages); | ||
RELEASE_ASSERT(result); | ||
return result; | ||
} | ||
|
||
void OSAllocator::commit(void* address, size_t bytes, bool writable, bool executable) | ||
{ | ||
ASSERT_UNUSED(executable, !executable); | ||
bool success = memory_extra::vss::commit(address, bytes, writable, -1); | ||
RELEASE_ASSERT(success); | ||
} | ||
|
||
void OSAllocator::decommit(void* address, size_t bytes) | ||
{ | ||
bool success = memory_extra::vss::decommit(address, bytes); | ||
RELEASE_ASSERT(success); | ||
} | ||
|
||
void OSAllocator::hintMemoryNotNeededSoon(void* address, size_t bytes) | ||
{ | ||
UNUSED_PARAM(address); | ||
UNUSED_PARAM(bytes); | ||
} | ||
|
||
void OSAllocator::releaseDecommitted(void* address, size_t bytes) | ||
{ | ||
bool success = memory_extra::vss::release(address, bytes); | ||
RELEASE_ASSERT(success); | ||
} | ||
|
||
bool OSAllocator::protect(void* address, size_t bytes, bool readable, bool writable) | ||
{ | ||
return memory_extra::vss::protect(address, bytes, readable, writable, -1); | ||
} | ||
|
||
} // namespace WTF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters