From 403ab0f2214f583db84a2dae275389be92072a35 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Thu, 1 Mar 2018 16:38:41 -0800 Subject: internal/bytealg: move IndexByte asssembly to the new bytealg package Move the IndexByte function from the runtime to a new bytealg package. The new package will eventually hold all the optimized assembly for groveling through byte slices and strings. It seems a better home for this code than randomly keeping it in runtime. Once this is in, the next step is to move the other functions (Compare, Equal, ...). Update #19792 This change seems complicated enough that we might just declare "not worth it" and abandon. Opinions welcome. The core assembly is all unchanged, except minor modifications where the code reads cpu feature bits. The wrapper functions have been cleaned up as they are now actually checked by vet. Change-Id: I9fa75bee5d85db3a65b3fd3b7997e60367523796 Reviewed-on: https://go-review.googlesource.com/98016 Run-TryBot: Keith Randall TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/runtime/error.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/runtime/error.go') diff --git a/src/runtime/error.go b/src/runtime/error.go index e1291e1543..4b6fb32b78 100644 --- a/src/runtime/error.go +++ b/src/runtime/error.go @@ -4,7 +4,7 @@ package runtime -import _ "unsafe" // for go:linkname +import "internal/bytealg" // The Error interface identifies a run time error. type Error interface { @@ -118,11 +118,6 @@ func printany(i interface{}) { } } -// strings.IndexByte is implemented in runtime/asm_$goarch.s -// but amusingly we need go:linkname to get access to it here in the runtime. -//go:linkname stringsIndexByte strings.IndexByte -func stringsIndexByte(s string, c byte) int - // panicwrap generates a panic for a call to a wrapped value method // with a nil pointer receiver. // @@ -133,7 +128,7 @@ func panicwrap() { // name is something like "main.(*T).F". // We want to extract pkg ("main"), typ ("T"), and meth ("F"). // Do it by finding the parens. - i := stringsIndexByte(name, '(') + i := bytealg.IndexByteString(name, '(') if i < 0 { throw("panicwrap: no ( in " + name) } @@ -142,7 +137,7 @@ func panicwrap() { throw("panicwrap: unexpected string after package name: " + name) } name = name[i+2:] - i = stringsIndexByte(name, ')') + i = bytealg.IndexByteString(name, ')') if i < 0 { throw("panicwrap: no ) in " + name) } -- cgit v1.3-5-g9baa