Lines 248-254
static void* ComputeRandomAllocationAddress() {
Link Here
|
248 |
// x64 CPUs have a 48-bit address space and on some platforms the OS will |
248 |
// x64 CPUs have a 48-bit address space and on some platforms the OS will |
249 |
// give us access to 47 bits, so to be safe we right shift by 18 to leave |
249 |
// give us access to 47 bits, so to be safe we right shift by 18 to leave |
250 |
// 46 bits. |
250 |
// 46 bits. |
|
|
251 |
# ifdef __ia64__ |
252 |
// On ia64 virtual address space looks like one of: |
253 |
// virt_addr_64 = [ <63..61> | <unimplemented> | L3 | L2 | L1 | offset ] |
254 |
// virt_addr_64 = [ <63..61> | <unimplemented> | L4 | L3 | L2 | L1 | offset ] |
255 |
// where L{1..L4} are page tables. Each page table (except top-level L3 or L4) |
256 |
// is itself a page-size entry and can store PageSize / 8 entries. Top-level |
257 |
// entry is 1/8 of of L1/L2 (as 3 upper bits are part of <63..61> address part). |
258 |
// Note: that makes addressable size directly depend on page size. |
259 |
// |
260 |
// We conservatively assume 3 levels of page tables here. This makes the |
261 |
// following formula: |
262 |
// L3 = log2(PAGE / 8 / 8) = log2(PAGE / 8) - 3 |
263 |
// L2 = log2(PAGE / 8) |
264 |
// L1 = log2(PAGE / 8) |
265 |
// offset = log2(PAGE) = log2(PAGE / 8) + 3 |
266 |
// thus |
267 |
// L3 + L2 + L1 + offset = 4 * log2(PAGE / 8) |
268 |
// For more details see http://www.ia64-linux.org/doc/IA64linuxkernel.PDF |
269 |
// (slide 19: "user regions"). |
270 |
static uint64_t ia64_virt_bits = std::min<uint64_t>( |
271 |
4 * (mozilla::FloorLog2(gc::SystemPageSize() / 8)), |
272 |
46); |
273 |
rand >>= (64 - ia64_virt_bits); |
274 |
# else |
251 |
rand >>= 18; |
275 |
rand >>= 18; |
|
|
276 |
# endif |
252 |
#else |
277 |
#else |
253 |
// On 32-bit, right shift by 34 to leave 30 bits, range [0, 1GiB). Then add |
278 |
// On 32-bit, right shift by 34 to leave 30 bits, range [0, 1GiB). Then add |
254 |
// 512MiB to get range [512MiB, 1.5GiB), or [0x20000000, 0x60000000). This |
279 |
// 512MiB to get range [512MiB, 1.5GiB), or [0x20000000, 0x60000000). This |
255 |
- |
|
|