use new hugify method only in fb builds
[hiphop-php.git] / hphp / util / alloc-defs.h
blobe48e822f588f3f023b32a9db1ccba92081921cbe
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
16 #ifndef incl_HPHP_COMPILATION_ALLOC_FLAGS_H
17 #define incl_HPHP_COMPILATION_ALLOC_FLAGS_H
19 #include <cstddef>
21 #include <folly/CPortability.h>
22 #include "hphp/util/low-ptr-def.h"
24 #if FOLLY_SANITIZE
25 // ASan is less precise than valgrind so we'll need a superset of those tweaks
26 # define VALGRIND
27 // TODO: (t2869817) ASan doesn't play well with jemalloc
28 # ifdef USE_JEMALLOC
29 # undef USE_JEMALLOC
30 # endif
31 #endif
33 #ifdef USE_JEMALLOC
34 #include <jemalloc/jemalloc.h>
35 # if (JEMALLOC_VERSION_MAJOR >= 5) && defined(USE_LOWPTR) && \
36 defined(__linux__) && !defined(USE_JEMALLOC_EXTENT_HOOKS)
37 # define USE_JEMALLOC_EXTENT_HOOKS 1
38 # endif
39 # if USE_JEMALLOC_EXTENT_HOOKS
40 # if (JEMALLOC_VERSION_MAJOR > 5) || (JEMALLOC_VERSION_MINOR >= 1)
41 # define JEMALLOC_METADATA_1G_PAGES 1
42 # endif
43 # endif
44 # if (JEMALLOC_VERSION_MAJOR > 4)
45 # define JEMALLOC_NEW_ARENA_CMD "arenas.create"
46 # else
47 # define JEMALLOC_NEW_ARENA_CMD "arenas.extend"
48 # endif
49 #endif
51 namespace HPHP {
52 constexpr bool use_jemalloc =
53 #ifdef USE_JEMALLOC
54 true
55 #else
56 false
57 #endif
60 // When we have control over the virtual address space for the heap, all
61 // static/uncounted strings/arrays have addresses lower than kUncountedMaxAddr,
62 // and all counted HeapObjects have higher addresses.
63 constexpr bool addr_encodes_persistency =
64 #if USE_JEMALLOC_EXTENT_HOOKS && defined(__x86_64__) && defined(__linux__)
65 true
66 #else
67 false
68 #endif
71 // ASAN modifies the generated code in ways that cause abnormally high C++
72 // stack usage.
73 constexpr size_t kStackSizeMinimum =
74 #if FOLLY_SANITIZE
75 16 << 20;
76 #else
77 8 << 20;
78 #endif
80 extern const size_t s_pageSize;
84 #endif