From 03ef105daeff4fef1fd66dbffb8e17d1f779b9ea Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 10 Oct 2019 16:16:54 +0000 Subject: all: remove nacl (part 3, more amd64p32) Part 1: CL 199499 (GOOS nacl) Part 2: CL 200077 (amd64p32 files, toolchain) Part 3: stuff that arguably should've been part of Part 2, but I forgot one of my grep patterns when splitting the original CL up into two parts. This one might also have interesting stuff to resurrect for any future x32 ABI support. Updates #30439 Change-Id: I2b4143374a253a003666f3c69e776b7e456bdb9c Reviewed-on: https://go-review.googlesource.com/c/go/+/200318 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/runtime/asm.s | 3 - src/runtime/gcinfo_test.go | 8 --- src/runtime/go_tls.h | 5 -- src/runtime/hash64.go | 2 +- src/runtime/internal/atomic/atomic_amd64.go | 89 +++++++++++++++++++++++++++ src/runtime/internal/atomic/atomic_amd64x.go | 91 ---------------------------- src/runtime/internal/atomic/atomic_test.go | 10 +-- src/runtime/panic32.go | 2 +- src/runtime/runtime2.go | 2 +- src/runtime/signal_amd64.go | 79 ++++++++++++++++++++++++ src/runtime/signal_amd64x.go | 79 ------------------------ src/runtime/stubs32.go | 2 +- src/runtime/stubs_amd64.go | 11 ++++ src/runtime/stubs_amd64x.go | 13 ---- src/runtime/sys_x86.go | 2 +- src/runtime/trace.go | 2 +- src/runtime/traceback.go | 4 +- 17 files changed, 189 insertions(+), 215 deletions(-) create mode 100644 src/runtime/internal/atomic/atomic_amd64.go delete mode 100644 src/runtime/internal/atomic/atomic_amd64x.go create mode 100644 src/runtime/signal_amd64.go delete mode 100644 src/runtime/signal_amd64x.go create mode 100644 src/runtime/stubs_amd64.go delete mode 100644 src/runtime/stubs_amd64x.go (limited to 'src/runtime') diff --git a/src/runtime/asm.s b/src/runtime/asm.s index c886d4e722..95a3424de2 100644 --- a/src/runtime/asm.s +++ b/src/runtime/asm.s @@ -19,9 +19,6 @@ GLOBL runtime·no_pointers_stackmap(SB),RODATA, $8 #ifdef GOARCH_386 #define SKIP4 BYTE $0x90; BYTE $0x90; BYTE $0x90; BYTE $0x90 #endif -#ifdef GOARCH_amd64p32 -#define SKIP4 BYTE $0x90; BYTE $0x90; BYTE $0x90; BYTE $0x90 -#endif #ifdef GOARCH_wasm #define SKIP4 UNDEF; UNDEF; UNDEF; UNDEF #endif diff --git a/src/runtime/gcinfo_test.go b/src/runtime/gcinfo_test.go index 0741f6361c..c228c779e4 100644 --- a/src/runtime/gcinfo_test.go +++ b/src/runtime/gcinfo_test.go @@ -187,14 +187,6 @@ func infoBigStruct() []byte { typeScalar, typeScalar, typeScalar, // t int; y uint16; u uint64 typePointer, typeScalar, // i string } - case "amd64p32": - return []byte{ - typePointer, // q *int - typeScalar, typeScalar, typeScalar, typeScalar, typeScalar, // w byte; e [17]byte - typePointer, typeScalar, typeScalar, // r []byte - typeScalar, typeScalar, typeScalar, typeScalar, typeScalar, // t int; y uint16; u uint64 - typePointer, typeScalar, // i string - } default: panic("unknown arch") } diff --git a/src/runtime/go_tls.h b/src/runtime/go_tls.h index 61f7dbef3c..a47e798d9d 100644 --- a/src/runtime/go_tls.h +++ b/src/runtime/go_tls.h @@ -11,11 +11,6 @@ #define g(r) 0(r)(TLS*1) #endif -#ifdef GOARCH_amd64p32 -#define get_tls(r) MOVL TLS, r -#define g(r) 0(r)(TLS*1) -#endif - #ifdef GOARCH_386 #define get_tls(r) MOVL TLS, r #define g(r) 0(r)(TLS*1) diff --git a/src/runtime/hash64.go b/src/runtime/hash64.go index e7908d7800..798d6dcd9e 100644 --- a/src/runtime/hash64.go +++ b/src/runtime/hash64.go @@ -6,7 +6,7 @@ // xxhash: https://code.google.com/p/xxhash/ // cityhash: https://code.google.com/p/cityhash/ -// +build amd64 amd64p32 arm64 mips64 mips64le ppc64 ppc64le s390x wasm +// +build amd64 arm64 mips64 mips64le ppc64 ppc64le s390x wasm package runtime diff --git a/src/runtime/internal/atomic/atomic_amd64.go b/src/runtime/internal/atomic/atomic_amd64.go new file mode 100644 index 0000000000..fc865e892d --- /dev/null +++ b/src/runtime/internal/atomic/atomic_amd64.go @@ -0,0 +1,89 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package atomic + +import "unsafe" + +// Export some functions via linkname to assembly in sync/atomic. +//go:linkname Load +//go:linkname Loadp +//go:linkname Load64 + +//go:nosplit +//go:noinline +func Load(ptr *uint32) uint32 { + return *ptr +} + +//go:nosplit +//go:noinline +func Loadp(ptr unsafe.Pointer) unsafe.Pointer { + return *(*unsafe.Pointer)(ptr) +} + +//go:nosplit +//go:noinline +func Load64(ptr *uint64) uint64 { + return *ptr +} + +//go:nosplit +//go:noinline +func LoadAcq(ptr *uint32) uint32 { + return *ptr +} + +//go:noescape +func Xadd(ptr *uint32, delta int32) uint32 + +//go:noescape +func Xadd64(ptr *uint64, delta int64) uint64 + +//go:noescape +func Xadduintptr(ptr *uintptr, delta uintptr) uintptr + +//go:noescape +func Xchg(ptr *uint32, new uint32) uint32 + +//go:noescape +func Xchg64(ptr *uint64, new uint64) uint64 + +//go:noescape +func Xchguintptr(ptr *uintptr, new uintptr) uintptr + +//go:nosplit +//go:noinline +func Load8(ptr *uint8) uint8 { + return *ptr +} + +//go:noescape +func And8(ptr *uint8, val uint8) + +//go:noescape +func Or8(ptr *uint8, val uint8) + +// NOTE: Do not add atomicxor8 (XOR is not idempotent). + +//go:noescape +func Cas64(ptr *uint64, old, new uint64) bool + +//go:noescape +func CasRel(ptr *uint32, old, new uint32) bool + +//go:noescape +func Store(ptr *uint32, val uint32) + +//go:noescape +func Store64(ptr *uint64, val uint64) + +//go:noescape +func StoreRel(ptr *uint32, val uint32) + +// StorepNoWB performs *ptr = val atomically and without a write +// barrier. +// +// NO go:noescape annotation; see atomic_pointer.go. +func StorepNoWB(ptr unsafe.Pointer, val unsafe.Pointer) diff --git a/src/runtime/internal/atomic/atomic_amd64x.go b/src/runtime/internal/atomic/atomic_amd64x.go deleted file mode 100644 index 31c1636b2e..0000000000 --- a/src/runtime/internal/atomic/atomic_amd64x.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build amd64 amd64p32 - -package atomic - -import "unsafe" - -// Export some functions via linkname to assembly in sync/atomic. -//go:linkname Load -//go:linkname Loadp -//go:linkname Load64 - -//go:nosplit -//go:noinline -func Load(ptr *uint32) uint32 { - return *ptr -} - -//go:nosplit -//go:noinline -func Loadp(ptr unsafe.Pointer) unsafe.Pointer { - return *(*unsafe.Pointer)(ptr) -} - -//go:nosplit -//go:noinline -func Load64(ptr *uint64) uint64 { - return *ptr -} - -//go:nosplit -//go:noinline -func LoadAcq(ptr *uint32) uint32 { - return *ptr -} - -//go:noescape -func Xadd(ptr *uint32, delta int32) uint32 - -//go:noescape -func Xadd64(ptr *uint64, delta int64) uint64 - -//go:noescape -func Xadduintptr(ptr *uintptr, delta uintptr) uintptr - -//go:noescape -func Xchg(ptr *uint32, new uint32) uint32 - -//go:noescape -func Xchg64(ptr *uint64, new uint64) uint64 - -//go:noescape -func Xchguintptr(ptr *uintptr, new uintptr) uintptr - -//go:nosplit -//go:noinline -func Load8(ptr *uint8) uint8 { - return *ptr -} - -//go:noescape -func And8(ptr *uint8, val uint8) - -//go:noescape -func Or8(ptr *uint8, val uint8) - -// NOTE: Do not add atomicxor8 (XOR is not idempotent). - -//go:noescape -func Cas64(ptr *uint64, old, new uint64) bool - -//go:noescape -func CasRel(ptr *uint32, old, new uint32) bool - -//go:noescape -func Store(ptr *uint32, val uint32) - -//go:noescape -func Store64(ptr *uint64, val uint64) - -//go:noescape -func StoreRel(ptr *uint32, val uint32) - -// StorepNoWB performs *ptr = val atomically and without a write -// barrier. -// -// NO go:noescape annotation; see atomic_pointer.go. -func StorepNoWB(ptr unsafe.Pointer, val unsafe.Pointer) diff --git a/src/runtime/internal/atomic/atomic_test.go b/src/runtime/internal/atomic/atomic_test.go index 0ba75447e8..9e4461ce38 100644 --- a/src/runtime/internal/atomic/atomic_test.go +++ b/src/runtime/internal/atomic/atomic_test.go @@ -86,14 +86,8 @@ func TestUnaligned64(t *testing.T) { // a continual source of pain. Test that on 32-bit systems they crash // instead of failing silently. - switch runtime.GOARCH { - default: - if unsafe.Sizeof(int(0)) != 4 { - t.Skip("test only runs on 32-bit systems") - } - case "amd64p32": - // amd64p32 can handle unaligned atomics. - t.Skipf("test not needed on %v", runtime.GOARCH) + if unsafe.Sizeof(int(0)) != 4 { + t.Skip("test only runs on 32-bit systems") } x := make([]uint32, 4) diff --git a/src/runtime/panic32.go b/src/runtime/panic32.go index b89ce9d563..aea8401a37 100644 --- a/src/runtime/panic32.go +++ b/src/runtime/panic32.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build 386 amd64p32 arm mips mipsle +// +build 386 arm mips mipsle package runtime diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index 2d68721701..dd399e00a6 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -922,7 +922,7 @@ var ( // Information about what cpu features are available. // Packages outside the runtime should not use these // as they are not an external api. - // Set on startup in asm_{386,amd64,amd64p32}.s + // Set on startup in asm_{386,amd64}.s processorVersionInfo uint32 isIntel bool lfenceBeforeRdtsc bool diff --git a/src/runtime/signal_amd64.go b/src/runtime/signal_amd64.go new file mode 100644 index 0000000000..9e9bb9ca33 --- /dev/null +++ b/src/runtime/signal_amd64.go @@ -0,0 +1,79 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build amd64 +// +build darwin dragonfly freebsd linux netbsd openbsd solaris + +package runtime + +import ( + "runtime/internal/sys" + "unsafe" +) + +func dumpregs(c *sigctxt) { + print("rax ", hex(c.rax()), "\n") + print("rbx ", hex(c.rbx()), "\n") + print("rcx ", hex(c.rcx()), "\n") + print("rdx ", hex(c.rdx()), "\n") + print("rdi ", hex(c.rdi()), "\n") + print("rsi ", hex(c.rsi()), "\n") + print("rbp ", hex(c.rbp()), "\n") + print("rsp ", hex(c.rsp()), "\n") + print("r8 ", hex(c.r8()), "\n") + print("r9 ", hex(c.r9()), "\n") + print("r10 ", hex(c.r10()), "\n") + print("r11 ", hex(c.r11()), "\n") + print("r12 ", hex(c.r12()), "\n") + print("r13 ", hex(c.r13()), "\n") + print("r14 ", hex(c.r14()), "\n") + print("r15 ", hex(c.r15()), "\n") + print("rip ", hex(c.rip()), "\n") + print("rflags ", hex(c.rflags()), "\n") + print("cs ", hex(c.cs()), "\n") + print("fs ", hex(c.fs()), "\n") + print("gs ", hex(c.gs()), "\n") +} + +//go:nosplit +//go:nowritebarrierrec +func (c *sigctxt) sigpc() uintptr { return uintptr(c.rip()) } + +func (c *sigctxt) sigsp() uintptr { return uintptr(c.rsp()) } +func (c *sigctxt) siglr() uintptr { return 0 } +func (c *sigctxt) fault() uintptr { return uintptr(c.sigaddr()) } + +// preparePanic sets up the stack to look like a call to sigpanic. +func (c *sigctxt) preparePanic(sig uint32, gp *g) { + // Work around Leopard bug that doesn't set FPE_INTDIV. + // Look at instruction to see if it is a divide. + // Not necessary in Snow Leopard (si_code will be != 0). + if GOOS == "darwin" && sig == _SIGFPE && gp.sigcode0 == 0 { + pc := (*[4]byte)(unsafe.Pointer(gp.sigpc)) + i := 0 + if pc[i]&0xF0 == 0x40 { // 64-bit REX prefix + i++ + } else if pc[i] == 0x66 { // 16-bit instruction prefix + i++ + } + if pc[i] == 0xF6 || pc[i] == 0xF7 { + gp.sigcode0 = _FPE_INTDIV + } + } + + pc := uintptr(c.rip()) + sp := uintptr(c.rsp()) + + if shouldPushSigpanic(gp, pc, *(*uintptr)(unsafe.Pointer(sp))) { + // Make it look the like faulting PC called sigpanic. + if sys.RegSize > sys.PtrSize { + sp -= sys.PtrSize + *(*uintptr)(unsafe.Pointer(sp)) = 0 + } + sp -= sys.PtrSize + *(*uintptr)(unsafe.Pointer(sp)) = pc + c.set_rsp(uint64(sp)) + } + c.set_rip(uint64(funcPC(sigpanic))) +} diff --git a/src/runtime/signal_amd64x.go b/src/runtime/signal_amd64x.go deleted file mode 100644 index 459499e973..0000000000 --- a/src/runtime/signal_amd64x.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build amd64 amd64p32 -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package runtime - -import ( - "runtime/internal/sys" - "unsafe" -) - -func dumpregs(c *sigctxt) { - print("rax ", hex(c.rax()), "\n") - print("rbx ", hex(c.rbx()), "\n") - print("rcx ", hex(c.rcx()), "\n") - print("rdx ", hex(c.rdx()), "\n") - print("rdi ", hex(c.rdi()), "\n") - print("rsi ", hex(c.rsi()), "\n") - print("rbp ", hex(c.rbp()), "\n") - print("rsp ", hex(c.rsp()), "\n") - print("r8 ", hex(c.r8()), "\n") - print("r9 ", hex(c.r9()), "\n") - print("r10 ", hex(c.r10()), "\n") - print("r11 ", hex(c.r11()), "\n") - print("r12 ", hex(c.r12()), "\n") - print("r13 ", hex(c.r13()), "\n") - print("r14 ", hex(c.r14()), "\n") - print("r15 ", hex(c.r15()), "\n") - print("rip ", hex(c.rip()), "\n") - print("rflags ", hex(c.rflags()), "\n") - print("cs ", hex(c.cs()), "\n") - print("fs ", hex(c.fs()), "\n") - print("gs ", hex(c.gs()), "\n") -} - -//go:nosplit -//go:nowritebarrierrec -func (c *sigctxt) sigpc() uintptr { return uintptr(c.rip()) } - -func (c *sigctxt) sigsp() uintptr { return uintptr(c.rsp()) } -func (c *sigctxt) siglr() uintptr { return 0 } -func (c *sigctxt) fault() uintptr { return uintptr(c.sigaddr()) } - -// preparePanic sets up the stack to look like a call to sigpanic. -func (c *sigctxt) preparePanic(sig uint32, gp *g) { - // Work around Leopard bug that doesn't set FPE_INTDIV. - // Look at instruction to see if it is a divide. - // Not necessary in Snow Leopard (si_code will be != 0). - if GOOS == "darwin" && sig == _SIGFPE && gp.sigcode0 == 0 { - pc := (*[4]byte)(unsafe.Pointer(gp.sigpc)) - i := 0 - if pc[i]&0xF0 == 0x40 { // 64-bit REX prefix - i++ - } else if pc[i] == 0x66 { // 16-bit instruction prefix - i++ - } - if pc[i] == 0xF6 || pc[i] == 0xF7 { - gp.sigcode0 = _FPE_INTDIV - } - } - - pc := uintptr(c.rip()) - sp := uintptr(c.rsp()) - - if shouldPushSigpanic(gp, pc, *(*uintptr)(unsafe.Pointer(sp))) { - // Make it look the like faulting PC called sigpanic. - if sys.RegSize > sys.PtrSize { - sp -= sys.PtrSize - *(*uintptr)(unsafe.Pointer(sp)) = 0 - } - sp -= sys.PtrSize - *(*uintptr)(unsafe.Pointer(sp)) = pc - c.set_rsp(uint64(sp)) - } - c.set_rip(uint64(funcPC(sigpanic))) -} diff --git a/src/runtime/stubs32.go b/src/runtime/stubs32.go index 149560fd93..a7f52f6b9e 100644 --- a/src/runtime/stubs32.go +++ b/src/runtime/stubs32.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build 386 arm amd64p32 mips mipsle +// +build 386 arm mips mipsle package runtime diff --git a/src/runtime/stubs_amd64.go b/src/runtime/stubs_amd64.go new file mode 100644 index 0000000000..b4c0df1153 --- /dev/null +++ b/src/runtime/stubs_amd64.go @@ -0,0 +1,11 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package runtime + +// stackcheck checks that SP is in range [g->stack.lo, g->stack.hi). +func stackcheck() + +// Called from assembly only; declared for go vet. +func settls() // argument in DI diff --git a/src/runtime/stubs_amd64x.go b/src/runtime/stubs_amd64x.go deleted file mode 100644 index e7a1be8135..0000000000 --- a/src/runtime/stubs_amd64x.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build amd64 amd64p32 - -package runtime - -// stackcheck checks that SP is in range [g->stack.lo, g->stack.hi). -func stackcheck() - -// Called from assembly only; declared for go vet. -func settls() // argument in DI diff --git a/src/runtime/sys_x86.go b/src/runtime/sys_x86.go index 2b4ed8bdf5..f917cb8bd7 100644 --- a/src/runtime/sys_x86.go +++ b/src/runtime/sys_x86.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build amd64 amd64p32 386 +// +build amd64 386 package runtime diff --git a/src/runtime/trace.go b/src/runtime/trace.go index d074783550..f919362be8 100644 --- a/src/runtime/trace.go +++ b/src/runtime/trace.go @@ -84,7 +84,7 @@ const ( // and ppc64le. // Tracing won't work reliably for architectures where cputicks is emulated // by nanotime, so the value doesn't matter for those architectures. - traceTickDiv = 16 + 48*(sys.Goarch386|sys.GoarchAmd64|sys.GoarchAmd64p32) + traceTickDiv = 16 + 48*(sys.Goarch386|sys.GoarchAmd64) // Maximum number of PCs in a single stack trace. // Since events contain only stack id rather than whole stack trace, // we can allow quite large values here. diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go index 5153390f1d..96fb33c04b 100644 --- a/src/runtime/traceback.go +++ b/src/runtime/traceback.go @@ -26,8 +26,8 @@ import ( // takes up only 4 bytes on the stack, while on 64-bit systems it takes up 8 bytes. // Typically this is ptrSize. // -// As an exception, amd64p32 has ptrSize == 4 but the CALL instruction still -// stores an 8-byte return PC onto the stack. To accommodate this, we use regSize +// As an exception, amd64p32 had ptrSize == 4 but the CALL instruction still +// stored an 8-byte return PC onto the stack. To accommodate this, we used regSize // as the size of the architecture-pushed return PC. // // usesLR is defined below in terms of minFrameSize, which is defined in -- cgit v1.3