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

Unified Diff: third_party/tcmalloc/chromium/src/thread_cache.h

Issue 9320005: [NOT TO COMMIT!] Replace third_party/tcmalloc/chromium with tcmalloc r136 (the latest). (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/tcmalloc/chromium/src/thread_cache.h
diff --git a/third_party/tcmalloc/chromium/src/thread_cache.h b/third_party/tcmalloc/chromium/src/thread_cache.h
index 9220aabeace610bf65918f509caee186a6c3d27f..1d0413b2a8a1dc712defa76ae103eea9ff011209 100644
--- a/third_party/tcmalloc/chromium/src/thread_cache.h
+++ b/third_party/tcmalloc/chromium/src/thread_cache.h
@@ -42,10 +42,16 @@
#include <stdint.h> // for uint32_t, uint64_t
#endif
#include <sys/types.h> // for ssize_t
+#include "common.h"
+#include "linked_list.h"
+#include "maybe_threads.h"
+#include "page_heap_allocator.h"
+#include "sampler.h"
+#include "static_vars.h"
+
#include "common.h" // for SizeMap, kMaxSize, etc
-#include "free_list.h" // for FL_Pop, FL_PopRange, etc
#include "internal_logging.h" // for ASSERT, etc
-#include "maybe_threads.h"
+#include "linked_list.h" // for SLL_Pop, SLL_PopRange, etc
#include "page_heap_allocator.h" // for PageHeapAllocator
#include "sampler.h" // for Sampler
#include "static_vars.h" // for Static
@@ -88,7 +94,6 @@ class ThreadCache {
void Deallocate(void* ptr, size_t size_class);
void Scavenge();
- void Print(TCMalloc_Printer* out) const;
int GetSamplePeriod();
@@ -114,10 +119,6 @@ class ThreadCache {
// REQUIRES: Static::pageheap_lock is held.
static void GetThreadStats(uint64_t* total_bytes, uint64_t* class_count);
- // Write debugging statistics to 'out'.
- // REQUIRES: Static::pageheap_lock is held.
- static void PrintThreads(TCMalloc_Printer* out);
-
// Sets the total thread cache size to new_size, recomputing the
// individual thread cache sizes as necessary.
// REQUIRES: Static::pageheap lock is held.
@@ -192,7 +193,7 @@ class ThreadCache {
void clear_lowwatermark() { lowater_ = length_; }
void Push(void* ptr) {
- FL_Push(&list_, ptr);
+ SLL_Push(&list_, ptr);
length_++;
}
@@ -200,16 +201,20 @@ class ThreadCache {
ASSERT(list_ != NULL);
length_--;
if (length_ < lowater_) lowater_ = length_;
- return FL_Pop(&list_);
+ return SLL_Pop(&list_);
+ }
+
+ void* Next() {
+ return SLL_Next(&list_);
}
void PushRange(int N, void *start, void *end) {
- FL_PushRange(&list_, start, end);
+ SLL_PushRange(&list_, start, end);
length_ += N;
}
void PopRange(int N, void **start, void **end) {
- FL_PopRange(&list_, N, start, end);
+ SLL_PopRange(&list_, N, start, end);
ASSERT(length_ >= N);
length_ -= N;
if (length_ < lowater_) lowater_ = length_;
@@ -343,6 +348,12 @@ inline void ThreadCache::Deallocate(void* ptr, size_t cl) {
FreeList* list = &list_[cl];
size_ += Static::sizemap()->ByteSizeForClass(cl);
ssize_t size_headroom = max_size_ - size_ - 1;
+
+ // This catches back-to-back frees of allocs in the same size
+ // class. A more comprehensive (and expensive) test would be to walk
+ // the entire freelist. But this might be enough to find some bugs.
+ ASSERT(ptr != list->Next());
+
list->Push(ptr);
ssize_t list_headroom =
static_cast<ssize_t>(list->max_length()) - list->length();
« no previous file with comments | « third_party/tcmalloc/chromium/src/third_party/valgrind.h ('k') | third_party/tcmalloc/chromium/src/thread_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698