File tree 1 file changed +18
-2
lines changed
1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -41,15 +41,31 @@ void arena::initialize_semispace() {
41
41
abort ();
42
42
}
43
43
//
44
+ // std::align() may modify addr and request.
45
+ //
46
+ auto *start_block = reinterpret_cast <char *>(addr);
47
+ auto *end_block = start_block + request;
48
+ //
44
49
// We allocated 2 * HYPERBLOCK_SIZE worth of address space but we're only going to use 1, aligned on a
45
50
// HYPERBLOCK_SIZE boundry. This is so we can get end of the hyperblock by setting the low bits of any
46
51
// address within the space to 1.
47
- // We don't worry about unused address space either side of our aligned address space because there will be no
48
- // memory mapped to it.
49
52
//
50
53
current_addr_ptr = reinterpret_cast <char *>(
51
54
std::align (HYPERBLOCK_SIZE, HYPERBLOCK_SIZE, addr, request));
52
55
//
56
+ // Release any unused address space at the start of the mmap()ed block.
57
+ //
58
+ if (size_t front_slop = current_addr_ptr - start_block) {
59
+ munmap (start_block, front_slop);
60
+ }
61
+ //
62
+ // Release any unused address space at the end of the mmap()ed block.
63
+ //
64
+ auto *end_aligned = current_addr_ptr + HYPERBLOCK_SIZE;
65
+ if (size_t back_slop = end_block - end_aligned) {
66
+ munmap (end_aligned, back_slop);
67
+ }
68
+ //
53
69
// We put a semispace id in the last byte of the hyperblock so we can identify which semispace an address
54
70
// belongs to by setting the low bits to 1 to access this id.
55
71
//
You can’t perform that action at this time.
0 commit comments