diff options
Diffstat (limited to 'src/runtime/malloc.go')
| -rw-r--r-- | src/runtime/malloc.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 3a533d9100..14dc6765f7 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -411,12 +411,14 @@ func (h *mheap) sysAlloc(n uintptr) unsafe.Pointer { if p == 0 { return nil } + // p can be just about anywhere in the address + // space, including before arena_end. if p == h.arena_end { // The new reservation is contiguous // with the old reservation. h.arena_end = new_end h.arena_reserved = reserved - } else if h.arena_start <= p && p+p_size-h.arena_start-1 <= _MaxMem { + } else if h.arena_end < p && p+p_size-h.arena_start-1 <= _MaxMem { // We were able to reserve more memory // within the arena space, but it's // not contiguous with our previous @@ -430,6 +432,16 @@ func (h *mheap) sysAlloc(n uintptr) unsafe.Pointer { h.setArenaUsed(used, false) h.arena_reserved = reserved } else { + // We got a mapping, but it's not + // linear with our current arena, so + // we can't use it. + // + // TODO: Make it possible to allocate + // from this. We can't decrease + // arena_used, but we could introduce + // a new variable for the current + // allocation position. + // We haven't added this allocation to // the stats, so subtract it from a // fake stat (but avoid underflow). |
