From 9195aa172bbc20627f23bfb1612180c83a0a7bab Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 19 Mar 2019 14:00:59 +0000 Subject: libgo: fix build on AIX Since aix/ppc64 has been added to GC toolchain, a mix between new and old files were created in gcc toolchain. This commit corrects this merge for aix/ppc64 and aix/ppc. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/167658 From-SVN: r269797 --- libgo/go/runtime/malloc.go | 6 +++--- libgo/go/runtime/mem_gccgo.go | 5 +++++ libgo/go/runtime/netpoll_aix.go | 1 - libgo/go/runtime/os_aix.go | 17 ++++++++++++----- libgo/go/runtime/stubs2.go | 1 - libgo/go/runtime/timestub2.go | 2 -- 6 files changed, 20 insertions(+), 12 deletions(-) (limited to 'libgo/go/runtime') diff --git a/libgo/go/runtime/malloc.go b/libgo/go/runtime/malloc.go index b6a7ee1..c0b4caa 100644 --- a/libgo/go/runtime/malloc.go +++ b/libgo/go/runtime/malloc.go @@ -218,7 +218,7 @@ const ( // we further limit it to 31 bits. // // WebAssembly currently has a limit of 4GB linear memory. - heapAddrBits = (_64bit*(1-sys.GoarchWasm)*(1-sys.GoosAix))*48 + (1-_64bit+sys.GoarchWasm)*(32-(sys.GoarchMips+sys.GoarchMipsle)) + 60*sys.GoosAix + heapAddrBits = (_64bit*(1-sys.GoarchWasm)*(1-sys.GoosAix))*48 + (1-_64bit+sys.GoarchWasm)*(32-(sys.GoarchMips+sys.GoarchMipsle)) + 60*(sys.GoosAix*_64bit) // maxAlloc is the maximum size of an allocation. On 64-bit, // it's theoretically possible to allocate 1<= 1e9 { - ts.tv_sec++ - ts.tv_nsec -= 1e9 + + sec := int64(ts.tv_sec) + ns/1e9 + nsec := int64(ts.tv_nsec) + ns%1e9 + if nsec >= 1e9 { + sec++ + nsec -= 1e9 + } + if sec != int64(timespec_sec_t(sec)) { + // Handle overflows (timespec_sec_t is 32-bit in 32-bit applications) + sec = 1<<31 - 1 } + ts.tv_sec = timespec_sec_t(sec) + ts.tv_nsec = timespec_nsec_t(nsec) if sem_timedwait((*semt)(unsafe.Pointer(_m_.mos.waitsema)), &ts) != 0 { err := errno() diff --git a/libgo/go/runtime/stubs2.go b/libgo/go/runtime/stubs2.go index 304c8e4..1cb910c 100644 --- a/libgo/go/runtime/stubs2.go +++ b/libgo/go/runtime/stubs2.go @@ -7,7 +7,6 @@ // +build !nacl // +build !js // +build !darwin -// +build !aix package runtime diff --git a/libgo/go/runtime/timestub2.go b/libgo/go/runtime/timestub2.go index 00c2c55..7a28603 100644 --- a/libgo/go/runtime/timestub2.go +++ b/libgo/go/runtime/timestub2.go @@ -5,8 +5,6 @@ // +build !darwin // +build !windows // +build !freebsd -// +build !aix - package runtime func walltime() (sec int64, nsec int32) -- cgit v1.1 From ea5ac5a69b4b474bb221051e705f98d8599253fa Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 19 Mar 2019 18:42:43 +0000 Subject: compiler,runtime: pass old slice's ptr/len/cap by value to growslice In the C calling convention, on AMD64, and probably a number of other architectures, a 3-word struct argument is passed on stack. This is less efficient than passing in three registers. Further, this may affect the code generation in other part of the program, even if the function is not actually called. Slices are common in Go and append is a common slice operation, which calls growslice in the growing path. To improve the code generation, pass the slice header's three fields as separate values, instead of a struct, to growslice. The drawback is that this makes the runtime implementation slightly diverges from the gc runtime. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/168277 From-SVN: r269811 --- libgo/go/runtime/slice.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'libgo/go/runtime') diff --git a/libgo/go/runtime/slice.go b/libgo/go/runtime/slice.go index 335532d..9137951 100644 --- a/libgo/go/runtime/slice.go +++ b/libgo/go/runtime/slice.go @@ -77,31 +77,31 @@ func makeslice64(et *_type, len64, cap64 int64) unsafe.Pointer { // and it returns a new slice with at least that capacity, with the old data // copied into it. // The new slice's length is set to the requested capacity. -func growslice(et *_type, old slice, cap int) slice { +func growslice(et *_type, oldarray unsafe.Pointer, oldlen, oldcap, cap int) slice { if raceenabled { callerpc := getcallerpc() - racereadrangepc(old.array, uintptr(old.len*int(et.size)), callerpc, funcPC(growslice)) + racereadrangepc(oldarray, uintptr(oldlen*int(et.size)), callerpc, funcPC(growslice)) } if msanenabled { - msanread(old.array, uintptr(old.len*int(et.size))) + msanread(oldarray, uintptr(oldlen*int(et.size))) } - if cap < old.cap { + if cap < oldcap { panic(errorString("growslice: cap out of range")) } if et.size == 0 { // append should not create a slice with nil pointer but non-zero len. - // We assume that append doesn't need to preserve old.array in this case. + // We assume that append doesn't need to preserve oldarray in this case. return slice{unsafe.Pointer(&zerobase), cap, cap} } - newcap := old.cap + newcap := oldcap doublecap := newcap + newcap if cap > doublecap { newcap = cap } else { - if old.len < 1024 { + if oldlen < 1024 { newcap = doublecap } else { // Check 0 < newcap to detect overflow @@ -125,13 +125,13 @@ func growslice(et *_type, old slice, cap int) slice { // For powers of 2, use a variable shift. switch { case et.size == 1: - lenmem = uintptr(old.len) + lenmem = uintptr(oldlen) newlenmem = uintptr(cap) capmem = roundupsize(uintptr(newcap)) overflow = uintptr(newcap) > maxAlloc newcap = int(capmem) case et.size == sys.PtrSize: - lenmem = uintptr(old.len) * sys.PtrSize + lenmem = uintptr(oldlen) * sys.PtrSize newlenmem = uintptr(cap) * sys.PtrSize capmem = roundupsize(uintptr(newcap) * sys.PtrSize) overflow = uintptr(newcap) > maxAlloc/sys.PtrSize @@ -144,13 +144,13 @@ func growslice(et *_type, old slice, cap int) slice { } else { shift = uintptr(sys.Ctz32(uint32(et.size))) & 31 } - lenmem = uintptr(old.len) << shift + lenmem = uintptr(oldlen) << shift newlenmem = uintptr(cap) << shift capmem = roundupsize(uintptr(newcap) << shift) overflow = uintptr(newcap) > (maxAlloc >> shift) newcap = int(capmem >> shift) default: - lenmem = uintptr(old.len) * et.size + lenmem = uintptr(oldlen) * et.size newlenmem = uintptr(cap) * et.size capmem, overflow = math.MulUintptr(et.size, uintptr(newcap)) capmem = roundupsize(capmem) @@ -177,19 +177,19 @@ func growslice(et *_type, old slice, cap int) slice { var p unsafe.Pointer if et.kind&kindNoPointers != 0 { p = mallocgc(capmem, nil, false) - // The append() that calls growslice is going to overwrite from old.len to cap (which will be the new length). + // The append() that calls growslice is going to overwrite from oldlen to cap (which will be the new length). // Only clear the part that will not be overwritten. memclrNoHeapPointers(add(p, newlenmem), capmem-newlenmem) } else { // Note: can't use rawmem (which avoids zeroing of memory), because then GC can scan uninitialized memory. p = mallocgc(capmem, et, true) if writeBarrier.enabled { - // Only shade the pointers in old.array since we know the destination slice p + // Only shade the pointers in oldarray since we know the destination slice p // only contains nil pointers because it has been cleared during alloc. - bulkBarrierPreWriteSrcOnly(uintptr(p), uintptr(old.array), lenmem) + bulkBarrierPreWriteSrcOnly(uintptr(p), uintptr(oldarray), lenmem) } } - memmove(p, old.array, lenmem) + memmove(p, oldarray, lenmem) return slice{p, cap, newcap} } -- cgit v1.1 From 04862afe9f5c54a420823f95bb6ae152eec64b8b Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 8 Apr 2019 18:36:25 +0000 Subject: libgo: update to Go 1.12.2 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/170706 From-SVN: r270214 --- libgo/go/runtime/runtime-lldb_test.go | 1 + 1 file changed, 1 insertion(+) (limited to 'libgo/go/runtime') diff --git a/libgo/go/runtime/runtime-lldb_test.go b/libgo/go/runtime/runtime-lldb_test.go index fe3a0eb..08d6a34 100644 --- a/libgo/go/runtime/runtime-lldb_test.go +++ b/libgo/go/runtime/runtime-lldb_test.go @@ -139,6 +139,7 @@ func TestLldbPython(t *testing.T) { if final := os.Getenv("GOROOT_FINAL"); final != "" && runtime.GOROOT() != final { t.Skip("gdb test can fail with GOROOT_FINAL pending") } + testenv.SkipFlaky(t, 31188) checkLldbPython(t) -- cgit v1.1