Changeset 151149 in webkit


Ignore:
Timestamp:
Jun 3, 2013 8:20:32 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[EFL] Implement GCActivityCallback
https://bugs.webkit.org/show_bug.cgi?id=95923

Patch by Hojong Han <hojong.han@samsung.com> on 2013-06-03
Reviewed by Geoffrey Garen.

Implements the activity triggered garbage collector.
Additional GCs can be triggered by platfrom timer.
It has sort of compaction effect not to make JSC heap grow fast
so that memory usage becomes lower than usual.

  • PlatformEfl.cmake: Added.
  • heap/HeapTimer.cpp:

(JSC):
(JSC::HeapTimer::HeapTimer):
(JSC::HeapTimer::~HeapTimer):
(JSC::HeapTimer::add):
(JSC::HeapTimer::stop):
(JSC::HeapTimer::timerEvent):

  • heap/HeapTimer.h:

(HeapTimer):

  • jsc.cpp:

(main):

  • runtime/GCActivityCallback.cpp:

(JSC):
(JSC::DefaultGCActivityCallback::DefaultGCActivityCallback):
(JSC::DefaultGCActivityCallback::scheduleTimer):
(JSC::DefaultGCActivityCallback::cancelTimer):
(JSC::DefaultGCActivityCallback::didAllocate):

  • runtime/GCActivityCallback.h:

(GCActivityCallback):
(JSC::GCActivityCallback::GCActivityCallback):
(DefaultGCActivityCallback):

Location:
trunk/Source/JavaScriptCore
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r151133 r151149  
     12013-06-03  Hojong Han  <hojong.han@samsung.com>
     2
     3        [EFL] Implement GCActivityCallback
     4        https://bugs.webkit.org/show_bug.cgi?id=95923
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Implements the activity triggered garbage collector.
     9        Additional GCs can be triggered by platfrom timer.
     10        It has sort of compaction effect not to make JSC heap grow fast
     11        so that memory usage becomes lower than usual.
     12
     13        * PlatformEfl.cmake: Added.
     14        * heap/HeapTimer.cpp:
     15        (JSC):
     16        (JSC::HeapTimer::HeapTimer):
     17        (JSC::HeapTimer::~HeapTimer):
     18        (JSC::HeapTimer::add):
     19        (JSC::HeapTimer::stop):
     20        (JSC::HeapTimer::timerEvent):
     21        * heap/HeapTimer.h:
     22        (HeapTimer):
     23        * jsc.cpp:
     24        (main):
     25        * runtime/GCActivityCallback.cpp:
     26        (JSC):
     27        (JSC::DefaultGCActivityCallback::DefaultGCActivityCallback):
     28        (JSC::DefaultGCActivityCallback::scheduleTimer):
     29        (JSC::DefaultGCActivityCallback::cancelTimer):
     30        (JSC::DefaultGCActivityCallback::didAllocate):
     31        * runtime/GCActivityCallback.h:
     32        (GCActivityCallback):
     33        (JSC::GCActivityCallback::GCActivityCallback):
     34        (DefaultGCActivityCallback):
     35
    1362013-06-03  Roger Fong  <roger_fong@apple.com>
    237
  • trunk/Source/JavaScriptCore/heap/HeapTimer.cpp

    r149255 r151149  
    3939#include <QThread>
    4040#include <QTimerEvent>
     41#elif PLATFORM(EFL)
     42#include <Ecore.h>
    4143#endif
    4244
     
    166168}
    167169
     170#elif PLATFORM(EFL)
     171
     172HeapTimer::HeapTimer(VM* vm)
     173    : m_vm(vm)
     174    , m_timer(0)
     175{
     176}
     177
     178HeapTimer::~HeapTimer()
     179{
     180    stop();
     181}
     182
     183Ecore_Timer* HeapTimer::add(double delay, void* agent)
     184{
     185    return ecore_timer_add(delay, reinterpret_cast<Ecore_Task_Cb>(timerEvent), agent);
     186}
     187   
     188void HeapTimer::stop()
     189{
     190    if (!m_timer)
     191        return;
     192
     193    ecore_timer_del(m_timer);
     194    m_timer = 0;
     195}
     196
     197bool HeapTimer::timerEvent(void* info)
     198{
     199    HeapTimer* agent = static_cast<HeapTimer*>(info);
     200   
     201    APIEntryShim shim(agent->m_vm);
     202    agent->doWork();
     203    agent->m_timer = 0;
     204   
     205    return ECORE_CALLBACK_CANCEL;
     206}
     207
    168208#else
    169209HeapTimer::HeapTimer(VM* vm)
  • trunk/Source/JavaScriptCore/heap/HeapTimer.h

    r148704 r151149  
    3939#include <QObject>
    4040#include <QThread>
     41#elif PLATFORM(EFL)
     42typedef struct _Ecore_Timer Ecore_Timer;
    4143#endif
    4244
     
    8284    QThread* m_newThread;
    8385    QMutex m_mutex;
     86#elif PLATFORM(EFL)
     87    static bool timerEvent(void*);
     88    Ecore_Timer* add(double delay, void* agent);
     89    void stop();
     90    Ecore_Timer* m_timer;
    8491#endif
    8592   
  • trunk/Source/JavaScriptCore/jsc.cpp

    r149825 r151149  
    9191#endif
    9292
     93#if PLATFORM(EFL)
     94#include <Ecore.h>
     95#endif
     96
    9397using namespace JSC;
    9498using namespace WTF;
     
    538542#endif
    539543
     544#if PLATFORM(EFL)
     545    ecore_init();
     546#endif
     547
    540548    // Initialize JSC before getting VM.
    541549#if ENABLE(SAMPLING_REGIONS)
     
    552560    if (Options::logHeapStatisticsAtExit())
    553561        HeapStatistics::reportSuccess();
     562
     563#if PLATFORM(EFL)
     564    ecore_shutdown();
     565#endif
     566
    554567    return res;
    555568}
  • trunk/Source/JavaScriptCore/runtime/GCActivityCallback.cpp

    r148696 r151149  
    3939#include <wtf/WTFThreadData.h>
    4040
     41#if PLATFORM(EFL)
     42#include <wtf/MainThread.h>
     43#endif
     44
    4145namespace JSC {
    4246
    43 #if USE(CF) || PLATFORM(QT)
     47#if USE(CF) || PLATFORM(QT) || PLATFORM(EFL)
    4448
    4549const double gcTimeSlicePerMB = 0.01; // Percentage of CPU time we will spend to reclaim 1 MB
     
    6468DefaultGCActivityCallback::DefaultGCActivityCallback(Heap* heap)
    6569    : GCActivityCallback(heap->vm())
     70    , m_delay(hour)
     71{
     72}
     73#elif PLATFORM(EFL)
     74DefaultGCActivityCallback::DefaultGCActivityCallback(Heap* heap)
     75    : GCActivityCallback(heap->vm(), WTF::isMainThread())
    6676    , m_delay(hour)
    6777{
     
    117127    m_timer.stop();
    118128}
     129#elif PLATFORM(EFL)
     130void DefaultGCActivityCallback::scheduleTimer(double newDelay)
     131{
     132    if (newDelay * timerSlop > m_delay)
     133        return;
     134
     135    stop();
     136    m_delay = newDelay;
     137   
     138    ASSERT(!m_timer);
     139    m_timer = add(newDelay, this);
     140}
     141
     142void DefaultGCActivityCallback::cancelTimer()
     143{
     144    m_delay = hour;
     145    stop();
     146}
    119147#endif
    120148
    121149void DefaultGCActivityCallback::didAllocate(size_t bytes)
    122150{
     151#if PLATFORM(EFL)
     152    if (!isEnabled())
     153        return;
     154
     155    ASSERT(WTF::isMainThread());
     156#endif
     157
    123158    // The first byte allocated in an allocation cycle will report 0 bytes to didAllocate.
    124159    // We pretend it's one byte so that we don't ignore this allocation entirely.
  • trunk/Source/JavaScriptCore/runtime/GCActivityCallback.h

    r148696 r151149  
    5858    {
    5959    }
     60#elif PLATFORM(EFL)
     61    GCActivityCallback(VM* vm, bool flag)
     62        : HeapTimer(vm)
     63        , m_enabled(flag)
     64    {
     65    }
    6066#else
    6167    GCActivityCallback(VM* vm)
     
    8591    DefaultGCActivityCallback(Heap*, CFRunLoopRef);
    8692#endif
    87 #if USE(CF) || PLATFORM(QT)
     93#if USE(CF) || PLATFORM(QT) || PLATFORM(EFL)
    8894protected:
    8995    void cancelTimer();
Note: See TracChangeset for help on using the changeset viewer.