From 08c8a26e9ca87ad2dd5b26d397e6107b68adfe76 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 3 May 2019 21:45:35 +0000 Subject: compiler: recognize and optimize array range clear Recognize for i := range a { a[i] = zero } for array or slice a, and rewrite it to call memclr, as the gc compiler does. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/169398 From-SVN: r270862 --- libgo/go/runtime/mbarrier.go | 1 + 1 file changed, 1 insertion(+) (limited to 'libgo/go/runtime') diff --git a/libgo/go/runtime/mbarrier.go b/libgo/go/runtime/mbarrier.go index d3ffd3c..89febb9 100644 --- a/libgo/go/runtime/mbarrier.go +++ b/libgo/go/runtime/mbarrier.go @@ -23,6 +23,7 @@ import ( // //go:linkname typedmemmove runtime.typedmemmove //go:linkname typedslicecopy runtime.typedslicecopy +//go:linkname memclrHasPointers runtime.memclrHasPointers // Go uses a hybrid barrier that combines a Yuasa-style deletion // barrier—which shades the object whose reference is being -- cgit v1.1 From fbe4e644c0c8f1303ec91a25b8da6e626976500c Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Wed, 8 May 2019 17:40:45 +0000 Subject: runtime: use builtin memmove directly We can use the intrinsic memmove directly, without going through C. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/170004 * go-gcc.cc (Gcc_backend::Gcc_backend): Define memmove builtin. From-SVN: r271016 --- libgo/go/runtime/stubs.go | 1 + 1 file changed, 1 insertion(+) (limited to 'libgo/go/runtime') diff --git a/libgo/go/runtime/stubs.go b/libgo/go/runtime/stubs.go index dfdb38e..435cdf7 100644 --- a/libgo/go/runtime/stubs.go +++ b/libgo/go/runtime/stubs.go @@ -100,6 +100,7 @@ func reflect_memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr) { // memmove copies n bytes from "from" to "to". //go:noescape +//extern __builtin_memmove func memmove(to, from unsafe.Pointer, n uintptr) //go:linkname reflect_memmove reflect.memmove -- cgit v1.1