⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 181534 in webkit


Ignore:
Timestamp:
Mar 16, 2015, 3:19:42 AM (11 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r181411 - Many users of Heap::reportExtraMemory* are wrong, causing lots of memory growth
https://bugs.webkit.org/show_bug.cgi?id=142593

Reviewed by Andreas Kling.

Adopt deprecatedReportExtraMemory as a short-term fix for runaway
memory growth in these cases where we have not adopted
reportExtraMemoryVisited.

Long-term, we should use reportExtraMemoryAllocated+reportExtraMemoryVisited.
That's tracked by https://bugs.webkit.org/show_bug.cgi?id=142595.

Source/JavaScriptCore:

  • API/JSBase.cpp:

(JSReportExtraMemoryCost):

  • runtime/SparseArrayValueMap.cpp:

(JSC::SparseArrayValueMap::add):

Source/WebCore:

Using IOSDebug, I can see that the canvas stress test @ http://jsfiddle.net/fvyw4ba0/,
which used to keep > 1000 1MB NonVolatile GPU allocations live, now keeps about 10 live.

  • Modules/mediasource/SourceBuffer.cpp:

(WebCore::SourceBuffer::reportExtraMemoryAllocated):

  • bindings/js/JSDocumentCustom.cpp:

(WebCore::toJS):

  • bindings/js/JSImageDataCustom.cpp:

(WebCore::toJS):

  • bindings/js/JSNodeListCustom.cpp:

(WebCore::createWrapper):

  • dom/CollectionIndexCache.cpp:

(WebCore::reportExtraMemoryAllocatedForCollectionIndexCache):

  • html/HTMLCanvasElement.cpp:

(WebCore::HTMLCanvasElement::createImageBuffer):

  • html/HTMLImageLoader.cpp:

(WebCore::HTMLImageLoader::imageChanged):

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::parseAttribute):

  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::dropProtection):

Location:
releases/WebKitGTK/webkit-2.8/Source
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.8/Source/JavaScriptCore/API/JSBase.cpp

    r181533 r181534  
    140140    JSLockHolder locker(exec);
    141141
    142     // FIXME: switch to deprecatedReportExtraMemory.
    143     // https://bugs.webkit.org/show_bug.cgi?id=142593
    144     exec->vm().heap.reportExtraMemoryAllocated(size);
     142    exec->vm().heap.deprecatedReportExtraMemory(size);
    145143}
    146144
  • releases/WebKitGTK/webkit-2.8/Source/JavaScriptCore/ChangeLog

    r181533 r181534  
     12015-03-11  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Many users of Heap::reportExtraMemory* are wrong, causing lots of memory growth
     4        https://bugs.webkit.org/show_bug.cgi?id=142593
     5
     6        Reviewed by Andreas Kling.
     7
     8        Adopt deprecatedReportExtraMemory as a short-term fix for runaway
     9        memory growth in these cases where we have not adopted
     10        reportExtraMemoryVisited.
     11
     12        Long-term, we should use reportExtraMemoryAllocated+reportExtraMemoryVisited.
     13        That's tracked by https://bugs.webkit.org/show_bug.cgi?id=142595.
     14
     15        * API/JSBase.cpp:
     16        (JSReportExtraMemoryCost):
     17        * runtime/SparseArrayValueMap.cpp:
     18        (JSC::SparseArrayValueMap::add):
     19
    1202015-03-11  Geoffrey Garen  <ggaren@apple.com>
    221
  • releases/WebKitGTK/webkit-2.8/Source/JavaScriptCore/runtime/SparseArrayValueMap.cpp

    r181533 r181534  
    8181    size_t capacity = m_map.capacity();
    8282    if (capacity != m_reportedCapacity) {
    83         // FIXME: Switch to deprecatedReportExtraMemory, or adopt reportExtraMemoryVisited.
    84         // https://bugs.webkit.org/show_bug.cgi?id=142593
    85         Heap::heap(array)->reportExtraMemoryAllocated((capacity - m_reportedCapacity) * (sizeof(unsigned) + sizeof(WriteBarrier<Unknown>)));
     83        // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
     84        // https://bugs.webkit.org/show_bug.cgi?id=142595
     85        Heap::heap(array)->deprecatedReportExtraMemory((capacity - m_reportedCapacity) * (sizeof(unsigned) + sizeof(WriteBarrier<Unknown>)));
    8686        m_reportedCapacity = capacity;
    8787    }
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog

    r181533 r181534  
     12015-03-12  Geoffrey Garen  <ggaren@apple.com>
     2
     3        REGRESSION: Crash under Heap::reportExtraMemoryAllocatedSlowCase for media element
     4        https://bugs.webkit.org/show_bug.cgi?id=142636
     5
     6        Reviewed by Mark Hahnenberg.
     7
     8        This was a pre-existing bug that I made a lot worse in
     9        <https://trac.webkit.org/changeset/181411>.
     10
     11        * html/HTMLMediaElement.cpp:
     12        (WebCore::HTMLMediaElement::parseAttribute): Compare size before
     13        subtracting rather than subtracting and then comparing to zero. The
     14        latter technique is not valid for unsigned integers, which will happily
     15        underflow into giant numbers.
     16
     17        * Modules/mediasource/SourceBuffer.cpp:
     18        (WebCore::SourceBuffer::reportExtraMemoryAllocated): This code was
     19         technically correct, but I took the opportunity to clean it up a bit.
     20         There's no need to do two checks here, and it smells bad to check for
     21         a negative unsigned integer.
     22
     232015-03-11  Geoffrey Garen  <ggaren@apple.com>
     24
     25        Many users of Heap::reportExtraMemory* are wrong, causing lots of memory growth
     26        https://bugs.webkit.org/show_bug.cgi?id=142593
     27
     28        Reviewed by Andreas Kling.
     29
     30        Adopt deprecatedReportExtraMemory as a short-term fix for runaway
     31        memory growth in these cases where we have not adopted
     32        reportExtraMemoryVisited.
     33
     34        Long-term, we should use reportExtraMemoryAllocated+reportExtraMemoryVisited.
     35        That's tracked by https://bugs.webkit.org/show_bug.cgi?id=142595.
     36
     37        Using IOSDebug, I can see that the canvas stress test @ http://jsfiddle.net/fvyw4ba0/,
     38        which used to keep > 1000 1MB NonVolatile GPU allocations live, now keeps about 10 live.
     39
     40        * Modules/mediasource/SourceBuffer.cpp:
     41        (WebCore::SourceBuffer::reportExtraMemoryAllocated):
     42        * bindings/js/JSDocumentCustom.cpp:
     43        (WebCore::toJS):
     44        * bindings/js/JSImageDataCustom.cpp:
     45        (WebCore::toJS):
     46        * bindings/js/JSNodeListCustom.cpp:
     47        (WebCore::createWrapper):
     48        * dom/CollectionIndexCache.cpp:
     49        (WebCore::reportExtraMemoryAllocatedForCollectionIndexCache):
     50        * html/HTMLCanvasElement.cpp:
     51        (WebCore::HTMLCanvasElement::createImageBuffer):
     52        * html/HTMLImageLoader.cpp:
     53        (WebCore::HTMLImageLoader::imageChanged):
     54        * html/HTMLMediaElement.cpp:
     55        (WebCore::HTMLMediaElement::parseAttribute):
     56        * xml/XMLHttpRequest.cpp:
     57        (WebCore::XMLHttpRequest::dropProtection):
     58
    1592015-03-11  Geoffrey Garen  <ggaren@apple.com>
    260
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/Modules/mediasource/SourceBuffer.cpp

    r181533 r181534  
    19821982{
    19831983    size_t extraMemoryCost = this->extraMemoryCost();
    1984     if (extraMemoryCost < m_reportedExtraMemoryCost)
     1984    if (extraMemoryCost <= m_reportedExtraMemoryCost)
    19851985        return;
    19861986
     
    19891989
    19901990    JSC::JSLockHolder lock(scriptExecutionContext()->vm());
    1991     if (extraMemoryCostDelta > 0) {
    1992         // FIXME: Switch to deprecatedReportExtraMemory, or adopt reportExtraMemoryVisited.
    1993         // https://bugs.webkit.org/show_bug.cgi?id=142593
    1994         scriptExecutionContext()->vm().heap.reportExtraMemoryAllocated(extraMemoryCostDelta);
    1995     }
     1991    // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
     1992    // https://bugs.webkit.org/show_bug.cgi?id=142595
     1993    scriptExecutionContext()->vm().heap.deprecatedReportExtraMemory(extraMemoryCostDelta);
    19961994}
    19971995
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/bindings/js/JSDocumentCustom.cpp

    r181533 r181534  
    110110            nodeCount++;
    111111       
    112         // FIXME: Switch to deprecatedReportExtraMemory, or adopt reportExtraMemoryVisited.
    113         // https://bugs.webkit.org/show_bug.cgi?id=142593
    114         exec->heap()->reportExtraMemoryAllocated(nodeCount * sizeof(Node));
     112        // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
     113        // https://bugs.webkit.org/show_bug.cgi?id=142595
     114        exec->heap()->deprecatedReportExtraMemory(nodeCount * sizeof(Node));
    115115    }
    116116
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/bindings/js/JSImageDataCustom.cpp

    r181533 r181534  
    4848    Identifier dataName(exec, "data");
    4949    wrapper->putDirect(exec->vm(), dataName, toJS(exec, globalObject, imageData->data()), DontDelete | ReadOnly);
    50     // FIXME: Switch to deprecatedReportExtraMemory, or adopt reportExtraMemoryVisited.
    51     // https://bugs.webkit.org/show_bug.cgi?id=142593
    52     exec->heap()->reportExtraMemoryAllocated(imageData->data()->length());
     50    // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
     51    // https://bugs.webkit.org/show_bug.cgi?id=142595
     52    exec->heap()->deprecatedReportExtraMemory(imageData->data()->length());
    5353   
    5454    return wrapper;
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/bindings/js/JSNodeListCustom.cpp

    r181533 r181534  
    6363JSC::JSValue createWrapper(JSDOMGlobalObject& globalObject, NodeList& nodeList)
    6464{
    65     // FIXME: Switch to deprecatedReportExtraMemory, or adopt reportExtraMemoryVisited.
    66     // https://bugs.webkit.org/show_bug.cgi?id=142593
    67     globalObject.vm().heap.reportExtraMemoryAllocated(nodeList.memoryCost());
     65    // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
     66    // https://bugs.webkit.org/show_bug.cgi?id=142595
     67    globalObject.vm().heap.deprecatedReportExtraMemory(nodeList.memoryCost());
    6868    return createNewWrapper<JSNodeList>(&globalObject, &nodeList);
    6969}
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/dom/CollectionIndexCache.cpp

    r181533 r181534  
    3535    JSC::VM& vm = JSDOMWindowBase::commonVM();
    3636    JSC::JSLockHolder lock(vm);
    37     // FIXME: Switch to deprecatedReportExtraMemory, or adopt reportExtraMemoryVisited.
    38     // https://bugs.webkit.org/show_bug.cgi?id=142593
    39     vm.heap.reportExtraMemoryAllocated(cost);
     37    // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
     38    // https://bugs.webkit.org/show_bug.cgi?id=142595
     39    vm.heap.deprecatedReportExtraMemory(cost);
    4040}
    4141
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/html/HTMLCanvasElement.cpp

    r181533 r181534  
    581581    JSC::JSLockHolder lock(scriptExecutionContext()->vm());
    582582    size_t numBytes = 4 * m_imageBuffer->internalSize().width() * m_imageBuffer->internalSize().height();
    583     // FIXME: Switch to deprecatedReportExtraMemory, or adopt reportExtraMemoryVisited.
    584     // https://bugs.webkit.org/show_bug.cgi?id=142593
    585     scriptExecutionContext()->vm().heap.reportExtraMemoryAllocated(numBytes);
     583    // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
     584    // https://bugs.webkit.org/show_bug.cgi?id=142595
     585    scriptExecutionContext()->vm().heap.deprecatedReportExtraMemory(numBytes);
    586586
    587587#if USE(IOSURFACE_CANVAS_BACKING_STORE) || ENABLE(ACCELERATED_2D_CANVAS)
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/html/HTMLImageLoader.cpp

    r181533 r181534  
    8888            JSC::VM& vm = JSDOMWindowBase::commonVM();
    8989            JSC::JSLockHolder lock(vm);
    90             // FIXME: Switch to deprecatedReportExtraMemory, or adopt reportExtraMemoryVisited.
    91             // https://bugs.webkit.org/show_bug.cgi?id=142593
    92             vm.heap.reportExtraMemoryAllocated(cachedImage->encodedSize());
     90            // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
     91            // https://bugs.webkit.org/show_bug.cgi?id=142595
     92            vm.heap.deprecatedReportExtraMemory(cachedImage->encodedSize());
    9393        }
    9494    }
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/html/HTMLMediaElement.cpp

    r181533 r181534  
    686686
    687687        if (m_player) {
    688             JSC::VM& vm = JSDOMWindowBase::commonVM();
    689             JSC::JSLockHolder lock(vm);
    690 
    691688            size_t extraMemoryCost = m_player->extraMemoryCost();
    692             size_t extraMemoryCostDelta = extraMemoryCost - m_reportedExtraMemoryCost;
    693             m_reportedExtraMemoryCost = extraMemoryCost;
    694 
    695             if (extraMemoryCostDelta > 0) {
    696                 // FIXME: Switch to deprecatedReportExtraMemory, or adopt reportExtraMemoryVisited.
    697                 // https://bugs.webkit.org/show_bug.cgi?id=142593
    698                 vm.heap.reportExtraMemoryAllocated(extraMemoryCostDelta);
     689            if (extraMemoryCost > m_reportedExtraMemoryCost) {
     690                JSC::VM& vm = JSDOMWindowBase::commonVM();
     691                JSC::JSLockHolder lock(vm);
     692
     693                size_t extraMemoryCostDelta = extraMemoryCost - m_reportedExtraMemoryCost;
     694                m_reportedExtraMemoryCost = extraMemoryCost;
     695                // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
     696                // https://bugs.webkit.org/show_bug.cgi?id=142595
     697                vm.heap.deprecatedReportExtraMemory(extraMemoryCostDelta);
    699698            }
    700699        }
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/xml/XMLHttpRequest.cpp

    r181533 r181534  
    914914    JSC::VM& vm = scriptExecutionContext()->vm();
    915915    JSC::JSLockHolder lock(vm);
    916     // FIXME: Switch to deprecatedReportExtraMemory, or adopt reportExtraMemoryVisited.
    917     // https://bugs.webkit.org/show_bug.cgi?id=142593
    918     vm.heap.reportExtraMemoryAllocated(m_responseBuilder.length() * 2);
     916    // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
     917    // https://bugs.webkit.org/show_bug.cgi?id=142595
     918    vm.heap.deprecatedReportExtraMemory(m_responseBuilder.length() * 2);
    919919
    920920    unsetPendingActivity(this);
Note: See TracChangeset for help on using the changeset viewer.