WebKit Bugzilla
Attachment 371236 Details for
Bug 198466
: [WinCairo] Implement cpu and memory measuring functions.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198466-20190604102336.patch (text/plain), 14.08 KB, created by
Takashi Komori
on 2019-06-03 18:26:01 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Takashi Komori
Created:
2019-06-03 18:26:01 PDT
Size:
14.08 KB
patch
obsolete
>Subversion Revision: 246039 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index ce55f4dba6eccb246965d63a28121de3c1406cd0..ecd5a60936b9cf98e3795757bfe7d83f67fd5561 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,27 @@ >+2019-06-03 Takashi Komori <Takashi.Komori@sony.com> >+ >+ [WinCairo] Implement cpu and memory measuring functions. >+ https://bugs.webkit.org/show_bug.cgi?id=198466 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Tests: inspector/memory/tracking.html >+ inspector/cpu-profiler/tracking.html >+ >+ * PlatformWinCairo.cmake: >+ * page/ResourceUsageThread.h: >+ * page/win/ResourceUsageOverlayWin.cpp: Copied from Tools/WebKitTestRunner/InjectedBundle/win/TestRunnerWin.cpp. >+ (WebCore::ResourceUsageOverlay::platformInitialize): >+ (WebCore::ResourceUsageOverlay::platformDestroy): >+ * page/win/ResourceUsageThreadWin.cpp: Added. >+ (WebCore::ResourceUsageThread::platformSaveStateBeforeStarting): >+ (WebCore::fileTimeToUint64): >+ (WebCore::getCurrentCpuTime): >+ (WebCore::cpuUsage): >+ (WebCore::memoryUsage): >+ (WebCore::ResourceUsageThread::platformCollectCPUData): >+ (WebCore::ResourceUsageThread::platformCollectMemoryData): >+ > 2019-06-03 Don Olmstead <don.olmstead@sony.com> > > [CMake] Add WebKit::JavaScriptCore target >diff --git a/Source/WebCore/PlatformWinCairo.cmake b/Source/WebCore/PlatformWinCairo.cmake >index ed69d743ae599c8f20966ef9a3bb1faeac86dc42..be04b83c7504176091914178c142b262d95b4b6a 100644 >--- a/Source/WebCore/PlatformWinCairo.cmake >+++ b/Source/WebCore/PlatformWinCairo.cmake >@@ -12,6 +12,8 @@ list(APPEND WebCore_PRIVATE_INCLUDE_DIRECTORIES > > list(APPEND WebCore_SOURCES > page/win/FrameCairoWin.cpp >+ page/win/ResourceUsageOverlayWin.cpp >+ page/win/ResourceUsageThreadWin.cpp > > platform/graphics/GLContext.cpp > platform/graphics/PlatformDisplay.cpp >diff --git a/Source/WebCore/page/ResourceUsageThread.h b/Source/WebCore/page/ResourceUsageThread.h >index 35ae3f03be365ee8606fe49ee6b7cf2aac2d55fd..0e35ea292525ca7982f26f05bcdd345ce66db030 100644 >--- a/Source/WebCore/page/ResourceUsageThread.h >+++ b/Source/WebCore/page/ResourceUsageThread.h >@@ -72,7 +72,7 @@ private: > void recomputeCollectionMode(); > > void createThreadIfNeeded(); >- void threadBody(); >+ NO_RETURN void threadBody(); > > void platformSaveStateBeforeStarting(); > void platformCollectCPUData(JSC::VM*, ResourceUsageData&); >diff --git a/Source/WebCore/page/win/ResourceUsageOverlayWin.cpp b/Source/WebCore/page/win/ResourceUsageOverlayWin.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..018d81ddb8e2da651245c43fc56613c29f2d40a9 >--- /dev/null >+++ b/Source/WebCore/page/win/ResourceUsageOverlayWin.cpp >@@ -0,0 +1,44 @@ >+/* >+ * Copyright (C) 2017 Igalia S.L. >+ * Copyright (C) 2019 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 "ResourceUsageOverlay.h" >+ >+#if ENABLE(RESOURCE_USAGE) && OS(WINDOWS) >+ >+namespace WebCore { >+ >+void ResourceUsageOverlay::platformInitialize() >+{ >+} >+ >+void ResourceUsageOverlay::platformDestroy() >+{ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/page/win/ResourceUsageThreadWin.cpp b/Source/WebCore/page/win/ResourceUsageThreadWin.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..0bdbb9f0fd34e3200be0fe952fe958d9af26d73a >--- /dev/null >+++ b/Source/WebCore/page/win/ResourceUsageThreadWin.cpp >@@ -0,0 +1,140 @@ >+/* >+ * Copyright (C) 2017 Igalia S.L. >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * Copyright (C) 2019 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 "ResourceUsageThread.h" >+ >+#if ENABLE(RESOURCE_USAGE) && OS(WINDOWS) >+ >+#include <JavaScriptCore/GCActivityCallback.h> >+#include <JavaScriptCore/VM.h> >+#include <psapi.h> >+ >+namespace WebCore { >+ >+void ResourceUsageThread::platformSaveStateBeforeStarting() >+{ >+} >+ >+static uint64_t fileTimeToUint64(FILETIME ft) >+{ >+ ULARGE_INTEGER u; >+ u.LowPart = ft.dwLowDateTime; >+ u.HighPart = ft.dwHighDateTime; >+ >+ return u.QuadPart; >+} >+ >+static bool getCurrentCpuTime(uint64_t& nowTime, uint64_t& userTime, uint64_t& kernelTime) >+{ >+ FILETIME creationFileTime, exitFileTime, kernelFileTime, userFileTime; >+ if (!GetProcessTimes(GetCurrentProcess(), &creationFileTime, &exitFileTime, &kernelFileTime, &userFileTime)) >+ return false; >+ >+ FILETIME nowFileTime; >+ GetSystemTimeAsFileTime(&nowFileTime); >+ >+ nowTime = fileTimeToUint64(nowFileTime); >+ userTime = fileTimeToUint64(userFileTime); >+ kernelTime = fileTimeToUint64(kernelFileTime); >+ >+ return true; >+} >+ >+static float cpuUsage() >+{ >+ static int numberOfProcessors = 0; >+ static uint64_t lastTime = 0; >+ static uint64_t lastKernelTime = 0; >+ static uint64_t lastUserTime = 0; >+ >+ if (!lastTime) { >+ SYSTEM_INFO systemInfo; >+ GetSystemInfo(&systemInfo); >+ numberOfProcessors = systemInfo.dwNumberOfProcessors; >+ >+ getCurrentCpuTime(lastTime, lastKernelTime, lastUserTime); >+ return 0; >+ } >+ >+ uint64_t nowTime, kernelTime, userTime; >+ if (!getCurrentCpuTime(nowTime, kernelTime, userTime)) >+ return 0; >+ >+ uint64_t elapsed = nowTime - lastTime; >+ uint64_t totalCPUTime = (kernelTime - lastKernelTime); >+ totalCPUTime += (userTime - lastUserTime); >+ >+ lastTime = nowTime; >+ lastKernelTime = kernelTime; >+ lastUserTime = userTime; >+ >+ float usage = (100.0 * totalCPUTime) / elapsed / numberOfProcessors; >+ return clampTo<float>(usage, 0, 100); >+} >+ >+static size_t memoryUsage() >+{ >+ PROCESS_MEMORY_COUNTERS_EX pmc; >+ if (GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc))) >+ return pmc.PrivateUsage; >+ >+ return 0; >+} >+ >+void ResourceUsageThread::platformCollectCPUData(JSC::VM*, ResourceUsageData& data) >+{ >+ data.cpu = cpuUsage(); >+ >+ // FIXME: Exclude the ResourceUsage thread. >+ // FIXME: Exclude the SamplingProfiler thread. >+ // FIXME: Classify usage per thread. >+ data.cpuExcludingDebuggerThreads = data.cpu; >+} >+ >+void ResourceUsageThread::platformCollectMemoryData(JSC::VM* vm, ResourceUsageData& data) >+{ >+ data.totalDirtySize = memoryUsage(); >+ >+ size_t currentGCHeapCapacity = vm->heap.blockBytesAllocated(); >+ size_t currentGCOwnedExtra = vm->heap.extraMemorySize(); >+ size_t currentGCOwnedExternal = vm->heap.externalMemorySize(); >+ RELEASE_ASSERT(currentGCOwnedExternal <= currentGCOwnedExtra); >+ >+ data.categories[MemoryCategory::GCHeap].dirtySize = currentGCHeapCapacity; >+ data.categories[MemoryCategory::GCOwned].dirtySize = currentGCOwnedExtra - currentGCOwnedExternal; >+ data.categories[MemoryCategory::GCOwned].externalSize = currentGCOwnedExternal; >+ >+ data.totalExternalSize = currentGCOwnedExternal; >+ >+ data.timeOfNextEdenCollection = data.timestamp + vm->heap.edenActivityCallback()->timeUntilFire().valueOr(Seconds(std::numeric_limits<double>::infinity())); >+ data.timeOfNextFullCollection = data.timestamp + vm->heap.fullActivityCallback()->timeUntilFire().valueOr(Seconds(std::numeric_limits<double>::infinity())); >+} >+ >+} >+ >+#endif >diff --git a/Source/cmake/OptionsWinCairo.cmake b/Source/cmake/OptionsWinCairo.cmake >index 17a821661b213c2f2e8659b2120e4342aa0eca19..f6b50bceca02e6703f3f5d7ea6ed4fd49fa520ed 100644 >--- a/Source/cmake/OptionsWinCairo.cmake >+++ b/Source/cmake/OptionsWinCairo.cmake >@@ -32,6 +32,7 @@ SET_AND_EXPOSE_TO_BUILD(USE_MEDIA_FOUNDATION ON) > SET_AND_EXPOSE_TO_BUILD(USE_INSPECTOR_SOCKET_SERVER ${ENABLE_REMOTE_INSPECTOR}) > > set(ENABLE_GRAPHICS_CONTEXT_3D ON) >+set(ENABLE_RESOURCE_USAGE ON) > set(ENABLE_WEBKIT ON) > > set(USE_ANGLE_EGL ON) >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index b2854a677626accbf2ad1ba4d2ab7d3a1ff2c438..6767769ffc63550b6d27bea48db1eaee289b67a6 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,13 @@ >+2019-06-03 Takashi Komori <Takashi.Komori@sony.com> >+ >+ [WinCairo] Implement cpu and memory measuring functions. >+ https://bugs.webkit.org/show_bug.cgi?id=198466 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebKitTestRunner/InjectedBundle/win/TestRunnerWin.cpp: >+ (WTR::TestRunner::inspectorTestStubURL): >+ > 2019-06-03 Don Olmstead <don.olmstead@sony.com> > > [CMake] Add WebKit::JavaScriptCore target >diff --git a/Tools/WebKitTestRunner/InjectedBundle/win/TestRunnerWin.cpp b/Tools/WebKitTestRunner/InjectedBundle/win/TestRunnerWin.cpp >index 793b59b8250abf9aa5531dc6cb3879f88332258d..79dc9fdcd9917df49273e671b32a2812e736e033 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/win/TestRunnerWin.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/win/TestRunnerWin.cpp >@@ -27,6 +27,8 @@ > #include "TestRunner.h" > > #include "ActivateFonts.h" >+#include <shlwapi.h> >+#include <wininet.h> > > namespace WTR { > >@@ -37,7 +39,25 @@ JSRetainPtr<JSStringRef> TestRunner::pathToLocalResource(JSStringRef) > > JSRetainPtr<JSStringRef> TestRunner::inspectorTestStubURL() > { >- return JSStringCreateWithUTF8CString(""); >+ wchar_t exePath[MAX_PATH]; >+ if (::GetModuleFileName(nullptr, exePath, MAX_PATH)) { >+ wchar_t drive[_MAX_DRIVE]; >+ wchar_t dir[_MAX_DIR]; >+ _wsplitpath(exePath, drive, dir, nullptr, nullptr); >+ >+ wchar_t stubPath[MAX_PATH]; >+ wcsncpy(stubPath, drive, MAX_PATH); >+ wcsncat(stubPath, dir, MAX_PATH - wcslen(stubPath)); >+ wcsncat(stubPath, L"\\WebKit.resources\\WebInspectorUI\\TestStub.html", MAX_PATH - wcslen(stubPath)); >+ >+ wchar_t fileURI[INTERNET_MAX_PATH_LENGTH]; >+ DWORD fileURILength = INTERNET_MAX_PATH_LENGTH; >+ UrlCreateFromPathW(stubPath, fileURI, &fileURILength, 0); >+ >+ return JSStringCreateWithCharacters(fileURI, fileURILength); >+ } >+ >+ return nullptr; > } > > void TestRunner::platformInitialize() >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 63029f88bdda0aa5d4834262ef3728220e557621..4a6f539c8fa812ac274bc1483b8035fd296c09c1 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,12 @@ >+2019-06-03 Takashi Komori <Takashi.Komori@sony.com> >+ >+ [WinCairo] Implement cpu and memory measuring functions. >+ https://bugs.webkit.org/show_bug.cgi?id=198466 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * platform/wincairo/TestExpectations: >+ > 2019-06-03 Devin Rousso <drousso@apple.com> > > Flaky Test: inspector/canvas/recording.html >diff --git a/LayoutTests/platform/wincairo/TestExpectations b/LayoutTests/platform/wincairo/TestExpectations >index 5f10b53bd72646ab04a05bfb3a457cf1c15bab30..8a9cd8a7a8f2fc1b017cdad7be15bd13860302c6 100644 >--- a/LayoutTests/platform/wincairo/TestExpectations >+++ b/LayoutTests/platform/wincairo/TestExpectations >@@ -1564,6 +1564,9 @@ imported/blink [ Skip ] > imported/mozilla [ Skip ] > imported/w3c [ Skip ] > inspector [ Skip ] >+inspector/memory/ [ Pass ] >+inspector/cpu-profiler/ [ Pass ] >+inspector/cpu-profiler/threads.html [ Failure ] > js/dom/deep-recursion-test.html [ Failure ] > js/dom/dom-static-property-for-in-iteration.html [ Failure ] > js/dom/regress-157246.html [ Failure ] >diff --git a/ChangeLog b/ChangeLog >index 84c37506d46a6589e32b1f04a415d550dfd66ecf..d9d022e6585f547b18547dbf68fa759f076d21e1 100644 >--- a/ChangeLog >+++ b/ChangeLog >@@ -1,3 +1,12 @@ >+2019-06-03 Takashi Komori <Takashi.Komori@sony.com> >+ >+ [WinCairo] Implement cpu and memory measuring functions. >+ https://bugs.webkit.org/show_bug.cgi?id=198466 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Source/cmake/OptionsWinCairo.cmake: >+ > 2019-06-03 Zan Dobersek <zdobersek@igalia.com> > > [Nicosia] Disable async scrolling until implemented
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 198466
:
371142
|
371236
|
371237
|
371252
|
371257