1
2
3
4
5
6
7 package codegen
8
9 import "runtime"
10
11
12
13 func movesmall4() {
14 x := [...]byte{1, 2, 3, 4}
15
16
17
18
19
20 copy(x[1:], x[:])
21 }
22
23 func movesmall7() {
24 x := [...]byte{1, 2, 3, 4, 5, 6, 7}
25
26
27
28
29 copy(x[1:], x[:])
30 }
31
32 func movesmall16() {
33 x := [...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
34
35
36 copy(x[1:], x[:])
37 }
38
39 var x [256]byte
40
41
42
43 func moveDisjointStack32() {
44 var s [32]byte
45
46
47
48 copy(s[:], x[:32])
49 runtime.KeepAlive(&s)
50 }
51
52 func moveDisjointStack64() {
53 var s [96]byte
54
55
56
57 copy(s[:], x[:96])
58 runtime.KeepAlive(&s)
59 }
60
61 func moveDisjointStack() {
62 var s [256]byte
63
64
65
66
67
68 copy(s[:], x[:])
69 runtime.KeepAlive(&s)
70 }
71
72 func moveDisjointArg(b *[256]byte) {
73 var s [256]byte
74
75
76
77
78
79 copy(s[:], b[:])
80 runtime.KeepAlive(&s)
81 }
82
83 func moveDisjointNoOverlap(a *[256]byte) {
84
85
86
87
88
89 copy(a[:], a[128:])
90 }
91
92
93
94 func moveArchLowering1(b []byte, x *[1]byte) {
95 _ = b[1]
96
97
98
99 copy(b, x[:])
100 }
101
102 func moveArchLowering2(b []byte, x *[2]byte) {
103 _ = b[2]
104
105
106
107 copy(b, x[:])
108 }
109
110 func moveArchLowering4(b []byte, x *[4]byte) {
111 _ = b[4]
112
113
114
115 copy(b, x[:])
116 }
117
118 func moveArchLowering8(b []byte, x *[8]byte) {
119 _ = b[8]
120
121
122
123 copy(b, x[:])
124 }
125
126 func moveArchLowering16(b []byte, x *[16]byte) {
127 _ = b[16]
128
129 copy(b, x[:])
130 }
131
132
133
134 func ptrEqual() {
135
136
137
138 copy(x[:], x[:])
139 }
140
141 func ptrOneOffset() {
142
143
144
145 copy(x[1:], x[:])
146 }
147
148 func ptrBothOffset() {
149
150
151
152 copy(x[1:], x[2:])
153 }
154
155
156 func noMaskOnCopy(a []int, s string, x int) int {
157
158 return a[x&^copy([]byte{}, s)]
159 }
160
View as plain text