...
Source file src/pkg/cmd/compile/internal/gc/racewalk.go
1
2
3
4
5 package gc
6
7 import (
8 "cmd/compile/internal/types"
9 "cmd/internal/src"
10 "cmd/internal/sys"
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 var omit_pkgs = []string{
36 "runtime/internal/atomic",
37 "runtime/internal/sys",
38 "runtime/internal/math",
39 "runtime",
40 "runtime/race",
41 "runtime/msan",
42 "internal/cpu",
43 }
44
45
46
47 var norace_inst_pkgs = []string{"sync", "sync/atomic"}
48
49 func ispkgin(pkgs []string) bool {
50 if myimportpath != "" {
51 for _, p := range pkgs {
52 if myimportpath == p {
53 return true
54 }
55 }
56 }
57
58 return false
59 }
60
61 func instrument(fn *Node) {
62 if fn.Func.Pragma&Norace != 0 {
63 return
64 }
65
66 if !flag_race || !ispkgin(norace_inst_pkgs) {
67 fn.Func.SetInstrumentBody(true)
68 }
69
70 if flag_race {
71 lno := lineno
72 lineno = src.NoXPos
73
74 if thearch.LinkArch.Arch.Family != sys.AMD64 {
75 fn.Func.Enter.Prepend(mkcall("racefuncenterfp", nil, nil))
76 fn.Func.Exit.Append(mkcall("racefuncexit", nil, nil))
77 } else {
78
79
80
81
82
83
84 nodpc := nodfp.copy()
85 nodpc.Type = types.Types[TUINTPTR]
86 nodpc.Xoffset = int64(-Widthptr)
87 fn.Func.Dcl = append(fn.Func.Dcl, nodpc)
88 fn.Func.Enter.Prepend(mkcall("racefuncenter", nil, nil, nodpc))
89 fn.Func.Exit.Append(mkcall("racefuncexit", nil, nil))
90 }
91 lineno = lno
92 }
93 }
94
View as plain text