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

Side by Side Diff: third_party/tcmalloc/chromium/src/google/tcmalloc.h

Issue 9323026: [NOT TO COMMIT!] r109: Diff of the current tcmalloc from the original google-perftools r109. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 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
OLDNEW
1 // Copyright (c) 2009, Google Inc. 1 // Copyright (c) 2007, 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
11 // copyright notice, this list of conditions and the following disclaimer 11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the 12 // in the documentation and/or other materials provided with the
13 // distribution. 13 // distribution.
14 // * Neither the name of Google Inc. nor the names of its 14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from 15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission. 16 // this software without specific prior written permission.
17 // 17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 // --- 30 // ---
31 // Author: Andrew Fikes 31 // Author: Craig Silverstein <opensource@google.com>
32 // 32 //
33 // Utility class for coalescing sampled stack traces. Not thread-safe. 33 // Some obscure memory-allocation routines may not be declared on all
34 34 // systems. In those cases, we'll just declare them ourselves.
35 #ifndef TCMALLOC_STACK_TRACE_TABLE_H_ 35 // This file is meant to be used only internally, for unittests.
36 #define TCMALLOC_STACK_TRACE_TABLE_H_
37 36
38 #include <config.h> 37 #include <config.h>
39 #include <stdint.h> // for uintptr_t
40 #include "common.h"
41 38
42 namespace tcmalloc { 39 #ifndef _XOPEN_SOURCE
40 # define _XOPEN_SOURCE 600 // for posix_memalign
41 #endif
42 #include <stdlib.h> // for posix_memalign
43 // FreeBSD has malloc.h, but complains if you use it
44 #if defined(HAVE_MALLOC_H) && !defined(__FreeBSD__)
45 #include <malloc.h> // for memalign, valloc, pvalloc
46 #endif
43 47
44 class PERFTOOLS_DLL_DECL StackTraceTable { 48 // __THROW is defined in glibc systems. It means, counter-intuitively,
45 public: 49 // "This function will never throw an exception." It's an optional
46 // REQUIRES: L < pageheap_lock 50 // optimization tool, but we may need to use it to match glibc prototypes.
47 StackTraceTable(); 51 #ifndef __THROW // I guess we're not on a glibc system
48 ~StackTraceTable(); 52 # define __THROW // __THROW is just an optimization, so ok to make it ""
53 #endif
49 54
50 // Adds stack trace "t" to table. 55 #if !HAVE_CFREE_SYMBOL
51 // 56 extern "C" void cfree(void* ptr) __THROW;
52 // REQUIRES: L >= pageheap_lock 57 #endif
53 void AddTrace(const StackTrace& t); 58 #if !HAVE_POSIX_MEMALIGN_SYMBOL
54 59 extern "C" int posix_memalign(void** ptr, size_t align, size_t size) __THROW;
55 // Returns stack traces formatted per MallocExtension guidelines. 60 #endif
56 // May return NULL on error. Clears state before returning. 61 #if !HAVE_MEMALIGN_SYMBOL
57 // 62 extern "C" void* memalign(size_t __alignment, size_t __size) __THROW;
58 // REQUIRES: L < pageheap_lock 63 #endif
59 void** ReadStackTracesAndClear(); 64 #if !HAVE_VALLOC_SYMBOL
60 65 extern "C" void* valloc(size_t __size) __THROW;
61 // Exposed for PageHeapAllocator 66 #endif
62 struct Bucket { 67 #if !HAVE_PVALLOC_SYMBOL
63 // Key 68 extern "C" void* pvalloc(size_t __size) __THROW;
64 uintptr_t hash; 69 #endif
65 StackTrace trace;
66
67 // Payload
68 int count;
69 Bucket* next;
70
71 bool KeyEqual(uintptr_t h, const StackTrace& t) const;
72 };
73
74 // For testing
75 int depth_total() const { return depth_total_; }
76 int bucket_total() const { return bucket_total_; }
77
78 private:
79 static const int kHashTableSize = 1 << 14; // => table_ is 128k
80
81 bool error_;
82 int depth_total_;
83 int bucket_total_;
84 Bucket** table_;
85 };
86
87 } // namespace tcmalloc
88
89 #endif // TCMALLOC_STACK_TRACE_TABLE_H_
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/google/profiler.h ('k') | third_party/tcmalloc/chromium/src/heap-checker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698