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

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

Issue 9701040: Revert 126715 - Update the tcmalloc vendor branch to r144 (gperftools 2.0). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 <gperftools/malloc_extension.h> 41 #include <google/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 <gperftools/stacktrace.h> 64 # include <google/stacktrace.h>
65 #endif 65 #endif
66 66
67 class TCMalloc_Printer;
67 namespace base { 68 namespace base {
68 struct MallocRange; 69 struct MallocRange;
69 } 70 }
70 71
71 namespace tcmalloc { 72 namespace tcmalloc {
72 73
73 // ------------------------------------------------------------------------- 74 // -------------------------------------------------------------------------
74 // Map from page-id to per-page data 75 // Map from page-id to per-page data
75 // ------------------------------------------------------------------------- 76 // -------------------------------------------------------------------------
76 77
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // REQUIRES: span->location == IN_USE 130 // REQUIRES: span->location == IN_USE
130 // REQUIRES: span->sizeclass == 0 131 // REQUIRES: span->sizeclass == 0
131 Span* Split(Span* span, Length n); 132 Span* Split(Span* span, Length n);
132 133
133 // Return the descriptor for the specified page. Returns NULL if 134 // Return the descriptor for the specified page. Returns NULL if
134 // this PageID was not allocated previously. 135 // this PageID was not allocated previously.
135 inline Span* GetDescriptor(PageID p) const { 136 inline Span* GetDescriptor(PageID p) const {
136 return reinterpret_cast<Span*>(pagemap_.get(p)); 137 return reinterpret_cast<Span*>(pagemap_.get(p));
137 } 138 }
138 139
140 // Dump state to stderr
141 void Dump(TCMalloc_Printer* out);
142
139 // If this page heap is managing a range with starting page # >= start, 143 // If this page heap is managing a range with starting page # >= start,
140 // store info about the range in *r and return true. Else return false. 144 // store info about the range in *r and return true. Else return false.
141 bool GetNextRange(PageID start, base::MallocRange* r); 145 bool GetNextRange(PageID start, base::MallocRange* r);
142 146
143 // Page heap statistics 147 // Page heap statistics
144 struct Stats { 148 struct Stats {
145 Stats() : system_bytes(0), free_bytes(0), unmapped_bytes(0) {} 149 Stats() : system_bytes(0), free_bytes(0), unmapped_bytes(0) {}
146 uint64_t system_bytes; // Total bytes allocated from system 150 uint64_t system_bytes; // Total bytes allocated from system
147 uint64_t free_bytes; // Total bytes on normal freelists 151 uint64_t free_bytes; // Total bytes on normal freelists
148 uint64_t unmapped_bytes; // Total bytes on returned freelists 152 uint64_t unmapped_bytes; // Total bytes on returned freelists
149 }; 153 };
150 inline Stats stats() const { return stats_; } 154 inline Stats stats() const { return stats_; }
151 155 void GetClassSizes(int64 class_sizes_normal[kMaxPages],
152 struct SmallSpanStats { 156 int64 class_sizes_returned[kMaxPages],
153 // For each free list of small spans, the length (in spans) of the 157 int64* normal_pages_in_spans,
154 // normal and returned free lists for that size. 158 int64* returned_pages_in_spans);
155 int64 normal_length[kMaxPages];
156 int64 returned_length[kMaxPages];
157 };
158 void GetSmallSpanStats(SmallSpanStats* result);
159
160 // Stats for free large spans (i.e., spans with more than kMaxPages pages).
161 struct LargeSpanStats {
162 int64 spans; // Number of such spans
163 int64 normal_pages; // Combined page length of normal large spans
164 int64 returned_pages; // Combined page length of unmapped spans
165 };
166 void GetLargeSpanStats(LargeSpanStats* result);
167 159
168 bool Check(); 160 bool Check();
169 // Like Check() but does some more comprehensive checking. 161 // Like Check() but does some more comprehensive checking.
170 bool CheckExpensive(); 162 bool CheckExpensive();
171 bool CheckList(Span* list, Length min_pages, Length max_pages, 163 bool CheckList(Span* list, Length min_pages, Length max_pages,
172 int freelist); // ON_NORMAL_FREELIST or ON_RETURNED_FREELIST 164 int freelist); // ON_NORMAL_FREELIST or ON_RETURNED_FREELIST
173 165
174 // Try to release at least num_pages for reuse by the OS. Returns 166 // Try to release at least num_pages for reuse by the OS. Returns
175 // the actual number of pages released, which may be less than 167 // the actual number of pages released, which may be less than
176 // num_pages if there weren't enough pages to release. The result 168 // num_pages if there weren't enough pages to release. The result
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 int release_index_; 277 int release_index_;
286 }; 278 };
287 279
288 } // namespace tcmalloc 280 } // namespace tcmalloc
289 281
290 #ifdef _MSC_VER 282 #ifdef _MSC_VER
291 #pragma warning(pop) 283 #pragma warning(pop)
292 #endif 284 #endif
293 285
294 #endif // TCMALLOC_PAGE_HEAP_H_ 286 #endif // TCMALLOC_PAGE_HEAP_H_
OLDNEW
« no previous file with comments | « third_party/tcmalloc/vendor/src/memory_region_map.cc ('k') | third_party/tcmalloc/vendor/src/page_heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698