Title: [248441] trunk/Source
Revision
248441
Author
[email protected]
Date
2019-08-08 13:48:37 -0700 (Thu, 08 Aug 2019)

Log Message

OpenSource MemoryFootprint API for JSC command line tool
https://bugs.webkit.org/show_bug.cgi?id=200541

Reviewed by Saam Barati.

Source/_javascript_Core:

Use wtf/spi/darwin/ProcessMemoryFootprint.h instead of WebKitAdditions/MemoryFootprint.h
for process memory stats.

* jsc.cpp:
(MemoryFootprint::MemoryFootprint):

Source/WTF:

OpenSource version of WebKitAdditions/MemoryFootprint.h.

* WTF.xcodeproj/project.pbxproj:
* wtf/spi/darwin/ProcessMemoryFootprint.h: Added.
(ProcessMemoryFootprint::now):
(ProcessMemoryFootprint::resetPeak):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (248440 => 248441)


--- trunk/Source/_javascript_Core/ChangeLog	2019-08-08 20:32:41 UTC (rev 248440)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-08-08 20:48:37 UTC (rev 248441)
@@ -1,3 +1,16 @@
+2019-08-08  Michael Saboff  <[email protected]>
+
+        OpenSource MemoryFootprint API for JSC command line tool
+        https://bugs.webkit.org/show_bug.cgi?id=200541
+
+        Reviewed by Saam Barati.
+
+        Use wtf/spi/darwin/ProcessMemoryFootprint.h instead of WebKitAdditions/MemoryFootprint.h
+        for process memory stats.
+
+        * jsc.cpp:
+        (MemoryFootprint::MemoryFootprint):
+
 2019-08-08  Devin Rousso  <[email protected]>
 
         Web Inspector: rename `queryObjects` to `queryInstances` for clarity

Modified: trunk/Source/_javascript_Core/jsc.cpp (248440 => 248441)


--- trunk/Source/_javascript_Core/jsc.cpp	2019-08-08 20:32:41 UTC (rev 248440)
+++ trunk/Source/_javascript_Core/jsc.cpp	2019-08-08 20:48:37 UTC (rev 248441)
@@ -137,13 +137,19 @@
 #include <arm/arch.h>
 #endif
 
-#if __has_include(<WebKitAdditions/MemoryFootprint.h>)
-#include <WebKitAdditions/MemoryFootprint.h>
+#if OS(DARWIN)
+#include <wtf/spi/darwin/ProcessMemoryFootprint.h>
+struct MemoryFootprint : ProcessMemoryFootprint {
+    MemoryFootprint(const ProcessMemoryFootprint& src)
+        : ProcessMemoryFootprint(src)
+    {
+    }
+};
 #else
 struct MemoryFootprint {
     uint64_t current;
     uint64_t peak;
-    
+
     static MemoryFootprint now()
     {
         return { 0L, 0L };

Modified: trunk/Source/WTF/ChangeLog (248440 => 248441)


--- trunk/Source/WTF/ChangeLog	2019-08-08 20:32:41 UTC (rev 248440)
+++ trunk/Source/WTF/ChangeLog	2019-08-08 20:48:37 UTC (rev 248441)
@@ -1,3 +1,17 @@
+2019-08-08  Michael Saboff  <[email protected]>
+
+        OpenSource MemoryFootprint API for JSC command line tool
+        https://bugs.webkit.org/show_bug.cgi?id=200541
+
+        Reviewed by Saam Barati.
+
+        OpenSource version of WebKitAdditions/MemoryFootprint.h.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/spi/darwin/ProcessMemoryFootprint.h: Added.
+        (ProcessMemoryFootprint::now):
+        (ProcessMemoryFootprint::resetPeak):
+
 2019-08-08  Per Arne Vollan  <[email protected]>
 
         [Mac] Use the PID of the WebContent process when issuing local file read sandbox extensions

Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (248440 => 248441)


--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2019-08-08 20:32:41 UTC (rev 248440)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2019-08-08 20:48:37 UTC (rev 248441)
@@ -397,6 +397,7 @@
 		5FAD3AE021B9636600BEE178 /* URLHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLHelpers.h; sourceTree = "<group>"; };
 		5FAD3AE121B9636600BEE178 /* URLHelpers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLHelpers.cpp; sourceTree = "<group>"; };
 		6541CAF41630DB26006D0DEC /* CopyWTFHeaders.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CopyWTFHeaders.xcconfig; sourceTree = "<group>"; };
+		6593CDE922FA4A520087714B /* ProcessMemoryFootprint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProcessMemoryFootprint.h; sourceTree = "<group>"; };
 		70A993FC1AD7151300FA615B /* SymbolRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SymbolRegistry.cpp; sourceTree = "<group>"; };
 		70A993FD1AD7151300FA615B /* SymbolRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SymbolRegistry.h; sourceTree = "<group>"; };
 		70ECA60A1B02426800449739 /* AtomStringImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AtomStringImpl.cpp; sourceTree = "<group>"; };
@@ -1374,6 +1375,7 @@
 				14933E21228C22DF00F79E46 /* DataVaultSPI.h */,
 				E431CC4A21187ADB000C8A07 /* DispatchSPI.h */,
 				93DDE9311CDC052D00FD3491 /* dyldSPI.h */,
+				6593CDE922FA4A520087714B /* ProcessMemoryFootprint.h */,
 				A5098AFF1C169E0700087797 /* SandboxSPI.h */,
 				CE73E02419DCB7AB00580D5C /* XPCSPI.h */,
 			);
@@ -1496,7 +1498,7 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/sh;
-			shellScript = "if [[ \"${DEPLOYMENT_LOCATION}\" == \"NO\" ]]; then\n    PRIVATE_HEADERS_PATH=\"${TARGET_BUILD_DIR%/}/${PRIVATE_HEADERS_FOLDER_PATH}\"\n    ICU_PRIVATE_HEADERS_PATH=\"${TARGET_BUILD_DIR%/}/${ICU_PRIVATE_HEADERS_FOLDER_PATH}\"\nelse\n    PRIVATE_HEADERS_PATH=\"${DSTROOT}/${PRIVATE_HEADERS_FOLDER_PATH}\"\n    ICU_PRIVATE_HEADERS_PATH=\"${DSTROOT}/${ICU_PRIVATE_HEADERS_FOLDER_PATH}\"\nfi;\n\nmkdir -p \"${PRIVATE_HEADERS_PATH}\"\nrsync -av --no-owner --no-group --prune-empty-dirs --exclude \".svn\" --exclude \"usr\" --exclude \"DerivedSources\" --include \"*/\" --include \"*.h\" --exclude \"*\" \"${SRCROOT}/wtf/\" \"${PRIVATE_HEADERS_PATH}\"\n\nrsync -av --no-owner --no-group --prune-empty-dirs --exclude \".svn\" --exclude \"usr\" --exclude \"DerivedSources\" --include \"
 ;*/\" --include \"*.rb\" --exclude \"*\" \"${SRCROOT}/Scripts\" \"${PRIVATE_HEADERS_PATH}\"\n\nif [[ \"${USE_INTERNAL_SDK}\" != \"YES\" ]]; then\nmkdir -p \"${ICU_PRIVATE_HEADERS_PATH}\"\nrsync -av --no-owner --no-group --prune-empty-dirs --exclude \".svn\" --exclude \"usr\" --exclude \"DerivedSources\" --include \"*/\" --include \"*.h\" --exclude \"*\" \"${SRCROOT}/icu/\" \"${ICU_PRIVATE_HEADERS_PATH}\"\nfi";
+			shellScript = "if [[ \"${DEPLOYMENT_LOCATION}\" == \"NO\" ]]; then\n    PRIVATE_HEADERS_PATH=\"${TARGET_BUILD_DIR%/}/${PRIVATE_HEADERS_FOLDER_PATH}\"\n    ICU_PRIVATE_HEADERS_PATH=\"${TARGET_BUILD_DIR%/}/${ICU_PRIVATE_HEADERS_FOLDER_PATH}\"\nelse\n    PRIVATE_HEADERS_PATH=\"${DSTROOT}/${PRIVATE_HEADERS_FOLDER_PATH}\"\n    ICU_PRIVATE_HEADERS_PATH=\"${DSTROOT}/${ICU_PRIVATE_HEADERS_FOLDER_PATH}\"\nfi;\n\nmkdir -p \"${PRIVATE_HEADERS_PATH}\"\nrsync -av --no-owner --no-group --prune-empty-dirs --exclude \".svn\" --exclude \"usr\" --exclude \"DerivedSources\" --include \"*/\" --include \"*.h\" --exclude \"*\" \"${SRCROOT}/wtf/\" \"${PRIVATE_HEADERS_PATH}\"\n\nrsync -av --no-owner --no-group --prune-empty-dirs --exclude \".svn\" --exclude \"usr\" --exclude \"DerivedSources\" --include \"
 */\" --include \"*.rb\" --exclude \"*\" \"${SRCROOT}/Scripts\" \"${PRIVATE_HEADERS_PATH}\"\n\nif [[ \"${USE_INTERNAL_SDK}\" != \"YES\" ]]; then\nmkdir -p \"${ICU_PRIVATE_HEADERS_PATH}\"\nrsync -av --no-owner --no-group --prune-empty-dirs --exclude \".svn\" --exclude \"usr\" --exclude \"DerivedSources\" --include \"*/\" --include \"*.h\" --exclude \"*\" \"${SRCROOT}/icu/\" \"${ICU_PRIVATE_HEADERS_PATH}\"\nfi\n";
 		};
 /* End PBXShellScriptBuildPhase section */
 

Added: trunk/Source/WTF/wtf/spi/darwin/ProcessMemoryFootprint.h (0 => 248441)


--- trunk/Source/WTF/wtf/spi/darwin/ProcessMemoryFootprint.h	                        (rev 0)
+++ trunk/Source/WTF/wtf/spi/darwin/ProcessMemoryFootprint.h	2019-08-08 20:48:37 UTC (rev 248441)
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2018-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. ``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
+ * 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.
+ */
+
+#pragma once
+
+#if OS(DARWIN)
+
+#if !PLATFORM(IOS_FAMILY_SIMULATOR) && __has_include(<libproc.h>)
+#    include <libproc.h>
+#    if RUSAGE_INFO_CURRENT >= 4
+#        define HAS_MAX_FOOTPRINT
+#        if defined(RLIMIT_FOOTPRINT_INTERVAL) && __has_include(<libproc_internal.h>) \
+             && ((PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) \
+                 || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400))
+#            define HAS_RESET_FOOTPRINT_INTERVAL
+#            define MAX_FOOTPRINT_FIELD ri_interval_max_phys_footprint
+#            include <libproc_internal.h>
+#        else
+#            define MAX_FOOTPRINT_FIELD ri_lifetime_max_phys_footprint
+#        endif
+#    else
+#        define HAS_ONLY_PHYS_FOOTPRINT
+#    endif
+#endif
+
+struct ProcessMemoryFootprint {
+public:
+    uint64_t current;
+    uint64_t peak;
+
+    static ProcessMemoryFootprint now()
+    {
+#ifdef HAS_MAX_FOOTPRINT
+        rusage_info_v4 rusage;
+        if (proc_pid_rusage(getpid(), RUSAGE_INFO_V4, (rusage_info_t *)&rusage))
+            return { 0L, 0L };
+
+        return { rusage.ri_phys_footprint, rusage.MAX_FOOTPRINT_FIELD };
+#elif defined(HAS_ONLY_PHYS_FOOTPRINT)
+        rusage_info_v0 rusage;
+        if (proc_pid_rusage(getpid(), RUSAGE_INFO_V0, (rusage_info_t *)&rusage))
+            return { 0L, 0L };
+
+        return { rusage.ri_phys_footprint, 0L };
+#else
+        return { 0L, 0L };
+#endif
+    }
+
+    static void resetPeak()
+    {
+#ifdef HAS_RESET_FOOTPRINT_INTERVAL
+        proc_reset_footprint_interval(getpid());
+#endif
+    }
+};
+
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to