Skip to content

Commit e4d16db

Browse files
committed
[JSC][GTK] glib RunLoop does not accept negative start interval
https://bugs.webkit.org/show_bug.cgi?id=170775 Reviewed by Saam Barati. Source/JavaScriptCore: * heap/GCActivityCallback.cpp: (JSC::GCActivityCallback::scheduleTimer): Source/WTF: RunLoop::Timer for glib does not accept negative start interval. We use 0_s if the given value is negative. * wtf/glib/RunLoopGLib.cpp: (WTF::RunLoop::TimerBase::secondsUntilFire): Canonical link: https://commits.webkit.org/187862@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215454 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 3998a1d commit e4d16db

5 files changed

Lines changed: 37 additions & 6 deletions

File tree

‎Source/JavaScriptCore/ChangeLog‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2017-04-18 Yusuke Suzuki <utatane.tea@gmail.com>
2+
3+
[JSC][GTK] glib RunLoop does not accept negative start interval
4+
https://bugs.webkit.org/show_bug.cgi?id=170775
5+
6+
Reviewed by Saam Barati.
7+
8+
* heap/GCActivityCallback.cpp:
9+
(JSC::GCActivityCallback::scheduleTimer):
10+
111
2017-04-17 Saam Barati <sbarati@apple.com>
212

313
BytecodeGenerator ".call" and ".apply" is exponential in nesting depth

‎Source/JavaScriptCore/heap/GCActivityCallback.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void GCActivityCallback::scheduleTimer(Seconds newDelay)
8989
m_delay = newDelay;
9090

9191
Seconds secondsUntilFire = m_timer.secondsUntilFire();
92-
m_timer.startOneShot(secondsUntilFire - delta);
92+
m_timer.startOneShot(std::max<Seconds>(secondsUntilFire - delta, 0_s));
9393
}
9494

9595
void GCActivityCallback::cancelTimer()

‎Source/WTF/ChangeLog‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2017-04-18 Yusuke Suzuki <utatane.tea@gmail.com>
2+
3+
[JSC][GTK] glib RunLoop does not accept negative start interval
4+
https://bugs.webkit.org/show_bug.cgi?id=170775
5+
6+
Reviewed by Saam Barati.
7+
8+
RunLoop::Timer for glib does not accept negative start interval.
9+
We use 0_s if the given value is negative.
10+
11+
* wtf/glib/RunLoopGLib.cpp:
12+
(WTF::RunLoop::TimerBase::secondsUntilFire):
13+
114
2017-04-17 Alex Christensen <achristensen@webkit.org>
215

316
Allow Variants of RetainPtrs

‎Source/WTF/wtf/RunLoop.h‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ class RunLoop : public FunctionDispatcher {
8484
WTF_EXPORT_PRIVATE explicit TimerBase(RunLoop&);
8585
WTF_EXPORT_PRIVATE virtual ~TimerBase();
8686

87-
void startRepeating(double repeatInterval) { start(repeatInterval, true); }
87+
void startRepeating(double repeatInterval) { startInternal(repeatInterval, true); }
8888
void startRepeating(std::chrono::milliseconds repeatInterval) { startRepeating(repeatInterval.count() * 0.001); }
8989
void startRepeating(Seconds repeatInterval) { startRepeating(repeatInterval.value()); }
90-
void startOneShot(double interval) { start(interval, false); }
91-
void startOneShot(std::chrono::milliseconds interval) { start(interval.count() * 0.001, false); }
92-
void startOneShot(Seconds interval) { start(interval.value(), false); }
90+
void startOneShot(double interval) { startInternal(interval, false); }
91+
void startOneShot(std::chrono::milliseconds interval) { startOneShot(interval.count() * 0.001); }
92+
void startOneShot(Seconds interval) { startOneShot(interval.value()); }
9393

9494
WTF_EXPORT_PRIVATE void stop();
9595
WTF_EXPORT_PRIVATE bool isActive() const;
@@ -103,6 +103,11 @@ class RunLoop : public FunctionDispatcher {
103103
#endif
104104

105105
private:
106+
void startInternal(double nextFireInterval, bool repeat)
107+
{
108+
start(std::max(nextFireInterval, 0.0), repeat);
109+
}
110+
106111
WTF_EXPORT_PRIVATE void start(double nextFireInterval, bool repeat);
107112

108113
Ref<RunLoop> m_runLoop;

‎Source/WTF/wtf/glib/RunLoopGLib.cpp‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,10 @@ bool RunLoop::TimerBase::isActive() const
218218

219219
Seconds RunLoop::TimerBase::secondsUntilFire() const
220220
{
221-
return std::max<Seconds>(Seconds::fromMicroseconds(g_source_get_ready_time(m_source.get()) - g_get_monotonic_time()), 0_s);
221+
gint64 time = g_source_get_ready_time(m_source.get());
222+
if (time != -1)
223+
return std::max<Seconds>(Seconds::fromMicroseconds(time - g_get_monotonic_time()), 0_s);
224+
return 0_s;
222225
}
223226

224227
} // namespace WTF

0 commit comments

Comments
 (0)