Changeset 243022 in webkit


Ignore:
Timestamp:
Mar 15, 2019, 4:12:12 PM (6 years ago)
Author:
rniwa@webkit.org
Message:

REGRESSION (r239814): Most classes that user Timer have 7 bytes of padding after the Timer
https://bugs.webkit.org/show_bug.cgi?id=194196

Reviewed by Simon Fraser.

Use std::nan as the value of m_unalignedNextFireTime to indicate the timer had been deleted
instead of having a dedicated boolean, which consumes 7 extra bytes for padding.

Note that some code in WebKit uses +Infinity as a fire time so we can't use that.

  • platform/Timer.cpp:

(WebCore::TimerBase::TimerBase):
(WebCore::TimerBase::~TimerBase):
(WebCore::TimerBase::setNextFireTime):
(WebCore::TimerBase::nextUnalignedFireInterval const):

  • platform/Timer.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243019 r243022  
     12019-03-15  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        REGRESSION (r239814): Most classes that user Timer have 7 bytes of padding after the Timer
     4        https://bugs.webkit.org/show_bug.cgi?id=194196
     5
     6        Reviewed by Simon Fraser.
     7
     8        Use std::nan as the value of m_unalignedNextFireTime to indicate the timer had been deleted
     9        instead of having a dedicated boolean, which consumes 7 extra bytes for padding.
     10
     11        Note that some code in WebKit uses +Infinity as a fire time so we can't use that.
     12
     13        * platform/Timer.cpp:
     14        (WebCore::TimerBase::TimerBase):
     15        (WebCore::TimerBase::~TimerBase):
     16        (WebCore::TimerBase::setNextFireTime):
     17        (WebCore::TimerBase::nextUnalignedFireInterval const):
     18        * platform/Timer.h:
     19
    1202019-03-15  Sihui Liu  <sihui_liu@apple.com>
    221
  • trunk/Source/WebCore/platform/Timer.cpp

    r241113 r243022  
    255255
    256256TimerBase::TimerBase()
    257     : m_wasDeleted(false)
    258257{
    259258}
     
    265264    stop();
    266265    ASSERT(!inHeap());
    267     if (m_heapItem) {
     266    if (m_heapItem)
    268267        m_heapItem->clearTimer();
    269         m_heapItem = nullptr;
    270     }
    271     m_wasDeleted = true;
     268    m_unalignedNextFireTime = MonotonicTime::nan();
    272269}
    273270
     
    468465    ASSERT(canAccessThreadLocalDataForThread(m_thread.get()));
    469466    RELEASE_ASSERT(canAccessThreadLocalDataForThread(m_thread.get()) || shouldSuppressThreadSafetyCheck());
    470     RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!m_wasDeleted);
    471 
    472     if (m_unalignedNextFireTime != newTime)
     467    bool timerHasBeenDeleted = std::isnan(m_unalignedNextFireTime);
     468    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!timerHasBeenDeleted);
     469
     470    if (m_unalignedNextFireTime != newTime) {
     471        RELEASE_ASSERT(!std::isnan(newTime));
    473472        m_unalignedNextFireTime = newTime;
     473    }
    474474
    475475    // Keep heap valid while changing the next-fire time.
     
    518518{
    519519    ASSERT(isActive());
    520     return std::max(m_unalignedNextFireTime - MonotonicTime::now(), 0_s);
     520    auto result = std::max(m_unalignedNextFireTime - MonotonicTime::now(), 0_s);
     521    RELEASE_ASSERT(std::isfinite(result));
     522    return result;
    521523}
    522524
  • trunk/Source/WebCore/platform/Timer.h

    r241113 r243022  
    9797    MonotonicTime m_unalignedNextFireTime; // m_nextFireTime not considering alignment interval
    9898    Seconds m_repeatInterval; // 0 if not repeating
    99     bool m_wasDeleted { false };
    10099
    101100    RefPtr<ThreadTimerHeapItem> m_heapItem;
Note: See TracChangeset for help on using the changeset viewer.