Title: [279007] trunk/Source
Revision
279007
Author
[email protected]
Date
2021-06-17 13:49:31 -0700 (Thu, 17 Jun 2021)

Log Message

Remove Mac-specific CPUTime functions
https://bugs.webkit.org/show_bug.cgi?id=227109

Reviewed by Yusuke Suzuki.

Source/WebKit:

Permit calling thread_selfusage, since it is used by clock_gettime(CLOCK_THREAD_CPUTIME_ID, tp).

* Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb.in:
* WebProcess/com.apple.WebProcess.sb.in:

Source/WTF:

There's no reason for the Mac-specific CPU time functions to exist, since getrusage and
clock_gettime work fine on Mac. It's actually slightly more efficient to use the POSIX calls
since getrusage returns CPU time for both current and terminated threads in a single
syscall, while using task_info requires two syscalls to do the same thing.

* WTF.xcodeproj/project.pbxproj:
* wtf/PlatformGTK.cmake:
* wtf/PlatformJSCOnly.cmake:
* wtf/PlatformPlayStation.cmake:
* wtf/PlatformWPE.cmake:
* wtf/cocoa/CPUTimeCocoa.cpp: Removed.
* wtf/posix/CPUTimePOSIX.cpp: Renamed from Source/WTF/wtf/unix/CPUTimeUnix.cpp.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (279006 => 279007)


--- trunk/Source/WTF/ChangeLog	2021-06-17 20:48:44 UTC (rev 279006)
+++ trunk/Source/WTF/ChangeLog	2021-06-17 20:49:31 UTC (rev 279007)
@@ -1,3 +1,23 @@
+2021-06-17  Ben Nham  <[email protected]>
+
+        Remove Mac-specific CPUTime functions
+        https://bugs.webkit.org/show_bug.cgi?id=227109
+
+        Reviewed by Yusuke Suzuki.
+
+        There's no reason for the Mac-specific CPU time functions to exist, since getrusage and
+        clock_gettime work fine on Mac. It's actually slightly more efficient to use the POSIX calls
+        since getrusage returns CPU time for both current and terminated threads in a single
+        syscall, while using task_info requires two syscalls to do the same thing.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/PlatformGTK.cmake:
+        * wtf/PlatformJSCOnly.cmake:
+        * wtf/PlatformPlayStation.cmake:
+        * wtf/PlatformWPE.cmake:
+        * wtf/cocoa/CPUTimeCocoa.cpp: Removed.
+        * wtf/posix/CPUTimePOSIX.cpp: Renamed from Source/WTF/wtf/unix/CPUTimeUnix.cpp.
+
 2021-06-17  Tim Horton  <[email protected]>
 
         Adopt WKHoverGestureRecognizer

Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (279006 => 279007)


--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2021-06-17 20:48:44 UTC (rev 279006)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2021-06-17 20:49:31 UTC (rev 279007)
@@ -174,7 +174,6 @@
 		E3149A39228BB43500BFA6C7 /* Vector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F95B63420CB53C100479635 /* Vector.cpp */; };
 		E3149A3B228BDCAC00BFA6C7 /* ConcurrentBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3149A3A228BDCAB00BFA6C7 /* ConcurrentBuffer.cpp */; };
 		E388886F20C9095100E632BC /* WorkerPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E388886D20C9095100E632BC /* WorkerPool.cpp */; };
-		E38C41251EB4E04C0042957D /* CPUTimeCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38C41241EB4E04C0042957D /* CPUTimeCocoa.cpp */; };
 		E38C41281EB4E0680042957D /* CPUTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38C41261EB4E0680042957D /* CPUTime.cpp */; };
 		E38D6E271F5522E300A75CC4 /* StringBuilderJSON.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38D6E261F5522E300A75CC4 /* StringBuilderJSON.cpp */; };
 		E392FA2722E92BFF00ECDC73 /* ResourceUsageCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E392FA2622E92BFF00ECDC73 /* ResourceUsageCocoa.cpp */; };
@@ -183,6 +182,7 @@
 		E3BE09A724A5854D009DF2B4 /* ICUHelpers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3BE09A624A58545009DF2B4 /* ICUHelpers.cpp */; };
 		E4A0AD391A96245500536DF6 /* WorkQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD371A96245500536DF6 /* WorkQueue.cpp */; };
 		E4A0AD3D1A96253C00536DF6 /* WorkQueueCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */; };
+		EB2C86D9267B275D0052CB9A /* CPUTimePOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EB2C86D8267B275C0052CB9A /* CPUTimePOSIX.cpp */; };
 		EB61EDC72409CCC1001EFE36 /* SystemTracingCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EB61EDC62409CCC0001EFE36 /* SystemTracingCocoa.cpp */; };
 		FE032AD22463E43B0012D7C7 /* WTFConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE032AD02463E43B0012D7C7 /* WTFConfig.cpp */; };
 		FE05FAFF1FE5007500093230 /* WTFAssertions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE05FAFE1FE5007500093230 /* WTFAssertions.cpp */; };
@@ -740,7 +740,6 @@
 		E38020DB2401C0930037CA9E /* CompactRefPtrTuple.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CompactRefPtrTuple.h; sourceTree = "<group>"; };
 		E388886D20C9095100E632BC /* WorkerPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerPool.cpp; sourceTree = "<group>"; };
 		E388886E20C9095100E632BC /* WorkerPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerPool.h; sourceTree = "<group>"; };
-		E38C41241EB4E04C0042957D /* CPUTimeCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPUTimeCocoa.cpp; sourceTree = "<group>"; };
 		E38C41261EB4E0680042957D /* CPUTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPUTime.cpp; sourceTree = "<group>"; };
 		E38C41271EB4E0680042957D /* CPUTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPUTime.h; sourceTree = "<group>"; };
 		E38D6E261F5522E300A75CC4 /* StringBuilderJSON.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringBuilderJSON.cpp; sourceTree = "<group>"; };
@@ -759,6 +758,7 @@
 		E4A0AD371A96245500536DF6 /* WorkQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueue.cpp; sourceTree = "<group>"; };
 		E4A0AD381A96245500536DF6 /* WorkQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkQueue.h; sourceTree = "<group>"; };
 		E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueueCocoa.cpp; sourceTree = "<group>"; };
+		EB2C86D8267B275C0052CB9A /* CPUTimePOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPUTimePOSIX.cpp; sourceTree = "<group>"; };
 		EB61EDC62409CCC0001EFE36 /* SystemTracingCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SystemTracingCocoa.cpp; sourceTree = "<group>"; };
 		EB95E1EF161A72410089A2F5 /* ByteOrder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteOrder.h; sourceTree = "<group>"; };
 		EBFF67FC240D7D660078FF1B /* OSVariantSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSVariantSPI.h; sourceTree = "<group>"; };
@@ -899,6 +899,7 @@
 		A331D96321F24A2E009F02AA /* posix */ = {
 			isa = PBXGroup;
 			children = (
+				EB2C86D8267B275C0052CB9A /* CPUTimePOSIX.cpp */,
 				A331D96621F24ABD009F02AA /* FileSystemPOSIX.cpp */,
 				A3EE5C3921FFAC5E00FABD61 /* OSAllocatorPOSIX.cpp */,
 				A32D8FA421FFFAB400780662 /* ThreadingPOSIX.cpp */,
@@ -1564,7 +1565,6 @@
 			isa = PBXGroup;
 			children = (
 				1469419B16EAB10A0024E146 /* AutodrainedPool.cpp */,
-				E38C41241EB4E04C0042957D /* CPUTimeCocoa.cpp */,
 				CEA072A9236FFBF70018839C /* CrashReporter.cpp */,
 				CEA072A8236FFBF70018839C /* CrashReporter.h */,
 				143DDE9720C8BE99007F76FA /* Entitlements.h */,
@@ -1685,7 +1685,7 @@
 				0F30CB5A1FCDF134004B5323 /* ConcurrentPtrHashSet.cpp in Sources */,
 				0F8E85DB1FD485B000691889 /* CountingLock.cpp in Sources */,
 				E38C41281EB4E0680042957D /* CPUTime.cpp in Sources */,
-				E38C41251EB4E04C0042957D /* CPUTimeCocoa.cpp in Sources */,
+				EB2C86D9267B275D0052CB9A /* CPUTimePOSIX.cpp in Sources */,
 				CEA072AA236FFBF70018839C /* CrashReporter.cpp in Sources */,
 				515F794E1CFC9F4A00CCED93 /* CrossThreadCopier.cpp in Sources */,
 				517F82D71FD22F3000DA3DEA /* CrossThreadTaskHandler.cpp in Sources */,

Modified: trunk/Source/WTF/wtf/PlatformGTK.cmake (279006 => 279007)


--- trunk/Source/WTF/wtf/PlatformGTK.cmake	2021-06-17 20:48:44 UTC (rev 279006)
+++ trunk/Source/WTF/wtf/PlatformGTK.cmake	2021-06-17 20:49:31 UTC (rev 279007)
@@ -37,12 +37,12 @@
     glib/SocketConnection.cpp
     glib/URLGLib.cpp
 
+    posix/CPUTimePOSIX.cpp
     posix/OSAllocatorPOSIX.cpp
     posix/ThreadingPOSIX.cpp
 
     text/unix/TextBreakIteratorInternalICUUnix.cpp
 
-    unix/CPUTimeUnix.cpp
     unix/LanguageUnix.cpp
     unix/UniStdExtrasUnix.cpp
 )

Modified: trunk/Source/WTF/wtf/PlatformJSCOnly.cmake (279006 => 279007)


--- trunk/Source/WTF/wtf/PlatformJSCOnly.cmake	2021-06-17 20:48:44 UTC (rev 279006)
+++ trunk/Source/WTF/wtf/PlatformJSCOnly.cmake	2021-06-17 20:49:31 UTC (rev 279007)
@@ -44,7 +44,7 @@
         )
     else ()
         list(APPEND WTF_SOURCES
-            unix/CPUTimeUnix.cpp
+            posix/CPUTimePOSIX.cpp
         )
     endif ()
 

Modified: trunk/Source/WTF/wtf/PlatformPlayStation.cmake (279006 => 279007)


--- trunk/Source/WTF/wtf/PlatformPlayStation.cmake	2021-06-17 20:48:44 UTC (rev 279006)
+++ trunk/Source/WTF/wtf/PlatformPlayStation.cmake	2021-06-17 20:49:31 UTC (rev 279007)
@@ -8,6 +8,7 @@
     playstation/LanguagePlayStation.cpp
     playstation/UniStdExtrasPlayStation.cpp
 
+    posix/CPUTimePOSIX.cpp
     posix/FileSystemPOSIX.cpp
     posix/OSAllocatorPOSIX.cpp
     posix/ThreadingPOSIX.cpp
@@ -14,7 +15,6 @@
 
     text/unix/TextBreakIteratorInternalICUUnix.cpp
 
-    unix/CPUTimeUnix.cpp
     unix/MemoryPressureHandlerUnix.cpp
 )
 

Modified: trunk/Source/WTF/wtf/PlatformWPE.cmake (279006 => 279007)


--- trunk/Source/WTF/wtf/PlatformWPE.cmake	2021-06-17 20:48:44 UTC (rev 279006)
+++ trunk/Source/WTF/wtf/PlatformWPE.cmake	2021-06-17 20:49:31 UTC (rev 279007)
@@ -30,12 +30,12 @@
 
     linux/CurrentProcessMemoryStatus.cpp
 
+    posix/CPUTimePOSIX.cpp
     posix/OSAllocatorPOSIX.cpp
     posix/ThreadingPOSIX.cpp
 
     text/unix/TextBreakIteratorInternalICUUnix.cpp
 
-    unix/CPUTimeUnix.cpp
     unix/LanguageUnix.cpp
     unix/MemoryPressureHandlerUnix.cpp
     unix/UniStdExtrasUnix.cpp

Deleted: trunk/Source/WTF/wtf/cocoa/CPUTimeCocoa.cpp (279006 => 279007)


--- trunk/Source/WTF/wtf/cocoa/CPUTimeCocoa.cpp	2021-06-17 20:48:44 UTC (rev 279006)
+++ trunk/Source/WTF/wtf/cocoa/CPUTimeCocoa.cpp	2021-06-17 20:49:31 UTC (rev 279007)
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2017-2019 Apple 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.
- */
-
-#import "config.h"
-#import "CPUTime.h"
-
-#import "MachSendRight.h"
-#import <mach/mach.h>
-#import <mach/mach_time.h>
-#import <mach/task.h>
-#import <mach/task_info.h>
-#import <mach/thread_info.h>
-#import <sys/time.h>
-
-namespace WTF {
-
-static constexpr int64_t microsecondsPerSecond = 1000000;
-
-static int64_t timeValueToMicroseconds(const time_value_t& value)
-{
-    int64_t result = value.seconds;
-    result *= microsecondsPerSecond;
-    result += value.microseconds;
-    return result;
-}
-
-std::optional<CPUTime> CPUTime::get()
-{
-    // Account for current threads.
-    task_thread_times_info threadInfoData;
-    mach_msg_type_number_t threadInfoCount = TASK_THREAD_TIMES_INFO_COUNT;
-    kern_return_t result = task_info(mach_task_self(), TASK_THREAD_TIMES_INFO, reinterpret_cast<task_info_t>(&threadInfoData), &threadInfoCount);
-    if (result != KERN_SUCCESS)
-        return std::nullopt;
-
-    int64_t userTime = timeValueToMicroseconds(threadInfoData.user_time);
-    int64_t systemTime = timeValueToMicroseconds(threadInfoData.system_time);
-
-    // Account for termined threads.
-    task_basic_info taskInfoData;
-    mach_msg_type_number_t taskInfoCount = TASK_BASIC_INFO_COUNT;
-    result = task_info(mach_task_self(), TASK_BASIC_INFO, reinterpret_cast<task_info_t>(&taskInfoData), &taskInfoCount);
-    if (result != KERN_SUCCESS)
-        return std::nullopt;
-
-    userTime += timeValueToMicroseconds(taskInfoData.user_time);
-    systemTime += timeValueToMicroseconds(taskInfoData.system_time);
-
-    return CPUTime { MonotonicTime::now(), Seconds::fromMicroseconds(userTime), Seconds::fromMicroseconds(systemTime) };
-}
-
-Seconds CPUTime::forCurrentThread()
-{
-    mach_msg_type_number_t infoCount = THREAD_BASIC_INFO_COUNT;
-    thread_basic_info_data_t info;
-
-    auto threadPort = MachSendRight::adopt(mach_thread_self());
-    auto ret = thread_info(threadPort.sendRight(), THREAD_BASIC_INFO, reinterpret_cast<thread_info_t>(&info), &infoCount);
-    RELEASE_ASSERT(ret == KERN_SUCCESS);
-
-    return Seconds(info.user_time.seconds + info.system_time.seconds) + Seconds::fromMicroseconds(info.user_time.microseconds + info.system_time.microseconds);
-}
-
-}

Copied: trunk/Source/WTF/wtf/posix/CPUTimePOSIX.cpp (from rev 279006, trunk/Source/WTF/wtf/unix/CPUTimeUnix.cpp) (0 => 279007)


--- trunk/Source/WTF/wtf/posix/CPUTimePOSIX.cpp	                        (rev 0)
+++ trunk/Source/WTF/wtf/posix/CPUTimePOSIX.cpp	2021-06-17 20:49:31 UTC (rev 279007)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2017 Yusuke Suzuki <[email protected]>
+ *
+ * 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/CPUTime.h>
+
+#include <sys/resource.h>
+#include <sys/time.h>
+#include <time.h>
+
+namespace WTF {
+
+static Seconds timevalToSeconds(const struct timeval& value)
+{
+    return Seconds(value.tv_sec) + Seconds::fromMicroseconds(value.tv_usec);
+}
+
+std::optional<CPUTime> CPUTime::get()
+{
+    struct rusage resource { };
+    int ret = getrusage(RUSAGE_SELF, &resource);
+    ASSERT_UNUSED(ret, !ret);
+    return CPUTime { MonotonicTime::now(), timevalToSeconds(resource.ru_utime), timevalToSeconds(resource.ru_stime) };
+}
+
+Seconds CPUTime::forCurrentThread()
+{
+    struct timespec ts { };
+    int ret = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
+    RELEASE_ASSERT(!ret);
+    return Seconds(ts.tv_sec) + Seconds::fromNanoseconds(ts.tv_nsec);
+}
+
+}

Deleted: trunk/Source/WTF/wtf/unix/CPUTimeUnix.cpp (279006 => 279007)


--- trunk/Source/WTF/wtf/unix/CPUTimeUnix.cpp	2021-06-17 20:48:44 UTC (rev 279006)
+++ trunk/Source/WTF/wtf/unix/CPUTimeUnix.cpp	2021-06-17 20:49:31 UTC (rev 279007)
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2017 Yusuke Suzuki <[email protected]>
- *
- * 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/CPUTime.h>
-
-#include <sys/resource.h>
-#include <sys/time.h>
-#include <time.h>
-
-namespace WTF {
-
-static Seconds timevalToSeconds(const struct timeval& value)
-{
-    return Seconds(value.tv_sec) + Seconds::fromMicroseconds(value.tv_usec);
-}
-
-std::optional<CPUTime> CPUTime::get()
-{
-    struct rusage resource { };
-    int ret = getrusage(RUSAGE_SELF, &resource);
-    ASSERT_UNUSED(ret, !ret);
-    return CPUTime { MonotonicTime::now(), timevalToSeconds(resource.ru_utime), timevalToSeconds(resource.ru_stime) };
-}
-
-Seconds CPUTime::forCurrentThread()
-{
-    struct timespec ts { };
-    int ret = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
-    RELEASE_ASSERT(!ret);
-    return Seconds(ts.tv_sec) + Seconds::fromNanoseconds(ts.tv_nsec);
-}
-
-}

Modified: trunk/Source/WebKit/ChangeLog (279006 => 279007)


--- trunk/Source/WebKit/ChangeLog	2021-06-17 20:48:44 UTC (rev 279006)
+++ trunk/Source/WebKit/ChangeLog	2021-06-17 20:49:31 UTC (rev 279007)
@@ -1,3 +1,15 @@
+2021-06-17  Ben Nham  <[email protected]>
+
+        Remove Mac-specific CPUTime functions
+        https://bugs.webkit.org/show_bug.cgi?id=227109
+
+        Reviewed by Yusuke Suzuki.
+
+        Permit calling thread_selfusage, since it is used by clock_gettime(CLOCK_THREAD_CPUTIME_ID, tp).
+
+        * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb.in:
+        * WebProcess/com.apple.WebProcess.sb.in:
+
 2021-06-17  Chris Dumez  <[email protected]>
 
         Trying to take empty snapshots of the view should not cause crashes

Modified: trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb.in (279006 => 279007)


--- trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb.in	2021-06-17 20:48:44 UTC (rev 279006)
+++ trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb.in	2021-06-17 20:49:31 UTC (rev 279007)
@@ -1337,6 +1337,7 @@
         (syscall-number SYS_bsdthread_terminate)
         (syscall-number SYS_workq_kernreturn)
         (syscall-number SYS_thread_selfid)
+        (syscall-number SYS_thread_selfusage)
         (syscall-number SYS_kevent_qos)
         (syscall-number SYS_kevent_id)
         (syscall-number SYS___mac_syscall)

Modified: trunk/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in (279006 => 279007)


--- trunk/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in	2021-06-17 20:48:44 UTC (rev 279006)
+++ trunk/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in	2021-06-17 20:49:31 UTC (rev 279007)
@@ -1965,6 +1965,7 @@
         (syscall-number SYS_bsdthread_terminate)
         (syscall-number SYS_workq_kernreturn)
         (syscall-number SYS_thread_selfid)
+        (syscall-number SYS_thread_selfusage)
         (syscall-number SYS_kevent)
         (syscall-number SYS_kevent_qos)
         (syscall-number SYS_kevent_id)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to