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

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

Issue 9311003: Update the tcmalloc chromium branch to r144 (gperftools 2.0), and merge chromium-specific changes. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebasec Created 8 years, 9 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) 2008, Google Inc. 1 // Copyright (c) 2008, 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 20 matching lines...) Expand all
31 // Author: Sanjay Ghemawat <opensource@google.com> 31 // Author: Sanjay Ghemawat <opensource@google.com>
32 32
33 #ifndef TCMALLOC_PAGE_HEAP_H_ 33 #ifndef TCMALLOC_PAGE_HEAP_H_
34 #define TCMALLOC_PAGE_HEAP_H_ 34 #define TCMALLOC_PAGE_HEAP_H_
35 35
36 #include <config.h> 36 #include <config.h>
37 #include <stddef.h> // for size_t 37 #include <stddef.h> // for size_t
38 #ifdef HAVE_STDINT_H 38 #ifdef HAVE_STDINT_H
39 #include <stdint.h> // for uint64_t, int64_t, uint16_t 39 #include <stdint.h> // for uint64_t, int64_t, uint16_t
40 #endif 40 #endif
41 #include <google/malloc_extension.h> 41 #include <gperftools/malloc_extension.h>
42 #include "base/basictypes.h" 42 #include "base/basictypes.h"
43 #include "common.h" 43 #include "common.h"
44 #include "packed-cache-inl.h" 44 #include "packed-cache-inl.h"
45 #include "pagemap.h" 45 #include "pagemap.h"
46 #include "span.h" 46 #include "span.h"
47 47
48 // We need to dllexport PageHeap just for the unittest. MSVC complains 48 // We need to dllexport PageHeap just for the unittest. MSVC complains
49 // that we don't dllexport the PageHeap members, but we don't need to 49 // that we don't dllexport the PageHeap members, but we don't need to
50 // test those, so I just suppress this warning. 50 // test those, so I just suppress this warning.
51 #ifdef _MSC_VER 51 #ifdef _MSC_VER
52 #pragma warning(push) 52 #pragma warning(push)
53 #pragma warning(disable:4251) 53 #pragma warning(disable:4251)
54 #endif 54 #endif
55 55
56 // This #ifdef should almost never be set. Set NO_TCMALLOC_SAMPLES if 56 // This #ifdef should almost never be set. Set NO_TCMALLOC_SAMPLES if
57 // you're porting to a system where you really can't get a stacktrace. 57 // you're porting to a system where you really can't get a stacktrace.
58 // Because we control the definition of GetStackTrace, all clients of 58 // Because we control the definition of GetStackTrace, all clients of
59 // GetStackTrace should #include us rather than stacktrace.h. 59 // GetStackTrace should #include us rather than stacktrace.h.
60 #ifdef NO_TCMALLOC_SAMPLES 60 #ifdef NO_TCMALLOC_SAMPLES
61 // We use #define so code compiles even if you #include stacktrace.h somehow. 61 // We use #define so code compiles even if you #include stacktrace.h somehow.
62 # define GetStackTrace(stack, depth, skip) (0) 62 # define GetStackTrace(stack, depth, skip) (0)
63 #else 63 #else
64 # include <google/stacktrace.h> 64 # include <gperftools/stacktrace.h>
65 #endif 65 #endif
66 66
67 class TCMalloc_Printer;
68 namespace base { 67 namespace base {
69 struct MallocRange; 68 struct MallocRange;
70 } 69 }
71 70
72 namespace tcmalloc { 71 namespace tcmalloc {
73 72
74 // ------------------------------------------------------------------------- 73 // -------------------------------------------------------------------------
75 // Map from page-id to per-page data 74 // Map from page-id to per-page data
76 // ------------------------------------------------------------------------- 75 // -------------------------------------------------------------------------
77 76
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // REQUIRES: span->location == IN_USE 137 // REQUIRES: span->location == IN_USE
139 // REQUIRES: span->sizeclass == 0 138 // REQUIRES: span->sizeclass == 0
140 Span* Split(Span* span, Length n); 139 Span* Split(Span* span, Length n);
141 140
142 // Return the descriptor for the specified page. Returns NULL if 141 // Return the descriptor for the specified page. Returns NULL if
143 // this PageID was not allocated previously. 142 // this PageID was not allocated previously.
144 inline Span* GetDescriptor(PageID p) const { 143 inline Span* GetDescriptor(PageID p) const {
145 return reinterpret_cast<Span*>(pagemap_.get(p)); 144 return reinterpret_cast<Span*>(pagemap_.get(p));
146 } 145 }
147 146
148 // Dump state to stderr
149 void Dump(TCMalloc_Printer* out);
150
151 // If this page heap is managing a range with starting page # >= start, 147 // If this page heap is managing a range with starting page # >= start,
152 // store info about the range in *r and return true. Else return false. 148 // store info about the range in *r and return true. Else return false.
153 bool GetNextRange(PageID start, base::MallocRange* r); 149 bool GetNextRange(PageID start, base::MallocRange* r);
154 150
155 // Page heap statistics 151 // Page heap statistics
156 struct Stats { 152 struct Stats {
157 Stats() : system_bytes(0), free_bytes(0), unmapped_bytes(0) {} 153 Stats() : system_bytes(0), free_bytes(0), unmapped_bytes(0) {}
158 uint64_t system_bytes; // Total bytes allocated from system 154 uint64_t system_bytes; // Total bytes allocated from system
159 uint64_t free_bytes; // Total bytes on normal freelists 155 uint64_t free_bytes; // Total bytes on normal freelists
160 uint64_t unmapped_bytes; // Total bytes on returned freelists 156 uint64_t unmapped_bytes; // Total bytes on returned freelists
161 uint64_t committed_bytes; // Bytes committed, always <= system_bytes_. 157 uint64_t committed_bytes; // Bytes committed, always <= system_bytes_.
162 158
163 }; 159 };
164 inline Stats stats() const { return stats_; } 160 inline Stats stats() const { return stats_; }
165 void GetClassSizes(int64 class_sizes_normal[kMaxPages], 161
166 int64 class_sizes_returned[kMaxPages], 162 struct SmallSpanStats {
167 int64* normal_pages_in_spans, 163 // For each free list of small spans, the length (in spans) of the
168 int64* returned_pages_in_spans); 164 // normal and returned free lists for that size.
165 int64 normal_length[kMaxPages];
166 int64 returned_length[kMaxPages];
167 };
168 void GetSmallSpanStats(SmallSpanStats* result);
169
170 // Stats for free large spans (i.e., spans with more than kMaxPages pages).
171 struct LargeSpanStats {
172 int64 spans; // Number of such spans
173 int64 normal_pages; // Combined page length of normal large spans
174 int64 returned_pages; // Combined page length of unmapped spans
175 };
176 void GetLargeSpanStats(LargeSpanStats* result);
169 177
170 bool Check(); 178 bool Check();
171 // Like Check() but does some more comprehensive checking. 179 // Like Check() but does some more comprehensive checking.
172 bool CheckExpensive(); 180 bool CheckExpensive();
173 bool CheckList(Span* list, Length min_pages, Length max_pages, 181 bool CheckList(Span* list, Length min_pages, Length max_pages,
174 int freelist); // ON_NORMAL_FREELIST or ON_RETURNED_FREELIST 182 int freelist); // ON_NORMAL_FREELIST or ON_RETURNED_FREELIST
175 183
176 // Try to release at least num_pages for reuse by the OS. Returns 184 // Try to release at least num_pages for reuse by the OS. Returns
177 // the actual number of pages released, which may be less than 185 // the actual number of pages released, which may be less than
178 // num_pages if there weren't enough pages to release. The result 186 // num_pages if there weren't enough pages to release. The result
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 int release_index_; 302 int release_index_;
295 }; 303 };
296 304
297 } // namespace tcmalloc 305 } // namespace tcmalloc
298 306
299 #ifdef _MSC_VER 307 #ifdef _MSC_VER
300 #pragma warning(pop) 308 #pragma warning(pop)
301 #endif 309 #endif
302 310
303 #endif // TCMALLOC_PAGE_HEAP_H_ 311 #endif // TCMALLOC_PAGE_HEAP_H_
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/memory_region_map.cc ('k') | third_party/tcmalloc/chromium/src/page_heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698