mirror of
https://github.com/golang/go
synced 2024-11-20 06:44:40 -07:00
b035e97315
This CL implements the many multiword write barriers by calling writebarrierptr, so that only writebarrierptr needs the actual barrier. In lieu of an actual barrier, writebarrierptr checks that the value being copied is not a small non-zero integer. This is enough to shake out bugs where the barrier is being called when it should not (for non-pointer values). It also found a few tests in sync/atomic that were being too clever. This CL adds a write barrier for the memory moved during the builtin copy function, which I forgot when inserting barriers for Go 1.4. This CL re-enables some write barriers that were disabled for Go 1.4. Those were disabled because it is possible to change the generated code so that they are unnecessary most of the time, but we have not changed the generated code yet. For safety they must be enabled. None of this is terribly efficient. We are aiming for correct first. LGTM=rlh R=rlh CC=golang-codereviews https://golang.org/cl/168770043
42 lines
907 B
Go
42 lines
907 B
Go
// Copyright 2014 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// +build ignore
|
|
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
if flag.NArg() > 0 {
|
|
f, err := os.Create(flag.Arg(0))
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
os.Stdout = f
|
|
}
|
|
fmt.Printf("// generated by wbfat_gen.go; use go generate\n\n")
|
|
fmt.Printf("package runtime\n")
|
|
for i := uint(2); i <= 4; i++ {
|
|
for j := 1; j < 1<<i; j++ {
|
|
fmt.Printf("\n//go:nosplit\n")
|
|
fmt.Printf("func writebarrierfat%0*b(dst *[%d]uintptr, _ *byte, src [%d]uintptr) {\n", int(i), j, i, i)
|
|
for k := uint(0); k < i; k++ {
|
|
if j&(1<<(i-1-k)) != 0 {
|
|
fmt.Printf("\twritebarrierptr(&dst[%d], src[%d])\n", k, k)
|
|
} else {
|
|
fmt.Printf("\tdst[%d] = src[%d]\n", k, k)
|
|
}
|
|
}
|
|
fmt.Printf("}\n")
|
|
}
|
|
}
|
|
}
|