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

Side by Side Diff: third_party/tcmalloc/chromium/src/system-alloc.cc

Issue 7430007: Merge tcmalloc r111 (perftools v. 1.8) with the chromium/ branch. Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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) 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 DEFINE_bool(malloc_skip_mmap, 126 DEFINE_bool(malloc_skip_mmap,
127 EnvToBool("TCMALLOC_SKIP_MMAP", false), 127 EnvToBool("TCMALLOC_SKIP_MMAP", false),
128 "Whether mmap can be used to obtain memory."); 128 "Whether mmap can be used to obtain memory.");
129 129
130 // static allocators 130 // static allocators
131 class SbrkSysAllocator : public SysAllocator { 131 class SbrkSysAllocator : public SysAllocator {
132 public: 132 public:
133 SbrkSysAllocator() : SysAllocator() { 133 SbrkSysAllocator() : SysAllocator() {
134 } 134 }
135 void* Alloc(size_t size, size_t *actual_size, size_t alignment); 135 void* Alloc(size_t size, size_t *actual_size, size_t alignment);
136 void FlagsInitialized() {}
137 }; 136 };
138 static char sbrk_space[sizeof(SbrkSysAllocator)]; 137 static char sbrk_space[sizeof(SbrkSysAllocator)];
139 138
140 class MmapSysAllocator : public SysAllocator { 139 class MmapSysAllocator : public SysAllocator {
141 public: 140 public:
142 MmapSysAllocator() : SysAllocator() { 141 MmapSysAllocator() : SysAllocator() {
143 } 142 }
144 void* Alloc(size_t size, size_t *actual_size, size_t alignment); 143 void* Alloc(size_t size, size_t *actual_size, size_t alignment);
145 void FlagsInitialized() {}
146 }; 144 };
147 static char mmap_space[sizeof(MmapSysAllocator)]; 145 static char mmap_space[sizeof(MmapSysAllocator)];
148 146
149 class DevMemSysAllocator : public SysAllocator { 147 class DevMemSysAllocator : public SysAllocator {
150 public: 148 public:
151 DevMemSysAllocator() : SysAllocator() { 149 DevMemSysAllocator() : SysAllocator() {
152 } 150 }
153 void* Alloc(size_t size, size_t *actual_size, size_t alignment); 151 void* Alloc(size_t size, size_t *actual_size, size_t alignment);
154 void FlagsInitialized() {}
155 }; 152 };
156 153
157 class DefaultSysAllocator : public SysAllocator { 154 class DefaultSysAllocator : public SysAllocator {
158 public: 155 public:
159 DefaultSysAllocator() : SysAllocator() { 156 DefaultSysAllocator() : SysAllocator() {
160 for (int i = 0; i < kMaxAllocators; i++) { 157 for (int i = 0; i < kMaxAllocators; i++) {
161 failed_[i] = true; 158 failed_[i] = true;
162 allocs_[i] = NULL; 159 allocs_[i] = NULL;
160 names_[i] = NULL;
163 } 161 }
164 } 162 }
165 void SetChildAllocator(SysAllocator* alloc, unsigned int index, 163 void SetChildAllocator(SysAllocator* alloc, unsigned int index,
166 const char* name) { 164 const char* name) {
167 if (index < kMaxAllocators && alloc != NULL) { 165 if (index < kMaxAllocators && alloc != NULL) {
168 allocs_[index] = alloc; 166 allocs_[index] = alloc;
169 failed_[index] = false; 167 failed_[index] = false;
168 names_[index] = name;
170 } 169 }
171 } 170 }
172 void* Alloc(size_t size, size_t *actual_size, size_t alignment); 171 void* Alloc(size_t size, size_t *actual_size, size_t alignment);
173 void FlagsInitialized() {}
174 172
175 private: 173 private:
176 static const int kMaxAllocators = 2; 174 static const int kMaxAllocators = 2;
177 bool failed_[kMaxAllocators]; 175 bool failed_[kMaxAllocators];
178 SysAllocator* allocs_[kMaxAllocators]; 176 SysAllocator* allocs_[kMaxAllocators];
179 const char* names_[kMaxAllocators]; 177 const char* names_[kMaxAllocators];
180 }; 178 };
181 static char default_space[sizeof(DefaultSysAllocator)]; 179 static char default_space[sizeof(DefaultSysAllocator)];
182 static const char sbrk_name[] = "SbrkSysAllocator"; 180 static const char sbrk_name[] = "SbrkSysAllocator";
183 static const char mmap_name[] = "MmapSysAllocator"; 181 static const char mmap_name[] = "MmapSysAllocator";
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 } 514 }
517 } 515 }
518 #endif 516 #endif
519 } 517 }
520 518
521 void TCMalloc_SystemCommit(void* start, size_t length) { 519 void TCMalloc_SystemCommit(void* start, size_t length) {
522 // Nothing to do here. TCMalloc_SystemRelease does not alter pages 520 // Nothing to do here. TCMalloc_SystemRelease does not alter pages
523 // such that they need to be re-committed before they can be used by the 521 // such that they need to be re-committed before they can be used by the
524 // application. 522 // application.
525 } 523 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698