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

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

Issue 9323026: [NOT TO COMMIT!] r109: Diff of the current tcmalloc from the original google-perftools r109. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years, 10 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // the cache is T. See also the big comment at the top of the file. 132 // the cache is T. See also the big comment at the top of the file.
133 template <int kKeybits, typename T> 133 template <int kKeybits, typename T>
134 class PackedCache { 134 class PackedCache {
135 public: 135 public:
136 typedef uintptr_t K; 136 typedef uintptr_t K;
137 typedef size_t V; 137 typedef size_t V;
138 #ifdef TCMALLOC_SMALL_BUT_SLOW 138 #ifdef TCMALLOC_SMALL_BUT_SLOW
139 // Decrease the size map cache if running in the small memory mode. 139 // Decrease the size map cache if running in the small memory mode.
140 static const int kHashbits = 12; 140 static const int kHashbits = 12;
141 #else 141 #else
142 static const int kHashbits = 16; 142 // We don't want the hash map to occupy 512K memory at Chromium, so
143 // kHashbits is decreased from 16 to 12.
144 static const int kHashbits = 12;
143 #endif 145 #endif
144 static const int kValuebits = 7; 146 static const int kValuebits = 7;
145 static const bool kUseWholeKeys = kKeybits + kValuebits <= 8 * sizeof(T); 147 static const bool kUseWholeKeys = kKeybits + kValuebits <= 8 * sizeof(T);
146 148
147 explicit PackedCache(V initial_value) { 149 explicit PackedCache(V initial_value) {
148 COMPILE_ASSERT(kKeybits <= sizeof(K) * 8, key_size); 150 COMPILE_ASSERT(kKeybits <= sizeof(K) * 8, key_size);
149 COMPILE_ASSERT(kValuebits <= sizeof(V) * 8, value_size); 151 COMPILE_ASSERT(kValuebits <= sizeof(V) * 8, value_size);
150 COMPILE_ASSERT(kHashbits <= kKeybits, hash_function); 152 COMPILE_ASSERT(kHashbits <= kKeybits, hash_function);
151 COMPILE_ASSERT(kKeybits - kHashbits + kValuebits <= kTbits, 153 COMPILE_ASSERT(kKeybits - kHashbits + kValuebits <= kTbits,
152 entry_size_must_be_big_enough); 154 entry_size_must_be_big_enough);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 static const V kValueMask = N_ONES_(V, kValuebits); 231 static const V kValueMask = N_ONES_(V, kValuebits);
230 232
231 // array_ is the cache. Its elements are volatile because any 233 // array_ is the cache. Its elements are volatile because any
232 // thread can write any array element at any time. 234 // thread can write any array element at any time.
233 volatile T array_[1 << kHashbits]; 235 volatile T array_[1 << kHashbits];
234 }; 236 };
235 237
236 #undef N_ONES_ 238 #undef N_ONES_
237 239
238 #endif // TCMALLOC_PACKED_CACHE_INL_H_ 240 #endif // TCMALLOC_PACKED_CACHE_INL_H_
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/memory_region_map.cc ('k') | third_party/tcmalloc/chromium/src/page_heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698