@@ -19,8 +19,8 @@ func TestTracebackArgs(t *testing.T) {
19
19
}{
20
20
// simple ints
21
21
{
22
- func () int { return testTracebackArgs1 (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 ) },
23
- "testTracebackArgs1(0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, ... )" ,
22
+ func () int { return testTracebackArgs1 (1 , 2 , 3 , 4 , 5 ) },
23
+ "testTracebackArgs1(0x1, 0x2, 0x3, 0x4, 0x5)" ,
24
24
},
25
25
// some aggregates
26
26
{
@@ -53,6 +53,58 @@ func TestTracebackArgs(t *testing.T) {
53
53
},
54
54
"testTracebackArgs5(0x0, {0x1, {}, {{}, {}}}, {}, {}, {}, {}, {}, ...)" ,
55
55
},
56
+
57
+ // edge cases for ...
58
+ // no ... for 10 args
59
+ {
60
+ func () int { return testTracebackArgs6a (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ) },
61
+ "testTracebackArgs6a(0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa)" ,
62
+ },
63
+ // has ... for 11 args
64
+ {
65
+ func () int { return testTracebackArgs6b (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 ) },
66
+ "testTracebackArgs6b(0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, ...)" ,
67
+ },
68
+ // no ... for aggregates with 10 words
69
+ {
70
+ func () int { return testTracebackArgs7a ([10 ]int {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 }) },
71
+ "testTracebackArgs7a({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa})" ,
72
+ },
73
+ // has ... for aggregates with 11 words
74
+ {
75
+ func () int { return testTracebackArgs7b ([11 ]int {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 }) },
76
+ "testTracebackArgs7b({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, ...})" ,
77
+ },
78
+ // no ... for aggregates, but with more args
79
+ {
80
+ func () int { return testTracebackArgs7c ([10 ]int {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 }, 11 ) },
81
+ "testTracebackArgs7c({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa}, ...)" ,
82
+ },
83
+ // has ... for aggregates and also for more args
84
+ {
85
+ func () int { return testTracebackArgs7d ([11 ]int {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 }, 12 ) },
86
+ "testTracebackArgs7d({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, ...}, ...)" ,
87
+ },
88
+ // nested aggregates, no ...
89
+ {
90
+ func () int { return testTracebackArgs8a (testArgsType8a {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , [2 ]int {9 , 10 }}) },
91
+ "testTracebackArgs8a({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, {0x9, 0xa}})" ,
92
+ },
93
+ // nested aggregates, ... in inner but not outer
94
+ {
95
+ func () int { return testTracebackArgs8b (testArgsType8b {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , [3 ]int {9 , 10 , 11 }}) },
96
+ "testTracebackArgs8b({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, {0x9, 0xa, ...}})" ,
97
+ },
98
+ // nested aggregates, ... in outer but not inner
99
+ {
100
+ func () int { return testTracebackArgs8c (testArgsType8c {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , [2 ]int {9 , 10 }, 11 }) },
101
+ "testTracebackArgs8c({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, {0x9, 0xa}, ...})" ,
102
+ },
103
+ // nested aggregates, ... in both inner and outer
104
+ {
105
+ func () int { return testTracebackArgs8d (testArgsType8d {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , [3 ]int {9 , 10 , 11 }, 12 }) },
106
+ "testTracebackArgs8d({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, {0x9, 0xa, ...}, ...})" ,
107
+ },
56
108
}
57
109
for _ , test := range tests {
58
110
n := test .fn ()
@@ -64,11 +116,11 @@ func TestTracebackArgs(t *testing.T) {
64
116
}
65
117
66
118
//go:noinline
67
- func testTracebackArgs1 (a , b , c , d , e , f , g , h , i , j , k , l int ) int {
119
+ func testTracebackArgs1 (a , b , c , d , e int ) int {
68
120
n := runtime .Stack (testTracebackArgsBuf [:], false )
69
121
if a < 0 {
70
122
// use in-reg args to keep them alive
71
- return a + b + c + d + e + f + g + h + i + j + k + l
123
+ return a + b + c + d + e
72
124
}
73
125
return n
74
126
}
@@ -119,3 +171,122 @@ func testTracebackArgs5(a bool, x struct {
119
171
}
120
172
return n
121
173
}
174
+
175
+ //go:noinline
176
+ func testTracebackArgs6a (a , b , c , d , e , f , g , h , i , j int ) int {
177
+ n := runtime .Stack (testTracebackArgsBuf [:], false )
178
+ if a < 0 {
179
+ // use in-reg args to keep them alive
180
+ return a + b + c + d + e + f + g + h + i + j
181
+ }
182
+ return n
183
+ }
184
+
185
+ //go:noinline
186
+ func testTracebackArgs6b (a , b , c , d , e , f , g , h , i , j , k int ) int {
187
+ n := runtime .Stack (testTracebackArgsBuf [:], false )
188
+ if a < 0 {
189
+ // use in-reg args to keep them alive
190
+ return a + b + c + d + e + f + g + h + i + j + k
191
+ }
192
+ return n
193
+ }
194
+
195
+ //go:noinline
196
+ func testTracebackArgs7a (a [10 ]int ) int {
197
+ n := runtime .Stack (testTracebackArgsBuf [:], false )
198
+ if a [0 ] < 0 {
199
+ // use in-reg args to keep them alive
200
+ return a [1 ] + a [2 ] + a [3 ] + a [4 ] + a [5 ] + a [6 ] + a [7 ] + a [8 ] + a [9 ]
201
+ }
202
+ return n
203
+ }
204
+
205
+ //go:noinline
206
+ func testTracebackArgs7b (a [11 ]int ) int {
207
+ n := runtime .Stack (testTracebackArgsBuf [:], false )
208
+ if a [0 ] < 0 {
209
+ // use in-reg args to keep them alive
210
+ return a [1 ] + a [2 ] + a [3 ] + a [4 ] + a [5 ] + a [6 ] + a [7 ] + a [8 ] + a [9 ] + a [10 ]
211
+ }
212
+ return n
213
+ }
214
+
215
+ //go:noinline
216
+ func testTracebackArgs7c (a [10 ]int , b int ) int {
217
+ n := runtime .Stack (testTracebackArgsBuf [:], false )
218
+ if a [0 ] < 0 {
219
+ // use in-reg args to keep them alive
220
+ return a [1 ] + a [2 ] + a [3 ] + a [4 ] + a [5 ] + a [6 ] + a [7 ] + a [8 ] + a [9 ] + b
221
+ }
222
+ return n
223
+ }
224
+
225
+ //go:noinline
226
+ func testTracebackArgs7d (a [11 ]int , b int ) int {
227
+ n := runtime .Stack (testTracebackArgsBuf [:], false )
228
+ if a [0 ] < 0 {
229
+ // use in-reg args to keep them alive
230
+ return a [1 ] + a [2 ] + a [3 ] + a [4 ] + a [5 ] + a [6 ] + a [7 ] + a [8 ] + a [9 ] + a [10 ] + b
231
+ }
232
+ return n
233
+ }
234
+
235
+ type testArgsType8a struct {
236
+ a , b , c , d , e , f , g , h int
237
+ i [2 ]int
238
+ }
239
+ type testArgsType8b struct {
240
+ a , b , c , d , e , f , g , h int
241
+ i [3 ]int
242
+ }
243
+ type testArgsType8c struct {
244
+ a , b , c , d , e , f , g , h int
245
+ i [2 ]int
246
+ j int
247
+ }
248
+ type testArgsType8d struct {
249
+ a , b , c , d , e , f , g , h int
250
+ i [3 ]int
251
+ j int
252
+ }
253
+
254
+ //go:noinline
255
+ func testTracebackArgs8a (a testArgsType8a ) int {
256
+ n := runtime .Stack (testTracebackArgsBuf [:], false )
257
+ if a .a < 0 {
258
+ // use in-reg args to keep them alive
259
+ return a .b + a .c + a .d + a .e + a .f + a .g + a .h + a .i [0 ] + a .i [1 ]
260
+ }
261
+ return n
262
+ }
263
+
264
+ //go:noinline
265
+ func testTracebackArgs8b (a testArgsType8b ) int {
266
+ n := runtime .Stack (testTracebackArgsBuf [:], false )
267
+ if a .a < 0 {
268
+ // use in-reg args to keep them alive
269
+ return a .b + a .c + a .d + a .e + a .f + a .g + a .h + a .i [0 ] + a .i [1 ] + a .i [2 ]
270
+ }
271
+ return n
272
+ }
273
+
274
+ //go:noinline
275
+ func testTracebackArgs8c (a testArgsType8c ) int {
276
+ n := runtime .Stack (testTracebackArgsBuf [:], false )
277
+ if a .a < 0 {
278
+ // use in-reg args to keep them alive
279
+ return a .b + a .c + a .d + a .e + a .f + a .g + a .h + a .i [0 ] + a .i [1 ] + a .j
280
+ }
281
+ return n
282
+ }
283
+
284
+ //go:noinline
285
+ func testTracebackArgs8d (a testArgsType8d ) int {
286
+ n := runtime .Stack (testTracebackArgsBuf [:], false )
287
+ if a .a < 0 {
288
+ // use in-reg args to keep them alive
289
+ return a .b + a .c + a .d + a .e + a .f + a .g + a .h + a .i [0 ] + a .i [1 ] + a .i [2 ] + a .j
290
+ }
291
+ return n
292
+ }
0 commit comments