Title: [207855] trunk/Source
Revision
207855
Author
[email protected]
Date
2016-10-25 16:22:48 -0700 (Tue, 25 Oct 2016)

Log Message

HeapTimer should not hardcode all of its subclasses and USE(CF) shouldn't be a bizarre special case
https://bugs.webkit.org/show_bug.cgi?id=163947

Reviewed by Geoffrey Garen.
Source/_javascript_Core:

        
I want to introduce another HeapTimer. Prior to this change, that would have meant writing
exact copies of that timer's logic for each platform that has a HeapTimer (CF, GLIB, and
EFL). That logic would in turn be a duplicate of the logic already present in
IncrementalSweeper and GCActivityCallback: all of the subclasses of HeapTimer have their
own code for scheduling timers, so a new subclass would have to duplicate that code. Then,
to add insult to injury, the USE(CF) version of HeapTimer would have to have an extra case
for that new subclass since it doesn't use virtual methods effectively.
        
This changes HeapTimer on USE(CF) to know to get its runloop from Heap and to use virtual
methods effectively so that it doesn't have to know about all of its subclasses.
        
This also moves IncrementalSweeper's code for scheduling timers into HeapTimer. This means
that future subclasses of HeapTimer could simply use that logic.
        
This keeps changes to GCActivityCallback to a minimum. It still has a lot of
platform-specific code and I'm not sure that this code can be trivially deduplicated since
that code has more quirks. That's fine for now, since I mainly just need a sane way of
creating new timers that use IncrementalSweeper-like scheduling logic.

* heap/EdenGCActivityCallback.cpp:
* heap/EdenGCActivityCallback.h:
* heap/FullGCActivityCallback.cpp:
* heap/FullGCActivityCallback.h:
* heap/GCActivityCallback.cpp:
(JSC::GCActivityCallback::GCActivityCallback):
* heap/GCActivityCallback.h:
* heap/Heap.cpp:
(JSC::Heap::Heap):
* heap/Heap.h:
(JSC::Heap::runLoop):
* heap/HeapTimer.cpp:
(JSC::HeapTimer::HeapTimer):
(JSC::HeapTimer::setRunLoop):
(JSC::HeapTimer::~HeapTimer):
(JSC::HeapTimer::timerDidFire):
(JSC::HeapTimer::scheduleTimer):
(JSC::HeapTimer::cancelTimer):
(JSC::retainAPILock): Deleted.
(JSC::releaseAPILock): Deleted.
* heap/HeapTimer.h:
* heap/IncrementalSweeper.cpp:
(JSC::IncrementalSweeper::scheduleTimer):
(JSC::IncrementalSweeper::cancelTimer): Deleted.
* heap/IncrementalSweeper.h:

Source/WebCore:


No new tests because no new behavior.

* platform/ios/WebSafeGCActivityCallbackIOS.h:
* platform/ios/WebSafeIncrementalSweeperIOS.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (207854 => 207855)


--- trunk/Source/_javascript_Core/ChangeLog	2016-10-25 23:21:03 UTC (rev 207854)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-10-25 23:22:48 UTC (rev 207855)
@@ -1,3 +1,55 @@
+2016-10-25  Filip Pizlo  <[email protected]>
+
+        HeapTimer should not hardcode all of its subclasses and USE(CF) shouldn't be a bizarre special case
+        https://bugs.webkit.org/show_bug.cgi?id=163947
+
+        Reviewed by Geoffrey Garen.
+        
+        I want to introduce another HeapTimer. Prior to this change, that would have meant writing
+        exact copies of that timer's logic for each platform that has a HeapTimer (CF, GLIB, and
+        EFL). That logic would in turn be a duplicate of the logic already present in
+        IncrementalSweeper and GCActivityCallback: all of the subclasses of HeapTimer have their
+        own code for scheduling timers, so a new subclass would have to duplicate that code. Then,
+        to add insult to injury, the USE(CF) version of HeapTimer would have to have an extra case
+        for that new subclass since it doesn't use virtual methods effectively.
+        
+        This changes HeapTimer on USE(CF) to know to get its runloop from Heap and to use virtual
+        methods effectively so that it doesn't have to know about all of its subclasses.
+        
+        This also moves IncrementalSweeper's code for scheduling timers into HeapTimer. This means
+        that future subclasses of HeapTimer could simply use that logic.
+        
+        This keeps changes to GCActivityCallback to a minimum. It still has a lot of
+        platform-specific code and I'm not sure that this code can be trivially deduplicated since
+        that code has more quirks. That's fine for now, since I mainly just need a sane way of
+        creating new timers that use IncrementalSweeper-like scheduling logic.
+
+        * heap/EdenGCActivityCallback.cpp:
+        * heap/EdenGCActivityCallback.h:
+        * heap/FullGCActivityCallback.cpp:
+        * heap/FullGCActivityCallback.h:
+        * heap/GCActivityCallback.cpp:
+        (JSC::GCActivityCallback::GCActivityCallback):
+        * heap/GCActivityCallback.h:
+        * heap/Heap.cpp:
+        (JSC::Heap::Heap):
+        * heap/Heap.h:
+        (JSC::Heap::runLoop):
+        * heap/HeapTimer.cpp:
+        (JSC::HeapTimer::HeapTimer):
+        (JSC::HeapTimer::setRunLoop):
+        (JSC::HeapTimer::~HeapTimer):
+        (JSC::HeapTimer::timerDidFire):
+        (JSC::HeapTimer::scheduleTimer):
+        (JSC::HeapTimer::cancelTimer):
+        (JSC::retainAPILock): Deleted.
+        (JSC::releaseAPILock): Deleted.
+        * heap/HeapTimer.h:
+        * heap/IncrementalSweeper.cpp:
+        (JSC::IncrementalSweeper::scheduleTimer):
+        (JSC::IncrementalSweeper::cancelTimer): Deleted.
+        * heap/IncrementalSweeper.h:
+
 2016-10-25  JF Bastien  <[email protected]>
 
         Remove redundant argument count check

Modified: trunk/Source/_javascript_Core/heap/EdenGCActivityCallback.cpp (207854 => 207855)


--- trunk/Source/_javascript_Core/heap/EdenGCActivityCallback.cpp	2016-10-25 23:21:03 UTC (rev 207854)
+++ trunk/Source/_javascript_Core/heap/EdenGCActivityCallback.cpp	2016-10-25 23:22:48 UTC (rev 207855)
@@ -94,6 +94,6 @@
     return 0;
 }
 
-#endif // USE(CF) || PLATFORM(EFL)
+#endif // USE(CF) || USE(GLIB)
 
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/heap/EdenGCActivityCallback.h (207854 => 207855)


--- trunk/Source/_javascript_Core/heap/EdenGCActivityCallback.h	2016-10-25 23:21:03 UTC (rev 207854)
+++ trunk/Source/_javascript_Core/heap/EdenGCActivityCallback.h	2016-10-25 23:22:48 UTC (rev 207855)
@@ -36,13 +36,6 @@
     void doCollection() override;
 
 protected:
-#if USE(CF)
-    EdenGCActivityCallback(Heap* heap, CFRunLoopRef runLoop)
-        : GCActivityCallback(heap, runLoop)
-    {
-    }
-#endif
-
     double lastGCLength() override;
     double gcTimeSlice(size_t bytes) override;
     double deathRate() override;

Modified: trunk/Source/_javascript_Core/heap/FullGCActivityCallback.cpp (207854 => 207855)


--- trunk/Source/_javascript_Core/heap/FullGCActivityCallback.cpp	2016-10-25 23:21:03 UTC (rev 207854)
+++ trunk/Source/_javascript_Core/heap/FullGCActivityCallback.cpp	2016-10-25 23:22:48 UTC (rev 207855)
@@ -110,6 +110,6 @@
     return 0;
 }
 
-#endif // USE(CF) || PLATFORM(EFL)
+#endif // USE(CF) || USE(GLIB)
 
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/heap/FullGCActivityCallback.h (207854 => 207855)


--- trunk/Source/_javascript_Core/heap/FullGCActivityCallback.h	2016-10-25 23:21:03 UTC (rev 207854)
+++ trunk/Source/_javascript_Core/heap/FullGCActivityCallback.h	2016-10-25 23:22:48 UTC (rev 207855)
@@ -39,13 +39,6 @@
     void setDidSyncGCRecently() { m_didSyncGCRecently = true; }
 
 protected:
-#if USE(CF)
-    FullGCActivityCallback(Heap* heap, CFRunLoopRef runLoop)
-        : GCActivityCallback(heap, runLoop)
-    {
-    }
-#endif
-
     double lastGCLength() override;
     double gcTimeSlice(size_t bytes) override;
     double deathRate() override;

Modified: trunk/Source/_javascript_Core/heap/GCActivityCallback.cpp (207854 => 207855)


--- trunk/Source/_javascript_Core/heap/GCActivityCallback.cpp	2016-10-25 23:21:03 UTC (rev 207854)
+++ trunk/Source/_javascript_Core/heap/GCActivityCallback.cpp	2016-10-25 23:22:48 UTC (rev 207855)
@@ -50,14 +50,9 @@
 
 #if USE(CF)
 GCActivityCallback::GCActivityCallback(Heap* heap)
-    : GCActivityCallback(heap->vm(), CFRunLoopGetCurrent())
+    : GCActivityCallback(heap->vm())
 {
 }
-
-GCActivityCallback::GCActivityCallback(Heap* heap, CFRunLoopRef runLoop)
-    : GCActivityCallback(heap->vm(), runLoop)
-{
-}
 #elif PLATFORM(EFL)
 GCActivityCallback::GCActivityCallback(Heap* heap)
     : GCActivityCallback(heap->vm(), WTF::isMainThread())

Modified: trunk/Source/_javascript_Core/heap/GCActivityCallback.h (207854 => 207855)


--- trunk/Source/_javascript_Core/heap/GCActivityCallback.h	2016-10-25 23:21:03 UTC (rev 207854)
+++ trunk/Source/_javascript_Core/heap/GCActivityCallback.h	2016-10-25 23:22:48 UTC (rev 207855)
@@ -70,8 +70,8 @@
     virtual double deathRate() = 0;
 
 #if USE(CF)
-    GCActivityCallback(VM* vm, CFRunLoopRef runLoop)
-        : HeapTimer(vm, runLoop)
+    GCActivityCallback(VM* vm)
+        : HeapTimer(vm)
         , m_enabled(true)
         , m_delay(s_decade)
     {
@@ -101,10 +101,6 @@
 
     bool m_enabled;
 
-#if USE(CF)
-protected:
-    GCActivityCallback(Heap*, CFRunLoopRef);
-#endif
 #if USE(CF) || USE(GLIB)
 protected:
     void cancelTimer();

Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (207854 => 207855)


--- trunk/Source/_javascript_Core/heap/Heap.cpp	2016-10-25 23:21:03 UTC (rev 207854)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp	2016-10-25 23:22:48 UTC (rev 207855)
@@ -219,13 +219,12 @@
     // schedule the timer if we've never done a collection.
     , m_lastFullGCLength(0.01)
     , m_lastEdenGCLength(0.01)
+#if USE(CF)
+    , m_runLoop(CFRunLoopGetCurrent())
+#endif // USE(CF)
     , m_fullActivityCallback(GCActivityCallback::createFullTimer(this))
     , m_edenActivityCallback(GCActivityCallback::createEdenTimer(this))
-#if USE(CF)
-    , m_sweeper(std::make_unique<IncrementalSweeper>(this, CFRunLoopGetCurrent()))
-#else
     , m_sweeper(std::make_unique<IncrementalSweeper>(this))
-#endif
     , m_deferralDepth(0)
 #if USE(FOUNDATION)
     , m_delayedReleaseRecursionCount(0)

Modified: trunk/Source/_javascript_Core/heap/Heap.h (207854 => 207855)


--- trunk/Source/_javascript_Core/heap/Heap.h	2016-10-25 23:21:03 UTC (rev 207854)
+++ trunk/Source/_javascript_Core/heap/Heap.h	2016-10-25 23:22:48 UTC (rev 207855)
@@ -270,6 +270,10 @@
     unsigned barrierThreshold() const { return m_barrierThreshold; }
     const unsigned* addressOfBarrierThreshold() const { return &m_barrierThreshold; }
 
+#if USE(CF)
+    CFRunLoopRef runLoop() const { return m_runLoop.get(); }
+#endif // USE(CF)
+
 private:
     friend class AllocatingScope;
     friend class CodeBlock;
@@ -444,6 +448,9 @@
     Vector<WeakBlock*> m_logicallyEmptyWeakBlocks;
     size_t m_indexOfNextLogicallyEmptyWeakBlockToSweep { WTF::notFound };
     
+#if USE(CF)
+    RetainPtr<CFRunLoopRef> m_runLoop;
+#endif // USE(CF)
     RefPtr<FullGCActivityCallback> m_fullActivityCallback;
     RefPtr<GCActivityCallback> m_edenActivityCallback;
     std::unique_ptr<IncrementalSweeper> m_sweeper;

Modified: trunk/Source/_javascript_Core/heap/HeapTimer.cpp (207854 => 207855)


--- trunk/Source/_javascript_Core/heap/HeapTimer.cpp	2016-10-25 23:21:03 UTC (rev 207854)
+++ trunk/Source/_javascript_Core/heap/HeapTimer.cpp	2016-10-25 23:22:48 UTC (rev 207855)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -46,69 +46,71 @@
     
 const CFTimeInterval HeapTimer::s_decade = 60 * 60 * 24 * 365 * 10;
 
-static const void* retainAPILock(const void* info)
+HeapTimer::HeapTimer(VM* vm)
+    : m_vm(vm)
+    , m_apiLock(&vm->apiLock())
 {
-    static_cast<JSLock*>(const_cast<void*>(info))->ref();
-    return info;
+    setRunLoop(vm->heap.runLoop());
 }
 
-static void releaseAPILock(const void* info)
+void HeapTimer::setRunLoop(CFRunLoopRef runLoop)
 {
-    static_cast<JSLock*>(const_cast<void*>(info))->deref();
+    if (m_runLoop) {
+        CFRunLoopRemoveTimer(m_runLoop.get(), m_timer.get(), kCFRunLoopCommonModes);
+        CFRunLoopTimerInvalidate(m_timer.get());
+        m_runLoop.clear();
+        m_timer.clear();
+    }
+    
+    if (runLoop) {
+        m_runLoop = runLoop;
+        memset(&m_context, 0, sizeof(CFRunLoopTimerContext));
+        m_context.info = this;
+        m_timer = adoptCF(CFRunLoopTimerCreate(kCFAllocatorDefault, s_decade, s_decade, 0, 0, HeapTimer::timerDidFire, &m_context));
+        CFRunLoopAddTimer(m_runLoop.get(), m_timer.get(), kCFRunLoopCommonModes);
+    }
 }
 
-HeapTimer::HeapTimer(VM* vm, CFRunLoopRef runLoop)
-    : m_vm(vm)
-    , m_runLoop(runLoop)
-{
-    memset(&m_context, 0, sizeof(CFRunLoopTimerContext));
-    m_context.info = &vm->apiLock();
-    m_context.retain = retainAPILock;
-    m_context.release = releaseAPILock;
-    m_timer = adoptCF(CFRunLoopTimerCreate(kCFAllocatorDefault, s_decade, s_decade, 0, 0, HeapTimer::timerDidFire, &m_context));
-    CFRunLoopAddTimer(m_runLoop.get(), m_timer.get(), kCFRunLoopCommonModes);
-}
-
 HeapTimer::~HeapTimer()
 {
-    CFRunLoopRemoveTimer(m_runLoop.get(), m_timer.get(), kCFRunLoopCommonModes);
-    CFRunLoopTimerInvalidate(m_timer.get());
+    setRunLoop(0);
 }
 
-void HeapTimer::timerDidFire(CFRunLoopTimerRef timer, void* context)
+void HeapTimer::timerDidFire(CFRunLoopTimerRef, void* contextPtr)
 {
-    JSLock* apiLock = static_cast<JSLock*>(context);
-    apiLock->lock();
+    HeapTimer* timer = static_cast<HeapTimer*>(contextPtr);
+    timer->m_apiLock->lock();
 
-    RefPtr<VM> vm = apiLock->vm();
+    RefPtr<VM> vm = timer->m_apiLock->vm();
     if (!vm) {
         // The VM has been destroyed, so we should just give up.
-        apiLock->unlock();
+        timer->m_apiLock->unlock();
         return;
     }
 
-    HeapTimer* heapTimer = 0;
-    if (vm->heap.fullActivityCallback() && vm->heap.fullActivityCallback()->m_timer.get() == timer)
-        heapTimer = vm->heap.fullActivityCallback();
-    else if (vm->heap.edenActivityCallback() && vm->heap.edenActivityCallback()->m_timer.get() == timer)
-        heapTimer = vm->heap.edenActivityCallback();
-    else if (vm->heap.sweeper()->m_timer.get() == timer)
-        heapTimer = vm->heap.sweeper();
-    else
-        RELEASE_ASSERT_NOT_REACHED();
-
     {
         JSLockHolder locker(vm.get());
-        heapTimer->doWork();
+        timer->doWork();
     }
 
-    apiLock->unlock();
+    timer->m_apiLock->unlock();
 }
 
+void HeapTimer::scheduleTimer(double intervalInSeconds)
+{
+    CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + intervalInSeconds);
+}
+
+void HeapTimer::cancelTimer()
+{
+    CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + s_decade);
+}
+
 #elif PLATFORM(EFL)
 
 HeapTimer::HeapTimer(VM* vm)
     : m_vm(vm)
+    , m_apiLock(&vm->apiLock())
     , m_timer(0)
 {
 }
@@ -143,6 +145,19 @@
     return ECORE_CALLBACK_CANCEL;
 }
 
+void HeapTimer::scheduleTimer(double intervalInSeconds)
+{
+    if (ecore_timer_freeze_get(m_timer))
+        ecore_timer_thaw(m_timer);
+
+    double targetTime = currentTime() + intervalInSeconds;
+    ecore_timer_interval_set(m_timer, targetTime);
+}
+
+void HeapTimer::cancelTimer()
+{
+    ecore_timer_freeze(m_timer);
+}
 #elif USE(GLIB)
 
 static GSourceFuncs heapTimerSourceFunctions = {
@@ -197,6 +212,19 @@
     m_apiLock->unlock();
 }
 
+void HeapTimer::scheduleTimer(double intervalInSeconds)
+{
+    auto delayDuration = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<double>(intervalInSeconds));
+    gint64 currentTime = g_get_monotonic_time();
+    gint64 targetTime = currentTime + std::min<gint64>(G_MAXINT64 - currentTime, delayDuration.count());
+    ASSERT(targetTime >= currentTime);
+    g_source_set_ready_time(m_timer.get(), targetTime);
+}
+
+void HeapTimer::cancelTimer()
+{
+    g_source_set_ready_time(m_timer.get(), -1);
+}
 #else
 HeapTimer::HeapTimer(VM* vm)
     : m_vm(vm)
@@ -211,6 +239,13 @@
 {
 }
 
+void HeapTimer::scheduleTimer(double)
+{
+}
+
+void HeapTimer::cancelTimer()
+{
+}
 #endif
     
 

Modified: trunk/Source/_javascript_Core/heap/HeapTimer.h (207854 => 207855)


--- trunk/Source/_javascript_Core/heap/HeapTimer.h	2016-10-25 23:21:03 UTC (rev 207854)
+++ trunk/Source/_javascript_Core/heap/HeapTimer.h	2016-10-25 23:22:48 UTC (rev 207855)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2015-2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,7 +26,9 @@
 #pragma once
 
 #include <wtf/Lock.h>
+#include <wtf/RefPtr.h>
 #include <wtf/RetainPtr.h>
+#include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/Threading.h>
 
 #if USE(CF)
@@ -44,24 +46,31 @@
 
 class HeapTimer {
 public:
+    HeapTimer(VM*);
 #if USE(CF)
-    HeapTimer(VM*, CFRunLoopRef);
     static void timerDidFire(CFRunLoopTimerRef, void*);
-#else
-    HeapTimer(VM*);
 #endif
     
     JS_EXPORT_PRIVATE virtual ~HeapTimer();
     virtual void doWork() = 0;
+
+    void scheduleTimer(double intervalInSeconds);
+    void cancelTimer();
+
+#if USE(CF)
+    JS_EXPORT_PRIVATE void setRunLoop(CFRunLoopRef);
+#endif // USE(CF)
     
 protected:
     VM* m_vm;
 
+    RefPtr<JSLock> m_apiLock;
 #if USE(CF)
     static const CFTimeInterval s_decade;
 
     RetainPtr<CFRunLoopTimerRef> m_timer;
     RetainPtr<CFRunLoopRef> m_runLoop;
+    
     CFRunLoopTimerContext m_context;
 
     Lock m_shutdownMutex;
@@ -72,7 +81,6 @@
     Ecore_Timer* m_timer;
 #elif USE(GLIB)
     void timerDidFire();
-    RefPtr<JSLock> m_apiLock;
     GRefPtr<GSource> m_timer;
 #endif
     

Modified: trunk/Source/_javascript_Core/heap/IncrementalSweeper.cpp (207854 => 207855)


--- trunk/Source/_javascript_Core/heap/IncrementalSweeper.cpp	2016-10-25 23:21:03 UTC (rev 207854)
+++ trunk/Source/_javascript_Core/heap/IncrementalSweeper.cpp	2016-10-25 23:22:48 UTC (rev 207855)
@@ -31,39 +31,19 @@
 #include "JSString.h"
 #include "MarkedBlock.h"
 #include "JSCInlines.h"
-
-#if PLATFORM(EFL)
-#include <Ecore.h>
 #include <wtf/CurrentTime.h>
-#elif USE(GLIB)
-#include <glib.h>
-#endif
 
 namespace JSC {
 
-#if USE(CF) || PLATFORM(EFL) || USE(GLIB)
-
 static const double sweepTimeSlice = .01; // seconds
 static const double sweepTimeTotal = .10;
 static const double sweepTimeMultiplier = 1.0 / sweepTimeTotal;
 
-#if USE(CF)
-IncrementalSweeper::IncrementalSweeper(Heap* heap, CFRunLoopRef runLoop)
-    : HeapTimer(heap->vm(), runLoop)
-    , m_currentAllocator(nullptr)
-{
-}
-
 void IncrementalSweeper::scheduleTimer()
 {
-    CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + (sweepTimeSlice * sweepTimeMultiplier));
+    HeapTimer::scheduleTimer(sweepTimeSlice * sweepTimeMultiplier);
 }
 
-void IncrementalSweeper::cancelTimer()
-{
-    CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + s_decade);
-}
-#elif PLATFORM(EFL)
 IncrementalSweeper::IncrementalSweeper(Heap* heap)
     : HeapTimer(heap->vm())
     , m_currentAllocator(nullptr)
@@ -70,41 +50,6 @@
 {
 }
 
-void IncrementalSweeper::scheduleTimer()
-{
-    if (ecore_timer_freeze_get(m_timer))
-        ecore_timer_thaw(m_timer);
-
-    double targetTime = currentTime() + (sweepTimeSlice * sweepTimeMultiplier);
-    ecore_timer_interval_set(m_timer, targetTime);
-}
-
-void IncrementalSweeper::cancelTimer()
-{
-    ecore_timer_freeze(m_timer);
-}
-#elif USE(GLIB)
-IncrementalSweeper::IncrementalSweeper(Heap* heap)
-    : HeapTimer(heap->vm())
-    , m_currentAllocator(nullptr)
-{
-}
-
-void IncrementalSweeper::scheduleTimer()
-{
-    auto delayDuration = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<double>(sweepTimeSlice * sweepTimeMultiplier));
-    gint64 currentTime = g_get_monotonic_time();
-    gint64 targetTime = currentTime + std::min<gint64>(G_MAXINT64 - currentTime, delayDuration.count());
-    ASSERT(targetTime >= currentTime);
-    g_source_set_ready_time(m_timer.get(), targetTime);
-}
-
-void IncrementalSweeper::cancelTimer()
-{
-    g_source_set_ready_time(m_timer.get(), -1);
-}
-#endif
-
 void IncrementalSweeper::doWork()
 {
     doSweep(WTF::monotonicallyIncreasingTime());
@@ -157,30 +102,4 @@
         cancelTimer();
 }
 
-#else
-
-IncrementalSweeper::IncrementalSweeper(Heap* heap)
-    : HeapTimer(heap->vm())
-{
-}
-
-void IncrementalSweeper::doWork()
-{
-}
-
-void IncrementalSweeper::startSweeping()
-{
-}
-
-void IncrementalSweeper::willFinishSweeping()
-{
-}
-
-bool IncrementalSweeper::sweepNextBlock()
-{
-    return false;
-}
-
-#endif
-
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/heap/IncrementalSweeper.h (207854 => 207855)


--- trunk/Source/_javascript_Core/heap/IncrementalSweeper.h	2016-10-25 23:21:03 UTC (rev 207854)
+++ trunk/Source/_javascript_Core/heap/IncrementalSweeper.h	2016-10-25 23:22:48 UTC (rev 207855)
@@ -36,11 +36,7 @@
 class IncrementalSweeper : public HeapTimer {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-#if USE(CF)
-    JS_EXPORT_PRIVATE IncrementalSweeper(Heap*, CFRunLoopRef);
-#else
-    explicit IncrementalSweeper(Heap*);
-#endif
+    JS_EXPORT_PRIVATE explicit IncrementalSweeper(Heap*);
 
     void startSweeping();
 
@@ -48,14 +44,11 @@
     bool sweepNextBlock();
     void willFinishSweeping();
 
-#if USE(CF) || PLATFORM(EFL) || USE(GLIB)
 private:
     void doSweep(double startTime);
     void scheduleTimer();
-    void cancelTimer();
     
     MarkedAllocator* m_currentAllocator;
-#endif
 };
 
 } // namespace JSC

Modified: trunk/Source/WebCore/ChangeLog (207854 => 207855)


--- trunk/Source/WebCore/ChangeLog	2016-10-25 23:21:03 UTC (rev 207854)
+++ trunk/Source/WebCore/ChangeLog	2016-10-25 23:22:48 UTC (rev 207855)
@@ -1,3 +1,15 @@
+2016-10-25  Filip Pizlo  <[email protected]>
+
+        HeapTimer should not hardcode all of its subclasses and USE(CF) shouldn't be a bizarre special case
+        https://bugs.webkit.org/show_bug.cgi?id=163947
+
+        Reviewed by Geoffrey Garen.
+
+        No new tests because no new behavior.
+
+        * platform/ios/WebSafeGCActivityCallbackIOS.h:
+        * platform/ios/WebSafeIncrementalSweeperIOS.h:
+
 2016-10-25  Dave Hyatt  <[email protected]>
 
         [CSS Parser] Improvements to selector parsing

Modified: trunk/Source/WebCore/platform/ios/WebSafeGCActivityCallbackIOS.h (207854 => 207855)


--- trunk/Source/WebCore/platform/ios/WebSafeGCActivityCallbackIOS.h	2016-10-25 23:21:03 UTC (rev 207854)
+++ trunk/Source/WebCore/platform/ios/WebSafeGCActivityCallbackIOS.h	2016-10-25 23:22:48 UTC (rev 207855)
@@ -43,8 +43,9 @@
 
 private:
     WebSafeFullGCActivityCallback(JSC::Heap* heap)
-        : JSC::FullGCActivityCallback(heap, WebThreadRunLoop())
+        : JSC::FullGCActivityCallback(heap)
     {
+        setRunLoop(WebThreadRunLoop());
     }
 };
 
@@ -59,8 +60,9 @@
 
 private:
     WebSafeEdenGCActivityCallback(JSC::Heap* heap)
-        : JSC::EdenGCActivityCallback(heap, WebThreadRunLoop())
+        : JSC::EdenGCActivityCallback(heap)
     {
+        setRunLoop(WebThreadRunLoop());
     }
 };
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/ios/WebSafeIncrementalSweeperIOS.h (207854 => 207855)


--- trunk/Source/WebCore/platform/ios/WebSafeIncrementalSweeperIOS.h	2016-10-25 23:21:03 UTC (rev 207854)
+++ trunk/Source/WebCore/platform/ios/WebSafeIncrementalSweeperIOS.h	2016-10-25 23:22:48 UTC (rev 207855)
@@ -34,8 +34,9 @@
 class WebSafeIncrementalSweeper final : public JSC::IncrementalSweeper {
 public:
     explicit WebSafeIncrementalSweeper(JSC::Heap* heap)
-        : JSC::IncrementalSweeper(heap, WebThreadRunLoop())
+        : JSC::IncrementalSweeper(heap)
     {
+        setRunLoop(WebThreadRunLoop());
     }
 
     ~WebSafeIncrementalSweeper() override { }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to