diff options
| author | Paul Borman <borman@google.com> | 2012-02-08 14:39:16 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2012-02-08 14:39:16 -0500 |
| commit | d37a8b73c504c232084666b292f20debb397bd27 (patch) | |
| tree | 05044135254dcb16a8292b7b56b6194eb1ee7576 /src/pkg/runtime/malloc.goc | |
| parent | 1127b229763811c5e90d4d96b2c9f150e816df1d (diff) | |
| download | go-d37a8b73c504c232084666b292f20debb397bd27.tar.xz | |
runtime: drop to 32 bit malloc if 64 bit will not work
On 64 bit UML it is not possible to reserve memory at 0xF8<<32.
Detect when linux cannot use these high virtual memory addresses
and drop back to the 32 bit memory allocator.
R=rsc, cw
CC=golang-dev
https://golang.org/cl/5634050
Diffstat (limited to 'src/pkg/runtime/malloc.goc')
| -rw-r--r-- | src/pkg/runtime/malloc.goc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc index f1509cd9d9..4e6bbe1b0f 100644 --- a/src/pkg/runtime/malloc.goc +++ b/src/pkg/runtime/malloc.goc @@ -289,12 +289,13 @@ runtime·mallocinit(void) // Actually we reserve 17 GB (because the bitmap ends up being 1 GB) // but it hardly matters: fc is not valid UTF-8 either, and we have to // allocate 15 GB before we get that far. + // + // If this fails we fall back to the 32 bit memory mechanism arena_size = 16LL<<30; bitmap_size = arena_size / (sizeof(void*)*8/4); p = runtime·SysReserve((void*)(0x00f8ULL<<32), bitmap_size + arena_size); - if(p == nil) - runtime·throw("runtime: cannot reserve arena virtual address space"); - } else { + } + if (p == nil) { // On a 32-bit machine, we can't typically get away // with a giant virtual address space reservation. // Instead we map the memory information bitmap @@ -359,8 +360,8 @@ runtime·MHeap_SysAlloc(MHeap *h, uintptr n) return p; } - // On 64-bit, our reservation is all we have. - if(sizeof(void*) == 8) + // If using 64-bit, our reservation is all we have. + if(sizeof(void*) == 8 && (uintptr)h->bitmap >= 0xffffffffU) return nil; // On 32-bit, once the reservation is gone we can |
