Title: [293823] trunk/Source
Revision
293823
Author
commit-qu...@webkit.org
Date
2022-05-04 23:38:33 -0700 (Wed, 04 May 2022)

Log Message

SharedMemory::systemPageSize is redundant function
https://bugs.webkit.org/show_bug.cgi?id=240057

Patch by Kimmo Kinnunen <kkinnu...@apple.com> on 2022-05-04
Reviewed by Antti Koivisto.

Source/WebKit:

Remove SharedMemory::systemPageSize().
Use WTF::pageSize() from PageBlock.h.

* Platform/SharedMemory.h:
* Platform/cocoa/SharedMemoryCocoa.cpp:
* Platform/unix/SharedMemoryUnix.cpp:
* Platform/win/SharedMemoryWin.cpp:
* Shared/SharedStringHashStore.cpp:
(WebKit::tableSizeForKeyCount):
* UIProcess/linux/MemoryPressureMonitor.cpp:
(WebKit::calculateMemoryAvailable):
* mac/WebKit2.order:

Source/WTF:

* wtf/PageBlock.cpp:
(WTF::systemPageSize):
Remove pointless static variable from OS(WINDOWS) variant.
* wtf/linux/CurrentProcessMemoryStatus.cpp:
(WTF::currentProcessMemoryStatus):
Remove another redundant implementation.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (293822 => 293823)


--- trunk/Source/WTF/ChangeLog	2022-05-05 06:36:37 UTC (rev 293822)
+++ trunk/Source/WTF/ChangeLog	2022-05-05 06:38:33 UTC (rev 293823)
@@ -1,3 +1,17 @@
+2022-05-04  Kimmo Kinnunen  <kkinnu...@apple.com>
+
+        SharedMemory::systemPageSize is redundant function
+        https://bugs.webkit.org/show_bug.cgi?id=240057
+
+        Reviewed by Antti Koivisto.
+
+        * wtf/PageBlock.cpp:
+        (WTF::systemPageSize):
+        Remove pointless static variable from OS(WINDOWS) variant.
+        * wtf/linux/CurrentProcessMemoryStatus.cpp:
+        (WTF::currentProcessMemoryStatus):
+        Remove another redundant implementation.
+
 2022-05-04  Brent Fulgham  <bfulg...@apple.com>
 
         Remove deprecated 'JavaEnabled' feature flag and related code

Modified: trunk/Source/WTF/wtf/PageBlock.cpp (293822 => 293823)


--- trunk/Source/WTF/wtf/PageBlock.cpp	2022-05-05 06:36:37 UTC (rev 293822)
+++ trunk/Source/WTF/wtf/PageBlock.cpp	2022-05-05 06:38:33 UTC (rev 293823)
@@ -51,11 +51,9 @@
 
 inline size_t systemPageSize()
 {
-    static size_t size = 0;
     SYSTEM_INFO system_info;
     GetSystemInfo(&system_info);
-    size = system_info.dwPageSize;
-    return size;
+    return system_info.dwPageSize;
 }
 
 #endif

Modified: trunk/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.cpp (293822 => 293823)


--- trunk/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.cpp	2022-05-05 06:36:37 UTC (rev 293822)
+++ trunk/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.cpp	2022-05-05 06:38:33 UTC (rev 293823)
@@ -29,17 +29,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <wtf/PageBlock.h>
 
 namespace WTF {
 
-static inline size_t systemPageSize()
-{
-    static size_t pageSize = 0;
-    if (!pageSize)
-        pageSize = sysconf(_SC_PAGE_SIZE);
-    return pageSize;
-}
-
 void currentProcessMemoryStatus(ProcessMemoryStatus& memoryStatus)
 {
     FILE* file = fopen("/proc/self/statm", "r");
@@ -52,7 +45,7 @@
     if (!line)
         return;
 
-    size_t pageSize = systemPageSize();
+    size_t pageSize = WTF::pageSize();
     char* end = nullptr;
     unsigned long long intValue = strtoull(line, &end, 10);
     memoryStatus.size = intValue * pageSize;

Modified: trunk/Source/WebKit/ChangeLog (293822 => 293823)


--- trunk/Source/WebKit/ChangeLog	2022-05-05 06:36:37 UTC (rev 293822)
+++ trunk/Source/WebKit/ChangeLog	2022-05-05 06:38:33 UTC (rev 293823)
@@ -1,5 +1,25 @@
 2022-05-04  Kimmo Kinnunen  <kkinnu...@apple.com>
 
+        SharedMemory::systemPageSize is redundant function
+        https://bugs.webkit.org/show_bug.cgi?id=240057
+
+        Reviewed by Antti Koivisto.
+
+        Remove SharedMemory::systemPageSize().
+        Use WTF::pageSize() from PageBlock.h.
+
+        * Platform/SharedMemory.h:
+        * Platform/cocoa/SharedMemoryCocoa.cpp:
+        * Platform/unix/SharedMemoryUnix.cpp:
+        * Platform/win/SharedMemoryWin.cpp:
+        * Shared/SharedStringHashStore.cpp:
+        (WebKit::tableSizeForKeyCount):
+        * UIProcess/linux/MemoryPressureMonitor.cpp:
+        (WebKit::calculateMemoryAvailable):
+        * mac/WebKit2.order:
+
+2022-05-04  Kimmo Kinnunen  <kkinnu...@apple.com>
+
         Empty remote backing store collection prepare starts up GPU process
         https://bugs.webkit.org/show_bug.cgi?id=240067
 

Modified: trunk/Source/WebKit/Platform/SharedMemory.h (293822 => 293823)


--- trunk/Source/WebKit/Platform/SharedMemory.h	2022-05-05 06:36:37 UTC (rev 293822)
+++ trunk/Source/WebKit/Platform/SharedMemory.h	2022-05-05 06:38:33 UTC (rev 293823)
@@ -151,9 +151,6 @@
     Protection protection() const { return m_protection; }
 #endif
 
-    // Return the system page size in bytes.
-    static unsigned systemPageSize();
-
     Ref<WebCore::SharedBuffer> createSharedBuffer(size_t) const;
 
 private:

Modified: trunk/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp (293822 => 293823)


--- trunk/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp	2022-05-05 06:36:37 UTC (rev 293822)
+++ trunk/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp	2022-05-05 06:38:33 UTC (rev 293823)
@@ -345,11 +345,6 @@
     return true;
 }
 
-unsigned SharedMemory::systemPageSize()
-{
-    return vm_page_size;
-}
-
 WTF::MachSendRight SharedMemory::createSendRight(Protection protection) const
 {
     ASSERT(m_protection == protection || m_protection == Protection::ReadWrite && protection == Protection::ReadOnly);

Modified: trunk/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp (293822 => 293823)


--- trunk/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp	2022-05-05 06:36:37 UTC (rev 293822)
+++ trunk/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp	2022-05-05 06:38:33 UTC (rev 293823)
@@ -250,16 +250,6 @@
     return true;
 }
 
-unsigned SharedMemory::systemPageSize()
-{
-    static unsigned pageSize = 0;
-
-    if (!pageSize)
-        pageSize = getpagesize();
-
-    return pageSize;
-}
-
 } // namespace WebKit
 
 #endif

Modified: trunk/Source/WebKit/Platform/win/SharedMemoryWin.cpp (293822 => 293823)


--- trunk/Source/WebKit/Platform/win/SharedMemoryWin.cpp	2022-05-05 06:36:37 UTC (rev 293822)
+++ trunk/Source/WebKit/Platform/win/SharedMemoryWin.cpp	2022-05-05 06:38:33 UTC (rev 293823)
@@ -245,18 +245,4 @@
     return true;
 }
 
-unsigned SharedMemory::systemPageSize()
-{
-    static unsigned pageSize = 0;
-
-    if (!pageSize) {
-        SYSTEM_INFO systemInfo;
-        ::GetSystemInfo(&systemInfo);
-        pageSize = systemInfo.dwPageSize;
-    }
-
-    return pageSize;
-}
-
-
 } // namespace WebKit

Modified: trunk/Source/WebKit/Shared/SharedStringHashStore.cpp (293822 => 293823)


--- trunk/Source/WebKit/Shared/SharedStringHashStore.cpp	2022-05-05 06:36:37 UTC (rev 293822)
+++ trunk/Source/WebKit/Shared/SharedStringHashStore.cpp	2022-05-05 06:38:33 UTC (rev 293823)
@@ -27,6 +27,7 @@
 #include "SharedStringHashStore.h"
 
 #include <algorithm>
+#include <wtf/PageBlock.h>
 
 namespace WebKit {
 
@@ -56,7 +57,7 @@
     unsigned tableSize = nextPowerOf2(keyCount * sharedStringHashTableMaxLoad);
 
     // Ensure that the table size is at least the size of a page.
-    size_t minimumTableSize = SharedMemory::systemPageSize() / sizeof(SharedStringHash);
+    size_t minimumTableSize = pageSize() / sizeof(SharedStringHash);
     if (tableSize < minimumTableSize)
         return minimumTableSize;
 

Modified: trunk/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.cpp (293822 => 293823)


--- trunk/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.cpp	2022-05-05 06:36:37 UTC (rev 293822)
+++ trunk/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.cpp	2022-05-05 06:38:33 UTC (rev 293823)
@@ -34,6 +34,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <wtf/PageBlock.h>
 #include <wtf/Threading.h>
 #include <wtf/UniStdExtras.h>
 #include <wtf/text/CString.h>
@@ -133,14 +134,6 @@
     return sumLow;
 }
 
-static inline size_t systemPageSize()
-{
-    static size_t pageSize = 0;
-    if (!pageSize)
-        pageSize = sysconf(_SC_PAGE_SIZE);
-    return pageSize;
-}
-
 // If MemAvailable was not present in /proc/meminfo, because it's an old kernel version,
 // we can do the same calculation with the information we have from meminfo and the low watermaks.
 // See https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773
@@ -153,11 +146,11 @@
     if (lowWatermark == notSet)
         return notSet;
 
-    lowWatermark *= systemPageSize() / KB;
+    lowWatermark *= pageSize() / KB;
 
     // Estimate the amount of memory available for userspace allocations, without causing swapping.
     // Free memory cannot be taken below the low watermark, before the system starts swapping.
-    lowWatermark *= systemPageSize() / KB;
+    lowWatermark *= pageSize() / KB;
     size_t memoryAvailable = memoryFree - lowWatermark;
 
     // Not all the page cache can be freed, otherwise the system will start swapping. Assume at least

Modified: trunk/Source/WebKit/mac/WebKit2.order (293822 => 293823)


--- trunk/Source/WebKit/mac/WebKit2.order	2022-05-05 06:36:37 UTC (rev 293822)
+++ trunk/Source/WebKit/mac/WebKit2.order	2022-05-05 06:38:33 UTC (rev 293823)
@@ -1254,7 +1254,6 @@
 __ZN3WTF6VectorIyLm0ENS_15CrashOnOverflowEE6resizeEm
 __ZN3WTF6VectorIyLm0ENS_15CrashOnOverflowEE15reserveCapacityEm
 __ZN3WTF16VectorBufferBaseIyE14allocateBufferEm
-__ZN6WebKit12SharedMemory14systemPageSizeEv
 __ZN6WebKit12SharedMemory6createEm
 __ZN6WebKit12SharedMemory18createFromVMBufferEPvm
 __ZN6WebKit16VisitedLinkTable15setSharedMemoryEN3WTF10PassRefPtrINS_12SharedMemoryEEE
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to