Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: Source/platform/Timer.cpp

Issue 1148943003: Oilpan: more lazy sweep ASan exemptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« Source/platform/Timer.h ('K') | « Source/platform/Timer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 TimerHeapIterator operator--(int) { checkConsistency(-1); return TimerHeapIt erator(m_pointer--); } 120 TimerHeapIterator operator--(int) { checkConsistency(-1); return TimerHeapIt erator(m_pointer--); }
121 121
122 TimerHeapIterator& operator+=(ptrdiff_t i) { checkConsistency(); m_pointer + = i; checkConsistency(); return *this; } 122 TimerHeapIterator& operator+=(ptrdiff_t i) { checkConsistency(); m_pointer + = i; checkConsistency(); return *this; }
123 TimerHeapIterator& operator-=(ptrdiff_t i) { checkConsistency(); m_pointer - = i; checkConsistency(); return *this; } 123 TimerHeapIterator& operator-=(ptrdiff_t i) { checkConsistency(); m_pointer - = i; checkConsistency(); return *this; }
124 124
125 TimerHeapReference operator*() const { return TimerHeapReference(*m_pointer) ; } 125 TimerHeapReference operator*() const { return TimerHeapReference(*m_pointer) ; }
126 TimerHeapReference operator[](ptrdiff_t i) const { return TimerHeapReference (m_pointer[i]); } 126 TimerHeapReference operator[](ptrdiff_t i) const { return TimerHeapReference (m_pointer[i]); }
127 TimerBase* operator->() const { return *m_pointer; } 127 TimerBase* operator->() const { return *m_pointer; }
128 128
129 private: 129 private:
130 NO_LAZY_SWEEP_SANITIZE_ADDRESS
130 void checkConsistency(ptrdiff_t offset = 0) const 131 void checkConsistency(ptrdiff_t offset = 0) const
131 { 132 {
132 ASSERT(m_pointer >= threadGlobalTimerHeap().data()); 133 ASSERT(m_pointer >= threadGlobalTimerHeap().data());
133 ASSERT(m_pointer <= threadGlobalTimerHeap().data() + threadGlobalTimerHe ap().size()); 134 ASSERT(m_pointer <= threadGlobalTimerHeap().data() + threadGlobalTimerHe ap().size());
134 ASSERT_UNUSED(offset, m_pointer + offset >= threadGlobalTimerHeap().data ()); 135 ASSERT_UNUSED(offset, m_pointer + offset >= threadGlobalTimerHeap().data ());
135 ASSERT_UNUSED(offset, m_pointer + offset <= threadGlobalTimerHeap().data () + threadGlobalTimerHeap().size()); 136 ASSERT_UNUSED(offset, m_pointer + offset <= threadGlobalTimerHeap().data () + threadGlobalTimerHeap().size());
136 } 137 }
137 138
138 friend bool operator==(TimerHeapIterator, TimerHeapIterator); 139 friend bool operator==(TimerHeapIterator, TimerHeapIterator);
139 friend bool operator!=(TimerHeapIterator, TimerHeapIterator); 140 friend bool operator!=(TimerHeapIterator, TimerHeapIterator);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 231
231 double TimerBase::nextFireInterval() const 232 double TimerBase::nextFireInterval() const
232 { 233 {
233 ASSERT(isActive()); 234 ASSERT(isActive());
234 double current = monotonicallyIncreasingTime(); 235 double current = monotonicallyIncreasingTime();
235 if (m_nextFireTime < current) 236 if (m_nextFireTime < current)
236 return 0; 237 return 0;
237 return m_nextFireTime - current; 238 return m_nextFireTime - current;
238 } 239 }
239 240
241 NO_LAZY_SWEEP_SANITIZE_ADDRESS
240 inline void TimerBase::checkHeapIndex() const 242 inline void TimerBase::checkHeapIndex() const
241 { 243 {
242 ASSERT(timerHeap() == threadGlobalTimerHeap()); 244 ASSERT(timerHeap() == threadGlobalTimerHeap());
243 ASSERT(!timerHeap().isEmpty()); 245 ASSERT(!timerHeap().isEmpty());
244 ASSERT(m_heapIndex >= 0); 246 ASSERT(m_heapIndex >= 0);
245 ASSERT(m_heapIndex < static_cast<int>(timerHeap().size())); 247 ASSERT(m_heapIndex < static_cast<int>(timerHeap().size()));
246 ASSERT(timerHeap()[m_heapIndex] == this); 248 ASSERT(timerHeap()[m_heapIndex] == this);
247 } 249 }
248 250
249 inline void TimerBase::checkConsistency() const 251 inline void TimerBase::checkConsistency() const
250 { 252 {
251 // Timers should be in the heap if and only if they have a non-zero next fir e time. 253 // Timers should be in the heap if and only if they have a non-zero next fir e time.
252 ASSERT(inHeap() == (m_nextFireTime != 0)); 254 ASSERT(inHeap() == (m_nextFireTime != 0));
253 if (inHeap()) 255 if (inHeap())
254 checkHeapIndex(); 256 checkHeapIndex();
255 } 257 }
256 258
257 void TimerBase::heapDecreaseKey() 259 void TimerBase::heapDecreaseKey()
258 { 260 {
259 ASSERT(m_nextFireTime != 0); 261 ASSERT(m_nextFireTime != 0);
260 checkHeapIndex(); 262 checkHeapIndex();
261 TimerBase** heapData = timerHeap().data(); 263 TimerBase** heapData = timerHeap().data();
262 push_heap(TimerHeapIterator(heapData), TimerHeapIterator(heapData + m_heapIn dex + 1), TimerHeapLessThanFunction()); 264 push_heap(TimerHeapIterator(heapData), TimerHeapIterator(heapData + m_heapIn dex + 1), TimerHeapLessThanFunction());
263 checkHeapIndex(); 265 checkHeapIndex();
264 } 266 }
265 267
268 NO_LAZY_SWEEP_SANITIZE_ADDRESS
266 inline void TimerBase::heapDelete() 269 inline void TimerBase::heapDelete()
267 { 270 {
268 ASSERT(m_nextFireTime == 0); 271 ASSERT(m_nextFireTime == 0);
269 heapPop(); 272 heapPop();
270 timerHeap().removeLast(); 273 timerHeap().removeLast();
271 m_heapIndex = -1; 274 m_heapIndex = -1;
272 } 275 }
273 276
277 NO_LAZY_SWEEP_SANITIZE_ADDRESS
274 void TimerBase::heapDeleteMin() 278 void TimerBase::heapDeleteMin()
275 { 279 {
276 ASSERT(m_nextFireTime == 0); 280 ASSERT(m_nextFireTime == 0);
277 heapPopMin(); 281 heapPopMin();
278 timerHeap().removeLast(); 282 timerHeap().removeLast();
279 m_heapIndex = -1; 283 m_heapIndex = -1;
280 } 284 }
281 285
282 inline void TimerBase::heapIncreaseKey() 286 inline void TimerBase::heapIncreaseKey()
283 { 287 {
(...skipping 14 matching lines...) Expand all
298 inline void TimerBase::heapPop() 302 inline void TimerBase::heapPop()
299 { 303 {
300 // Temporarily force this timer to have the minimum key so we can pop it. 304 // Temporarily force this timer to have the minimum key so we can pop it.
301 double fireTime = m_nextFireTime; 305 double fireTime = m_nextFireTime;
302 m_nextFireTime = -std::numeric_limits<double>::infinity(); 306 m_nextFireTime = -std::numeric_limits<double>::infinity();
303 heapDecreaseKey(); 307 heapDecreaseKey();
304 heapPopMin(); 308 heapPopMin();
305 m_nextFireTime = fireTime; 309 m_nextFireTime = fireTime;
306 } 310 }
307 311
312 NO_LAZY_SWEEP_SANITIZE_ADDRESS
308 void TimerBase::heapPopMin() 313 void TimerBase::heapPopMin()
309 { 314 {
310 ASSERT(this == timerHeap().first()); 315 ASSERT(this == timerHeap().first());
311 checkHeapIndex(); 316 checkHeapIndex();
312 Vector<TimerBase*>& heap = timerHeap(); 317 Vector<TimerBase*>& heap = timerHeap();
313 TimerBase** heapData = heap.data(); 318 TimerBase** heapData = heap.data();
314 pop_heap(TimerHeapIterator(heapData), TimerHeapIterator(heapData + heap.size ()), TimerHeapLessThanFunction()); 319 pop_heap(TimerHeapIterator(heapData), TimerHeapIterator(heapData + heap.size ()), TimerHeapLessThanFunction());
315 checkHeapIndex(); 320 checkHeapIndex();
316 ASSERT(this == timerHeap().last()); 321 ASSERT(this == timerHeap().last());
317 } 322 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 else if (!m_nextFireTime) 366 else if (!m_nextFireTime)
362 heapDelete(); 367 heapDelete();
363 else if (m_nextFireTime < oldTime) 368 else if (m_nextFireTime < oldTime)
364 heapDecreaseKey(); 369 heapDecreaseKey();
365 else 370 else
366 heapIncreaseKey(); 371 heapIncreaseKey();
367 ASSERT(m_heapIndex != oldHeapIndex); 372 ASSERT(m_heapIndex != oldHeapIndex);
368 ASSERT(!inHeap() || hasValidHeapPosition()); 373 ASSERT(!inHeap() || hasValidHeapPosition());
369 } 374 }
370 375
376 NO_LAZY_SWEEP_SANITIZE_ADDRESS
371 void TimerBase::setNextFireTime(double newUnalignedTime) 377 void TimerBase::setNextFireTime(double newUnalignedTime)
372 { 378 {
373 ASSERT(m_thread == currentThread()); 379 ASSERT(m_thread == currentThread());
374 380
375 if (m_unalignedNextFireTime != newUnalignedTime) 381 if (m_unalignedNextFireTime != newUnalignedTime)
376 m_unalignedNextFireTime = newUnalignedTime; 382 m_unalignedNextFireTime = newUnalignedTime;
377 383
378 // Accessing thread global data is slow. Cache the heap pointer. 384 // Accessing thread global data is slow. Cache the heap pointer.
379 if (!m_cachedThreadGlobalTimerHeap) 385 if (!m_cachedThreadGlobalTimerHeap)
380 m_cachedThreadGlobalTimerHeap = &threadGlobalTimerHeap(); 386 m_cachedThreadGlobalTimerHeap = &threadGlobalTimerHeap();
(...skipping 24 matching lines...) Expand all
405 setNextFireTime(m_unalignedNextFireTime); 411 setNextFireTime(m_unalignedNextFireTime);
406 } 412 }
407 413
408 double TimerBase::nextUnalignedFireInterval() const 414 double TimerBase::nextUnalignedFireInterval() const
409 { 415 {
410 ASSERT(isActive()); 416 ASSERT(isActive());
411 return std::max(m_unalignedNextFireTime - monotonicallyIncreasingTime(), 0.0 ); 417 return std::max(m_unalignedNextFireTime - monotonicallyIncreasingTime(), 0.0 );
412 } 418 }
413 419
414 } // namespace blink 420 } // namespace blink
OLDNEW
« Source/platform/Timer.h ('K') | « Source/platform/Timer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698