From 523f2ea77b8845700d302fc69f6c34ac296af55d Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 14 Mar 2018 13:36:31 +0100 Subject: [PATCH] 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 Reviewed-by: Rob Pike --- src/runtime/string.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 -- 2.50.0