]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: don't use floating point in findnull on Plan 9
authorDavid du Colombier <0intro@gmail.com>
Wed, 14 Mar 2018 12:36:31 +0000 (13:36 +0100)
committerDavid du Colombier <0intro@gmail.com>
Wed, 14 Mar 2018 13:15:52 +0000 (13:15 +0000)
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>
src/runtime/string.go

index e958f763cf587d398ce772f7419eef5f04960890..31518aed70789ca4286c972b975c82f8b9abe2d6 100644 (file)
@@ -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