Changeset 91206 in webkit
- Timestamp:
- Jul 18, 2011 1:38:42 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r91199 r91206 1 2011-07-18 James Robinson <jamesr@chromium.org> 2 3 Timer scheduling should be based off the monotonic clock 4 https://bugs.webkit.org/show_bug.cgi?id=64544 5 6 Reviewed by Darin Adler. 7 8 Switches ThreadCondition::timedWait and related utility functions from currentTime() to 9 monotonicallyIncreasingTime(). 10 11 Add WTF::monotonicallyIncreasingTime() to list of exported functions so it can be accessed from WebCore/WebKit. 12 13 * JavaScriptCore.exp: 14 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: 15 * wtf/ThreadingPthreads.cpp: 16 (WTF::ThreadCondition::timedWait): 17 * wtf/ThreadingWin.cpp: 18 (WTF::absoluteTimeToWaitTimeoutInterval): 19 * wtf/gtk/ThreadingGtk.cpp: 20 (WTF::ThreadCondition::timedWait): 21 * wtf/qt/ThreadingQt.cpp: 22 (WTF::ThreadCondition::timedWait): 23 1 24 2011-07-18 Filip Pizlo <fpizlo@apple.com> 2 25 -
trunk/Source/JavaScriptCore/JavaScriptCore.exp
r91194 r91206 450 450 __ZN3WTF23dayInMonthFromDayInYearEib 451 451 __ZN3WTF23waitForThreadCompletionEjPPv 452 __ZN3WTF27monotonicallyIncreasingTimeEv 452 453 __ZN3WTF27releaseFastMallocFreeMemoryEv 453 454 __ZN3WTF28setMainThreadCallbacksPausedEb -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
r91194 r91206 241 241 ?lookupSetter@JSObject@JSC@@UAE?AVJSValue@2@PAVExecState@2@ABVIdentifier@2@@Z 242 242 ?materializePropertyMap@Structure@JSC@@AAEXAAVJSGlobalData@2@@Z 243 ?monotonicallyIncreasingTime@WTF@@YANXZ 243 244 ?monthFromDayInYear@WTF@@YAHH_N@Z 244 245 ?msToYear@WTF@@YAHN@Z -
trunk/Source/JavaScriptCore/wtf/ThreadingPthreads.cpp
r91094 r91206 364 364 bool ThreadCondition::timedWait(Mutex& mutex, double absoluteTime) 365 365 { 366 if (absoluteTime < currentTime())366 if (absoluteTime < monotonicallyIncreasingTime()) 367 367 return false; 368 368 -
trunk/Source/JavaScriptCore/wtf/ThreadingWin.cpp
r78597 r91206 484 484 DWORD absoluteTimeToWaitTimeoutInterval(double absoluteTime) 485 485 { 486 double currentTime = WTF::currentTime();486 double currentTime = monotonicallyIncreasingTime(); 487 487 488 488 // Time is in the past - return immediately. -
trunk/Source/JavaScriptCore/wtf/gtk/ThreadingGtk.cpp
r64384 r91206 214 214 { 215 215 // Time is in the past - return right away. 216 if (absoluteTime < currentTime())216 if (absoluteTime < monotonicallyIncreasingTime()) 217 217 return false; 218 218 -
trunk/Source/JavaScriptCore/wtf/qt/ThreadingQt.cpp
r64384 r91206 256 256 bool ThreadCondition::timedWait(Mutex& mutex, double absoluteTime) 257 257 { 258 double currentTime = WTF::currentTime();258 double currentTime = monotonicallyIncreasingTime(); 259 259 260 260 // Time is in the past - return immediately. -
trunk/Source/WebCore/ChangeLog
r91201 r91206 1 2011-07-18 James Robinson <jamesr@chromium.org> 2 3 Timer scheduling should be based off the monotonic clock 4 https://bugs.webkit.org/show_bug.cgi?id=64544 5 6 Reviewed by Darin Adler. 7 8 Changes the Timer scheduling logic from using absolute values in terms of currentTime() to using relative 9 intervals in terms of monotonicallyIncreasingTime(). This provides better standards compliance, compatibility, 10 and predictability when the system clock is adjusted. 11 12 No automated tests since there is no way to modify the system clock from DRT. 13 14 * platform/SharedTimer.h: 15 (WebCore::MainThreadSharedTimer::setFireInterval): 16 * platform/ThreadTimers.cpp: 17 (WebCore::ThreadTimers::updateSharedTimer): 18 (WebCore::ThreadTimers::sharedTimerFiredInternal): 19 * platform/Timer.cpp: 20 (WebCore::TimerBase::start): 21 (WebCore::TimerBase::nextFireInterval): 22 * platform/android/SharedTimerAndroid.cpp: 23 (WebCore::setSharedTimerFireInterval): 24 * platform/brew/SharedTimerBrew.cpp: 25 (WebCore::setSharedTimerFireInterval): 26 * platform/chromium/PlatformBridge.h: 27 * platform/chromium/SharedTimerChromium.cpp: 28 (WebCore::setSharedTimerFireInterval): 29 * platform/efl/SharedTimerEfl.cpp: 30 (WebCore::addNewTimer): 31 (WebCore::setSharedTimerFireInterval): 32 * platform/gtk/SharedTimerGtk.cpp: 33 (WebCore::setSharedTimerFireInterval): 34 * platform/haiku/SharedTimerHaiku.cpp: 35 (WebCore::SharedTimerHaiku::start): 36 (WebCore::setSharedTimerFireInterval): 37 * platform/mac/SharedTimerMac.mm: 38 (WebCore::setSharedTimerFireInterval): 39 * platform/qt/SharedTimerQt.cpp: 40 (WebCore::SharedTimerQt::start): 41 (WebCore::setSharedTimerFireInterval): 42 * platform/win/SharedTimerWin.cpp: 43 (WebCore::setSharedTimerFireInterval): 44 * platform/wince/SharedTimerWinCE.cpp: 45 (WebCore::setSharedTimerFireInterval): 46 * platform/wx/SharedTimerWx.cpp: 47 (WebCore::setSharedTimerFireInterval): 48 * workers/WorkerRunLoop.cpp: 49 (WebCore::WorkerSharedTimer::setFireInterval): 50 1 51 2011-07-18 Pratik Solanki <psolanki@apple.com> 2 52 -
trunk/Source/WebCore/platform/SharedTimer.h
r76248 r91206 42 42 virtual void setFiredFunction(void (*)()) = 0; 43 43 44 // The fire time is relative to the classic POSIX epoch of January 1, 1970, 45 // as the result of currentTime() is. 46 virtual void setFireTime(double) = 0; 44 // The fire interval is in seconds relative to the current monotonic clock time. 45 virtual void setFireInterval(double) = 0; 47 46 virtual void stop() = 0; 48 47 }; … … 52 51 // FIXME: make ports implement MainThreadSharedTimer directly instead. 53 52 void setSharedTimerFiredFunction(void (*)()); 54 void setSharedTimerFire Time(double);53 void setSharedTimerFireInterval(double); 55 54 void stopSharedTimer(); 56 55 … … 63 62 } 64 63 65 virtual void setFire Time(double fireTime)64 virtual void setFireInterval(double interval) 66 65 { 67 setSharedTimerFire Time(fireTime);66 setSharedTimerFireInterval(interval); 68 67 } 69 68 -
trunk/Source/WebCore/platform/ThreadTimers.cpp
r48086 r91206 32 32 #include "Timer.h" 33 33 #include <wtf/CurrentTime.h> 34 35 using namespace std; 34 36 35 37 namespace WebCore { … … 82 84 m_sharedTimer->stop(); 83 85 else 84 m_sharedTimer->setFire Time(m_timerHeap.first()->m_nextFireTime);86 m_sharedTimer->setFireInterval(max(m_timerHeap.first()->m_nextFireTime - monotonicallyIncreasingTime(), 0.0)); 85 87 } 86 88 … … 98 100 m_firingTimers = true; 99 101 100 double fireTime = currentTime();102 double fireTime = monotonicallyIncreasingTime(); 101 103 double timeToQuit = fireTime + maxDurationOfFiringTimers; 102 104 … … 113 115 114 116 // Catch the case where the timer asked timers to fire in a nested event loop, or we are over time limit. 115 if (!m_firingTimers || timeToQuit < currentTime())117 if (!m_firingTimers || timeToQuit < monotonicallyIncreasingTime()) 116 118 break; 117 119 } -
trunk/Source/WebCore/platform/Timer.cpp
r53514 r91206 182 182 183 183 m_repeatInterval = repeatInterval; 184 setNextFireTime( currentTime() + nextFireInterval);184 setNextFireTime(monotonicallyIncreasingTime() + nextFireInterval); 185 185 } 186 186 … … 200 200 { 201 201 ASSERT(isActive()); 202 double current = currentTime();202 double current = monotonicallyIncreasingTime(); 203 203 if (m_nextFireTime < current) 204 204 return 0; -
trunk/Source/WebCore/platform/android/SharedTimerAndroid.cpp
r51140 r91206 46 46 } 47 47 48 // The fire time is relative to the classic POSIX epoch of January 1, 1970, 49 // as the result of currentTime() is. 50 void setSharedTimerFireTime(double fireTime) 48 void setSharedTimerFireInterval(double interval) 51 49 { 52 long long timeInMs = static_cast<long long>( (fireTime - WTF::currentTime())* 1000);50 long long timeInMs = static_cast<long long>(interval * 1000); 53 51 54 LOGV("setSharedTimerFire Time: in %ld millisec", timeInMs);52 LOGV("setSharedTimerFireInterval: in %ld millisec", timeInMs); 55 53 if (JavaSharedClient::GetTimerClient()) 56 54 JavaSharedClient::GetTimerClient()->setSharedTimer(timeInMs); -
trunk/Source/WebCore/platform/brew/SharedTimerBrew.cpp
r54200 r91206 49 49 } 50 50 51 void setSharedTimerFire Time(double fireTime)51 void setSharedTimerFireInterval(double interval) 52 52 { 53 53 ASSERT(sharedTimerFiredFunction); … … 55 55 CALLBACK_Cancel(&sharedTimerCallback); 56 56 57 double interval = fireTime - currentTime(); 58 int intervalInMS; 59 60 if (interval < 0) 61 intervalInMS = 0; 62 else { 63 interval *= 1000; 64 intervalInMS = static_cast<int>(interval); 65 } 57 int intervalInMS = statit_cast<int>(interval * 1000); 66 58 67 59 sharedTimerCallback.pfnCancel = 0; -
trunk/Source/WebCore/platform/chromium/PlatformBridge.h
r90952 r91206 235 235 // SharedTimers ------------------------------------------------------- 236 236 static void setSharedTimerFiredFunction(void (*func)()); 237 static void setSharedTimerFire Time(double);237 static void setSharedTimerFireInterval(double); 238 238 static void stopSharedTimer(); 239 239 -
trunk/Source/WebCore/platform/chromium/SharedTimerChromium.cpp
r76340 r91206 36 36 } 37 37 38 void setSharedTimerFire Time(double fireTime)38 void setSharedTimerFireInterval(double fireTime) 39 39 { 40 PlatformBridge::setSharedTimerFire Time(fireTime);40 PlatformBridge::setSharedTimerFireInterval(fireTime); 41 41 } 42 42 -
trunk/Source/WebCore/platform/efl/SharedTimerEfl.cpp
r89697 r91206 63 63 } 64 64 65 void addNewTimer(double fireTime)65 void addNewTimer(double interval) 66 66 { 67 double interval = fireTime - currentTime();68 67 stopSharedTimer(); 69 68 … … 71 70 } 72 71 73 void setSharedTimerFire Time(double fireTime)72 void setSharedTimerFireInterval(double interval) 74 73 { 75 addNewTimer( fireTime);74 addNewTimer(interval); 76 75 } 77 76 -
trunk/Source/WebCore/platform/gtk/SharedTimerGtk.cpp
r65438 r91206 51 51 } 52 52 53 void setSharedTimerFire Time(double fireTime)53 void setSharedTimerFireInterval(double interval) 54 54 { 55 55 ASSERT(sharedTimerFiredFunction); 56 56 57 double interval = fireTime - currentTime(); 58 guint intervalInMS; 59 if (interval < 0) 60 intervalInMS = 0; 61 else { 62 interval *= 1000; 63 intervalInMS = (guint)interval; 64 } 57 guint intervalInMS = static_cast<guint>(interval * 1000); 65 58 66 59 stopSharedTimer(); -
trunk/Source/WebCore/platform/haiku/SharedTimerHaiku.cpp
r47480 r91206 83 83 } 84 84 85 void SharedTimerHaiku::start(double fireTime)85 void SharedTimerHaiku::start(double intervalInSeconds) 86 86 { 87 87 m_shouldRun = true; 88 88 89 double intervalInSeconds = fireTime - currentTime(); 90 bigtime_t intervalInMicroSeconds = intervalInSeconds < 0 ? 0 : intervalInSeconds * 1000000; 89 bigtime_t intervalInMicroSeconds = intervalInSeconds * 1000000; 91 90 92 91 BMessageRunner::StartSending(Looper(), new BMessage(FIRE_MESSAGE), intervalInMicroSeconds, 1); … … 112 111 } 113 112 114 void setSharedTimerFire Time(double fireTime)113 void setSharedTimerFireInterval(double interval) 115 114 { 116 SharedTimerHaiku::instance()->start( fireTime);115 SharedTimerHaiku::instance()->start(interval); 117 116 } 118 117 -
trunk/Source/WebCore/platform/mac/SharedTimerMac.mm
r85036 r91206 168 168 } 169 169 170 void setSharedTimerFire Time(double fireTime)170 void setSharedTimerFireInterval(double interval) 171 171 { 172 172 ASSERT(sharedTimerFiredFunction); … … 177 177 } 178 178 179 CFAbsoluteTime fireDate = fireTime - kCFAbsoluteTimeIntervalSince1970;179 CFAbsoluteTime fireDate = CFAbsoluteTimeGetCurrent() + interval; 180 180 sharedTimer = CFRunLoopTimerCreate(0, fireDate, 0, 0, 0, timerFired, 0); 181 181 CFRunLoopAddTimer(CFRunLoopGetCurrent(), sharedTimer, kCFRunLoopCommonModes); -
trunk/Source/WebCore/platform/qt/SharedTimerQt.cpp
r78490 r91206 93 93 } 94 94 95 void SharedTimerQt::start(double fireTime)95 void SharedTimerQt::start(double interval) 96 96 { 97 double interval = fireTime - currentTime(); 98 unsigned int intervalInMS; 99 if (interval < 0) 100 intervalInMS = 0; 101 else { 102 interval *= 1000; 103 intervalInMS = (unsigned int)interval; 104 } 97 unsigned int intervalInMS = static_cast<unsigned int>(interval * 1000); 105 98 106 99 m_timer.start(intervalInMS, this); … … 129 122 } 130 123 131 void setSharedTimerFire Time(double fireTime)124 void setSharedTimerFireInterval(double interval) 132 125 { 133 126 if (!QCoreApplication::instance()) 134 127 return; 135 128 136 SharedTimerQt::inst()->start( fireTime);129 SharedTimerQt::inst()->start(interval); 137 130 } 138 131 -
trunk/Source/WebCore/platform/win/SharedTimerWin.cpp
r55542 r91206 147 147 } 148 148 149 void setSharedTimerFire Time(double fireTime)149 void setSharedTimerFireInterval(double interval) 150 150 { 151 151 ASSERT(sharedTimerFiredFunction); 152 152 153 double interval = fireTime - currentTime();154 153 unsigned intervalInMS; 155 if (interval < 0) 156 intervalInMS = 0; 157 else { 158 interval *= 1000; 159 if (interval > USER_TIMER_MAXIMUM) 160 intervalInMS = USER_TIMER_MAXIMUM; 161 else 162 intervalInMS = (unsigned)interval; 163 } 154 interval *= 1000; 155 if (interval > USER_TIMER_MAXIMUM) 156 intervalInMS = USER_TIMER_MAXIMUM; 157 else 158 intervalInMS = static_cast<unsigned>(interval); 164 159 165 160 initializeOffScreenTimerWindow(); -
trunk/Source/WebCore/platform/wince/SharedTimerWinCE.cpp
r75190 r91206 89 89 #define USER_TIMER_MINIMUM 0x0000000A 90 90 91 void setSharedTimerFire Time(double fireTime)91 void setSharedTimerFireInterval(double intervalSeconds) 92 92 { 93 93 ASSERT(sharedTimerFiredFunction); 94 94 95 double interval = (fireTime - currentTime())* 1000.;96 unsigned intervalInMS = interval< USER_TIMER_MINIMUM95 double intervalMS = intervalSeconds * 1000.; 96 unsigned clampedIntervalMS = intervalMS < USER_TIMER_MINIMUM 97 97 ? USER_TIMER_MINIMUM 98 : interval > USER_TIMER_MAXIMUM98 : intervalMS > USER_TIMER_MAXIMUM 99 99 ? USER_TIMER_MAXIMUM 100 : static_cast<unsigned>(interval );100 : static_cast<unsigned>(intervalMS); 101 101 102 102 if (timerID == TimerIdAuto) { … … 106 106 107 107 initializeOffScreenTimerWindow(); 108 if (SetTimer(timerWindowHandle, TimerIdAuto, intervalInMS, 0))108 if (SetTimer(timerWindowHandle, TimerIdAuto, clampedIntervalMS, 0)) 109 109 timerID = TimerIdAuto; 110 110 else if (timerID != TimerIdManual) -
trunk/Source/WebCore/platform/wx/SharedTimerWx.cpp
r86485 r91206 68 68 } 69 69 70 void setSharedTimerFire Time(double fireTime)70 void setSharedTimerFireInterval(double interval) 71 71 { 72 72 ASSERT(sharedTimerFiredFunction); 73 74 double interval = fireTime - currentTime();75 73 76 74 if (!wkTimer) -
trunk/Source/WebCore/workers/WorkerRunLoop.cpp
r84892 r91206 40 40 #include "WorkerContext.h" 41 41 #include "WorkerThread.h" 42 #include <wtf/CurrentTime.h> 42 43 43 44 namespace WebCore { … … 53 54 // SharedTimer interface. 54 55 virtual void setFiredFunction(void (*function)()) { m_sharedTimerFunction = function; } 55 virtual void setFire Time(double fireTime) { m_nextFireTime = fireTime; }56 virtual void setFireInterval(double interval) { m_nextFireTime = interval + monotonicallyIncreasingTime(); } 56 57 virtual void stop() { m_nextFireTime = 0; } 57 58 -
trunk/Source/WebKit/chromium/ChangeLog
r91205 r91206 1 2011-07-18 James Robinson <jamesr@chromium.org> 2 3 Timer scheduling should be based off the monotonic clock 4 https://bugs.webkit.org/show_bug.cgi?id=64544 5 6 Reviewed by Darin Adler. 7 8 Renames setSharedTimerFireTime to setSharedTimerFireInterval to be consistent with WebCore. 9 10 * public/WebKitClient.h: 11 (WebKit::WebKitClient::setSharedTimerFireInterval): 12 * src/PlatformBridge.cpp: 13 (WebCore::PlatformBridge::setSharedTimerFireInterval): 14 1 15 2011-07-18 Yuzhu Shen <yzshen@chromium.com> 2 16 -
trunk/Source/WebKit/chromium/public/WebKitClient.h
r88745 r91206 48 48 #endif 49 49 50 // FIXME: remove after rolling deps 51 #define WEBKIT_USE_MONOTONIC_CLOCK_FOR_TIMER_SCHEDULING 52 50 53 namespace WebKit { 51 54 … … 281 284 typedef void (*SharedTimerFunction)(); 282 285 virtual void setSharedTimerFiredFunction(SharedTimerFunction timerFunction) { } 283 virtual void setSharedTimerFire Time(double fireTime) { }286 virtual void setSharedTimerFireInterval(double) { } 284 287 virtual void stopSharedTimer() { } 285 288 -
trunk/Source/WebKit/chromium/src/PlatformBridge.cpp
r90952 r91206 666 666 } 667 667 668 void PlatformBridge::setSharedTimerFire Time(double fireTime)669 { 670 webKitClient()->setSharedTimerFire Time(fireTime);668 void PlatformBridge::setSharedTimerFireInterval(double interval) 669 { 670 webKitClient()->setSharedTimerFireInterval(interval); 671 671 } 672 672 -
trunk/Source/WebKit2/ChangeLog
r91188 r91206 1 2011-07-18 James Robinson <jamesr@chromium.org> 2 3 Timer scheduling should be based off the monotonic clock 4 https://bugs.webkit.org/show_bug.cgi?id=64544 5 6 Reviewed by Darin Adler. 7 8 Converts the WebKit2 RunLoop and CoreIPC timeouts to use monotonicallyIncreasingTime(). 9 10 * Platform/CoreIPC/Connection.cpp: 11 (CoreIPC::Connection::waitForMessage): 12 (CoreIPC::Connection::waitForSyncReply): 13 * Platform/RunLoop.h: 14 1 15 2011-07-18 Anders Carlsson <andersca@apple.com> 2 16 -
trunk/Source/WebKit2/Platform/CoreIPC/Connection.cpp
r89771 r91206 345 345 } 346 346 347 double absoluteTime = currentTime() + timeout;347 double absoluteTime = monotonicallyIncreasingTime() + timeout; 348 348 349 349 std::pair<unsigned, uint64_t> messageAndDestination(std::make_pair(messageID.toInt(), destinationID)); … … 436 436 timeout = 1e10; 437 437 438 double absoluteTime = currentTime() + timeout;438 double absoluteTime = monotonicallyIncreasingTime() + timeout; 439 439 440 440 bool timedOut = false; -
trunk/Source/WebKit2/Platform/RunLoop.h
r84886 r91206 59 59 60 60 #if PLATFORM(WIN) 61 // The absoluteTime is in seconds, starting on January 1, 1970. The time is assumed to use the 62 // same time zone as WTF::currentTime(). Dispatches sent (not posted) messages to the passed-in 61 // The absoluteTime is in seconds in terms of the monotonic clock. Dispatches sent (not posted) messages to the passed-in 63 62 // set of HWNDs until the semaphore is signaled or absoluteTime is reached. Returns true if the 64 63 // semaphore is signaled, false otherwise.
Note: See TracChangeset
for help on using the changeset viewer.