summaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/malloc.go14
-rw-r--r--src/runtime/mbitmap.go1
-rw-r--r--src/runtime/mgc.go2
-rw-r--r--src/runtime/sys_linux_386.s7
-rw-r--r--src/runtime/sys_linux_amd64.s9
-rw-r--r--src/runtime/sys_linux_arm.s7
6 files changed, 31 insertions, 9 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go
index da39dac510..6f07731a49 100644
--- a/src/runtime/malloc.go
+++ b/src/runtime/malloc.go
@@ -400,10 +400,12 @@ 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 {
h.arena_end = new_end
h.arena_reserved = reserved
- } else if h.arena_start <= p && p+p_size-h.arena_start-1 <= _MaxArena32 {
+ } else if h.arena_end < p && p+p_size-h.arena_start-1 <= _MaxArena32 {
// Keep everything page-aligned.
// Our pages are bigger than hardware pages.
h.arena_end = p + p_size
@@ -413,6 +415,16 @@ func (h *mheap) sysAlloc(n uintptr) unsafe.Pointer {
h.arena_used = used
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).
diff --git a/src/runtime/mbitmap.go b/src/runtime/mbitmap.go
index 89d8a4cc76..9b988fae25 100644
--- a/src/runtime/mbitmap.go
+++ b/src/runtime/mbitmap.go
@@ -374,6 +374,7 @@ func heapBitsForAddr(addr uintptr) heapBits {
// heapBitsForSpan returns the heapBits for the span base address base.
func heapBitsForSpan(base uintptr) (hbits heapBits) {
if base < mheap_.arena_start || base >= mheap_.arena_used {
+ print("runtime: base ", hex(base), " not in range [", hex(mheap_.arena_start), ",", hex(mheap_.arena_used), ")\n")
throw("heapBitsForSpan: base out of range")
}
return heapBitsForAddr(base)
diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go
index cd57720917..8f424926cb 100644
--- a/src/runtime/mgc.go
+++ b/src/runtime/mgc.go
@@ -1918,7 +1918,7 @@ func gchelper() {
traceGCScanDone()
}
- nproc := work.nproc // work.nproc can change right after we increment work.ndone
+ nproc := atomic.Load(&work.nproc) // work.nproc can change right after we increment work.ndone
if atomic.Xadd(&work.ndone, +1) == nproc-1 {
notewakeup(&work.alldone)
}
diff --git a/src/runtime/sys_linux_386.s b/src/runtime/sys_linux_386.s
index 45320c068a..ba6f7cc8dd 100644
--- a/src/runtime/sys_linux_386.s
+++ b/src/runtime/sys_linux_386.s
@@ -98,15 +98,18 @@ TEXT runtime·usleep(SB),NOSPLIT,$8
MOVL $1000000, CX
DIVL CX
MOVL AX, 0(SP)
+ MOVL $1000, AX // usec to nsec
+ MULL DX
MOVL DX, 4(SP)
- // select(0, 0, 0, 0, &tv)
- MOVL $142, AX
+ // pselect6(0, 0, 0, 0, &ts, 0)
+ MOVL $308, AX
MOVL $0, BX
MOVL $0, CX
MOVL $0, DX
MOVL $0, SI
LEAL 0(SP), DI
+ MOVL $0, BP
INVOKE_SYSCALL
RET
diff --git a/src/runtime/sys_linux_amd64.s b/src/runtime/sys_linux_amd64.s
index 6ddcb30ae2..8ab8d12d0f 100644
--- a/src/runtime/sys_linux_amd64.s
+++ b/src/runtime/sys_linux_amd64.s
@@ -82,15 +82,18 @@ TEXT runtime·usleep(SB),NOSPLIT,$16
MOVL $1000000, CX
DIVL CX
MOVQ AX, 0(SP)
- MOVQ DX, 8(SP)
+ MOVL $1000, AX // usec to nsec
+ MULL DX
+ MOVQ AX, 8(SP)
- // select(0, 0, 0, 0, &tv)
+ // pselect6(0, 0, 0, 0, &ts, 0)
MOVL $0, DI
MOVL $0, SI
MOVL $0, DX
MOVL $0, R10
MOVQ SP, R8
- MOVL $23, AX
+ MOVL $0, R9
+ MOVL $270, AX
SYSCALL
RET
diff --git a/src/runtime/sys_linux_arm.s b/src/runtime/sys_linux_arm.s
index 666b879f02..f21a351c05 100644
--- a/src/runtime/sys_linux_arm.s
+++ b/src/runtime/sys_linux_arm.s
@@ -36,7 +36,7 @@
#define SYS_gettid (SYS_BASE + 224)
#define SYS_tkill (SYS_BASE + 238)
#define SYS_sched_yield (SYS_BASE + 158)
-#define SYS_select (SYS_BASE + 142) // newselect
+#define SYS_pselect6 (SYS_BASE + 335)
#define SYS_ugetrlimit (SYS_BASE + 191)
#define SYS_sched_getaffinity (SYS_BASE + 242)
#define SYS_clock_gettime (SYS_BASE + 263)
@@ -387,13 +387,16 @@ TEXT runtime·usleep(SB),NOSPLIT,$12
MOVW usec+0(FP), R0
CALL runtime·usplitR0(SB)
MOVW R0, 4(R13)
+ MOVW $1000, R0 // usec to nsec
+ MUL R0, R1
MOVW R1, 8(R13)
MOVW $0, R0
MOVW $0, R1
MOVW $0, R2
MOVW $0, R3
MOVW $4(R13), R4
- MOVW $SYS_select, R7
+ MOVW $0, R5
+ MOVW $SYS_pselect6, R7
SWI $0
RET