aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/string.go
diff options
context:
space:
mode:
authorDavid du Colombier <0intro@gmail.com>2018-03-14 13:36:31 +0100
committerDavid du Colombier <0intro@gmail.com>2018-03-14 13:15:52 +0000
commit523f2ea77b8845700d302fc69f6c34ac296af55d (patch)
tree937756f56ebd743d672ad0e79aa02d41721473d0 /src/runtime/string.go
parentd32018a50017b075cd46be6b1f5cfb5050337140 (diff)
downloadgo-523f2ea77b8845700d302fc69f6c34ac296af55d.tar.xz
runtime: don't use floating point in findnull on Plan 9
In CL 98015, findnull was rewritten so it uses bytes.IndexByte. This broke the build on plan9/amd64 because the implementation of bytes.IndexByte on AMD64 relies on SSE instructions while floating point instructions are not allowed in the note handler. This change fixes findnull by using the former implementation on Plan 9, so it doesn't use bytes.IndexByte. Fixes #24387. Change-Id: I084d1a44d38d9f77a6c1ad492773f0a98226be16 Reviewed-on: https://go-review.googlesource.com/100577 Run-TryBot: David du Colombier <0intro@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/runtime/string.go')
-rw-r--r--src/runtime/string.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/runtime/string.go b/src/runtime/string.go
index e958f763cf..31518aed70 100644
--- a/src/runtime/string.go
+++ b/src/runtime/string.go
@@ -411,6 +411,18 @@ func findnull(s *byte) int {
return 0
}
+ // Avoid IndexByteString on Plan 9 because it uses SSE instructions
+ // on x86 machines, and those are classified as floating point instructions,
+ // which are illegal in a note handler.
+ if GOOS == "plan9" {
+ p := (*[maxAlloc/2 - 1]byte)(unsafe.Pointer(s))
+ l := 0
+ for p[l] != 0 {
+ l++
+ }
+ return l
+ }
+
// pageSize is the unit we scan at a time looking for NULL.
// It must be the minimum page size for any architecture Go
// runs on. It's okay (just a minor performance loss) if the