Changeset 71318 in webkit
- Timestamp:
- Nov 4, 2010 3:10:45 AM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r71317 r71318 1 2010-11-04 Pratik Solanki <psolanki@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Should make use of purge priorities for different resource types 6 https://bugs.webkit.org/show_bug.cgi?id=48684 7 8 Assign purge priorities to CachedResource objects. JavaScript and CSS stylesheets are more 9 important than images so hint to the kernel to purge them last. We do this by repurposing 10 the previously unused function, PurgeableBuffer::setPurgePriority(). It now just sets the 11 priority field and does not have side-effects like calling makePurgeable(true). 12 13 Also, remove unusued PurgeableBuffer::create(const Vector<char>&) function and move the 14 purgeable memory size threshold from CachedResource to PurgeableBuffer. 15 16 * WebCore.xcodeproj/project.pbxproj: Add new PurgePriority.h header and mark it as private 17 header. 18 * loader/CachedCSSStyleSheet.h: 19 (WebCore::CachedCSSStyleSheet::purgePriority): 20 * loader/CachedImage.h: 21 (WebCore::CachedImage::purgePriority): 22 * loader/CachedResource.cpp: 23 (WebCore::CachedResource::makePurgeable): Set the purge priority on the PurgeableBffer. 24 Also, move the check for purgeable size threshold to PurgeableBuffer. 25 * loader/CachedResource.h: 26 (WebCore::CachedResource::purgePriority): Added. New virtual method that lets the class 27 specify its purge priority. 28 * loader/CachedScript.h: 29 (WebCore::CachedScript::purgePriority): 30 * platform/PurgePriority.h: Added. Move the PurgePriority enum from PurgeableBuffer class to 31 its own header file. 32 (WebCore::): 33 * platform/PurgeableBuffer.h: 34 (WebCore::PurgeableBuffer::setPurgePriority): Update this previously unused function to just 35 set the priority and not call makePurgeable(true). 36 * platform/mac/PurgeableBufferMac.cpp: Update size threshold to 16KB which is what 37 CachedResource was using. 38 1 39 2010-11-04 Chris Guillory <chris.guillory@google.com> 2 40 -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r71313 r71318 1553 1553 7AFD4A8B1131C2760035B883 /* ScriptBreakpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AFD4A8A1131C2760035B883 /* ScriptBreakpoint.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1554 1554 7AFD4FF4113277B60035B883 /* ScriptDebugListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AFD4FF3113277B60035B883 /* ScriptDebugListener.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1555 7E33CD01127F340D00BE8F17 /* PurgePriority.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E33CD00127F340D00BE8F17 /* PurgePriority.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1555 1556 81A7325E1210189B00FC0D9E /* IDBCursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 81A7325D1210189B00FC0D9E /* IDBCursor.h */; }; 1556 1557 81A73260121018A400FC0D9E /* IDBCursor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81A7325F121018A400FC0D9E /* IDBCursor.cpp */; }; … … 7703 7704 7AFD4A8A1131C2760035B883 /* ScriptBreakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptBreakpoint.h; sourceTree = "<group>"; }; 7704 7705 7AFD4FF3113277B60035B883 /* ScriptDebugListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptDebugListener.h; sourceTree = "<group>"; }; 7706 7E33CD00127F340D00BE8F17 /* PurgePriority.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PurgePriority.h; sourceTree = "<group>"; }; 7705 7707 81A7325D1210189B00FC0D9E /* IDBCursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBCursor.h; sourceTree = "<group>"; }; 7706 7708 81A7325F121018A400FC0D9E /* IDBCursor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBCursor.cpp; sourceTree = "<group>"; }; … … 17447 17449 BC3BE12A0E98092F00835588 /* PopupMenuStyle.h */, 17448 17450 E4D687780ED7AE4F006EA978 /* PurgeableBuffer.h */, 17451 7E33CD00127F340D00BE8F17 /* PurgePriority.h */, 17449 17452 1C63A2460F71646600C09D5A /* RunLoopTimer.h */, 17450 17453 5162C7F211F77EFA00612EFE /* SchemeRegistry.cpp */, … … 20531 20534 1AF8E11A1256592600230FF7 /* ProxyServer.h in Headers */, 20532 20535 E4D687790ED7AE4F006EA978 /* PurgeableBuffer.h in Headers */, 20536 7E33CD01127F340D00BE8F17 /* PurgePriority.h in Headers */, 20533 20537 550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */, 20534 20538 B22279720D00BF220071B782 /* RadialGradientAttributes.h in Headers */, -
trunk/WebCore/loader/CachedCSSStyleSheet.h
r66963 r71318 56 56 private: 57 57 bool canUseSheet(bool enforceMIMEType, bool* hasValidMIMEType) const; 58 virtual PurgePriority purgePriority() const { return PurgeLast; } 58 59 59 60 protected: -
trunk/WebCore/loader/CachedImage.h
r66963 r71318 94 94 void notifyObservers(const IntRect* changeRect = 0); 95 95 void decodedDataDeletionTimerFired(Timer<CachedImage>*); 96 virtual PurgePriority purgePriority() const { return PurgeFirst; } 96 97 97 98 RefPtr<Image> m_image; -
trunk/WebCore/loader/CachedResource.cpp
r69886 r71318 518 518 return false; 519 519 520 // Purgeable buffers are allocated in multiples of the page size (4KB in common CPUs) so it does not make sense for very small buffers.521 const size_t purgeableThreshold = 4 * 4096;522 if (m_data->size() < purgeableThreshold)523 return false;524 525 520 if (m_data->hasPurgeableBuffer()) { 526 521 m_purgeableData = m_data->releasePurgeableBuffer(); … … 529 524 if (!m_purgeableData) 530 525 return false; 526 m_purgeableData->setPurgePriority(purgePriority()); 531 527 } 532 528 -
trunk/WebCore/loader/CachedResource.h
r69437 r71318 27 27 #include "FrameLoaderTypes.h" 28 28 #include "PlatformString.h" 29 #include "PurgePriority.h" 29 30 #include "ResourceResponse.h" 30 31 #include <wtf/HashCountedSet.h> … … 43 44 class Frame; 44 45 class InspectorResource; 46 class PurgeableBuffer; 45 47 class Request; 46 class PurgeableBuffer;47 48 48 49 // A resource that is held in the cache. Classes who want to use this object should derive … … 230 231 void clearResourceToRevalidate(); 231 232 void updateResponseAfterRevalidation(const ResourceResponse& validatingResponse); 233 virtual PurgePriority purgePriority() const { return PurgeDefault; } 232 234 233 235 double currentAge() const; -
trunk/WebCore/loader/CachedScript.h
r66963 r71318 55 55 private: 56 56 void decodedDataDeletionTimerFired(Timer<CachedScript>*); 57 virtual PurgePriority purgePriority() const { return PurgeLast; } 57 58 58 59 String m_script; -
trunk/WebCore/platform/PurgeableBuffer.h
r66301 r71318 27 27 #define PurgeableBuffer_h 28 28 29 #include "PurgePriority.h" 29 30 #include <wtf/Noncopyable.h> 30 31 #include <wtf/PassOwnPtr.h> … … 36 37 public: 37 38 static PassOwnPtr<PurgeableBuffer> create(const char* data, size_t); 38 static PassOwnPtr<PurgeableBuffer> create(const Vector<char>& vector) { return create(vector.data(), vector.size()); }39 39 40 40 ~PurgeableBuffer(); … … 44 44 size_t size() const { return m_size; } 45 45 46 enum PurgePriority { PurgeLast, PurgeMiddle, PurgeFirst, PurgeDefault = PurgeMiddle };47 46 PurgePriority purgePriority() const { return m_purgePriority; } 48 void setPurgePriority(PurgePriority );47 void setPurgePriority(PurgePriority priority) { m_purgePriority = priority; } 49 48 50 49 bool isPurgeable() const { return m_state != NonVolatile; } … … 68 67 inline PurgeableBuffer::~PurgeableBuffer() { } 69 68 inline const char* PurgeableBuffer::data() const { return 0; } 70 inline void PurgeableBuffer::setPurgePriority(PurgePriority) { }71 69 inline bool PurgeableBuffer::wasPurged() const { return false; } 72 70 inline bool PurgeableBuffer::makePurgeable(bool) { return false; } -
trunk/WebCore/platform/mac/PurgeableBufferMac.cpp
r66301 r71318 36 36 namespace WebCore { 37 37 38 static const size_t minPurgeableBufferSize = 4096; // one page 38 // Purgeable buffers are allocated in multiples of the page size (4KB in common CPUs) so 39 // it does not make sense for very small buffers. Set our minimum size to 16KB. 40 static const size_t minPurgeableBufferSize = 4 * 4096; 39 41 40 42 PurgeableBuffer::PurgeableBuffer(char* data, size_t size) … … 144 146 } 145 147 146 void PurgeableBuffer::setPurgePriority(PurgePriority priority)147 {148 if (priority == m_purgePriority)149 return;150 m_purgePriority = priority;151 if (m_state != Volatile)152 return;153 m_state = NonVolatile;154 makePurgeable(true);155 }156 157 148 const char* PurgeableBuffer::data() const 158 149 {
Note: See TracChangeset
for help on using the changeset viewer.