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

Side by Side Diff: Source/platform/heap/Heap.h

Issue 363173002: Don't zero out memory added to a free list if ASan is enabled (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | Source/platform/heap/Heap.cpp » ('j') | 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 391
392 const size_t finalizedHeaderSize = sizeof(FinalizedHeapObjectHeader); 392 const size_t finalizedHeaderSize = sizeof(FinalizedHeapObjectHeader);
393 393
394 class FreeListEntry : public HeapObjectHeader { 394 class FreeListEntry : public HeapObjectHeader {
395 public: 395 public:
396 NO_SANITIZE_ADDRESS 396 NO_SANITIZE_ADDRESS
397 explicit FreeListEntry(size_t size) 397 explicit FreeListEntry(size_t size)
398 : HeapObjectHeader(freeListEncodedSize(size)) 398 : HeapObjectHeader(freeListEncodedSize(size))
399 , m_next(0) 399 , m_next(0)
400 { 400 {
401 #if !defined(NDEBUG) && !ASAN 401 #if !defined(NDEBUG) && !defined(ADDRESS_SANITIZER)
402 // Zap free area with asterisks, aka 0x2a2a2a2a. 402 // Zap free area with asterisks, aka 0x2a2a2a2a.
403 // For ASAN don't zap since we keep accounting in the freelist entry. 403 // For ASan don't zap since we keep accounting in the freelist entry.
404 for (size_t i = sizeof(*this); i < size; i++) 404 for (size_t i = sizeof(*this); i < size; i++)
405 reinterpret_cast<Address>(this)[i] = freelistZapValue; 405 reinterpret_cast<Address>(this)[i] = freelistZapValue;
406 ASSERT(size >= objectHeaderSize); 406 ASSERT(size >= objectHeaderSize);
407 zapMagic(); 407 zapMagic();
408 #endif 408 #endif
409 } 409 }
410 410
411 Address address() { return reinterpret_cast<Address>(this); } 411 Address address() { return reinterpret_cast<Address>(this); }
412 412
413 NO_SANITIZE_ADDRESS 413 NO_SANITIZE_ADDRESS
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 Address headerAddress = m_currentAllocationPoint; 1366 Address headerAddress = m_currentAllocationPoint;
1367 m_currentAllocationPoint += allocationSize; 1367 m_currentAllocationPoint += allocationSize;
1368 m_remainingAllocationSize -= allocationSize; 1368 m_remainingAllocationSize -= allocationSize;
1369 Header* header = new (NotNull, headerAddress) Header(allocationSize, gcInfo) ; 1369 Header* header = new (NotNull, headerAddress) Header(allocationSize, gcInfo) ;
1370 size_t payloadSize = allocationSize - sizeof(Header); 1370 size_t payloadSize = allocationSize - sizeof(Header);
1371 stats().increaseObjectSpace(payloadSize); 1371 stats().increaseObjectSpace(payloadSize);
1372 Address result = headerAddress + sizeof(*header); 1372 Address result = headerAddress + sizeof(*header);
1373 ASSERT(!(reinterpret_cast<uintptr_t>(result) & allocationMask)); 1373 ASSERT(!(reinterpret_cast<uintptr_t>(result) & allocationMask));
1374 // Unpoison the memory used for the object (payload). 1374 // Unpoison the memory used for the object (payload).
1375 ASAN_UNPOISON_MEMORY_REGION(result, payloadSize); 1375 ASAN_UNPOISON_MEMORY_REGION(result, payloadSize);
1376 #if !defined(NDEBUG) || defined(LEAK_SANITIZER) 1376 #if !defined(NDEBUG) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER)
1377 memset(result, 0, payloadSize); 1377 memset(result, 0, payloadSize);
1378 #endif 1378 #endif
1379 ASSERT(heapPageFromAddress(headerAddress + allocationSize - 1)); 1379 ASSERT(heapPageFromAddress(headerAddress + allocationSize - 1));
1380 return result; 1380 return result;
1381 } 1381 }
1382 1382
1383 // FIXME: Allocate objects that do not need finalization separately 1383 // FIXME: Allocate objects that do not need finalization separately
1384 // and use separate sweeping to not have to check for finalizers. 1384 // and use separate sweeping to not have to check for finalizers.
1385 template<typename T> 1385 template<typename T>
1386 Address Heap::allocate(size_t size) 1386 Address Heap::allocate(size_t size)
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
2347 }; 2347 };
2348 2348
2349 template<typename T> 2349 template<typename T>
2350 struct IfWeakMember<WeakMember<T> > { 2350 struct IfWeakMember<WeakMember<T> > {
2351 static bool isDead(Visitor* visitor, const WeakMember<T>& t) { return !visit or->isAlive(t.get()); } 2351 static bool isDead(Visitor* visitor, const WeakMember<T>& t) { return !visit or->isAlive(t.get()); }
2352 }; 2352 };
2353 2353
2354 } 2354 }
2355 2355
2356 #endif // Heap_h 2356 #endif // Heap_h
OLDNEW
« no previous file with comments | « no previous file | Source/platform/heap/Heap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698