WebKit Bugzilla
Attachment 347858 Details for
Bug 188867
: [WTF] Add generic implementation for Memory querying
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188867.diff (text/plain), 11.75 KB, created by
Don Olmstead
on 2018-08-22 15:40:21 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Don Olmstead
Created:
2018-08-22 15:40:21 PDT
Size:
11.75 KB
patch
obsolete
>diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index d4eaa08ad7f..97c597bfa16 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,42 @@ >+2018-08-22 Don Olmstead <don.olmstead@sony.com> >+ >+ [WTF] Add generic implementation for Memory querying >+ https://bugs.webkit.org/show_bug.cgi?id=188867 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Moves generic implementation of MemoryPressureHandler from >+ MemoryPressureHandler.cpp into MemoryPressureHandlerGeneric. >+ >+ * wtf/MemoryPressureHandler.cpp: >+ (WTF::MemoryPressureHandler::install): Deleted. >+ (WTF::MemoryPressureHandler::uninstall): Deleted. >+ (WTF::MemoryPressureHandler::respondToMemoryPressure): Deleted. >+ (WTF::MemoryPressureHandler::platformReleaseMemory): Deleted. >+ (WTF::MemoryPressureHandler::ReliefLogger::platformMemoryUsage): Deleted. >+ * wtf/PlatformJSCOnly.cmake: >+ * wtf/generic/MemoryFootprintGeneric.cpp: Copied from Source/WTF/wtf/linux/CurrentProcessMemoryStatus.h. >+ (WTF::memoryFootprint): >+ * wtf/generic/MemoryPressureHandlerGeneric.cpp: Added. >+ (WTF::MemoryPressureHandler::memoryMeasurementTimerFired): >+ (WTF::MemoryPressureHandler::platformReleaseMemory): >+ (WTF::MemoryPressureHandler::install): >+ (WTF::MemoryPressureHandler::uninstall): >+ (WTF::MemoryPressureHandler::holdOff): >+ (WTF::MemoryPressureHandler::respondToMemoryPressure): >+ (WTF::MemoryPressureHandler::ReliefLogger::platformMemoryUsage): >+ * wtf/linux/CurrentProcessMemoryStatus.cpp: >+ * wtf/linux/CurrentProcessMemoryStatus.h: >+ * wtf/linux/MemoryFootprintLinux.cpp: >+ (WTF::computeMemoryFootprint): >+ (WTF::memoryFootprint): >+ * wtf/linux/MemoryPressureHandlerLinux.cpp: >+ * wtf/win/MemoryPressureHandlerWin.cpp: >+ (WTF::MemoryPressureHandler::memoryMeasurementTimerFired): >+ (WTF::MemoryPressureHandler::install): >+ (WTF::MemoryPressureHandler::uninstall): >+ (WTF::MemoryPressureHandler::windowsMeasurementTimerFired): Deleted. >+ > 2018-08-21 Antti Koivisto <antti@apple.com> > > Allow creating WeakPtrs to const objects >diff --git a/Source/WTF/wtf/MemoryPressureHandler.cpp b/Source/WTF/wtf/MemoryPressureHandler.cpp >index a7e4f425921..9d0a140eda7 100644 >--- a/Source/WTF/wtf/MemoryPressureHandler.cpp >+++ b/Source/WTF/wtf/MemoryPressureHandler.cpp >@@ -294,14 +294,6 @@ void MemoryPressureHandler::ReliefLogger::logMemoryUsageChange() > m_initialMemory->physical, currentMemory->physical, physicalDiff); > } > >-#if !PLATFORM(COCOA) && !OS(LINUX) && !OS(WINDOWS) >-void MemoryPressureHandler::install() { } >-void MemoryPressureHandler::uninstall() { } >-void MemoryPressureHandler::respondToMemoryPressure(Critical, Synchronous) { } >-void MemoryPressureHandler::platformReleaseMemory(Critical) { } >-std::optional<MemoryPressureHandler::ReliefLogger::MemoryUsage> MemoryPressureHandler::ReliefLogger::platformMemoryUsage() { return std::nullopt; } >-#endif >- > #if !OS(WINDOWS) > void MemoryPressureHandler::platformInitialize() { } > #endif >diff --git a/Source/WTF/wtf/PlatformJSCOnly.cmake b/Source/WTF/wtf/PlatformJSCOnly.cmake >index 525d9ee455e..36f608c4b5c 100644 >--- a/Source/WTF/wtf/PlatformJSCOnly.cmake >+++ b/Source/WTF/wtf/PlatformJSCOnly.cmake >@@ -30,7 +30,6 @@ else () > unix/CPUTimeUnix.cpp > ) > endif () >- > endif () > > if (WIN32) >@@ -57,9 +56,19 @@ elseif (APPLE) > list(APPEND WTF_INCLUDE_DIRECTORIES > ${DERIVED_SOURCES_WTF_DIR} > ) >-else () >+elseif (CMAKE_SYSTEM_NAME MATCHES ".*Linux") > list(APPEND WTF_SOURCES >+ linux/CurrentMemoryStatus.cpp > linux/MemoryFootprintLinux.cpp >+ linux/MemoryPressureHandlerLinux.cpp >+ ) >+ list(APPEND WTF_PUBLIC_HEADERS >+ linux/CurrentProcessMemoryStatus.h >+ ) >+else () >+ list(APPEND WTF_SOURCES >+ generic/MemoryFootprintGeneric.cpp >+ generic/MemoryPressureHandlerGeneric.cpp > ) > endif () > >diff --git a/Source/WTF/wtf/generic/MemoryFootprintGeneric.cpp b/Source/WTF/wtf/generic/MemoryFootprintGeneric.cpp >new file mode 100644 >index 00000000000..f2ae830f121 >--- /dev/null >+++ b/Source/WTF/wtf/generic/MemoryFootprintGeneric.cpp >@@ -0,0 +1,36 @@ >+/* >+ * Copyright (C) 2018 Sony Interactive Entertainment Inc. >+ * >+ * 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 "MemoryFootprint.h" >+ >+namespace WTF { >+ >+size_t memoryFootprint() >+{ >+ return 0; >+} >+ >+} // namespace WTF >diff --git a/Source/WTF/wtf/generic/MemoryPressureHandlerGeneric.cpp b/Source/WTF/wtf/generic/MemoryPressureHandlerGeneric.cpp >new file mode 100644 >index 00000000000..a2b570e64f1 >--- /dev/null >+++ b/Source/WTF/wtf/generic/MemoryPressureHandlerGeneric.cpp >@@ -0,0 +1,60 @@ >+/* >+ * Copyright (C) 2018 Sony Interactive Entertainment Inc. >+ * >+ * 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 "MemoryPressureHandler.h" >+ >+namespace WTF { >+ >+void MemoryPressureHandler::memoryMeasurementTimerFired() >+{ >+} >+ >+void MemoryPressureHandler::platformReleaseMemory(Critical) >+{ >+} >+ >+void MemoryPressureHandler::install() >+{ >+} >+ >+void MemoryPressureHandler::uninstall() >+{ >+} >+ >+void MemoryPressureHandler::holdOff(Seconds seconds) >+{ >+} >+ >+void MemoryPressureHandler::respondToMemoryPressure(Critical critical, Synchronous synchronous) >+{ >+} >+ >+std::optional<MemoryPressureHandler::ReliefLogger::MemoryUsage> MemoryPressureHandler::ReliefLogger::platformMemoryUsage() >+{ >+ return std::nullopt; >+} >+ >+} // namespace WTF >diff --git a/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.cpp b/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.cpp >index 52ef0bb3e72..8bb214ab1fd 100644 >--- a/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.cpp >+++ b/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.cpp >@@ -26,8 +26,6 @@ > #include "config.h" > #include "CurrentProcessMemoryStatus.h" > >-#if OS(LINUX) >- > #include <stdio.h> > #include <stdlib.h> > #include <unistd.h> >@@ -73,5 +71,3 @@ void currentProcessMemoryStatus(ProcessMemoryStatus& memoryStatus) > } > > } // namespace WTF >- >-#endif // OS(LINUX) >diff --git a/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.h b/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.h >index 4082504cd00..27b5b3e202a 100644 >--- a/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.h >+++ b/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.h >@@ -25,8 +25,6 @@ > > #pragma once > >-#if OS(LINUX) >- > namespace WTF { > > struct ProcessMemoryStatus { >@@ -45,5 +43,3 @@ void currentProcessMemoryStatus(ProcessMemoryStatus&); > > using WTF::ProcessMemoryStatus; > using WTF::currentProcessMemoryStatus; >- >-#endif // OS(LINUX) >diff --git a/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp b/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp >index 7bc9d7c77e4..0e4d546f491 100644 >--- a/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp >+++ b/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp >@@ -26,16 +26,13 @@ > #include "config.h" > #include "MemoryFootprint.h" > >-#if OS(LINUX) > #include "MonotonicTime.h" > #include <stdio.h> > #include <wtf/StdLibExtras.h> > #include <wtf/text/StringView.h> >-#endif > > namespace WTF { > >-#if OS(LINUX) > static const Seconds s_memoryFootprintUpdateInterval = 1_s; > > template<typename Functor> >@@ -88,11 +85,9 @@ static size_t computeMemoryFootprint() > fclose(file); > return totalPrivateDirtyInKB * KB; > } >-#endif > > size_t memoryFootprint() > { >-#if OS(LINUX) > static size_t footprint = 0; > static MonotonicTime previousUpdateTime = { }; > Seconds elapsed = MonotonicTime::now() - previousUpdateTime; >@@ -102,8 +97,6 @@ size_t memoryFootprint() > } > > return footprint; >-#endif >- return 0; > } > >-} >+} // namespace WTF >diff --git a/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp b/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp >index 274367f6cca..f9fbe232cad 100644 >--- a/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp >+++ b/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp >@@ -28,8 +28,6 @@ > #include "config.h" > #include "MemoryPressureHandler.h" > >-#if OS(LINUX) >- > #include <malloc.h> > #include <unistd.h> > #include <wtf/MainThread.h> >@@ -138,7 +136,4 @@ std::optional<MemoryPressureHandler::ReliefLogger::MemoryUsage> MemoryPressureHa > return MemoryUsage {processMemoryUsage(), memoryFootprint()}; > } > >- > } // namespace WTF >- >-#endif // OS(LINUX) >diff --git a/Source/WTF/wtf/win/MemoryPressureHandlerWin.cpp b/Source/WTF/wtf/win/MemoryPressureHandlerWin.cpp >index 5acff6b7449..63eea0dc10e 100644 >--- a/Source/WTF/wtf/win/MemoryPressureHandlerWin.cpp >+++ b/Source/WTF/wtf/win/MemoryPressureHandlerWin.cpp >@@ -36,7 +36,7 @@ void MemoryPressureHandler::platformInitialize() > m_lowMemoryHandle = CreateMemoryResourceNotification(LowMemoryResourceNotification); > } > >-void MemoryPressureHandler::windowsMeasurementTimerFired() >+void MemoryPressureHandler::memoryMeasurementTimerFired() > { > setUnderMemoryPressure(false); > >@@ -73,7 +73,7 @@ void MemoryPressureHandler::platformReleaseMemory(Critical) > void MemoryPressureHandler::install() > { > m_installed = true; >- m_windowsMeasurementTimer.startRepeating(60_s); >+ m_memoryMeasurementTimer.startRepeating(60_s); > } > > void MemoryPressureHandler::uninstall() >@@ -81,7 +81,7 @@ void MemoryPressureHandler::uninstall() > if (!m_installed) > return; > >- m_windowsMeasurementTimer.stop(); >+ m_memoryMeasurementTimer.stop(); > m_installed = false; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188867
:
347858
|
347861
|
347875
|
347893
|
347938