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

Unified Diff: third_party/tcmalloc/chromium/src/common.cc

Issue 7050034: Merge google-perftools r109 (the current contents of third_party/tcmalloc/vendor) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/tcmalloc/chromium/src/common.h ('k') | third_party/tcmalloc/chromium/src/config.h.in » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/tcmalloc/chromium/src/common.cc
===================================================================
--- third_party/tcmalloc/chromium/src/common.cc (revision 88335)
+++ third_party/tcmalloc/chromium/src/common.cc (working copy)
@@ -31,9 +31,8 @@
// Author: Sanjay Ghemawat <opensource@google.com>
#include "config.h"
+#include "common.h"
#include "system-alloc.h"
-#include "config.h"
-#include "common.h"
namespace tcmalloc {
@@ -53,6 +52,24 @@
return log;
}
+int AlignmentForSize(size_t size) {
+ int alignment = kAlignment;
+ if (size >= 2048) {
+ // Cap alignment at 256 for large sizes.
+ alignment = 256;
+ } else if (size >= 128) {
+ // Space wasted due to alignment is at most 1/8, i.e., 12.5%.
+ alignment = (1 << LgFloor(size)) / 8;
+ } else if (size >= 16) {
+ // We need an alignment of at least 16 bytes to satisfy
+ // requirements for some SSE types.
+ alignment = 16;
+ }
+ CHECK_CONDITION(size < 16 || alignment >= 16);
+ CHECK_CONDITION((alignment & (alignment - 1)) == 0);
+ return alignment;
+}
+
int SizeMap::NumMoveSize(size_t size) {
if (size == 0) return 0;
// Use approx 64k transfers between thread and central caches.
@@ -93,19 +110,7 @@
int lg = LgFloor(size);
if (lg > last_lg) {
// Increase alignment every so often to reduce number of size classes.
- if (size >= 2048) {
- // Cap alignment at 256 for large sizes
- alignment = 256;
- } else if (size >= 128) {
- // Space wasted due to alignment is at most 1/8, i.e., 12.5%.
- alignment = size / 8;
- } else if (size >= 16) {
- // We need an alignment of at least 16 bytes to satisfy
- // requirements for some SSE types.
- alignment = 16;
- }
- CHECK_CONDITION(size < 16 || alignment >= 16);
- CHECK_CONDITION((alignment & (alignment - 1)) == 0);
+ alignment = AlignmentForSize(size);
last_lg = lg;
}
CHECK_CONDITION((size % alignment) == 0);
« no previous file with comments | « third_party/tcmalloc/chromium/src/common.h ('k') | third_party/tcmalloc/chromium/src/config.h.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698