Changeset 122624 in webkit


Ignore:
Timestamp:
Jul 13, 2012 1:12:36 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[BlackBerry] Implement GCActivityCallback with platform timer
https://bugs.webkit.org/show_bug.cgi?id=90175

Patch by Yong Li <yoli@rim.com> on 2012-07-13
Reviewed by Rob Buis.

Implement GCActivityCallback and HeapTimer for BlackBerry port.

  • heap/HeapTimer.cpp:

(JSC):
(JSC::HeapTimer::HeapTimer):
(JSC::HeapTimer::~HeapTimer):
(JSC::HeapTimer::timerDidFire):
(JSC::HeapTimer::synchronize):
(JSC::HeapTimer::invalidate):
(JSC::HeapTimer::didStartVMShutdown):

  • heap/HeapTimer.h:

(HeapTimer):

  • runtime/GCActivityCallbackBlackBerry.cpp:

(JSC):
(JSC::DefaultGCActivityCallback::doWork):
(JSC::DefaultGCActivityCallback::didAllocate):
(JSC::DefaultGCActivityCallback::willCollect):
(JSC::DefaultGCActivityCallback::cancel):

Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r122595 r122624  
     12012-07-13  Yong Li  <yoli@rim.com>
     2
     3        [BlackBerry] Implement GCActivityCallback with platform timer
     4        https://bugs.webkit.org/show_bug.cgi?id=90175
     5
     6        Reviewed by Rob Buis.
     7
     8        Implement GCActivityCallback and HeapTimer for BlackBerry port.
     9
     10        * heap/HeapTimer.cpp:
     11        (JSC):
     12        (JSC::HeapTimer::HeapTimer):
     13        (JSC::HeapTimer::~HeapTimer):
     14        (JSC::HeapTimer::timerDidFire):
     15        (JSC::HeapTimer::synchronize):
     16        (JSC::HeapTimer::invalidate):
     17        (JSC::HeapTimer::didStartVMShutdown):
     18        * heap/HeapTimer.h:
     19        (HeapTimer):
     20        * runtime/GCActivityCallbackBlackBerry.cpp:
     21        (JSC):
     22        (JSC::DefaultGCActivityCallback::doWork):
     23        (JSC::DefaultGCActivityCallback::didAllocate):
     24        (JSC::DefaultGCActivityCallback::willCollect):
     25        (JSC::DefaultGCActivityCallback::cancel):
     26
    1272012-07-13  Patrick Gansterer  <paroga@webkit.org>
    228
  • trunk/Source/JavaScriptCore/heap/HeapTimer.cpp

    r121381 r122624  
    9999}
    100100
     101#elif PLATFORM(BLACKBERRY)
     102
     103HeapTimer::HeapTimer(JSGlobalData* globalData)
     104    : m_globalData(globalData)
     105    , m_timer(this, &HeapTimer::timerDidFire)
     106{
     107}
     108
     109HeapTimer::~HeapTimer()
     110{
     111}
     112
     113void HeapTimer::timerDidFire()
     114{
     115    doWork();
     116}
     117
     118void HeapTimer::synchronize()
     119{
     120}
     121
     122void HeapTimer::invalidate()
     123{
     124}
     125
     126void HeapTimer::didStartVMShutdown()
     127{
     128    delete this;
     129}
     130
    101131#else
    102    
     132
    103133HeapTimer::HeapTimer(JSGlobalData* globalData)
    104134    : m_globalData(globalData)
  • trunk/Source/JavaScriptCore/heap/HeapTimer.h

    r121381 r122624  
    3232#if USE(CF)
    3333#include <CoreFoundation/CoreFoundation.h>
     34#elif PLATFORM(BLACKBERRY)
     35#include <BlackBerryPlatformTimer.h>
    3436#endif
    3537
     
    6466
    6567    Mutex m_shutdownMutex;
     68#elif PLATFORM(BLACKBERRY)
     69    void timerDidFire();
     70
     71    BlackBerry::Platform::Timer<HeapTimer> m_timer;
    6672#endif
    6773   
  • trunk/Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp

    r120742 r122624  
    2121
    2222#include "Heap.h"
     23#include "JSGlobalData.h"
    2324#include <BlackBerryPlatformMemory.h>
    2425
    2526namespace JSC {
     27
     28static const size_t bytesWorthGC = 4 * 1024 * 1024;
    2629
    2730DefaultGCActivityCallback::DefaultGCActivityCallback(Heap* heap)
     
    3033}
    3134
    32 DefaultGCActivityCallback::doWork()
     35void DefaultGCActivityCallback::doWork()
    3336{
     37    m_globalData->heap.collect(Heap::DoNotSweep);
    3438}
    3539
    3640void DefaultGCActivityCallback::didAllocate(size_t bytesAllocated)
    3741{
    38     if (!BlackBerry::Platform::isMemoryLow())
     42    if (bytesAllocated < bytesWorthGC || m_timer.started())
    3943        return;
    4044
    41     if (bytesAllocated < 1 * 1024 * 1024)
    42         return;
    43 
    44     if (m_globalData->heap.isBusy() || !m_globalData->heap.isSafeToCollect())
    45         return;
    46 
    47     m_globalData->heap.collect(Heap::DoNotSweep);
     45    // Try using ~5% CPU time.
     46    m_timer.start(m_globalData->heap.lastGCLength() * 20);
    4847}
    4948
    5049void DefaultGCActivityCallback::willCollect()
    5150{
     51    cancel();
    5252}
    5353
    5454void DefaultGCActivityCallback::cancel()
    5555{
     56    m_timer.stop();
    5657}
    5758
Note: See TracChangeset for help on using the changeset viewer.