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

Side by Side Diff: third_party/tcmalloc/chromium/src/packed-cache-inl.h

Issue 576001: Merged third_party/tcmalloc/vendor/src(google-perftools r87) into... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Removed the unnecessary printf and ASSERT(0) Created 10 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) 2007, Google Inc. 1 // Copyright (c) 2007, 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // if a whole key plus a whole value fits in an entry. Otherwise, an 104 // if a whole key plus a whole value fits in an entry. Otherwise, an
105 // entry is the high bits of a key and a value, packed together. 105 // entry is the high bits of a key and a value, packed together.
106 // E.g., a 20 bit key and a 7 bit value only require a uint16 for each 106 // E.g., a 20 bit key and a 7 bit value only require a uint16 for each
107 // entry if kHashbits >= 11. 107 // entry if kHashbits >= 11.
108 // 108 //
109 // Alternatives to this scheme will be added as needed. 109 // Alternatives to this scheme will be added as needed.
110 110
111 #ifndef TCMALLOC_PACKED_CACHE_INL_H_ 111 #ifndef TCMALLOC_PACKED_CACHE_INL_H_
112 #define TCMALLOC_PACKED_CACHE_INL_H_ 112 #define TCMALLOC_PACKED_CACHE_INL_H_
113 113
114 #include "config.h"
115 #ifdef HAVE_STDINT_H
116 #include <stdint.h>
117 #endif
114 #include "base/basictypes.h" // for COMPILE_ASSERT 118 #include "base/basictypes.h" // for COMPILE_ASSERT
115 #include "internal_logging.h" 119 #include "internal_logging.h"
116 120
117 // A safe way of doing "(1 << n) - 1" -- without worrying about overflow 121 // A safe way of doing "(1 << n) - 1" -- without worrying about overflow
118 // Note this will all be resolved to a constant expression at compile-time 122 // Note this will all be resolved to a constant expression at compile-time
119 #define N_ONES_(IntType, N) \ 123 #define N_ONES_(IntType, N) \
120 ( (N) == 0 ? 0 : ((static_cast<IntType>(1) << ((N)-1))-1 + \ 124 ( (N) == 0 ? 0 : ((static_cast<IntType>(1) << ((N)-1))-1 + \
121 (static_cast<IntType>(1) << ((N)-1))) ) 125 (static_cast<IntType>(1) << ((N)-1))) )
122 126
123 // The types K and V provide upper bounds on the number of valid keys 127 // The types K and V provide upper bounds on the number of valid keys
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 static const V kValueMask = N_ONES_(V, kValuebits); 223 static const V kValueMask = N_ONES_(V, kValuebits);
220 224
221 // array_ is the cache. Its elements are volatile because any 225 // array_ is the cache. Its elements are volatile because any
222 // thread can write any array element at any time. 226 // thread can write any array element at any time.
223 volatile T array_[1 << kHashbits]; 227 volatile T array_[1 << kHashbits];
224 }; 228 };
225 229
226 #undef N_ONES_ 230 #undef N_ONES_
227 231
228 #endif // TCMALLOC_PACKED_CACHE_INL_H_ 232 #endif // TCMALLOC_PACKED_CACHE_INL_H_
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/memory_region_map.h ('k') | third_party/tcmalloc/chromium/src/page_heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698