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

Side by Side Diff: third_party/tcmalloc/chromium/src/tcmalloc.cc

Issue 7976011: Enable tcmalloc validation by default in debug builds (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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 | 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 // Copyright (c) 2005, Google Inc. 1 // Copyright (c) 2005, Google Inc.
2 // All rights reserved. 2 // 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 1773 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 // allocation size, which is known in the code above, but then is recalculated 1784 // allocation size, which is known in the code above, but then is recalculated
1785 // below. Another potential optimization would be careful manual inlining of 1785 // below. Another potential optimization would be careful manual inlining of
1786 // code, but I *think* that the compile will probably do this for me, and I've 1786 // code, but I *think* that the compile will probably do this for me, and I've
1787 // been careful to avoid aliasing issues that might make a compiler back-off. 1787 // been careful to avoid aliasing issues that might make a compiler back-off.
1788 1788
1789 // Evolution includes experimenting with different marks, to minimize the chance 1789 // Evolution includes experimenting with different marks, to minimize the chance
1790 // that a mark would be misunderstood (missed corruption). The marks are meant 1790 // that a mark would be misunderstood (missed corruption). The marks are meant
1791 // to be hashed encoding of the location, so that they can't be copied over a 1791 // to be hashed encoding of the location, so that they can't be copied over a
1792 // different region (by accident) without being detected (most of the time). 1792 // different region (by accident) without being detected (most of the time).
1793 1793
1794 // Uncomment the following define to turn on all the TCMalloc checking. 1794 // Enable the following define to turn on all the TCMalloc checking.
1795 // It will cost abotu 2% in performance, but it will catch double frees (most of 1795 // It will cost about 2% in performance, but it will catch double frees (most of
1796 // the time), and will often catch allocated-buffer overrun errors. This 1796 // the time), and will often catch allocated-buffer overrun errors. This
1797 // validation is only active when TCMalloc is used as the allocator. 1797 // validation is only active when TCMalloc is used as the allocator.
1798 // #define TCMALLOC_VALIDATION 1798 #ifndef NDEBUG
1799 #define TCMALLOC_VALIDATION
1800 #endif
1799 1801
1800 #if !defined(TCMALLOC_VALIDATION) 1802 #if !defined(TCMALLOC_VALIDATION)
1801 1803
1802 static size_t ExcludeSpaceForMark(size_t size) { return size; } 1804 static size_t ExcludeSpaceForMark(size_t size) { return size; }
1803 static void AddRoomForMark(size_t* size) {} 1805 static void AddRoomForMark(size_t* size) {}
1804 static void ExcludeMarkFromSize(size_t* new_size) {} 1806 static void ExcludeMarkFromSize(size_t* new_size) {}
1805 static void MarkAllocatedRegion(void* ptr) {} 1807 static void MarkAllocatedRegion(void* ptr) {}
1806 static void ValidateAllocatedRegion(void* ptr, size_t cl) {} 1808 static void ValidateAllocatedRegion(void* ptr, size_t cl) {}
1807 1809
1808 #else // TCMALLOC_VALIDATION 1810 #else // TCMALLOC_VALIDATION
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 *mark = ~allocated_mark; // Distinctively not allocated. 1928 *mark = ~allocated_mark; // Distinctively not allocated.
1927 } 1929 }
1928 1930
1929 static void MarkAllocatedRegion(void* ptr) { 1931 static void MarkAllocatedRegion(void* ptr) {
1930 if (ptr == NULL) return; 1932 if (ptr == NULL) return;
1931 MarkType* mark = GetMarkLocation(ptr); 1933 MarkType* mark = GetMarkLocation(ptr);
1932 *mark = GetMarkValue(ptr, mark); 1934 *mark = GetMarkValue(ptr, mark);
1933 } 1935 }
1934 1936
1935 #endif // TCMALLOC_VALIDATION 1937 #endif // TCMALLOC_VALIDATION
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698