[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 15:28:19 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 5408f3218789ab9b769fb09d69b0d597092a62a5
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 4 10:10:45 2010 +0000

    2010-11-04  Pratik Solanki  <psolanki at apple.com>
    
            Reviewed by Darin Adler.
    
            Should make use of purge priorities for different resource types
            https://bugs.webkit.org/show_bug.cgi?id=48684
    
            Assign purge priorities to CachedResource objects. JavaScript and CSS stylesheets are more
            important than images so hint to the kernel to purge them last. We do this by repurposing
            the previously unused function, PurgeableBuffer::setPurgePriority(). It now just sets the
            priority field and does not have side-effects like calling makePurgeable(true).
    
            Also, remove unusued PurgeableBuffer::create(const Vector<char>&) function and move the
            purgeable memory size threshold from CachedResource to PurgeableBuffer.
    
            * WebCore.xcodeproj/project.pbxproj: Add new PurgePriority.h header and mark it as private
            header.
            * loader/CachedCSSStyleSheet.h:
            (WebCore::CachedCSSStyleSheet::purgePriority):
            * loader/CachedImage.h:
            (WebCore::CachedImage::purgePriority):
            * loader/CachedResource.cpp:
            (WebCore::CachedResource::makePurgeable): Set the purge priority on the PurgeableBffer.
            Also, move the check for purgeable size threshold to PurgeableBuffer.
            * loader/CachedResource.h:
            (WebCore::CachedResource::purgePriority): Added. New virtual method that lets the class
            specify its purge priority.
            * loader/CachedScript.h:
            (WebCore::CachedScript::purgePriority):
            * platform/PurgePriority.h: Added. Move the PurgePriority enum from PurgeableBuffer class to
            its own header file.
            (WebCore::):
            * platform/PurgeableBuffer.h:
            (WebCore::PurgeableBuffer::setPurgePriority): Update this previously unused function to just
            set the priority and not call makePurgeable(true).
            * platform/mac/PurgeableBufferMac.cpp: Update size threshold to 16KB which is what
            CachedResource was using.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71318 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 6ce8fb6..a00cca9 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,41 @@
+2010-11-04  Pratik Solanki  <psolanki at apple.com>
+
+        Reviewed by Darin Adler.
+
+        Should make use of purge priorities for different resource types
+        https://bugs.webkit.org/show_bug.cgi?id=48684
+
+        Assign purge priorities to CachedResource objects. JavaScript and CSS stylesheets are more
+        important than images so hint to the kernel to purge them last. We do this by repurposing
+        the previously unused function, PurgeableBuffer::setPurgePriority(). It now just sets the
+        priority field and does not have side-effects like calling makePurgeable(true).
+
+        Also, remove unusued PurgeableBuffer::create(const Vector<char>&) function and move the
+        purgeable memory size threshold from CachedResource to PurgeableBuffer.
+
+        * WebCore.xcodeproj/project.pbxproj: Add new PurgePriority.h header and mark it as private
+        header.
+        * loader/CachedCSSStyleSheet.h:
+        (WebCore::CachedCSSStyleSheet::purgePriority):
+        * loader/CachedImage.h:
+        (WebCore::CachedImage::purgePriority):
+        * loader/CachedResource.cpp:
+        (WebCore::CachedResource::makePurgeable): Set the purge priority on the PurgeableBffer.
+        Also, move the check for purgeable size threshold to PurgeableBuffer.
+        * loader/CachedResource.h:
+        (WebCore::CachedResource::purgePriority): Added. New virtual method that lets the class
+        specify its purge priority.
+        * loader/CachedScript.h:
+        (WebCore::CachedScript::purgePriority):
+        * platform/PurgePriority.h: Added. Move the PurgePriority enum from PurgeableBuffer class to
+        its own header file.
+        (WebCore::):
+        * platform/PurgeableBuffer.h:
+        (WebCore::PurgeableBuffer::setPurgePriority): Update this previously unused function to just
+        set the priority and not call makePurgeable(true).
+        * platform/mac/PurgeableBufferMac.cpp: Update size threshold to 16KB which is what
+        CachedResource was using.
+
 2010-11-04  Chris Guillory  <chris.guillory at google.com>
 
         Reviewed by Chris Fleizach.
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 70a59c8..0367903 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -1552,6 +1552,7 @@
 		7ADE722610CBBB9B006B3B3A /* ContextMenuProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ADE722510CBBB9B006B3B3A /* ContextMenuProvider.h */; };
 		7AFD4A8B1131C2760035B883 /* ScriptBreakpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AFD4A8A1131C2760035B883 /* ScriptBreakpoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7AFD4FF4113277B60035B883 /* ScriptDebugListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AFD4FF3113277B60035B883 /* ScriptDebugListener.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		7E33CD01127F340D00BE8F17 /* PurgePriority.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E33CD00127F340D00BE8F17 /* PurgePriority.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		81A7325E1210189B00FC0D9E /* IDBCursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 81A7325D1210189B00FC0D9E /* IDBCursor.h */; };
 		81A73260121018A400FC0D9E /* IDBCursor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81A7325F121018A400FC0D9E /* IDBCursor.cpp */; };
 		81A73278121019E100FC0D9E /* IDBCursorBackendImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 81A73277121019E100FC0D9E /* IDBCursorBackendImpl.h */; };
@@ -7702,6 +7703,7 @@
 		7ADE722510CBBB9B006B3B3A /* ContextMenuProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContextMenuProvider.h; sourceTree = "<group>"; };
 		7AFD4A8A1131C2760035B883 /* ScriptBreakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptBreakpoint.h; sourceTree = "<group>"; };
 		7AFD4FF3113277B60035B883 /* ScriptDebugListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptDebugListener.h; sourceTree = "<group>"; };
+		7E33CD00127F340D00BE8F17 /* PurgePriority.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PurgePriority.h; sourceTree = "<group>"; };
 		81A7325D1210189B00FC0D9E /* IDBCursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBCursor.h; sourceTree = "<group>"; };
 		81A7325F121018A400FC0D9E /* IDBCursor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBCursor.cpp; sourceTree = "<group>"; };
 		81A73277121019E100FC0D9E /* IDBCursorBackendImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBCursorBackendImpl.h; sourceTree = "<group>"; };
@@ -17446,6 +17448,7 @@
 				ABC128760B33AA6D00C693D5 /* PopupMenuClient.h */,
 				BC3BE12A0E98092F00835588 /* PopupMenuStyle.h */,
 				E4D687780ED7AE4F006EA978 /* PurgeableBuffer.h */,
+				7E33CD00127F340D00BE8F17 /* PurgePriority.h */,
 				1C63A2460F71646600C09D5A /* RunLoopTimer.h */,
 				5162C7F211F77EFA00612EFE /* SchemeRegistry.cpp */,
 				5162C7F311F77EFB00612EFE /* SchemeRegistry.h */,
@@ -20530,6 +20533,7 @@
 				51A052561058874000CC9E95 /* ProtectionSpaceHash.h in Headers */,
 				1AF8E11A1256592600230FF7 /* ProxyServer.h in Headers */,
 				E4D687790ED7AE4F006EA978 /* PurgeableBuffer.h in Headers */,
+				7E33CD01127F340D00BE8F17 /* PurgePriority.h in Headers */,
 				550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */,
 				B22279720D00BF220071B782 /* RadialGradientAttributes.h in Headers */,
 				F55B3DCC1251F12D003EF269 /* RadioInputType.h in Headers */,
diff --git a/WebCore/loader/CachedCSSStyleSheet.h b/WebCore/loader/CachedCSSStyleSheet.h
index 03bde69..abcdb85 100644
--- a/WebCore/loader/CachedCSSStyleSheet.h
+++ b/WebCore/loader/CachedCSSStyleSheet.h
@@ -55,6 +55,7 @@ namespace WebCore {
     
     private:
         bool canUseSheet(bool enforceMIMEType, bool* hasValidMIMEType) const;
+        virtual PurgePriority purgePriority() const { return PurgeLast; }
 
     protected:
         RefPtr<TextResourceDecoder> m_decoder;
diff --git a/WebCore/loader/CachedImage.h b/WebCore/loader/CachedImage.h
index 15f4238..da8754a 100644
--- a/WebCore/loader/CachedImage.h
+++ b/WebCore/loader/CachedImage.h
@@ -93,6 +93,7 @@ private:
     // If not null, changeRect is the changed part of the image.
     void notifyObservers(const IntRect* changeRect = 0);
     void decodedDataDeletionTimerFired(Timer<CachedImage>*);
+    virtual PurgePriority purgePriority() const { return PurgeFirst; }
 
     RefPtr<Image> m_image;
     Timer<CachedImage> m_decodedDataDeletionTimer;
diff --git a/WebCore/loader/CachedResource.cpp b/WebCore/loader/CachedResource.cpp
index e519c29..009b50a 100644
--- a/WebCore/loader/CachedResource.cpp
+++ b/WebCore/loader/CachedResource.cpp
@@ -517,17 +517,13 @@ bool CachedResource::makePurgeable(bool purgeable)
         if (!m_data->hasOneRef())
             return false;
         
-        // Purgeable buffers are allocated in multiples of the page size (4KB in common CPUs) so it does not make sense for very small buffers.
-        const size_t purgeableThreshold = 4 * 4096;
-        if (m_data->size() < purgeableThreshold)
-            return false;
-        
         if (m_data->hasPurgeableBuffer()) {
             m_purgeableData = m_data->releasePurgeableBuffer();
         } else {
             m_purgeableData = PurgeableBuffer::create(m_data->data(), m_data->size());
             if (!m_purgeableData)
                 return false;
+            m_purgeableData->setPurgePriority(purgePriority());
         }
         
         m_purgeableData->makePurgeable(true);
diff --git a/WebCore/loader/CachedResource.h b/WebCore/loader/CachedResource.h
index 078da57..f747fc4 100644
--- a/WebCore/loader/CachedResource.h
+++ b/WebCore/loader/CachedResource.h
@@ -26,6 +26,7 @@
 #include "CachePolicy.h"
 #include "FrameLoaderTypes.h"
 #include "PlatformString.h"
+#include "PurgePriority.h"
 #include "ResourceResponse.h"
 #include <wtf/HashCountedSet.h>
 #include <wtf/HashSet.h>
@@ -42,8 +43,8 @@ class CachedResourceHandleBase;
 class CachedResourceLoader;
 class Frame;
 class InspectorResource;
-class Request;
 class PurgeableBuffer;
+class Request;
 
 // A resource that is held in the cache. Classes who want to use this object should derive
 // from CachedResourceClient, to get the function calls in case the requested data has arrived.
@@ -229,6 +230,7 @@ private:
     void switchClientsToRevalidatedResource();
     void clearResourceToRevalidate();
     void updateResponseAfterRevalidation(const ResourceResponse& validatingResponse);
+    virtual PurgePriority purgePriority() const { return PurgeDefault; }
 
     double currentAge() const;
     double freshnessLifetime() const;
diff --git a/WebCore/loader/CachedScript.h b/WebCore/loader/CachedScript.h
index 1bc4e8c..7311f9b 100644
--- a/WebCore/loader/CachedScript.h
+++ b/WebCore/loader/CachedScript.h
@@ -54,6 +54,7 @@ namespace WebCore {
 
     private:
         void decodedDataDeletionTimerFired(Timer<CachedScript>*);
+        virtual PurgePriority purgePriority() const { return PurgeLast; }
 
         String m_script;
         RefPtr<TextResourceDecoder> m_decoder;
diff --git a/WebCore/platform/PurgePriority.h b/WebCore/platform/PurgePriority.h
new file mode 100644
index 0000000..6a2894e
--- /dev/null
+++ b/WebCore/platform/PurgePriority.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef PurgePriority_h
+#define PurgePriority_h
+
+namespace WebCore {
+
+enum PurgePriority {
+    PurgeLast,
+    PurgeMiddle,
+    PurgeFirst,
+    PurgeDefault = PurgeMiddle
+};
+
+}
+
+#endif // PurgePriority_h
diff --git a/WebCore/platform/PurgeableBuffer.h b/WebCore/platform/PurgeableBuffer.h
index 32341c2..9bda2d5 100644
--- a/WebCore/platform/PurgeableBuffer.h
+++ b/WebCore/platform/PurgeableBuffer.h
@@ -26,6 +26,7 @@
 #ifndef PurgeableBuffer_h
 #define PurgeableBuffer_h
 
+#include "PurgePriority.h"
 #include <wtf/Noncopyable.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/Vector.h>
@@ -35,7 +36,6 @@ namespace WebCore {
     class PurgeableBuffer : public Noncopyable {
     public:
         static PassOwnPtr<PurgeableBuffer> create(const char* data, size_t);
-        static PassOwnPtr<PurgeableBuffer> create(const Vector<char>& vector) { return create(vector.data(), vector.size()); }
         
         ~PurgeableBuffer();
 
@@ -43,9 +43,8 @@ namespace WebCore {
         const char* data() const;
         size_t size() const { return m_size; }
         
-        enum PurgePriority { PurgeLast, PurgeMiddle, PurgeFirst, PurgeDefault = PurgeMiddle };
         PurgePriority purgePriority() const { return m_purgePriority; }
-        void setPurgePriority(PurgePriority);
+        void setPurgePriority(PurgePriority priority) { m_purgePriority = priority; }
         
         bool isPurgeable() const { return m_state != NonVolatile; }
         bool wasPurged() const;
@@ -67,7 +66,6 @@ namespace WebCore {
     inline PassOwnPtr<PurgeableBuffer> PurgeableBuffer::create(const char*, size_t) { return PassOwnPtr<PurgeableBuffer>(); }
     inline PurgeableBuffer::~PurgeableBuffer() { }
     inline const char* PurgeableBuffer::data() const { return 0; }
-    inline void PurgeableBuffer::setPurgePriority(PurgePriority) { }
     inline bool PurgeableBuffer::wasPurged() const { return false; }
     inline bool PurgeableBuffer::makePurgeable(bool) { return false; }
 #endif
diff --git a/WebCore/platform/mac/PurgeableBufferMac.cpp b/WebCore/platform/mac/PurgeableBufferMac.cpp
index 54de4ed..fdbac1f 100644
--- a/WebCore/platform/mac/PurgeableBufferMac.cpp
+++ b/WebCore/platform/mac/PurgeableBufferMac.cpp
@@ -35,7 +35,9 @@
 
 namespace WebCore {
 
-static const size_t minPurgeableBufferSize = 4096; // one page
+// Purgeable buffers are allocated in multiples of the page size (4KB in common CPUs) so
+// it does not make sense for very small buffers. Set our minimum size to 16KB.
+static const size_t minPurgeableBufferSize = 4 * 4096;
 
 PurgeableBuffer::PurgeableBuffer(char* data, size_t size)
     : m_data(data)
@@ -143,17 +145,6 @@ bool PurgeableBuffer::wasPurged() const
     return false;
 }
 
-void PurgeableBuffer::setPurgePriority(PurgePriority priority)
-{
-    if (priority == m_purgePriority)
-        return;
-    m_purgePriority = priority;
-    if (m_state != Volatile)
-        return;
-    m_state = NonVolatile;
-    makePurgeable(true);
-}
-    
 const char* PurgeableBuffer::data() const
 {
     ASSERT(m_state == NonVolatile);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list