OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <config.h> | 5 #include <config.h> |
6 | 6 |
7 // When defined, different heap allocators can be used via an environment | 7 // When defined, different heap allocators can be used via an environment |
8 // variable set before running the program. This may reduce the amount | 8 // variable set before running the program. This may reduce the amount |
9 // of inlining that we get with malloc/free/etc. Disabling makes it | 9 // of inlining that we get with malloc/free/etc. Disabling makes it |
10 // so that only tcmalloc can be used. | 10 // so that only tcmalloc can be used. |
(...skipping 17 matching lines...) Expand all Loading... |
28 static int new_mode = 0; | 28 static int new_mode = 0; |
29 | 29 |
30 typedef enum { | 30 typedef enum { |
31 TCMALLOC, // TCMalloc is the default allocator. | 31 TCMALLOC, // TCMalloc is the default allocator. |
32 JEMALLOC, // JEMalloc | 32 JEMALLOC, // JEMalloc |
33 WINDEFAULT, // Windows Heap | 33 WINDEFAULT, // Windows Heap |
34 WINLFH, // Windows LFH Heap | 34 WINLFH, // Windows LFH Heap |
35 } Allocator; | 35 } Allocator; |
36 | 36 |
37 // This is the default allocator. | 37 // This is the default allocator. |
38 static Allocator allocator = TCMALLOC; | 38 static Allocator allocator = JEMALLOC; |
39 | 39 |
40 // We include tcmalloc and the win_allocator to get as much inlining as | 40 // We include tcmalloc and the win_allocator to get as much inlining as |
41 // possible. | 41 // possible. |
42 #include "tcmalloc.cc" | 42 #include "tcmalloc.cc" |
43 #include "win_allocator.cc" | 43 #include "win_allocator.cc" |
44 | 44 |
45 // Forward declarations from jemalloc. | 45 // Forward declarations from jemalloc. |
46 extern "C" { | 46 extern "C" { |
47 void* je_malloc(size_t s); | 47 void* je_malloc(size_t s); |
48 void* je_realloc(void* p, size_t s); | 48 void* je_realloc(void* p, size_t s); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // to test whether the CRT has been initialized. Once we've ripped out | 251 // to test whether the CRT has been initialized. Once we've ripped out |
252 // the allocators from libcmt, we need to provide this definition so that | 252 // the allocators from libcmt, we need to provide this definition so that |
253 // the rest of the CRT is still usable. | 253 // the rest of the CRT is still usable. |
254 extern "C" void* _crtheap = reinterpret_cast<void*>(1); | 254 extern "C" void* _crtheap = reinterpret_cast<void*>(1); |
255 | 255 |
256 #endif // WIN32 | 256 #endif // WIN32 |
257 | 257 |
258 #include "generic_allocators.cc" | 258 #include "generic_allocators.cc" |
259 | 259 |
260 } // extern C | 260 } // extern C |
OLD | NEW |