|
27 | 27 | #include "hphp/util/hugetlb.h" |
28 | 28 | #include "hphp/util/numa.h" |
29 | 29 | #include "hphp/util/trace.h" |
| 30 | +#include "util/alloc-defs.h" |
30 | 31 |
|
31 | 32 | namespace HPHP::jit { |
32 | 33 |
|
@@ -117,29 +118,32 @@ CodeCache::CodeCache() { |
117 | 118 | } |
118 | 119 |
|
119 | 120 | #if USE_JEMALLOC |
120 | | - // When we have a low arena, TC must fit below lowArenaMinAddr(). If it |
121 | | - // doesn't, we shrink things to make it so. |
122 | | - auto const lowArenaStart = lowArenaMinAddr(); |
123 | | - if (Cfg::Server::Mode) { |
124 | | - Logger::Info("lowArenaMinAddr(): 0x%lx", lowArenaStart); |
125 | | - } |
126 | | - always_assert_flog( |
127 | | - usedBase + (32u << 20) <= lowArenaStart, |
128 | | - "brk is too big for LOWPTR build (usedBase = {}, lowArenaStart = {})", |
129 | | - usedBase, lowArenaStart |
130 | | - ); |
| 121 | + if constexpr (use_position_dependent_jemalloc_arenas) { |
| 122 | + // When using position-dependent custom arenas, |
| 123 | + // TC must fit below lowArenaMinAddr(). |
| 124 | + // If it doesn't, we shrink things to make it so. |
| 125 | + auto const lowArenaStart = lowArenaMinAddr(); |
| 126 | + if (Cfg::Server::Mode) { |
| 127 | + Logger::Info("lowArenaMinAddr(): 0x%lx", lowArenaStart); |
| 128 | + } |
| 129 | + always_assert_flog( |
| 130 | + usedBase + (32u << 20) <= lowArenaStart, |
| 131 | + "brk is too big for LOWPTR build (usedBase = {}, lowArenaStart = {})", |
| 132 | + usedBase, lowArenaStart |
| 133 | + ); |
131 | 134 |
|
132 | | - if (usedBase + m_totalSize > lowArenaStart) { |
133 | | - cutTCSizeTo(lowArenaStart - usedBase - thread_local_size); |
134 | | - new (this) CodeCache; |
135 | | - return; |
| 135 | + if (usedBase + m_totalSize > lowArenaStart) { |
| 136 | + cutTCSizeTo(lowArenaStart - usedBase - thread_local_size); |
| 137 | + new (this) CodeCache; |
| 138 | + return; |
| 139 | + } |
| 140 | + always_assert_flog( |
| 141 | + usedBase + m_totalSize <= lowArenaStart, |
| 142 | + "computed allocationSize ({}) is too large to fit within " |
| 143 | + "lowArenaStart ({}), usedBase = {}\n", |
| 144 | + m_totalSize, lowArenaStart, usedBase |
| 145 | + ); |
136 | 146 | } |
137 | | - always_assert_flog( |
138 | | - usedBase + m_totalSize <= lowArenaStart, |
139 | | - "computed allocationSize ({}) is too large to fit within " |
140 | | - "lowArenaStart ({}), usedBase = {}\n", |
141 | | - m_totalSize, lowArenaStart, usedBase |
142 | | - ); |
143 | 147 | #endif |
144 | 148 | // Use MAP_FIXED_NOREPLACE instead of MAP_FIXED so we actually get |
145 | 149 | // an error if we overlap with an existing mapping. |
|
0 commit comments