Changeset 201563 in webkit
- Timestamp:
- Jun 1, 2016, 12:47:19 PM (10 years ago)
- Location:
- branches/safari-601.1.46-branch/Source/WebCore
- Files:
-
- 11 edited
-
ChangeLog (modified) (1 diff)
-
bindings/js/JSDocumentCustom.cpp (modified) (1 diff)
-
dom/Node.h (modified) (1 diff)
-
platform/graphics/Image.h (modified) (1 diff)
-
svg/SVGGraphicsElement.h (modified) (1 diff)
-
svg/SVGPathElement.cpp (modified) (1 diff)
-
svg/SVGPathElement.h (modified) (1 diff)
-
svg/SVGPolyElement.cpp (modified) (1 diff)
-
svg/SVGPolyElement.h (modified) (1 diff)
-
svg/graphics/SVGImage.cpp (modified) (5 diffs)
-
svg/graphics/SVGImage.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-601.1.46-branch/Source/WebCore/ChangeLog
r200999 r201563 1 2016-06-01 Babak Shafiei <bshafiei@apple.com> 2 3 Merge r201561. 4 5 2016-06-01 Said Abou-Hallawa <sabouhallawa@apple.com> 6 7 SVGImage should report its memory cost to JS garbage collector 8 https://bugs.webkit.org/show_bug.cgi?id=158139 9 10 Reviewed by Geoffrey Garen. 11 12 Like what we do in HTMLImageLoader::notifyFinished() by reporting the memory 13 cost of the BitmapImage, we need to do something similar for the SVGImage. In 14 SVGImage::dataChange() and when allDataReceived is true, we can calculate 15 the size of all DOM nodes and their renderers. The size of the encoded data 16 has to be added as well to the total memory cost. An approximation for the 17 memory cost has to be used since it is costly to get an accurate number. 18 19 * bindings/js/JSDocumentCustom.cpp: 20 (WebCore::reportMemoryForDocumentIfFrameless): Use Node::approximateMemoryCost() 21 instead of sizeof(Node). A Node's descendant can override this function and 22 return a more accurate memory cost. 23 24 * dom/Node.h: 25 (WebCore::Node::approximateMemoryCost): Define this new virtual function in the 26 Node class. Its default value is sizeof(Node) but any descendant can return a 27 more accurate number. 28 29 * platform/graphics/Image.h: 30 (WebCore::Image::data): Define a const version of data() so it can be called 31 the const function SVGImage::reportApproximateMemoryCost(). 32 33 * svg/SVGGraphicsElement.h: Override approximateMemoryCost() to return 34 sizeof(SVGGraphicsElement). 35 36 * svg/SVGPathElement.cpp: 37 (WebCore::SVGPathElement::approximateMemoryCost): Override this function to return 38 the memory cost of the points and the m_path of the renderer. 39 * svg/SVGPathElement.h: 40 41 * svg/SVGPolyElement.cpp: 42 (WebCore::SVGPolyElement::approximateMemoryCost): Override this function to return 43 the memory cost of the points and the m_path of the renderer. 44 * svg/SVGPolyElement.h: 45 46 * svg/graphics/SVGImage.cpp: 47 (WebCore::SVGImage::reportApproximateMemoryCost): Calculate the memory cost of the 48 nodes in the SVGDocument of an SVGImage. Then report this number to the JS garbage 49 collector. 50 51 (WebCore::SVGImage::dataChanged): After loading all the SVG encoded data and building 52 its DOM tree and the render tree, report the total memory cost to the JS garbage collector. 53 * svg/graphics/SVGImage.h: 54 1 55 2016-05-16 Babak Shafiei <bshafiei@apple.com> 2 56 -
branches/safari-601.1.46-branch/Source/WebCore/bindings/js/JSDocumentCustom.cpp
r181411 r201563 106 106 // back/forward cache. 107 107 if (!document->frame()) { 108 size_t nodeCount = 0;108 size_t memoryCost = 0; 109 109 for (Node* n = document; n; n = NodeTraversal::next(*n)) 110 nodeCount++;110 memoryCost += n->approximateMemoryCost(); 111 111 112 112 // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated. 113 113 // https://bugs.webkit.org/show_bug.cgi?id=142595 114 exec->heap()->deprecatedReportExtraMemory( nodeCount * sizeof(Node));114 exec->heap()->deprecatedReportExtraMemory(memoryCost); 115 115 } 116 116 -
branches/safari-601.1.46-branch/Source/WebCore/dom/Node.h
r193556 r201563 165 165 virtual void setNodeValue(const String&, ExceptionCode&); 166 166 virtual NodeType nodeType() const = 0; 167 virtual size_t approximateMemoryCost() const { return sizeof(*this); } 167 168 ContainerNode* parentNode() const; 168 169 static ptrdiff_t parentNodeMemoryOffset() { return OBJECT_OFFSETOF(Node, m_parentNode); } -
branches/safari-601.1.46-branch/Source/WebCore/platform/graphics/Image.h
r193886 r201563 120 120 121 121 SharedBuffer* data() { return m_encodedImageData.get(); } 122 const SharedBuffer* data() const { return m_encodedImageData.get(); } 122 123 123 124 // Animation begins whenever someone draws the image, so startAnimation() is not normally called. -
branches/safari-601.1.46-branch/Source/WebCore/svg/SVGGraphicsElement.h
r183160 r201563 54 54 virtual RenderPtr<RenderElement> createElementRenderer(Ref<RenderStyle>&&, const RenderTreePosition&) override; 55 55 56 size_t approximateMemoryCost() const override { return sizeof(*this); } 57 56 58 protected: 57 59 SVGGraphicsElement(const QualifiedName&, Document&); -
branches/safari-601.1.46-branch/Source/WebCore/svg/SVGPathElement.cpp
r198407 r201563 360 360 } 361 361 362 size_t SVGPathElement::approximateMemoryCost() const 363 { 364 // This is an approximation for path memory cost since the path is parsed on demand. 365 size_t pathMemoryCost = (m_pathByteStream->size() / 10) * sizeof(FloatPoint); 366 // We need to account for the memory which is allocated by the RenderSVGPath::m_path. 367 return sizeof(*this) + (renderer() ? pathMemoryCost * 2 + sizeof(RenderSVGPath) : pathMemoryCost); 368 } 369 362 370 void SVGPathElement::pathSegListChanged(SVGPathSegRole role, ListModification listModification) 363 371 { -
branches/safari-601.1.46-branch/Source/WebCore/svg/SVGPathElement.h
r198248 r201563 100 100 void animatedPropertyWillBeDeleted(); 101 101 102 size_t approximateMemoryCost() const override; 103 102 104 private: 103 105 SVGPathElement(const QualifiedName&, Document&); -
branches/safari-601.1.46-branch/Source/WebCore/svg/SVGPolyElement.cpp
r198246 r201563 131 131 } 132 132 133 size_t SVGPolyElement::approximateMemoryCost() const 134 { 135 size_t pointsCost = pointList().size() * sizeof(FloatPoint); 136 // We need to account for the memory which is allocated by the RenderSVGPath::m_path. 137 return sizeof(*this) + (renderer() ? pointsCost * 2 + sizeof(RenderSVGPath) : pointsCost); 133 138 } 139 140 } -
branches/safari-601.1.46-branch/Source/WebCore/svg/SVGPolyElement.h
r198246 r201563 39 39 static const SVGPropertyInfo* pointsPropertyInfo(); 40 40 41 size_t approximateMemoryCost() const override; 42 41 43 protected: 42 44 SVGPolyElement(const QualifiedName&, Document&); -
branches/safari-601.1.46-branch/Source/WebCore/svg/graphics/SVGImage.cpp
r198633 r201563 30 30 31 31 #include "Chrome.h" 32 #include "DOMWindow.h" 32 33 #include "DocumentLoader.h" 33 34 #include "ElementIterator.h" … … 37 38 #include "ImageObserver.h" 38 39 #include "IntRect.h" 40 #include "JSDOMWindowBase.h" 39 41 #include "MainFrame.h" 40 42 #include "PageConfiguration.h" … … 48 50 #include "SVGSVGElement.h" 49 51 #include "Settings.h" 52 #include <runtime/JSCInlines.h> 53 #include <runtime/JSLock.h> 50 54 51 55 namespace WebCore { … … 352 356 } 353 357 358 void SVGImage::reportApproximateMemoryCost() const 359 { 360 Document* document = m_page->mainFrame().document(); 361 size_t decodedImageMemoryCost = 0; 362 363 for (Node* node = document; node; node = NodeTraversal::next(*node)) 364 decodedImageMemoryCost += node->approximateMemoryCost(); 365 366 JSC::VM& vm = JSDOMWindowBase::commonVM(); 367 JSC::JSLockHolder lock(vm); 368 // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated. 369 // https://bugs.webkit.org/show_bug.cgi?id=142595 370 vm.heap.deprecatedReportExtraMemory(decodedImageMemoryCost + data()->size()); 371 } 372 354 373 bool SVGImage::dataChanged(bool allDataReceived) 355 374 { … … 394 413 // Set the intrinsic size before a container size is available. 395 414 m_intrinsicSize = containerSize(); 415 reportApproximateMemoryCost(); 396 416 } 397 417 -
branches/safari-601.1.46-branch/Source/WebCore/svg/graphics/SVGImage.h
r193886 r201563 88 88 virtual bool dataChanged(bool allDataReceived) override; 89 89 90 void reportApproximateMemoryCost() const; 91 90 92 // FIXME: SVGImages will be unable to prune because this function is not implemented yet. 91 93 virtual void destroyDecodedData(bool) override { }
Note:
See TracChangeset
for help on using the changeset viewer.