summaryrefslogtreecommitdiff
path: root/src/runtime/wbfat_gen.go
blob: 78d5b6271ffbb8057cb9f65d1df3a3bb86e70e18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// 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")
		}
	}
}