Skip to content
This repository was archived by the owner on Feb 19, 2019. It is now read-only.

Commit 8099985

Browse files
author
ian
committed
runtime: adapt memory management to AIX mmap
On AIX: * mmap does not allow to map an already mapped range, * mmap range start at 0x30000000 for 32 bits processes, * mmap range start at 0x70000000_00000000 for 64 bits processes This is adapted from change 37845. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/46772 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249713 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent 17e0246 commit 8099985

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

gcc/go/gofrontend/MERGE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
63b766d67098877496a4b79d7f41e731fbe8abc8
1+
66d14d95a5a453682fe387319c80bc4fc40d96ad
22

33
The first line of this file holds the git revision number of the last
44
merge done from the gofrontend repository.

libgo/go/runtime/malloc.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ func mallocinit() {
291291
// allocation at 0x40 << 32 because when using 4k pages with 3-level
292292
// translation buffers, the user address space is limited to 39 bits
293293
// On darwin/arm64, the address space is even smaller.
294+
// On AIX, mmap adresses range start at 0x07000000_00000000 for 64 bits
295+
// processes.
294296
arenaSize := round(_MaxMem, _PageSize)
295297
bitmapSize = arenaSize / (sys.PtrSize * 8 / 2)
296298
spansSize = arenaSize / _PageSize * sys.PtrSize
@@ -301,12 +303,15 @@ func mallocinit() {
301303
p = uintptr(i)<<40 | uintptrMask&(0x0013<<28)
302304
case GOARCH == "arm64":
303305
p = uintptr(i)<<40 | uintptrMask&(0x0040<<32)
306+
case GOOS == "aix":
307+
i = 1
308+
p = uintptr(i)<<32 | uintptrMask&(0x70<<52)
304309
default:
305310
p = uintptr(i)<<40 | uintptrMask&(0x00c0<<32)
306311
}
307312
pSize = bitmapSize + spansSize + arenaSize + _PageSize
308313
p = uintptr(sysReserve(unsafe.Pointer(p), pSize, &reserved))
309-
if p != 0 {
314+
if p != 0 || GOOS == "aix" { // Useless to loop on AIX, as i is forced to 1
310315
break
311316
}
312317
}

libgo/go/runtime/mem_gccgo.go

+5
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,11 @@ func sysMap(v unsafe.Pointer, n uintptr, reserved bool, sysStat *uint64) {
270270
return
271271
}
272272

273+
if GOOS == "aix" {
274+
// AIX does not allow mapping a range that is already mapped.
275+
// So always unmap first even if it is already unmapped.
276+
munmap(v, n)
277+
}
273278
p := mmap(v, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_FIXED|_MAP_PRIVATE, mmapFD, 0)
274279
if uintptr(p) == _MAP_FAILED && errno() == _ENOMEM {
275280
throw("runtime: out of memory")

libgo/runtime/runtime_c.c

+6
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,19 @@ uintptr getEnd(void)
139139
uintptr
140140
getEnd()
141141
{
142+
#ifdef _AIX
143+
// mmap adresses range start at 0x30000000 on AIX for 32 bits processes
144+
uintptr end = 0x30000000U;
145+
#else
142146
uintptr end = 0;
143147
uintptr *pend;
144148

145149
pend = &__go_end;
146150
if (pend != nil) {
147151
end = *pend;
148152
}
153+
#endif
154+
149155
return end;
150156
}
151157

0 commit comments

Comments
 (0)