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

Side by Side Diff: third_party/tcmalloc/chromium/src/tcmalloc.cc

Issue 7671034: doubly-linked free-lists for thread caches and page heaps (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: enable doubly linked lists only in Debug builds Created 9 years, 3 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) 2005, Google Inc. 1 // Copyright (c) 2005, 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 #include <vector> // for vector 115 #include <vector> // for vector
116 116
117 #include <google/malloc_extension.h> 117 #include <google/malloc_extension.h>
118 #include <google/malloc_hook.h> // for MallocHook 118 #include <google/malloc_hook.h> // for MallocHook
119 #include "base/basictypes.h" // for int64 119 #include "base/basictypes.h" // for int64
120 #include "base/commandlineflags.h" // for RegisterFlagValidator, etc 120 #include "base/commandlineflags.h" // for RegisterFlagValidator, etc
121 #include "base/dynamic_annotations.h" // for RunningOnValgrind 121 #include "base/dynamic_annotations.h" // for RunningOnValgrind
122 #include "base/spinlock.h" // for SpinLockHolder 122 #include "base/spinlock.h" // for SpinLockHolder
123 #include "central_freelist.h" // for CentralFreeListPadded 123 #include "central_freelist.h" // for CentralFreeListPadded
124 #include "common.h" // for StackTrace, kPageShift, etc 124 #include "common.h" // for StackTrace, kPageShift, etc
125 #include "free_list.h" // for FL_Init
125 #include "internal_logging.h" // for ASSERT, TCMalloc_Printer, etc 126 #include "internal_logging.h" // for ASSERT, TCMalloc_Printer, etc
126 #include "linked_list.h" // for SLL_SetNext
127 #include "malloc_hook-inl.h" // for MallocHook::InvokeNewHook, etc 127 #include "malloc_hook-inl.h" // for MallocHook::InvokeNewHook, etc
128 #include "page_heap.h" // for PageHeap, PageHeap::Stats 128 #include "page_heap.h" // for PageHeap, PageHeap::Stats
129 #include "page_heap_allocator.h" // for PageHeapAllocator 129 #include "page_heap_allocator.h" // for PageHeapAllocator
130 #include "span.h" // for Span, DLL_Prepend, etc 130 #include "span.h" // for Span, DLL_Prepend, etc
131 #include "stack_trace_table.h" // for StackTraceTable 131 #include "stack_trace_table.h" // for StackTraceTable
132 #include "static_vars.h" // for Static 132 #include "static_vars.h" // for Static
133 #include "system-alloc.h" // for DumpSystemAllocatorStats, etc 133 #include "system-alloc.h" // for DumpSystemAllocatorStats, etc
134 #include "tcmalloc_guard.h" // for TCMallocGuard 134 #include "tcmalloc_guard.h" // for TCMallocGuard
135 #include "thread_cache.h" // for ThreadCache 135 #include "thread_cache.h" // for ThreadCache
136 136
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 1220
1221 ValidateAllocatedRegion(ptr, cl); 1221 ValidateAllocatedRegion(ptr, cl);
1222 1222
1223 if (cl != 0) { 1223 if (cl != 0) {
1224 ASSERT(!Static::pageheap()->GetDescriptor(p)->sample); 1224 ASSERT(!Static::pageheap()->GetDescriptor(p)->sample);
1225 ThreadCache* heap = GetCacheIfPresent(); 1225 ThreadCache* heap = GetCacheIfPresent();
1226 if (heap != NULL) { 1226 if (heap != NULL) {
1227 heap->Deallocate(ptr, cl); 1227 heap->Deallocate(ptr, cl);
1228 } else { 1228 } else {
1229 // Delete directly into central cache 1229 // Delete directly into central cache
1230 tcmalloc::SLL_SetNext(ptr, NULL); 1230 tcmalloc::FL_Init(ptr);
1231 Static::central_cache()[cl].InsertRange(ptr, ptr, 1); 1231 Static::central_cache()[cl].InsertRange(ptr, ptr, 1);
1232 } 1232 }
1233 } else { 1233 } else {
1234 SpinLockHolder h(Static::pageheap_lock()); 1234 SpinLockHolder h(Static::pageheap_lock());
1235 ASSERT(reinterpret_cast<uintptr_t>(ptr) % kPageSize == 0); 1235 ASSERT(reinterpret_cast<uintptr_t>(ptr) % kPageSize == 0);
1236 ASSERT(span != NULL && span->start == p); 1236 ASSERT(span != NULL && span->start == p);
1237 if (span->sample) { 1237 if (span->sample) {
1238 StackTrace* st = reinterpret_cast<StackTrace*>(span->objects); 1238 StackTrace* st = reinterpret_cast<StackTrace*>(span->objects);
1239 tcmalloc::DLL_Remove(span); 1239 tcmalloc::DLL_Remove(span);
1240 Static::stacktrace_allocator()->Delete(st); 1240 Static::stacktrace_allocator()->Delete(st);
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 *mark = ~allocated_mark; // Distinctively not allocated. 1926 *mark = ~allocated_mark; // Distinctively not allocated.
1927 } 1927 }
1928 1928
1929 static void MarkAllocatedRegion(void* ptr) { 1929 static void MarkAllocatedRegion(void* ptr) {
1930 if (ptr == NULL) return; 1930 if (ptr == NULL) return;
1931 MarkType* mark = GetMarkLocation(ptr); 1931 MarkType* mark = GetMarkLocation(ptr);
1932 *mark = GetMarkValue(ptr, mark); 1932 *mark = GetMarkValue(ptr, mark);
1933 } 1933 }
1934 1934
1935 #endif // TCMALLOC_VALIDATION 1935 #endif // TCMALLOC_VALIDATION
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/page_heap_allocator.h ('k') | third_party/tcmalloc/chromium/src/thread_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698