| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 TimerHeapReference& operator=(TimerHeapReference); | 70 TimerHeapReference& operator=(TimerHeapReference); |
| 71 private: | 71 private: |
| 72 TimerBase*& m_reference; | 72 TimerBase*& m_reference; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 inline TimerHeapReference TimerHeapPointer::operator*() const | 75 inline TimerHeapReference TimerHeapPointer::operator*() const |
| 76 { | 76 { |
| 77 return *m_pointer; | 77 return *m_pointer; |
| 78 } | 78 } |
| 79 | 79 |
| 80 NO_SANITIZE_ADDRESS |
| 80 inline TimerHeapReference& TimerHeapReference::operator=(TimerBase* timer) | 81 inline TimerHeapReference& TimerHeapReference::operator=(TimerBase* timer) |
| 81 { | 82 { |
| 82 m_reference = timer; | 83 m_reference = timer; |
| 83 Vector<TimerBase*>& heap = timer->timerHeap(); | 84 Vector<TimerBase*>& heap = timer->timerHeap(); |
| 84 if (&m_reference >= heap.data() && &m_reference < heap.data() + heap.size()) | 85 if (&m_reference >= heap.data() && &m_reference < heap.data() + heap.size()) |
| 85 timer->m_heapIndex = &m_reference - heap.data(); | 86 timer->m_heapIndex = &m_reference - heap.data(); |
| 86 return *this; | 87 return *this; |
| 87 } | 88 } |
| 88 | 89 |
| 90 NO_SANITIZE_ADDRESS |
| 89 inline TimerHeapReference& TimerHeapReference::operator=(TimerHeapReference b) | 91 inline TimerHeapReference& TimerHeapReference::operator=(TimerHeapReference b) |
| 90 { | 92 { |
| 91 TimerBase* timer = b; | 93 TimerBase* timer = b; |
| 92 return *this = timer; | 94 return *this = timer; |
| 93 } | 95 } |
| 94 | 96 |
| 95 inline void swap(TimerHeapReference a, TimerHeapReference b) | 97 inline void swap(TimerHeapReference a, TimerHeapReference b) |
| 96 { | 98 { |
| 97 TimerBase* timerA = a; | 99 TimerBase* timerA = a; |
| 98 TimerBase* timerB = b; | 100 TimerBase* timerB = b; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 inline TimerHeapIterator operator-(TimerHeapIterator a, size_t b) { return Timer
HeapIterator(a.m_pointer - b); } | 163 inline TimerHeapIterator operator-(TimerHeapIterator a, size_t b) { return Timer
HeapIterator(a.m_pointer - b); } |
| 162 inline ptrdiff_t operator-(TimerHeapIterator a, TimerHeapIterator b) { return a.
m_pointer - b.m_pointer; } | 164 inline ptrdiff_t operator-(TimerHeapIterator a, TimerHeapIterator b) { return a.
m_pointer - b.m_pointer; } |
| 163 | 165 |
| 164 // ---------------- | 166 // ---------------- |
| 165 | 167 |
| 166 class TimerHeapLessThanFunction { | 168 class TimerHeapLessThanFunction { |
| 167 public: | 169 public: |
| 168 bool operator()(const TimerBase*, const TimerBase*) const; | 170 bool operator()(const TimerBase*, const TimerBase*) const; |
| 169 }; | 171 }; |
| 170 | 172 |
| 173 NO_SANITIZE_ADDRESS |
| 171 inline bool TimerHeapLessThanFunction::operator()(const TimerBase* a, const Time
rBase* b) const | 174 inline bool TimerHeapLessThanFunction::operator()(const TimerBase* a, const Time
rBase* b) const |
| 172 { | 175 { |
| 173 // The comparisons below are "backwards" because the heap puts the largest | 176 // The comparisons below are "backwards" because the heap puts the largest |
| 174 // element first and we want the lowest time to be the first one in the heap
. | 177 // element first and we want the lowest time to be the first one in the heap
. |
| 175 double aFireTime = a->m_nextFireTime; | 178 double aFireTime = a->m_nextFireTime; |
| 176 double bFireTime = b->m_nextFireTime; | 179 double bFireTime = b->m_nextFireTime; |
| 177 if (bFireTime != aFireTime) | 180 if (bFireTime != aFireTime) |
| 178 return bFireTime < aFireTime; | 181 return bFireTime < aFireTime; |
| 179 | 182 |
| 180 // We need to look at the difference of the insertion orders instead of comp
aring the two | 183 // We need to look at the difference of the insertion orders instead of comp
aring the two |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 } | 286 } |
| 284 | 287 |
| 285 inline void TimerBase::heapInsert() | 288 inline void TimerBase::heapInsert() |
| 286 { | 289 { |
| 287 ASSERT(!inHeap()); | 290 ASSERT(!inHeap()); |
| 288 timerHeap().append(this); | 291 timerHeap().append(this); |
| 289 m_heapIndex = timerHeap().size() - 1; | 292 m_heapIndex = timerHeap().size() - 1; |
| 290 heapDecreaseKey(); | 293 heapDecreaseKey(); |
| 291 } | 294 } |
| 292 | 295 |
| 296 NO_SANITIZE_ADDRESS |
| 293 inline void TimerBase::heapPop() | 297 inline void TimerBase::heapPop() |
| 294 { | 298 { |
| 295 // Temporarily force this timer to have the minimum key so we can pop it. | 299 // Temporarily force this timer to have the minimum key so we can pop it. |
| 296 double fireTime = m_nextFireTime; | 300 double fireTime = m_nextFireTime; |
| 297 m_nextFireTime = -std::numeric_limits<double>::infinity(); | 301 m_nextFireTime = -std::numeric_limits<double>::infinity(); |
| 298 heapDecreaseKey(); | 302 heapDecreaseKey(); |
| 299 heapPopMin(); | 303 heapPopMin(); |
| 300 m_nextFireTime = fireTime; | 304 m_nextFireTime = fireTime; |
| 301 } | 305 } |
| 302 | 306 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 setNextFireTime(m_unalignedNextFireTime); | 404 setNextFireTime(m_unalignedNextFireTime); |
| 401 } | 405 } |
| 402 | 406 |
| 403 double TimerBase::nextUnalignedFireInterval() const | 407 double TimerBase::nextUnalignedFireInterval() const |
| 404 { | 408 { |
| 405 ASSERT(isActive()); | 409 ASSERT(isActive()); |
| 406 return std::max(m_unalignedNextFireTime - monotonicallyIncreasingTime(), 0.0
); | 410 return std::max(m_unalignedNextFireTime - monotonicallyIncreasingTime(), 0.0
); |
| 407 } | 411 } |
| 408 | 412 |
| 409 } // namespace blink | 413 } // namespace blink |
| OLD | NEW |