Unreviewed, rolling out r211571 and r211582.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Feb 2017 21:24:11 +0000 (21:24 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Feb 2017 21:24:11 +0000 (21:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167751

This change caused API test WebKit1.MemoryPressureHandler to
fail with an assertion. (Requested by ryanhaddad on #webkit).

Reverted changesets:

"[Mac] In-process memory pressure monitor for WebContent
processes."
https://bugs.webkit.org/show_bug.cgi?id=167491
http://trac.webkit.org/changeset/211571

"Unreviewed attempt to fix the Windows build after r211571."
http://trac.webkit.org/changeset/211582

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211589 268f45cc-cd09-0410-ab3c-d52691b4dbfc

21 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/heap/Heap.h
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/CMakeLists.txt
Source/WTF/wtf/MemoryFootprint.cpp [deleted file]
Source/WTF/wtf/MemoryFootprint.h [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/CommonVM.cpp
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/page/MainFrame.cpp
Source/WebCore/page/MainFrame.h
Source/WebCore/page/MemoryRelease.cpp
Source/WebCore/page/MemoryRelease.h
Source/WebCore/page/ResourceUsageThread.h
Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm
Source/WebCore/platform/MemoryPressureHandler.cpp
Source/WebCore/platform/MemoryPressureHandler.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebProcess.cpp

index 7272725..01cce56 100644 (file)
@@ -1,3 +1,21 @@
+2017-02-02  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r211571 and r211582.
+        https://bugs.webkit.org/show_bug.cgi?id=167751
+
+        This change caused API test WebKit1.MemoryPressureHandler to
+        fail with an assertion. (Requested by ryanhaddad on #webkit).
+
+        Reverted changesets:
+
+        "[Mac] In-process memory pressure monitor for WebContent
+        processes."
+        https://bugs.webkit.org/show_bug.cgi?id=167491
+        http://trac.webkit.org/changeset/211571
+
+        "Unreviewed attempt to fix the Windows build after r211571."
+        http://trac.webkit.org/changeset/211582
+
 2017-02-02  Andreas Kling  <akling@apple.com>
 
         [Mac] In-process memory pressure monitor for WebContent processes.
index 0a94776..228bfec 100644 (file)
@@ -1726,6 +1726,11 @@ void Heap::notifyIncrementalSweeper()
     m_sweeper->startSweeping();
 }
 
+NEVER_INLINE void Heap::didExceedMaxLiveSize()
+{
+    CRASH();
+}
+
 void Heap::updateAllocationLimits()
 {
     static const bool verbose = false;
@@ -1757,6 +1762,9 @@ void Heap::updateAllocationLimits()
 
     if (verbose)
         dataLog("extraMemorySize() = ", extraMemorySize(), ", currentHeapSize = ", currentHeapSize, "\n");
+
+    if (m_maxLiveSize && currentHeapSize > m_maxLiveSize)
+        didExceedMaxLiveSize();
     
     if (Options::gcMaxHeapSize() && currentHeapSize > Options::gcMaxHeapSize())
         HeapStatistics::exitWithFailure();
index b38b28d..2075f69 100644 (file)
@@ -132,6 +132,9 @@ public:
 
     VM* vm() const;
 
+    // Set a hard limit where JSC will crash if live heap size exceeds it.
+    void setMaxLiveSize(size_t size) { m_maxLiveSize = size; }
+
     MarkedSpace& objectSpace() { return m_objectSpace; }
     MachineThreads& machineThreads() { return m_machineThreads; }
 
@@ -600,6 +603,9 @@ private:
     size_t m_blockBytesAllocated { 0 };
     size_t m_externalMemorySize { 0 };
 #endif
+
+    NO_RETURN_DUE_TO_CRASH void didExceedMaxLiveSize();
+    size_t m_maxLiveSize { 0 };
     
     std::unique_ptr<MutatorScheduler> m_scheduler;
     
index 8579fe2..da82516 100644 (file)
@@ -1,3 +1,21 @@
+2017-02-02  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r211571 and r211582.
+        https://bugs.webkit.org/show_bug.cgi?id=167751
+
+        This change caused API test WebKit1.MemoryPressureHandler to
+        fail with an assertion. (Requested by ryanhaddad on #webkit).
+
+        Reverted changesets:
+
+        "[Mac] In-process memory pressure monitor for WebContent
+        processes."
+        https://bugs.webkit.org/show_bug.cgi?id=167491
+        http://trac.webkit.org/changeset/211571
+
+        "Unreviewed attempt to fix the Windows build after r211571."
+        http://trac.webkit.org/changeset/211582
+
 2017-02-02  Andreas Kling  <akling@apple.com>
 
         [Mac] In-process memory pressure monitor for WebContent processes.
index e42e0a5..fdd8701 100644 (file)
                A8A47487151A825B004123FF /* WTFThreadData.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4737B151A825B004123FF /* WTFThreadData.h */; };
                A8A4748C151A8264004123FF /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4748B151A8264004123FF /* config.h */; };
                AD7C434B1DD2A4A70026888B /* Expected.h in Headers */ = {isa = PBXBuildFile; fileRef = AD7C434A1DD2A4A70026888B /* Expected.h */; };
-               ADF2CE661E39F106006889DB /* MemoryFootprint.h in Headers */ = {isa = PBXBuildFile; fileRef = ADF2CE641E39F106006889DB /* MemoryFootprint.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               ADF2CE671E39F106006889DB /* MemoryFootprint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADF2CE651E39F106006889DB /* MemoryFootprint.cpp */; };
                B38FD7BD168953E80065C969 /* FeatureDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = B38FD7BC168953E80065C969 /* FeatureDefines.h */; };
                C4F8A93719C65EB400B2B15D /* Stopwatch.h in Headers */ = {isa = PBXBuildFile; fileRef = C4F8A93619C65EB400B2B15D /* Stopwatch.h */; };
                C8B0E1A1E01A486EB95E0D11 /* IndexSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 3137E1D7DBD84AC38FAE4D34 /* IndexSet.h */; };
                A8A4737B151A825B004123FF /* WTFThreadData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WTFThreadData.h; sourceTree = "<group>"; };
                A8A4748B151A8264004123FF /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
                AD7C434A1DD2A4A70026888B /* Expected.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Expected.h; sourceTree = "<group>"; };
-               ADF2CE641E39F106006889DB /* MemoryFootprint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryFootprint.h; sourceTree = "<group>"; };
-               ADF2CE651E39F106006889DB /* MemoryFootprint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryFootprint.cpp; sourceTree = "<group>"; };
                B38FD7BC168953E80065C969 /* FeatureDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FeatureDefines.h; sourceTree = "<group>"; };
                C4F8A93619C65EB400B2B15D /* Stopwatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Stopwatch.h; sourceTree = "<group>"; };
                CD5497AA15857D0300B5BC30 /* MediaTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaTime.cpp; sourceTree = "<group>"; };
                                A8A472CB151A825B004123FF /* MD5.h */,
                                CD5497AA15857D0300B5BC30 /* MediaTime.cpp */,
                                CD5497AB15857D0300B5BC30 /* MediaTime.h */,
-                               ADF2CE641E39F106006889DB /* MemoryFootprint.h */,
-                               ADF2CE651E39F106006889DB /* MemoryFootprint.cpp */,
                                A8A472CC151A825B004123FF /* MessageQueue.h */,
                                A8A472CD151A825B004123FF /* MetaAllocator.cpp */,
                                A8A472CE151A825B004123FF /* MetaAllocator.h */,
                                A8A4741C151A825B004123FF /* RefPtr.h in Headers */,
                                A8A4741E151A825B004123FF /* RetainPtr.h in Headers */,
                                2CDED0F418115C85004DBA70 /* RunLoop.h in Headers */,
-                               ADF2CE661E39F106006889DB /* MemoryFootprint.h in Headers */,
                                1469419216EAAF6D0024E146 /* RunLoopTimer.h in Headers */,
                                A5098B001C169E0700087797 /* SandboxSPI.h in Headers */,
                                14F3B0F715E45E4600210069 /* SaturatedArithmetic.h in Headers */,
                                1ACADD841884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm in Sources */,
                                A8A473AE151A825B004123FF /* diy-fp.cc in Sources */,
                                A8A473B0151A825B004123FF /* double-conversion.cc in Sources */,
-                               ADF2CE671E39F106006889DB /* MemoryFootprint.cpp in Sources */,
                                A8A473BA151A825B004123FF /* dtoa.cpp in Sources */,
                                A8A473B3151A825B004123FF /* fast-dtoa.cc in Sources */,
                                0F7C5FB61D885CF20044F5E2 /* FastBitVector.cpp in Sources */,
index 81af912..58c116b 100644 (file)
@@ -64,7 +64,6 @@ set(WTF_HEADERS
     MallocPtr.h
     MathExtras.h
     MediaTime.h
-    MemoryFootprint.h
     MessageQueue.h
     MetaAllocator.h
     MetaAllocatorHandle.h
@@ -205,7 +204,6 @@ set(WTF_SOURCES
     MD5.cpp
     MainThread.cpp
     MediaTime.cpp
-    MemoryFootprint.cpp
     MetaAllocator.cpp
     MonotonicTime.cpp
     NumberOfCores.cpp
diff --git a/Source/WTF/wtf/MemoryFootprint.cpp b/Source/WTF/wtf/MemoryFootprint.cpp
deleted file mode 100644 (file)
index dcc0de6..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#include "config.h"
-#include "MemoryFootprint.h"
-
-#if PLATFORM(COCOA)
-#include <mach/mach.h>
-#include <mach/task_info.h>
-#endif
-
-namespace WTF {
-
-std::optional<size_t> memoryFootprint()
-{
-#if PLATFORM(COCOA)
-    task_vm_info_data_t vmInfo;
-    mach_msg_type_number_t count = TASK_VM_INFO_COUNT;
-    kern_return_t result = task_info(mach_task_self(), TASK_VM_INFO, (task_info_t) &vmInfo, &count);
-    if (result != KERN_SUCCESS)
-        return std::nullopt;
-    return static_cast<size_t>(vmInfo.phys_footprint);
-#else
-    return std::nullopt;
-#endif
-}
-
-}
diff --git a/Source/WTF/wtf/MemoryFootprint.h b/Source/WTF/wtf/MemoryFootprint.h
deleted file mode 100644 (file)
index 7b8eca8..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#pragma once
-
-#include <wtf/Optional.h>
-
-namespace WTF {
-
-WTF_EXPORT_PRIVATE std::optional<size_t> memoryFootprint();
-
-}
-
-using WTF::memoryFootprint;
-
index e1c9871..c7e571a 100644 (file)
@@ -1,3 +1,21 @@
+2017-02-02  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r211571 and r211582.
+        https://bugs.webkit.org/show_bug.cgi?id=167751
+
+        This change caused API test WebKit1.MemoryPressureHandler to
+        fail with an assertion. (Requested by ryanhaddad on #webkit).
+
+        Reverted changesets:
+
+        "[Mac] In-process memory pressure monitor for WebContent
+        processes."
+        https://bugs.webkit.org/show_bug.cgi?id=167491
+        http://trac.webkit.org/changeset/211571
+
+        "Unreviewed attempt to fix the Windows build after r211571."
+        http://trac.webkit.org/changeset/211582
+
 2017-02-02  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed attempt to fix the Windows build after r211571.
index 0d5a4a6..b1b06aa 100644 (file)
@@ -46,6 +46,10 @@ VM& commonVMSlow()
     
     ScriptController::initializeThreading();
     g_commonVMOrNull = &VM::createLeaked(LargeHeap).leakRef();
+#if CPU(X86_64) || CPU(ARM64)
+    static const size_t maxGCHeapSize = 4 * GB;
+    g_commonVMOrNull->heap.setMaxLiveSize(maxGCHeapSize);
+#endif
     g_commonVMOrNull->heap.acquireAccess(); // At any time, we may do things that affect the GC.
 #if !PLATFORM(IOS)
     g_commonVMOrNull->setExclusiveThread(std::this_thread::get_id());
index 4a08279..b2194cc 100644 (file)
@@ -1742,7 +1742,7 @@ void FrameLoader::setState(FrameState newState)
         if (m_documentLoader)
             m_documentLoader->stopRecordingResponses();
         if (m_frame.isMainFrame() && oldState != newState)
-            static_cast<MainFrame&>(m_frame).didCompleteLoad();
+            static_cast<MainFrame&>(m_frame).performanceLogging().didReachPointOfInterest(PerformanceLogging::MainFrameLoadCompleted);
     }
 }
 
index 8b6be31..a17be3b 100644 (file)
@@ -95,12 +95,6 @@ void MainFrame::dropChildren()
         tree().removeChild(*child);
 }
 
-void MainFrame::didCompleteLoad()
-{
-    m_timeOfLastCompletedLoad = MonotonicTime::now();
-    performanceLogging().didReachPointOfInterest(PerformanceLogging::MainFrameLoadCompleted);
-}
-
 #if PLATFORM(MAC)
 ScrollLatchingState* MainFrame::latchingState()
 {
index 369ddba..3e088f0 100644 (file)
@@ -69,9 +69,6 @@ public:
 
     PerformanceLogging& performanceLogging() const { return *m_performanceLogging; }
 
-    void didCompleteLoad();
-    MonotonicTime timeOfLastCompletedLoad() const { return m_timeOfLastCompletedLoad; }
-
 private:
     MainFrame(Page&, PageConfiguration&);
 
@@ -94,8 +91,6 @@ private:
 #endif
 
     std::unique_ptr<PerformanceLogging> m_performanceLogging;
-
-    MonotonicTime m_timeOfLastCompletedLoad;
 };
 
 } // namespace WebCore
index 36612a8..d64444c 100644 (file)
 #include "CSSValuePool.h"
 #include "Chrome.h"
 #include "ChromeClient.h"
-#include "CommonVM.h"
 #include "Document.h"
 #include "FontCache.h"
 #include "GCController.h"
 #include "HTMLMediaElement.h"
 #include "InlineStyleSheetOwner.h"
 #include "InspectorInstrumentation.h"
-#include "Logging.h"
-#include "MainFrame.h"
 #include "MemoryCache.h"
 #include "Page.h"
 #include "PageCache.h"
 #include "WorkerThread.h"
 #include <wtf/FastMalloc.h>
 
-#if PLATFORM(COCOA)
-#include "ResourceUsageThread.h"
-#endif
-
 namespace WebCore {
 
 static void releaseNoncriticalMemory()
@@ -135,88 +128,6 @@ void releaseMemory(Critical critical, Synchronous synchronous)
 #endif
 }
 
-#if !RELEASE_LOG_DISABLED
-static unsigned pageCount()
-{
-    unsigned count = 0;
-    Page::forEachPage([&] (Page& page) {
-        if (!page.isUtilityPage())
-            ++count;
-    });
-    return count;
-}
-#endif
-
-void logMemoryStatisticsAtTimeOfDeath()
-{
-#if !RELEASE_LOG_DISABLED
-#if PLATFORM(COCOA)
-    auto pageSize = vmPageSize();
-    auto pages = pagesPerVMTag();
-
-    RELEASE_LOG(MemoryPressure, "Dirty memory per VM tag at time of death:");
-    for (unsigned i = 0; i < 256; ++i) {
-        size_t dirty = pages[i].dirty * pageSize;
-        if (!dirty)
-            continue;
-        String tagName = displayNameForVMTag(i);
-        if (!tagName)
-            tagName = String::format("Tag %u", i);
-        RELEASE_LOG(MemoryPressure, "%16s: %lu MB", tagName.latin1().data(), dirty / MB);
-    }
-#endif
-
-    auto& vm = commonVM();
-    RELEASE_LOG(MemoryPressure, "Memory usage statistics at time of death:");
-    RELEASE_LOG(MemoryPressure, "GC heap size: %zu", vm.heap.size());
-    RELEASE_LOG(MemoryPressure, "GC heap extra memory size: %zu", vm.heap.extraMemorySize());
-#if ENABLE(RESOURCE_USAGE)
-    RELEASE_LOG(MemoryPressure, "GC heap external memory: %zu", vm.heap.externalMemorySize());
-#endif
-    RELEASE_LOG(MemoryPressure, "Global object count: %zu", vm.heap.globalObjectCount());
-
-    RELEASE_LOG(MemoryPressure, "Page count: %u", pageCount());
-    RELEASE_LOG(MemoryPressure, "Document count: %u", Document::allDocuments().size());
-    RELEASE_LOG(MemoryPressure, "Live JavaScript objects:");
-    for (auto& it : *vm.heap.objectTypeCounts())
-        RELEASE_LOG(MemoryPressure, "  %s: %d", it.key, it.value);
-#endif
-}
-
-void didExceedMemoryLimitAndFailedToRecover()
-{
-    RELEASE_LOG(MemoryPressure, "Crashing non-visible process due to excessive memory usage + inability to free up memory below panic threshold.");
-    logMemoryStatisticsAtTimeOfDeath();
-    CRASH();
-}
-
-bool processIsEligibleForMemoryKill()
-{
-    bool hasVisiblePages = false;
-    bool hasAudiblePages = false;
-    bool hasMainFrameNavigatedInTheLastHour = false;
-
-    auto now = MonotonicTime::now();
-    Page::forEachPage([&] (Page& page) {
-        if (page.isUtilityPage())
-            return;
-        if (page.isVisible())
-            hasVisiblePages = true;
-        if (page.activityState() & ActivityState::IsAudible)
-            hasAudiblePages = true;
-        if (auto timeOfLastCompletedLoad = page.mainFrame().timeOfLastCompletedLoad()) {
-            if (now - timeOfLastCompletedLoad <= Seconds::fromMinutes(60))
-                hasMainFrameNavigatedInTheLastHour = true;
-        }
-    });
-
-    bool eligible = !hasVisiblePages && !hasAudiblePages && !hasMainFrameNavigatedInTheLastHour;
-    if (!eligible)
-        RELEASE_LOG(MemoryPressure, "Process not eligible for panic memory kill. Reasons: hasVisiblePages=%u, hasAudiblePages=%u, hasMainFrameNavigatedInTheLastHour=%u", hasVisiblePages, hasAudiblePages, hasMainFrameNavigatedInTheLastHour);
-
-    return eligible;
-}
-
 #if !PLATFORM(COCOA)
 void platformReleaseMemory(Critical) { }
 void jettisonExpensiveObjectsOnTopLevelNavigation() { }
index cd410a1..1d99372 100644 (file)
@@ -33,8 +33,5 @@ WEBCORE_EXPORT void releaseMemory(Critical, Synchronous);
 void platformReleaseMemory(Critical);
 void jettisonExpensiveObjectsOnTopLevelNavigation();
 WEBCORE_EXPORT void registerMemoryReleaseNotifyCallbacks();
-WEBCORE_EXPORT void logMemoryStatisticsAtTimeOfDeath();
-WEBCORE_EXPORT NO_RETURN_DUE_TO_CRASH void didExceedMemoryLimitAndFailedToRecover();
-WEBCORE_EXPORT bool processIsEligibleForMemoryKill();
 
 } // namespace WebCore
index 18a1e67..d971f5e 100644 (file)
@@ -80,7 +80,6 @@ struct TagInfo {
 };
 
 const char* displayNameForVMTag(unsigned);
-size_t vmPageSize();
 std::array<TagInfo, 256> pagesPerVMTag();
 void logFootprintComparison(const std::array<TagInfo, 256>&, const std::array<TagInfo, 256>&);
 #endif
index 064a61a..69136ad 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace WebCore {
 
-size_t vmPageSize()
+static size_t vmPageSize()
 {
 #if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
     return vm_kernel_page_size;
index 30515ee..b9ac0e5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2017 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2011, 2014 Apple Inc. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -27,7 +27,6 @@
 #include "MemoryPressureHandler.h"
 
 #include "Logging.h"
-#include <wtf/MemoryFootprint.h>
 
 namespace WebCore {
 
@@ -40,123 +39,12 @@ MemoryPressureHandler& MemoryPressureHandler::singleton()
 }
 
 MemoryPressureHandler::MemoryPressureHandler()
-    : m_measurementTimer(RunLoop::main(), this, &MemoryPressureHandler::measurementTimerFired)
 #if OS(LINUX)
-    , m_holdOffTimer(RunLoop::main(), this, &MemoryPressureHandler::holdOffTimerFired)
+    : m_holdOffTimer(RunLoop::main(), this, &MemoryPressureHandler::holdOffTimerFired)
 #endif
 {
 }
 
-void MemoryPressureHandler::setShouldUsePeriodicMemoryMonitor(bool use)
-{
-    if (use)
-        m_measurementTimer.startRepeating(30);
-    else
-        m_measurementTimer.stop();
-}
-
-#if !RELEASE_LOG_DISABLED
-static const char* toString(MemoryUsagePolicy policy)
-{
-    switch (policy) {
-    case MemoryUsagePolicy::Unrestricted: return "Unrestricted";
-    case MemoryUsagePolicy::Conservative: return "Conservative";
-    case MemoryUsagePolicy::Strict: return "Strict";
-    case MemoryUsagePolicy::Panic: return "Panic";
-    }
-}
-#endif
-
-static inline size_t thresholdForPolicy(MemoryUsagePolicy policy)
-{
-    switch (policy) {
-    case MemoryUsagePolicy::Conservative:
-        return 1 * GB;
-    case MemoryUsagePolicy::Strict:
-        return 2 * GB;
-    case MemoryUsagePolicy::Panic:
-#if CPU(X86_64) || CPU(ARM64)
-        return 4 * GB;
-#else
-        return 3 * GB;
-#endif
-    case MemoryUsagePolicy::Unrestricted:
-    default:
-        ASSERT_NOT_REACHED();
-        return 0;
-    }
-}
-
-static inline MemoryUsagePolicy policyForFootprint(size_t footprint)
-{
-    if (footprint >= thresholdForPolicy(MemoryUsagePolicy::Panic))
-        return MemoryUsagePolicy::Panic;
-    if (footprint >= thresholdForPolicy(MemoryUsagePolicy::Strict))
-        return MemoryUsagePolicy::Strict;
-    if (footprint >= thresholdForPolicy(MemoryUsagePolicy::Conservative))
-        return MemoryUsagePolicy::Conservative;
-    return MemoryUsagePolicy::Unrestricted;
-}
-
-void MemoryPressureHandler::measurementTimerFired()
-{
-    auto footprint = memoryFootprint();
-    if (!footprint)
-        return;
-
-    RELEASE_LOG(MemoryPressure, "Current memory footprint: %lu MB", footprint.value() / MB);
-
-    auto newPolicy = policyForFootprint(footprint.value());
-    if (newPolicy == m_memoryUsagePolicy) {
-        if (m_memoryUsagePolicy != MemoryUsagePolicy::Panic)
-            return;
-        RELEASE_LOG(MemoryPressure, "Memory usage still above panic threshold");
-    } else
-        RELEASE_LOG(MemoryPressure, "Memory usage policy changed: %s -> %s", toString(m_memoryUsagePolicy), toString(newPolicy));
-
-    m_memoryUsagePolicy = newPolicy;
-
-    if (newPolicy == MemoryUsagePolicy::Unrestricted)
-        return;
-
-    if (newPolicy == MemoryUsagePolicy::Conservative) {
-        // FIXME: Implement this policy by choosing which caches should respect it, and hooking them up. 
-        return;
-    }
-
-    if (newPolicy == MemoryUsagePolicy::Strict) {
-        RELEASE_LOG(MemoryPressure, "Attempting to reduce memory footprint by freeing less important objects.");
-        releaseMemory(Critical::No, Synchronous::No);
-        return;
-    }
-
-    RELEASE_ASSERT(newPolicy == MemoryUsagePolicy::Panic);
-
-    RELEASE_LOG(MemoryPressure, "Attempting to reduce memory footprint by freeing more important objects.");
-    if (m_processIsEligibleForMemoryKillCallback) {
-        if (!m_processIsEligibleForMemoryKillCallback()) {
-            releaseMemory(Critical::Yes, Synchronous::No);
-            return;
-        }
-    }
-
-    releaseMemory(Critical::Yes, Synchronous::Yes);
-
-    // Remeasure footprint to see how well the pressure handler did.
-    footprint = memoryFootprint();
-    RELEASE_ASSERT(footprint);
-
-    RELEASE_LOG(MemoryPressure, "New memory footprint: %lu MB", footprint.value() / MB);
-    if (footprint.value() < thresholdForPolicy(MemoryUsagePolicy::Panic)) {
-        m_memoryUsagePolicy = policyForFootprint(footprint.value());
-        RELEASE_LOG(MemoryPressure, "Pressure reduced below panic threshold. New memory usage policy: %s", toString(m_memoryUsagePolicy));
-        return;
-    }
-
-    if (m_memoryKillCallback)
-        m_memoryKillCallback();
-}
-
 void MemoryPressureHandler::beginSimulatedMemoryPressure()
 {
     m_isSimulatingMemoryPressure = true;
index f3df541..601a41e 100644 (file)
 #include <wtf/Forward.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/Optional.h>
-#include <wtf/RunLoop.h>
 
 #if PLATFORM(IOS)
 #include <wtf/Lock.h>
 #include <wtf/ThreadingPrimitives.h>
-#endif
-
+#elif OS(LINUX)
+#include <wtf/RunLoop.h>
 #if USE(GLIB)
 #include <wtf/glib/GRefPtr.h>
 #endif
+#endif
 
 namespace WebCore {
 
@@ -55,13 +55,6 @@ enum MemoryPressureReason {
 };
 #endif
 
-enum class MemoryUsagePolicy {
-    Unrestricted, // Allocate as much as you want
-    Conservative, // Maybe you don't cache every single thing
-    Strict, // Time to start pinching pennies for real
-    Panic, // OH GOD WE'RE SINKING, THROW EVERYTHING OVERBOARD
-};
-
 enum class Critical { No, Yes };
 enum class Synchronous { No, Yes };
 
@@ -75,24 +68,12 @@ public:
 
     WEBCORE_EXPORT void install();
 
-    WEBCORE_EXPORT void setShouldUsePeriodicMemoryMonitor(bool);
-
-    void setMemoryKillCallback(WTF::Function<void()> function) { m_memoryKillCallback = WTFMove(function); }
-    void setProcessIsEligibleForMemoryKillCallback(WTF::Function<bool()> function) { m_processIsEligibleForMemoryKillCallback = WTFMove(function); }
-
     void setLowMemoryHandler(LowMemoryHandler&& handler)
     {
         m_lowMemoryHandler = WTFMove(handler);
     }
 
-    bool isUnderMemoryPressure() const
-    {
-        return m_underMemoryPressure
-#if PLATFORM(MAC)
-            || m_memoryUsagePolicy >= MemoryUsagePolicy::Strict
-#endif
-            || m_isSimulatingMemoryPressure;
-    }
+    bool isUnderMemoryPressure() const { return m_underMemoryPressure || m_isSimulatingMemoryPressure; }
     void setUnderMemoryPressure(bool b) { m_underMemoryPressure = b; }
 
 #if PLATFORM(IOS)
@@ -168,9 +149,6 @@ private:
     void respondToMemoryPressure(Critical, Synchronous = Synchronous::No);
     void platformReleaseMemory(Critical);
 
-    NO_RETURN_DUE_TO_CRASH void didExceedMemoryLimitAndFailedToRecover();
-    void measurementTimerFired();
-
 #if OS(LINUX)
     class EventFDPoller {
         WTF_MAKE_NONCOPYABLE(EventFDPoller); WTF_MAKE_FAST_ALLOCATED;
@@ -192,16 +170,12 @@ private:
 #endif
 
     bool m_installed { false };
+    time_t m_lastRespondTime { 0 };
     LowMemoryHandler m_lowMemoryHandler;
 
     std::atomic<bool> m_underMemoryPressure;
     bool m_isSimulatingMemoryPressure { false };
 
-    RunLoop::Timer<MemoryPressureHandler> m_measurementTimer;
-    MemoryUsagePolicy m_memoryUsagePolicy { MemoryUsagePolicy::Unrestricted };
-    WTF::Function<void()> m_memoryKillCallback;
-    WTF::Function<bool()> m_processIsEligibleForMemoryKillCallback;
-
 #if PLATFORM(IOS)
     // FIXME: Can we share more of this with OpenSource?
     uint32_t m_memoryPressureReason { MemoryPressureReasonNone };
index e920863..2dfa540 100644 (file)
@@ -1,3 +1,21 @@
+2017-02-02  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r211571 and r211582.
+        https://bugs.webkit.org/show_bug.cgi?id=167751
+
+        This change caused API test WebKit1.MemoryPressureHandler to
+        fail with an assertion. (Requested by ryanhaddad on #webkit).
+
+        Reverted changesets:
+
+        "[Mac] In-process memory pressure monitor for WebContent
+        processes."
+        https://bugs.webkit.org/show_bug.cgi?id=167491
+        http://trac.webkit.org/changeset/211571
+
+        "Unreviewed attempt to fix the Windows build after r211571."
+        http://trac.webkit.org/changeset/211582
+
 2017-02-02  Dan Bernstein  <mitz@apple.com>
 
         The Make Frameworks Symbolic Link build phase can end up creating a symlink inside the Frameworks subdirectory
index 51b459d..9add706 100644 (file)
@@ -261,15 +261,6 @@ void WebProcess::initializeWebProcess(WebProcessCreationParameters&& parameters)
         memoryPressureHandler.setLowMemoryHandler([] (Critical critical, Synchronous synchronous) {
             WebCore::releaseMemory(critical, synchronous);
         });
-#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
-        memoryPressureHandler.setShouldUsePeriodicMemoryMonitor(true);
-        memoryPressureHandler.setMemoryKillCallback([] () {
-            WebCore::didExceedMemoryLimitAndFailedToRecover();
-        });
-        memoryPressureHandler.setProcessIsEligibleForMemoryKillCallback([] () {
-            return WebCore::processIsEligibleForMemoryKill();
-        });
-#endif
         memoryPressureHandler.install();
     }