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

Side by Side Diff: Source/heap/ThreadState.cpp

Issue 141713008: Use new ASAN APIs for scanning ASAN fake stacks during garbage collection. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Minor style changes. Created 6 years, 10 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 | Annotate | Revision Log
« Source/heap/ThreadState.h ('K') | « Source/heap/ThreadState.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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 , m_endOfStack(reinterpret_cast<intptr_t*>(getStackStart())) 233 , m_endOfStack(reinterpret_cast<intptr_t*>(getStackStart()))
234 , m_safePointScopeMarker(0) 234 , m_safePointScopeMarker(0)
235 , m_atSafePoint(false) 235 , m_atSafePoint(false)
236 , m_interruptors() 236 , m_interruptors()
237 , m_gcRequested(false) 237 , m_gcRequested(false)
238 , m_sweepRequested(0) 238 , m_sweepRequested(0)
239 , m_sweepInProgress(false) 239 , m_sweepInProgress(false)
240 , m_noAllocationCount(0) 240 , m_noAllocationCount(0)
241 , m_inGC(false) 241 , m_inGC(false)
242 , m_heapContainsCache(new HeapContainsCache()) 242 , m_heapContainsCache(new HeapContainsCache())
243 #if defined(ADDRESS_SANITIZER) && !OS(WIN)
244 , m_asanFakeStack(__asan_get_current_fake_stack())
245 #endif
243 { 246 {
244 ASSERT(!**s_threadSpecific); 247 ASSERT(!**s_threadSpecific);
245 **s_threadSpecific = this; 248 **s_threadSpecific = this;
246 249
247 m_persistents = new PersistentAnchor(); 250 m_persistents = new PersistentAnchor();
248 m_stats.clear(); 251 m_stats.clear();
249 m_statsAfterLastGC.clear(); 252 m_statsAfterLastGC.clear();
250 // First allocate the general heap, second iterate through to 253 // First allocate the general heap, second iterate through to
251 // allocate the type specific heaps 254 // allocate the type specific heaps
252 m_heaps[GeneralHeap] = new ThreadHeap<FinalizedHeapObjectHeader>(this); 255 m_heaps[GeneralHeap] = new ThreadHeap<FinalizedHeapObjectHeader>(this);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 delete state; 303 delete state;
301 } 304 }
302 305
303 void ThreadState::visitRoots(Visitor* visitor) 306 void ThreadState::visitRoots(Visitor* visitor)
304 { 307 {
305 AttachedThreadStateSet& threads = attachedThreads(); 308 AttachedThreadStateSet& threads = attachedThreads();
306 for (AttachedThreadStateSet::iterator it = threads.begin(), end = threads.en d(); it != end; ++it) 309 for (AttachedThreadStateSet::iterator it = threads.begin(), end = threads.en d(); it != end; ++it)
307 (*it)->trace(visitor); 310 (*it)->trace(visitor);
308 } 311 }
309 312
313 #if defined(ADDRESS_SANITIZER) && !OS(WIN)
314 NO_SANITIZE_ADDRESS
kcc1 2014/02/06 13:44:06 I'd put #ifdef inside the function body, this will
Mads Ager (chromium) 2014/02/06 14:15:17 Good idea. Done!
315 void ThreadState::visitAsanFakeStackForPointer(Visitor* visitor, Address ptr)
316 {
317 Address* start = reinterpret_cast<Address*>(m_startOfStack);
318 Address* end = reinterpret_cast<Address*>(m_endOfStack);
319 Address* fakeFrameStart = 0;
320 Address* fakeFrameEnd = 0;
321 Address* maybeFakeFrame = reinterpret_cast<Address*>(ptr);
322 Address* realFrameForFakeFrame =
323 reinterpret_cast<Address*>(
324 __asan_addr_is_in_fake_stack(
325 m_asanFakeStack, maybeFakeFrame,
326 reinterpret_cast<void**>(&fakeFrameStart),
327 reinterpret_cast<void**>(&fakeFrameEnd)));
328 if (realFrameForFakeFrame) {
329 // This is a fake frame from the asan fake stack.
330 if (realFrameForFakeFrame > end && start > realFrameForFakeFrame) {
331 // The real stack address for the asan fake frame is
332 // within the stack range that we need to scan so we need
333 // to visit the values in the fake frame.
334 for (Address* p = fakeFrameStart; p < fakeFrameEnd; p++)
335 Heap::checkAndMarkPointer(visitor, *p);
336 }
337 }
338 }
339 #endif
340
310 NO_SANITIZE_ADDRESS 341 NO_SANITIZE_ADDRESS
311 void ThreadState::visitStack(Visitor* visitor) 342 void ThreadState::visitStack(Visitor* visitor)
312 { 343 {
313 Address* end = reinterpret_cast<Address*>(m_startOfStack); 344 Address* end = reinterpret_cast<Address*>(m_startOfStack);
314 for (Address* current = reinterpret_cast<Address*>(m_endOfStack); current < end; ++current) { 345 for (Address* current = reinterpret_cast<Address*>(m_endOfStack); current < end; ++current) {
315 Heap::checkAndMarkPointer(visitor, *current); 346 Heap::checkAndMarkPointer(visitor, *current);
347 #if defined(ADDRESS_SANITIZER) && !OS(WIN)
348 visitAsanFakeStackForPointer(visitor, *current);
349 #endif
316 } 350 }
317 351
318 for (Vector<Address>::iterator it = m_safePointStackCopy.begin(); it != m_sa fePointStackCopy.end(); ++it) 352 for (Vector<Address>::iterator it = m_safePointStackCopy.begin(); it != m_sa fePointStackCopy.end(); ++it) {
319 Heap::checkAndMarkPointer(visitor, *it); 353 Heap::checkAndMarkPointer(visitor, *it);
354 #if defined(ADDRESS_SANITIZER) && !OS(WIN)
355 visitAsanFakeStackForPointer(visitor, *it);
356 #endif
357 }
320 } 358 }
321 359
322 void ThreadState::visitPersistents(Visitor* visitor) 360 void ThreadState::visitPersistents(Visitor* visitor)
323 { 361 {
324 for (PersistentNode* current = m_persistents->m_next; current != m_persisten ts; current = current->m_next) { 362 for (PersistentNode* current = m_persistents->m_next; current != m_persisten ts; current = current->m_next) {
325 current->trace(visitor); 363 current->trace(visitor);
326 } 364 }
327 } 365 }
328 366
329 void ThreadState::trace(Visitor* visitor) 367 void ThreadState::trace(Visitor* visitor)
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 state->safePoint(HeapPointersOnStack); 675 state->safePoint(HeapPointersOnStack);
638 } 676 }
639 677
640 ThreadState::AttachedThreadStateSet& ThreadState::attachedThreads() 678 ThreadState::AttachedThreadStateSet& ThreadState::attachedThreads()
641 { 679 {
642 DEFINE_STATIC_LOCAL(AttachedThreadStateSet, threads, ()); 680 DEFINE_STATIC_LOCAL(AttachedThreadStateSet, threads, ());
643 return threads; 681 return threads;
644 } 682 }
645 683
646 } 684 }
OLDNEW
« Source/heap/ThreadState.h ('K') | « Source/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698