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

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

Issue 11857007: TCMalloc: restrict maximum size of memory ranges (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Drive-by patch of int to size_t. Created 7 years, 11 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 namespace tcmalloc { 138 namespace tcmalloc {
139 139
140 // Convert byte size into pages. This won't overflow, but may return 140 // Convert byte size into pages. This won't overflow, but may return
141 // an unreasonably large value if bytes is huge enough. 141 // an unreasonably large value if bytes is huge enough.
142 inline Length pages(size_t bytes) { 142 inline Length pages(size_t bytes) {
143 return (bytes >> kPageShift) + 143 return (bytes >> kPageShift) +
144 ((bytes & (kPageSize - 1)) > 0 ? 1 : 0); 144 ((bytes & (kPageSize - 1)) > 0 ? 1 : 0);
145 } 145 }
146 146
147 // For security reasons, we want to limit the size of allocations.
148 // See crbug.com/169327.
149 bool IsAllocSizePermitted(size_t alloc_size);
Chris Evans 2013/01/15 01:53:08 Mark it inline. Any maybe have the implementation
jln (very slow on Chromium) 2013/01/15 02:00:51 Let me know how strongly you feel about it. Since
150
147 // For larger allocation sizes, we use larger memory alignments to 151 // For larger allocation sizes, we use larger memory alignments to
148 // reduce the number of size classes. 152 // reduce the number of size classes.
149 int AlignmentForSize(size_t size); 153 int AlignmentForSize(size_t size);
150 154
151 // Size-class information + mapping 155 // Size-class information + mapping
152 class SizeMap { 156 class SizeMap {
153 private: 157 private:
154 // Number of objects to move between a per-thread list and a central 158 // Number of objects to move between a per-thread list and a central
155 // list in one shot. We want this to be not too small so we can 159 // list in one shot. We want this to be not too small so we can
156 // amortize the lock overhead for accessing the central list. Making 160 // amortize the lock overhead for accessing the central list. Making
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 static const int kMaxStackDepth = 31; 264 static const int kMaxStackDepth = 31;
261 struct StackTrace { 265 struct StackTrace {
262 uintptr_t size; // Size of object 266 uintptr_t size; // Size of object
263 uintptr_t depth; // Number of PC values stored in array below 267 uintptr_t depth; // Number of PC values stored in array below
264 void* stack[kMaxStackDepth]; 268 void* stack[kMaxStackDepth];
265 }; 269 };
266 270
267 } // namespace tcmalloc 271 } // namespace tcmalloc
268 272
269 #endif // TCMALLOC_COMMON_H_ 273 #endif // TCMALLOC_COMMON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698