OLD | NEW |
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 "internal_logging.h" // for ASSERT, TCMalloc_Printer, etc | 125 #include "internal_logging.h" // for ASSERT, TCMalloc_Printer, etc |
126 #include "linked_list.h" // for SLL_SetNext | 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 "metadata_encrypt.h" |
128 #include "page_heap.h" // for PageHeap, PageHeap::Stats | 129 #include "page_heap.h" // for PageHeap, PageHeap::Stats |
129 #include "page_heap_allocator.h" // for PageHeapAllocator | 130 #include "page_heap_allocator.h" // for PageHeapAllocator |
130 #include "span.h" // for Span, DLL_Prepend, etc | 131 #include "span.h" // for Span, DLL_Prepend, etc |
131 #include "stack_trace_table.h" // for StackTraceTable | 132 #include "stack_trace_table.h" // for StackTraceTable |
132 #include "static_vars.h" // for Static | 133 #include "static_vars.h" // for Static |
133 #include "system-alloc.h" // for DumpSystemAllocatorStats, etc | 134 #include "system-alloc.h" // for DumpSystemAllocatorStats, etc |
134 #include "tcmalloc_guard.h" // for TCMallocGuard | 135 #include "tcmalloc_guard.h" // for TCMallocGuard |
135 #include "thread_cache.h" // for ThreadCache | 136 #include "thread_cache.h" // for ThreadCache |
136 | 137 |
137 // We only need malloc.h for struct mallinfo. | 138 // We only need malloc.h for struct mallinfo. |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 TCMallocGuard::TCMallocGuard() { | 979 TCMallocGuard::TCMallocGuard() { |
979 if (tcmallocguard_refcount++ == 0) { | 980 if (tcmallocguard_refcount++ == 0) { |
980 #ifdef HAVE_TLS // this is true if the cc/ld/libc combo support TLS | 981 #ifdef HAVE_TLS // this is true if the cc/ld/libc combo support TLS |
981 // Check whether the kernel also supports TLS (needs to happen at runtime) | 982 // Check whether the kernel also supports TLS (needs to happen at runtime) |
982 tcmalloc::CheckIfKernelSupportsTLS(); | 983 tcmalloc::CheckIfKernelSupportsTLS(); |
983 #endif | 984 #endif |
984 #ifdef WIN32_DO_PATCHING | 985 #ifdef WIN32_DO_PATCHING |
985 // patch the windows VirtualAlloc, etc. | 986 // patch the windows VirtualAlloc, etc. |
986 PatchWindowsFunctions(); // defined in windows/patch_functions.cc | 987 PatchWindowsFunctions(); // defined in windows/patch_functions.cc |
987 #endif | 988 #endif |
| 989 tcmalloc::InitEncryption(); |
988 tc_free(tc_malloc(1)); | 990 tc_free(tc_malloc(1)); |
989 ThreadCache::InitTSD(); | 991 ThreadCache::InitTSD(); |
990 tc_free(tc_malloc(1)); | 992 tc_free(tc_malloc(1)); |
991 // Either we, or debugallocation.cc, or valgrind will control memory | 993 // Either we, or debugallocation.cc, or valgrind will control memory |
992 // management. We register our extension if we're the winner. | 994 // management. We register our extension if we're the winner. |
993 #ifdef TCMALLOC_USING_DEBUGALLOCATION | 995 #ifdef TCMALLOC_USING_DEBUGALLOCATION |
994 // Let debugallocation register its extension. | 996 // Let debugallocation register its extension. |
995 #else | 997 #else |
996 if (RunningOnValgrind()) { | 998 if (RunningOnValgrind()) { |
997 // Let Valgrind uses its own malloc (so don't register our extension). | 999 // Let Valgrind uses its own malloc (so don't register our extension). |
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1926 *mark = ~allocated_mark; // Distinctively not allocated. | 1928 *mark = ~allocated_mark; // Distinctively not allocated. |
1927 } | 1929 } |
1928 | 1930 |
1929 static void MarkAllocatedRegion(void* ptr) { | 1931 static void MarkAllocatedRegion(void* ptr) { |
1930 if (ptr == NULL) return; | 1932 if (ptr == NULL) return; |
1931 MarkType* mark = GetMarkLocation(ptr); | 1933 MarkType* mark = GetMarkLocation(ptr); |
1932 *mark = GetMarkValue(ptr, mark); | 1934 *mark = GetMarkValue(ptr, mark); |
1933 } | 1935 } |
1934 | 1936 |
1935 #endif // TCMALLOC_VALIDATION | 1937 #endif // TCMALLOC_VALIDATION |
OLD | NEW |