diff options
| author | Cherry Mui <cherryyz@google.com> | 2021-05-18 14:49:21 -0400 |
|---|---|---|
| committer | Cherry Mui <cherryyz@google.com> | 2021-05-18 14:49:21 -0400 |
| commit | c7dd3e305d8ee48b1f9041eaf175d2ecd7475f5f (patch) | |
| tree | 7149a3c80c0fa737675f34fe2cdfca2a5986c3c1 /src/runtime | |
| parent | 077f03f4d878f3b62e4aa15cdbd7cabc9dd08a11 (diff) | |
| parent | 690a8c3fb136431d4f22894c545ea99278758570 (diff) | |
| download | go-c7dd3e305d8ee48b1f9041eaf175d2ecd7475f5f.tar.xz | |
[dev.typeparams] all: merge master (690a8c3) into dev.typeparams
Merge List:
+ 2021-05-18 690a8c3fb1 make.bash: fix misuse of continue
+ 2021-05-18 8b0901fd32 doc/go1.17: fix typo "avoding" -> "avoiding"
+ 2021-05-18 5e191f8f48 time: rewrite the documentation for layout strings
+ 2021-05-17 bfe3573d58 go/token: correct the interval notation used in some panic messages
+ 2021-05-17 a2c07a9a1a all: update golang.org/x/net to latest
+ 2021-05-17 b9b2bed893 syscall: some containers may fail syscall.TestSetuidEtc
+ 2021-05-17 b1aff42900 cmd/go: don't print 'go get' deprecation notices in the main module
+ 2021-05-17 bade680867 runtime/cgo: fix crosscall2 on ppc64x
+ 2021-05-15 ce92a2023c cmd/go: error out of 'go mod tidy' if the go version is newer than supported
+ 2021-05-14 02699f810a runtime: mark osyield nosplit on OpenBSD
+ 2021-05-14 3d324f127d net/http: prevent infinite wait during TestMissingStatusNoPanic
+ 2021-05-14 0eb38f2b16 cmd/go/internal/load: override Package.Root in module mode
+ 2021-05-14 a938e52986 cmd/go: fix a portability issue in the cd script command
+ 2021-05-14 d137b74539 cmd/go: fix spacing in help text of -overlay flag
+ 2021-05-14 c925e1546e cmd/internal/obj/arm64: disable AL and NV for some condition operation instructions
+ 2021-05-14 12d383c7c7 debug/macho: fix a typo in macho.go
+ 2021-05-14 3a0453514a all: fix spelling
+ 2021-05-13 b4833f7c06 cmd/link: always mark runtime.unreachableMethod symbol
+ 2021-05-13 92c189f211 cmd/link: resolve ABI alias for runtime.unreachableMethod
+ 2021-05-13 7a7624a3fa cmd/go: permit .tbd files as a linker flag
+ 2021-05-13 cde2d857fe cmd/go: be less strict about go version syntax in dependency go.mod files
+ 2021-05-13 2a61b3c590 regexp: fix repeat of preferred empty match
+ 2021-05-13 fd4631e24f cmd/compile/internal/dwarfgen: fix DWARF param DIE ordering
+ 2021-05-13 a63cded5e4 debug/dwarf: delay array type fixup to handle type cycles
+ 2021-05-13 0fa2302ee5 cmd/vendor: update golang.org/x/sys to latest
+ 2021-05-13 2c76a6f7f8 all: add //go:build lines to assembly files
+ 2021-05-12 6db7480f59 cmd/go/internal/modload: in updateLazyRoots, do not require the main module explicitly
+ 2021-05-12 f93b951f33 cmd/compile/abi-internal.md: fix table format
+ 2021-05-12 3b321a9d12 cmd/compile: add arch-specific inlining for runtime.memmove
+ 2021-05-12 07ff596404 runtime/internal/atomic: add LSE atomics instructions to arm64
+ 2021-05-12 03886707f9 runtime: fix handling of SPWRITE functions in traceback
+ 2021-05-12 e03383a2e2 cmd/link: check mmap error
+ 2021-05-12 af0f8c149e cmd/link: don't cast end address to int32
+ 2021-05-12 485474d204 cmd/go/testdata/script: fix test failing on nocgo builders
+ 2021-05-12 1a0ea1a08b runtime: fix typo in proc.go
+ 2021-05-11 9995c6b50a cmd/go: ignore implicit imports when the -find flag is set
Change-Id: I843fe029b8ac09424a83e8a4e8bdcc86edd40603
Diffstat (limited to 'src/runtime')
56 files changed, 176 insertions, 34 deletions
diff --git a/src/runtime/asm_mips64x.s b/src/runtime/asm_mips64x.s index c3b57e472a..d4d2280105 100644 --- a/src/runtime/asm_mips64x.s +++ b/src/runtime/asm_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "go_asm.h" diff --git a/src/runtime/asm_mipsx.s b/src/runtime/asm_mipsx.s index 1d828b03cf..ea7edf20cf 100644 --- a/src/runtime/asm_mipsx.s +++ b/src/runtime/asm_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "go_asm.h" diff --git a/src/runtime/asm_ppc64x.s b/src/runtime/asm_ppc64x.s index 2c39b38912..942cc14f17 100644 --- a/src/runtime/asm_ppc64x.s +++ b/src/runtime/asm_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "go_asm.h" diff --git a/src/runtime/atomic_mips64x.s b/src/runtime/atomic_mips64x.s index 6f42412502..e2118e6a20 100644 --- a/src/runtime/atomic_mips64x.s +++ b/src/runtime/atomic_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "textflag.h" diff --git a/src/runtime/atomic_mipsx.s b/src/runtime/atomic_mipsx.s index ed078a2d8a..1eacd273b4 100644 --- a/src/runtime/atomic_mipsx.s +++ b/src/runtime/atomic_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "textflag.h" diff --git a/src/runtime/atomic_ppc64x.s b/src/runtime/atomic_ppc64x.s index 57f672f330..b63de2dbd3 100644 --- a/src/runtime/atomic_ppc64x.s +++ b/src/runtime/atomic_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" diff --git a/src/runtime/cgo/asm_mips64x.s b/src/runtime/cgo/asm_mips64x.s index e51cdf3d12..ba948071fa 100644 --- a/src/runtime/cgo/asm_mips64x.s +++ b/src/runtime/cgo/asm_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "textflag.h" diff --git a/src/runtime/cgo/asm_mipsx.s b/src/runtime/cgo/asm_mipsx.s index 1127c8beb4..fd5d78ef97 100644 --- a/src/runtime/cgo/asm_mipsx.s +++ b/src/runtime/cgo/asm_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "textflag.h" diff --git a/src/runtime/cgo/asm_ppc64x.s b/src/runtime/cgo/asm_ppc64x.s index f4efc1e67d..187b2d42f6 100644 --- a/src/runtime/cgo/asm_ppc64x.s +++ b/src/runtime/cgo/asm_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" @@ -11,17 +12,20 @@ // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr) // Saves C callee-saved registers and calls cgocallback with three arguments. // fn is the PC of a func(a unsafe.Pointer) function. +// The value of R2 is saved on the new stack frame, and not +// the caller's frame due to issue #43228. TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0 // Start with standard C stack frame layout and linkage MOVD LR, R0 MOVD R0, 16(R1) // Save LR in caller's frame MOVW CR, R0 // Save CR in caller's frame - MOVD R0, 8(R1) - MOVD R2, 24(R1) // Save TOC in caller's frame + MOVW R0, 8(R1) BL saveregs2<>(SB) MOVDU R1, (-288-3*8-FIXED_FRAME)(R1) + // Save the caller's R2 + MOVD R2, 24(R1) // Initialize Go ABI environment BL runtime·reginit(SB) @@ -40,12 +44,13 @@ TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0 MOVD R6, FIXED_FRAME+16(R1) // ctxt uintptr BL runtime·cgocallback(SB) + // Restore the caller's R2 + MOVD 24(R1), R2 ADD $(288+3*8+FIXED_FRAME), R1 BL restoreregs2<>(SB) - MOVD 24(R1), R2 - MOVD 8(R1), R0 + MOVW 8(R1), R0 MOVFL R0, $0xff MOVD 16(R1), R0 MOVD R0, LR diff --git a/src/runtime/cgo/asm_riscv64.s b/src/runtime/cgo/asm_riscv64.s index b4ddbb020f..fcd1d36ca8 100644 --- a/src/runtime/cgo/asm_riscv64.s +++ b/src/runtime/cgo/asm_riscv64.s @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build riscv64 - #include "textflag.h" // Called by C code generated by cmd/cgo. diff --git a/src/runtime/duff_mips64x.s b/src/runtime/duff_mips64x.s index c4e04ccc9d..a897d7fd9b 100644 --- a/src/runtime/duff_mips64x.s +++ b/src/runtime/duff_mips64x.s @@ -2,6 +2,7 @@ // Run go generate from src/runtime to update. // See mkduff.go for comments. +//go:build mips64 || mips64le // +build mips64 mips64le #include "textflag.h" diff --git a/src/runtime/duff_ppc64x.s b/src/runtime/duff_ppc64x.s index d6b89ba940..d4e3b409d2 100644 --- a/src/runtime/duff_ppc64x.s +++ b/src/runtime/duff_ppc64x.s @@ -2,6 +2,7 @@ // Run go generate from src/runtime to update. // See mkduff.go for comments. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" diff --git a/src/runtime/internal/atomic/atomic_arm64.go b/src/runtime/internal/atomic/atomic_arm64.go index 131c687e1b..3c8736997f 100644 --- a/src/runtime/internal/atomic/atomic_arm64.go +++ b/src/runtime/internal/atomic/atomic_arm64.go @@ -7,7 +7,14 @@ package atomic -import "unsafe" +import ( + "unsafe" + "internal/cpu" +) + +const ( + offsetARM64HasATOMICS = unsafe.Offsetof(cpu.ARM64.HasATOMICS) +) //go:noescape func Xadd(ptr *uint32, delta int32) uint32 diff --git a/src/runtime/internal/atomic/atomic_arm64.s b/src/runtime/internal/atomic/atomic_arm64.s index 587e7f05e2..e9467afecd 100644 --- a/src/runtime/internal/atomic/atomic_arm64.s +++ b/src/runtime/internal/atomic/atomic_arm64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +#include "go_asm.h" #include "textflag.h" TEXT ·Casint32(SB), NOSPLIT, $0-17 @@ -127,10 +128,15 @@ TEXT ·Store64(SB), NOSPLIT, $0-16 TEXT ·Xchg(SB), NOSPLIT, $0-20 MOVD ptr+0(FP), R0 MOVW new+8(FP), R1 -again: + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + SWPALW R1, (R0), R2 + MOVW R2, ret+16(FP) + RET +load_store_loop: LDAXRW (R0), R2 STLXRW R1, (R0), R3 - CBNZ R3, again + CBNZ R3, load_store_loop MOVW R2, ret+16(FP) RET @@ -142,10 +148,15 @@ again: TEXT ·Xchg64(SB), NOSPLIT, $0-24 MOVD ptr+0(FP), R0 MOVD new+8(FP), R1 -again: + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + SWPALD R1, (R0), R2 + MOVD R2, ret+16(FP) + RET +load_store_loop: LDAXR (R0), R2 STLXR R1, (R0), R3 - CBNZ R3, again + CBNZ R3, load_store_loop MOVD R2, ret+16(FP) RET @@ -160,12 +171,20 @@ TEXT ·Cas(SB), NOSPLIT, $0-17 MOVD ptr+0(FP), R0 MOVW old+8(FP), R1 MOVW new+12(FP), R2 -again: + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + MOVD R1, R3 + CASALW R3, (R0), R2 + CMP R1, R3 + CSET EQ, R0 + MOVB R0, ret+16(FP) + RET +load_store_loop: LDAXRW (R0), R3 CMPW R1, R3 BNE ok STLXRW R2, (R0), R3 - CBNZ R3, again + CBNZ R3, load_store_loop ok: CSET EQ, R0 MOVB R0, ret+16(FP) @@ -183,12 +202,20 @@ TEXT ·Cas64(SB), NOSPLIT, $0-25 MOVD ptr+0(FP), R0 MOVD old+8(FP), R1 MOVD new+16(FP), R2 -again: + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + MOVD R1, R3 + CASALD R3, (R0), R2 + CMP R1, R3 + CSET EQ, R0 + MOVB R0, ret+24(FP) + RET +load_store_loop: LDAXR (R0), R3 CMP R1, R3 BNE ok STLXR R2, (R0), R3 - CBNZ R3, again + CBNZ R3, load_store_loop ok: CSET EQ, R0 MOVB R0, ret+24(FP) @@ -201,11 +228,17 @@ ok: TEXT ·Xadd(SB), NOSPLIT, $0-20 MOVD ptr+0(FP), R0 MOVW delta+8(FP), R1 -again: + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + LDADDALW R1, (R0), R2 + ADD R1, R2 + MOVW R2, ret+16(FP) + RET +load_store_loop: LDAXRW (R0), R2 ADDW R2, R1, R2 STLXRW R2, (R0), R3 - CBNZ R3, again + CBNZ R3, load_store_loop MOVW R2, ret+16(FP) RET @@ -216,11 +249,17 @@ again: TEXT ·Xadd64(SB), NOSPLIT, $0-24 MOVD ptr+0(FP), R0 MOVD delta+8(FP), R1 -again: + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + LDADDALD R1, (R0), R2 + ADD R1, R2 + MOVD R2, ret+16(FP) + RET +load_store_loop: LDAXR (R0), R2 ADD R2, R1, R2 STLXR R2, (R0), R3 - CBNZ R3, again + CBNZ R3, load_store_loop MOVD R2, ret+16(FP) RET @@ -236,37 +275,59 @@ TEXT ·Xchguintptr(SB), NOSPLIT, $0-24 TEXT ·And8(SB), NOSPLIT, $0-9 MOVD ptr+0(FP), R0 MOVB val+8(FP), R1 + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + MVN R1, R2 + LDCLRALB R2, (R0), R3 + RET +load_store_loop: LDAXRB (R0), R2 AND R1, R2 STLXRB R2, (R0), R3 - CBNZ R3, -3(PC) + CBNZ R3, load_store_loop RET TEXT ·Or8(SB), NOSPLIT, $0-9 MOVD ptr+0(FP), R0 MOVB val+8(FP), R1 + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + LDORALB R1, (R0), R2 + RET +load_store_loop: LDAXRB (R0), R2 ORR R1, R2 STLXRB R2, (R0), R3 - CBNZ R3, -3(PC) + CBNZ R3, load_store_loop RET // func And(addr *uint32, v uint32) TEXT ·And(SB), NOSPLIT, $0-12 MOVD ptr+0(FP), R0 MOVW val+8(FP), R1 + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + MVN R1, R2 + LDCLRALW R2, (R0), R3 + RET +load_store_loop: LDAXRW (R0), R2 AND R1, R2 STLXRW R2, (R0), R3 - CBNZ R3, -3(PC) + CBNZ R3, load_store_loop RET // func Or(addr *uint32, v uint32) TEXT ·Or(SB), NOSPLIT, $0-12 MOVD ptr+0(FP), R0 MOVW val+8(FP), R1 + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + LDORALW R1, (R0), R2 + RET +load_store_loop: LDAXRW (R0), R2 ORR R1, R2 STLXRW R2, (R0), R3 - CBNZ R3, -3(PC) + CBNZ R3, load_store_loop RET diff --git a/src/runtime/internal/atomic/atomic_mips64x.s b/src/runtime/internal/atomic/atomic_mips64x.s index 2751c6f808..fba668f94a 100644 --- a/src/runtime/internal/atomic/atomic_mips64x.s +++ b/src/runtime/internal/atomic/atomic_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "textflag.h" diff --git a/src/runtime/internal/atomic/atomic_mipsx.s b/src/runtime/internal/atomic/atomic_mipsx.s index 3f61321450..c0835d66ed 100644 --- a/src/runtime/internal/atomic/atomic_mipsx.s +++ b/src/runtime/internal/atomic/atomic_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "textflag.h" diff --git a/src/runtime/internal/atomic/atomic_ppc64x.s b/src/runtime/internal/atomic/atomic_ppc64x.s index 37c8515d37..dca26cb334 100644 --- a/src/runtime/internal/atomic/atomic_ppc64x.s +++ b/src/runtime/internal/atomic/atomic_ppc64x.s @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" - // For more details about how various memory models are // enforced on POWER, the following paper provides more // details about how they enforce C/C++ like models. This diff --git a/src/runtime/internal/atomic/sys_nonlinux_arm.s b/src/runtime/internal/atomic/sys_nonlinux_arm.s index 57568b2238..04036ca970 100644 --- a/src/runtime/internal/atomic/sys_nonlinux_arm.s +++ b/src/runtime/internal/atomic/sys_nonlinux_arm.s @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !linux,arm +//go:build !linux +// +build !linux #include "textflag.h" diff --git a/src/runtime/libfuzzer_amd64.s b/src/runtime/libfuzzer_amd64.s index 890fde341b..13645fc7af 100644 --- a/src/runtime/libfuzzer_amd64.s +++ b/src/runtime/libfuzzer_amd64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build libfuzzer // +build libfuzzer #include "go_asm.h" diff --git a/src/runtime/libfuzzer_arm64.s b/src/runtime/libfuzzer_arm64.s index 121673e092..4ad8242804 100644 --- a/src/runtime/libfuzzer_arm64.s +++ b/src/runtime/libfuzzer_arm64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build libfuzzer // +build libfuzzer #include "go_asm.h" diff --git a/src/runtime/memclr_386.s b/src/runtime/memclr_386.s index d2ef17f7ce..046c344119 100644 --- a/src/runtime/memclr_386.s +++ b/src/runtime/memclr_386.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !plan9 // +build !plan9 #include "go_asm.h" diff --git a/src/runtime/memclr_amd64.s b/src/runtime/memclr_amd64.s index 5d2bebb901..a10f57bd8c 100644 --- a/src/runtime/memclr_amd64.s +++ b/src/runtime/memclr_amd64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !plan9 // +build !plan9 #include "go_asm.h" diff --git a/src/runtime/memclr_mips64x.s b/src/runtime/memclr_mips64x.s index d7a3251e20..bc037013fe 100644 --- a/src/runtime/memclr_mips64x.s +++ b/src/runtime/memclr_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "go_asm.h" diff --git a/src/runtime/memclr_mipsx.s b/src/runtime/memclr_mipsx.s index eb2a8a7219..3d21c3c414 100644 --- a/src/runtime/memclr_mipsx.s +++ b/src/runtime/memclr_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "textflag.h" diff --git a/src/runtime/memclr_ppc64x.s b/src/runtime/memclr_ppc64x.s index 7512620894..65639322b2 100644 --- a/src/runtime/memclr_ppc64x.s +++ b/src/runtime/memclr_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" diff --git a/src/runtime/memmove_386.s b/src/runtime/memmove_386.s index d99546c633..1a43a1f724 100644 --- a/src/runtime/memmove_386.s +++ b/src/runtime/memmove_386.s @@ -23,6 +23,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +//go:build !plan9 // +build !plan9 #include "go_asm.h" diff --git a/src/runtime/memmove_amd64.s b/src/runtime/memmove_amd64.s index f1e3403596..24c6529f58 100644 --- a/src/runtime/memmove_amd64.s +++ b/src/runtime/memmove_amd64.s @@ -23,6 +23,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +//go:build !plan9 // +build !plan9 #include "go_asm.h" diff --git a/src/runtime/memmove_mips64x.s b/src/runtime/memmove_mips64x.s index 8a1b88afba..fef3c6be82 100644 --- a/src/runtime/memmove_mips64x.s +++ b/src/runtime/memmove_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "textflag.h" diff --git a/src/runtime/memmove_mipsx.s b/src/runtime/memmove_mipsx.s index 6c86558f8d..cd02fc25c4 100644 --- a/src/runtime/memmove_mipsx.s +++ b/src/runtime/memmove_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "textflag.h" diff --git a/src/runtime/memmove_ppc64x.s b/src/runtime/memmove_ppc64x.s index dbd835506f..fd16ad8129 100644 --- a/src/runtime/memmove_ppc64x.s +++ b/src/runtime/memmove_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" diff --git a/src/runtime/mkduff.go b/src/runtime/mkduff.go index 8632fe08a3..da191cc594 100644 --- a/src/runtime/mkduff.go +++ b/src/runtime/mkduff.go @@ -179,6 +179,7 @@ func copyARM64(w io.Writer) { func tagsPPC64x(w io.Writer) { fmt.Fprintln(w) + fmt.Fprintln(w, "//go:build ppc64 || ppc64le") fmt.Fprintln(w, "// +build ppc64 ppc64le") fmt.Fprintln(w) } @@ -202,6 +203,7 @@ func copyPPC64x(w io.Writer) { func tagsMIPS64x(w io.Writer) { fmt.Fprintln(w) + fmt.Fprintln(w, "//go:build mips64 || mips64le") fmt.Fprintln(w, "// +build mips64 mips64le") fmt.Fprintln(w) } diff --git a/src/runtime/mkpreempt.go b/src/runtime/mkpreempt.go index 3a9e6cc478..6c980540f5 100644 --- a/src/runtime/mkpreempt.go +++ b/src/runtime/mkpreempt.go @@ -123,6 +123,7 @@ func header(arch string) { fmt.Fprintf(out, "// Code generated by mkpreempt.go; DO NOT EDIT.\n\n") if beLe[arch] { base := arch[:len(arch)-1] + fmt.Fprintf(out, "//go:build %s || %sle\n", base, base) fmt.Fprintf(out, "// +build %s %sle\n\n", base, base) } fmt.Fprintf(out, "#include \"go_asm.h\"\n") diff --git a/src/runtime/msan_amd64.s b/src/runtime/msan_amd64.s index 669e9ca73f..1bb57a3b7e 100644 --- a/src/runtime/msan_amd64.s +++ b/src/runtime/msan_amd64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build msan // +build msan #include "go_asm.h" diff --git a/src/runtime/msan_arm64.s b/src/runtime/msan_arm64.s index f19906cfc8..93ade8dd89 100644 --- a/src/runtime/msan_arm64.s +++ b/src/runtime/msan_arm64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build msan // +build msan #include "go_asm.h" diff --git a/src/runtime/preempt.go b/src/runtime/preempt.go index 372185266f..1d5aae1363 100644 --- a/src/runtime/preempt.go +++ b/src/runtime/preempt.go @@ -413,6 +413,8 @@ func isAsyncSafePoint(gp *g, pc, sp, lr uintptr) (bool, uintptr) { // // TODO: Are there cases that are safe but don't have a // locals pointer map, like empty frame functions? + // It might be possible to preempt any assembly functions + // except the ones that have funcFlag_SPWRITE set in f.flag. return false, 0 } name := funcname(f) diff --git a/src/runtime/preempt_mips64x.s b/src/runtime/preempt_mips64x.s index 0d0c157c36..b755425bc5 100644 --- a/src/runtime/preempt_mips64x.s +++ b/src/runtime/preempt_mips64x.s @@ -1,5 +1,6 @@ // Code generated by mkpreempt.go; DO NOT EDIT. +//go:build mips64 || mips64le // +build mips64 mips64le #include "go_asm.h" diff --git a/src/runtime/preempt_mipsx.s b/src/runtime/preempt_mipsx.s index 86d3a918d3..c1bff60859 100644 --- a/src/runtime/preempt_mipsx.s +++ b/src/runtime/preempt_mipsx.s @@ -1,5 +1,6 @@ // Code generated by mkpreempt.go; DO NOT EDIT. +//go:build mips || mipsle // +build mips mipsle #include "go_asm.h" diff --git a/src/runtime/preempt_ppc64x.s b/src/runtime/preempt_ppc64x.s index 90634386db..70bd91982b 100644 --- a/src/runtime/preempt_ppc64x.s +++ b/src/runtime/preempt_ppc64x.s @@ -1,5 +1,6 @@ // Code generated by mkpreempt.go; DO NOT EDIT. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "go_asm.h" diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 378d5e32f5..ded406cc28 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -3136,7 +3136,7 @@ func checkIdleGCNoP() (*p, *g) { // an available P and available worker G. // // We can attempt to acquire these in either order, though both have - // synchonization concerns (see below). Workers are almost always + // synchronization concerns (see below). Workers are almost always // available (see comment in findRunnableGCWorker for the one case // there may be none). Since we're slightly less likely to find a P, // check for that first. @@ -3570,6 +3570,21 @@ func preemptPark(gp *g) { throw("bad g status") } gp.waitreason = waitReasonPreempted + + if gp.asyncSafePoint { + // Double-check that async preemption does not + // happen in SPWRITE assembly functions. + // isAsyncSafePoint must exclude this case. + f := findfunc(gp.sched.pc) + if !f.valid() { + throw("preempt at unknown pc") + } + if f.flag&funcFlag_SPWRITE != 0 { + println("runtime: unexpected SPWRITE function", funcname(f), "in async preempt") + throw("preempt SPWRITE") + } + } + // Transition from _Grunning to _Gscan|_Gpreempted. We can't // be in _Grunning when we dropg because then we'd be running // without an M, but the moment we're in _Gpreempted, diff --git a/src/runtime/race_amd64.s b/src/runtime/race_amd64.s index 58a919efe8..8d4813eadd 100644 --- a/src/runtime/race_amd64.s +++ b/src/runtime/race_amd64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build race // +build race #include "go_asm.h" diff --git a/src/runtime/race_arm64.s b/src/runtime/race_arm64.s index 82e3caadc8..c6d5b91edc 100644 --- a/src/runtime/race_arm64.s +++ b/src/runtime/race_arm64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build race // +build race #include "go_asm.h" diff --git a/src/runtime/race_ppc64le.s b/src/runtime/race_ppc64le.s index 069e4d86dd..963e57099c 100644 --- a/src/runtime/race_ppc64le.s +++ b/src/runtime/race_ppc64le.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build race // +build race #include "go_asm.h" diff --git a/src/runtime/rt0_linux_mips64x.s b/src/runtime/rt0_linux_mips64x.s index 55506755df..fabd8570b5 100644 --- a/src/runtime/rt0_linux_mips64x.s +++ b/src/runtime/rt0_linux_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && (mips64 || mips64le) // +build linux // +build mips64 mips64le diff --git a/src/runtime/rt0_linux_mipsx.s b/src/runtime/rt0_linux_mipsx.s index 74b8f50b73..9f5842b51a 100644 --- a/src/runtime/rt0_linux_mipsx.s +++ b/src/runtime/rt0_linux_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && (mips || mipsle) // +build linux // +build mips mipsle diff --git a/src/runtime/sys_aix_ppc64.s b/src/runtime/sys_aix_ppc64.s index a56d043f42..c171c191c0 100644 --- a/src/runtime/sys_aix_ppc64.s +++ b/src/runtime/sys_aix_ppc64.s @@ -2,9 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix -// +build ppc64 ppc64le - // // System calls and other sys.stuff for ppc64, Aix // diff --git a/src/runtime/sys_linux_mips64x.s b/src/runtime/sys_linux_mips64x.s index 0206cb88bd..e18d291445 100644 --- a/src/runtime/sys_linux_mips64x.s +++ b/src/runtime/sys_linux_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && (mips64 || mips64le) // +build linux // +build mips64 mips64le diff --git a/src/runtime/sys_linux_mipsx.s b/src/runtime/sys_linux_mipsx.s index d5317d3957..b3970be9cf 100644 --- a/src/runtime/sys_linux_mipsx.s +++ b/src/runtime/sys_linux_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && (mips || mipsle) // +build linux // +build mips mipsle diff --git a/src/runtime/sys_linux_ppc64x.s b/src/runtime/sys_linux_ppc64x.s index 46387288d5..05b5916db4 100644 --- a/src/runtime/sys_linux_ppc64x.s +++ b/src/runtime/sys_linux_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && (ppc64 || ppc64le) // +build linux // +build ppc64 ppc64le diff --git a/src/runtime/sys_openbsd1.go b/src/runtime/sys_openbsd1.go index 6f9ad356d4..cb5d35879c 100644 --- a/src/runtime/sys_openbsd1.go +++ b/src/runtime/sys_openbsd1.go @@ -23,6 +23,7 @@ func thrwakeup(ident uintptr, n int32) int32 { } func thrwakeup_trampoline() +//go:nosplit func osyield() { libcCall(unsafe.Pointer(funcPC(sched_yield_trampoline)), unsafe.Pointer(nil)) } diff --git a/src/runtime/tls_arm.s b/src/runtime/tls_arm.s index e42de8deb4..879caac9e1 100644 --- a/src/runtime/tls_arm.s +++ b/src/runtime/tls_arm.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !windows // +build !windows #include "go_asm.h" diff --git a/src/runtime/tls_mips64x.s b/src/runtime/tls_mips64x.s index 888c0efec6..779d64ba31 100644 --- a/src/runtime/tls_mips64x.s +++ b/src/runtime/tls_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "go_asm.h" diff --git a/src/runtime/tls_mipsx.s b/src/runtime/tls_mipsx.s index d2ffcd954c..ada8d06a9e 100644 --- a/src/runtime/tls_mipsx.s +++ b/src/runtime/tls_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "go_asm.h" diff --git a/src/runtime/tls_ppc64x.s b/src/runtime/tls_ppc64x.s index 25d796fcc6..7e935d0eb2 100644 --- a/src/runtime/tls_ppc64x.s +++ b/src/runtime/tls_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "go_asm.h" diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go index 167d51c452..89780edc1f 100644 --- a/src/runtime/traceback.go +++ b/src/runtime/traceback.go @@ -219,18 +219,25 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in // This function marks the top of the stack. Stop the traceback. frame.lr = 0 flr = funcInfo{} - } else if flag&funcFlag_SPWRITE != 0 { + } else if flag&funcFlag_SPWRITE != 0 && (callback == nil || n > 0) { // The function we are in does a write to SP that we don't know // how to encode in the spdelta table. Examples include context // switch routines like runtime.gogo but also any code that switches // to the g0 stack to run host C code. Since we can't reliably unwind // the SP (we might not even be on the stack we think we are), // we stop the traceback here. + // This only applies for profiling signals (callback == nil). + // + // For a GC stack traversal (callback != nil), we should only see + // a function when it has voluntarily preempted itself on entry + // during the stack growth check. In that case, the function has + // not yet had a chance to do any writes to SP and is safe to unwind. + // isAsyncSafePoint does not allow assembly functions to be async preempted, + // and preemptPark double-checks that SPWRITE functions are not async preempted. + // So for GC stack traversal we leave things alone (this if body does not execute for n == 0) + // at the bottom frame of the stack. But farther up the stack we'd better not + // find any. if callback != nil { - // Finding an SPWRITE should only happen for a profiling signal, which can - // arrive at any time. For a GC stack traversal (callback != nil), - // we shouldn't see this case, and we must be sure to walk the - // entire stack or the GC is invalid. So crash. println("traceback: unexpected SPWRITE function", funcname(f)) throw("traceback") } diff --git a/src/runtime/wincallback.go b/src/runtime/wincallback.go index 8411c98412..a7a787d8f6 100644 --- a/src/runtime/wincallback.go +++ b/src/runtime/wincallback.go @@ -22,7 +22,9 @@ func genasm386Amd64() { buf.WriteString(`// Code generated by wincallback.go using 'go generate'. DO NOT EDIT. +//go:build 386 || amd64 // +build 386 amd64 + // runtime·callbackasm is called by external code to // execute Go implemented callback function. It is not // called from the start, instead runtime·compilecallback diff --git a/src/runtime/zcallback_windows.s b/src/runtime/zcallback_windows.s index 37ffb38aca..e451c2b9d0 100644 --- a/src/runtime/zcallback_windows.s +++ b/src/runtime/zcallback_windows.s @@ -1,6 +1,8 @@ // Code generated by wincallback.go using 'go generate'. DO NOT EDIT. +//go:build 386 || amd64 // +build 386 amd64 + // runtime·callbackasm is called by external code to // execute Go implemented callback function. It is not // called from the start, instead runtime·compilecallback |
