| OLD | NEW |
| 1 // Copyright (c) 2005, Google Inc. | 1 // Copyright (c) 2011, 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 |
| 11 // copyright notice, this list of conditions and the following disclaimer | 11 // copyright notice, this list of conditions and the following disclaimer |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |