|
1 | 1 | // the type name must be in sync with WindowsDisassembler.BuildArguments |
2 | | - public unsafe class Runnable_$ID$ : global::$WorkloadTypeName$ |
| 2 | + public unsafe sealed class Runnable_$ID$ : global::$WorkloadTypeName$ |
3 | 3 | { |
4 | 4 | public static void Run(BenchmarkDotNet.Engines.IHost host, System.String benchmarkName) |
5 | 5 | { |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 |
|
54 | | - public delegate $OverheadMethodReturnTypeName$ OverheadDelegate($ArgumentsDefinition$); |
55 | | - |
56 | | - public delegate $WorkloadMethodReturnTypeModifiers$ $WorkloadMethodReturnType$ WorkloadDelegate($ArgumentsDefinition$); |
57 | | - |
58 | 54 | public Runnable_$ID$() |
59 | 55 | { |
60 | 56 | globalSetupAction = $GlobalSetupMethodName$; |
61 | 57 | globalCleanupAction = $GlobalCleanupMethodName$; |
62 | 58 | iterationSetupAction = $IterationSetupMethodName$; |
63 | 59 | iterationCleanupAction = $IterationCleanupMethodName$; |
64 | | - overheadDelegate = __Overhead; |
65 | | - workloadDelegate = $WorkloadMethodDelegate$; |
66 | 60 | $InitializeArgumentFields$ |
67 | 61 | } |
68 | 62 |
|
69 | 63 | private System.Action globalSetupAction; |
70 | 64 | private System.Action globalCleanupAction; |
71 | 65 | private System.Action iterationSetupAction; |
72 | 66 | private System.Action iterationCleanupAction; |
73 | | - private BenchmarkDotNet.Autogenerated.Runnable_$ID$.OverheadDelegate overheadDelegate; |
74 | | - private BenchmarkDotNet.Autogenerated.Runnable_$ID$.WorkloadDelegate workloadDelegate; |
75 | 67 | $DeclareArgumentFields$ |
76 | 68 |
|
77 | 69 | // this method is used only for the disassembly diagnoser purposes |
|
111 | 103 |
|
112 | 104 | #if RETURNS_CONSUMABLE_$ID$ |
113 | 105 |
|
| 106 | + // Prevent inlining the method invoke. |
| 107 | + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining | System.Runtime.CompilerServices.MethodImplOptions.NoOptimization)] |
| 108 | + private $OverheadMethodReturnTypeName$ __OverheadWrapper($ArgumentsDefinition$) |
| 109 | + { |
| 110 | + return __Overhead($PassArguments$); |
| 111 | + } |
| 112 | + |
| 113 | + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining | System.Runtime.CompilerServices.MethodImplOptions.NoOptimization)] |
| 114 | + private $WorkloadMethodReturnType$ __WorkloadWrapper($ArgumentsDefinition$) |
| 115 | + { |
| 116 | + return $WorkloadMethodCall$; |
| 117 | + } |
| 118 | + |
114 | 119 | private BenchmarkDotNet.Engines.Consumer consumer = new BenchmarkDotNet.Engines.Consumer(); |
115 | 120 |
|
116 | 121 | #if NETCOREAPP3_0_OR_GREATER |
|
121 | 126 | $LoadArguments$ |
122 | 127 | for (System.Int64 i = 0; i < invokeCount; i++) |
123 | 128 | { |
124 | | - consumer.Consume(overheadDelegate($PassArguments$));@Unroll@ |
| 129 | + consumer.Consume(__OverheadWrapper($PassArguments$));@Unroll@ |
125 | 130 | } |
126 | 131 | } |
127 | 132 |
|
|
133 | 138 | $LoadArguments$ |
134 | 139 | for (System.Int64 i = 0; i < invokeCount; i++) |
135 | 140 | { |
136 | | - consumer.Consume(overheadDelegate($PassArguments$)); |
| 141 | + consumer.Consume(__OverheadWrapper($PassArguments$)); |
137 | 142 | } |
138 | 143 | } |
139 | 144 |
|
|
145 | 150 | $LoadArguments$ |
146 | 151 | for (System.Int64 i = 0; i < invokeCount; i++) |
147 | 152 | { |
148 | | - consumer.Consume(workloadDelegate($PassArguments$)$ConsumeField$);@Unroll@ |
| 153 | + consumer.Consume(__WorkloadWrapper($PassArguments$)$ConsumeField$);@Unroll@ |
149 | 154 | } |
150 | 155 | } |
151 | 156 |
|
|
157 | 162 | $LoadArguments$ |
158 | 163 | for (System.Int64 i = 0; i < invokeCount; i++) |
159 | 164 | { |
160 | | - consumer.Consume(workloadDelegate($PassArguments$)$ConsumeField$); |
| 165 | + consumer.Consume(__WorkloadWrapper($PassArguments$)$ConsumeField$); |
161 | 166 | } |
162 | 167 | } |
163 | 168 |
|
|
175 | 180 |
|
176 | 181 | #elif RETURNS_NON_CONSUMABLE_STRUCT_$ID$ |
177 | 182 |
|
| 183 | + // Prevent inlining the method invoke. |
| 184 | + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining | System.Runtime.CompilerServices.MethodImplOptions.NoOptimization)] |
| 185 | + private $OverheadMethodReturnTypeName$ __OverheadWrapper($ArgumentsDefinition$) |
| 186 | + { |
| 187 | + return __Overhead($PassArguments$); |
| 188 | + } |
| 189 | + |
| 190 | + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining | System.Runtime.CompilerServices.MethodImplOptions.NoOptimization)] |
| 191 | + private $WorkloadMethodReturnType$ __WorkloadWrapper($ArgumentsDefinition$) |
| 192 | + { |
| 193 | + return $WorkloadMethodCall$; |
| 194 | + } |
| 195 | + |
178 | 196 | #if NETCOREAPP3_0_OR_GREATER |
179 | 197 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)] |
180 | 198 | #endif |
|
184 | 202 | $OverheadMethodReturnTypeName$ result = default($OverheadMethodReturnTypeName$); |
185 | 203 | for (System.Int64 i = 0; i < invokeCount; i++) |
186 | 204 | { |
187 | | - result = overheadDelegate($PassArguments$);@Unroll@ |
| 205 | + result = __OverheadWrapper($PassArguments$);@Unroll@ |
188 | 206 | } |
189 | 207 | BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(result); |
190 | 208 | } |
|
198 | 216 | $OverheadMethodReturnTypeName$ result = default($OverheadMethodReturnTypeName$); |
199 | 217 | for (System.Int64 i = 0; i < invokeCount; i++) |
200 | 218 | { |
201 | | - result = overheadDelegate($PassArguments$); |
| 219 | + result = __OverheadWrapper($PassArguments$); |
202 | 220 | } |
203 | 221 | BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(result); |
204 | 222 | } |
|
212 | 230 | $WorkloadMethodReturnType$ result = default($WorkloadMethodReturnType$); |
213 | 231 | for (System.Int64 i = 0; i < invokeCount; i++) |
214 | 232 | { |
215 | | - result = workloadDelegate($PassArguments$);@Unroll@ |
| 233 | + result = __WorkloadWrapper($PassArguments$);@Unroll@ |
216 | 234 | } |
217 | 235 | NonGenericKeepAliveWithoutBoxing(result); |
218 | 236 | } |
|
226 | 244 | $WorkloadMethodReturnType$ result = default($WorkloadMethodReturnType$); |
227 | 245 | for (System.Int64 i = 0; i < invokeCount; i++) |
228 | 246 | { |
229 | | - result = workloadDelegate($PassArguments$); |
| 247 | + result = __WorkloadWrapper($PassArguments$); |
230 | 248 | } |
231 | 249 | NonGenericKeepAliveWithoutBoxing(result); |
232 | 250 | } |
|
250 | 268 |
|
251 | 269 | #elif RETURNS_BYREF_$ID$ |
252 | 270 |
|
| 271 | + // Prevent inlining the method invoke. |
| 272 | + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining | System.Runtime.CompilerServices.MethodImplOptions.NoOptimization)] |
| 273 | + private $OverheadMethodReturnTypeName$ __OverheadWrapper($ArgumentsDefinition$) |
| 274 | + { |
| 275 | + return __Overhead($PassArguments$); |
| 276 | + } |
| 277 | + |
| 278 | + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining | System.Runtime.CompilerServices.MethodImplOptions.NoOptimization)] |
| 279 | + private ref $WorkloadMethodReturnType$ __WorkloadWrapper($ArgumentsDefinition$) |
| 280 | + { |
| 281 | + return ref $WorkloadMethodCall$; |
| 282 | + } |
| 283 | + |
253 | 284 | #if NETCOREAPP3_0_OR_GREATER |
254 | 285 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)] |
255 | 286 | #endif |
|
259 | 290 | $OverheadMethodReturnTypeName$ value = default($OverheadMethodReturnTypeName$); |
260 | 291 | for (System.Int64 i = 0; i < invokeCount; i++) |
261 | 292 | { |
262 | | - value = overheadDelegate($PassArguments$);@Unroll@ |
| 293 | + value = __OverheadWrapper($PassArguments$);@Unroll@ |
263 | 294 | } |
264 | 295 | BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(value); |
265 | 296 | } |
|
273 | 304 | $OverheadMethodReturnTypeName$ value = default($OverheadMethodReturnTypeName$); |
274 | 305 | for (System.Int64 i = 0; i < invokeCount; i++) |
275 | 306 | { |
276 | | - value = overheadDelegate($PassArguments$); |
| 307 | + value = __OverheadWrapper($PassArguments$); |
277 | 308 | } |
278 | 309 | BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(value); |
279 | 310 | } |
|
289 | 320 | ref $WorkloadMethodReturnType$ alias = ref workloadDefaultValueHolder; |
290 | 321 | for (System.Int64 i = 0; i < invokeCount; i++) |
291 | 322 | { |
292 | | - alias = workloadDelegate($PassArguments$);@Unroll@ |
| 323 | + alias = __WorkloadWrapper($PassArguments$);@Unroll@ |
293 | 324 | } |
294 | 325 | BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(ref alias); |
295 | 326 | } |
|
303 | 334 | ref $WorkloadMethodReturnType$ alias = ref workloadDefaultValueHolder; |
304 | 335 | for (System.Int64 i = 0; i < invokeCount; i++) |
305 | 336 | { |
306 | | - alias = workloadDelegate($PassArguments$); |
| 337 | + alias = __WorkloadWrapper($PassArguments$); |
307 | 338 | } |
308 | 339 | BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(ref alias); |
309 | 340 | } |
|
321 | 352 | } |
322 | 353 | #elif RETURNS_BYREF_READONLY_$ID$ |
323 | 354 |
|
| 355 | + // Prevent inlining the method invoke. |
| 356 | + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining | System.Runtime.CompilerServices.MethodImplOptions.NoOptimization)] |
| 357 | + private $OverheadMethodReturnTypeName$ __OverheadWrapper($ArgumentsDefinition$) |
| 358 | + { |
| 359 | + return __Overhead($PassArguments$); |
| 360 | + } |
| 361 | + |
| 362 | + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining | System.Runtime.CompilerServices.MethodImplOptions.NoOptimization)] |
| 363 | + private ref readonly $WorkloadMethodReturnType$ __WorkloadWrapper($ArgumentsDefinition$) |
| 364 | + { |
| 365 | + return ref $WorkloadMethodCall$; |
| 366 | + } |
| 367 | + |
324 | 368 | #if NETCOREAPP3_0_OR_GREATER |
325 | 369 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)] |
326 | 370 | #endif |
|
330 | 374 | $OverheadMethodReturnTypeName$ value = default($OverheadMethodReturnTypeName$); |
331 | 375 | for (System.Int64 i = 0; i < invokeCount; i++) |
332 | 376 | { |
333 | | - value = overheadDelegate($PassArguments$);@Unroll@ |
| 377 | + value = __OverheadWrapper($PassArguments$);@Unroll@ |
334 | 378 | } |
335 | 379 | BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(value); |
336 | 380 | } |
|
344 | 388 | $OverheadMethodReturnTypeName$ value = default($OverheadMethodReturnTypeName$); |
345 | 389 | for (System.Int64 i = 0; i < invokeCount; i++) |
346 | 390 | { |
347 | | - value = overheadDelegate($PassArguments$); |
| 391 | + value = __OverheadWrapper($PassArguments$); |
348 | 392 | } |
349 | 393 | BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(value); |
350 | 394 | } |
|
360 | 404 | ref $WorkloadMethodReturnType$ alias = ref workloadDefaultValueHolder; |
361 | 405 | for (System.Int64 i = 0; i < invokeCount; i++) |
362 | 406 | { |
363 | | - alias = workloadDelegate($PassArguments$);@Unroll@ |
| 407 | + alias = __WorkloadWrapper($PassArguments$);@Unroll@ |
364 | 408 | } |
365 | 409 | BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxingReadonly(alias); |
366 | 410 | } |
|
374 | 418 | ref $WorkloadMethodReturnType$ alias = ref workloadDefaultValueHolder; |
375 | 419 | for (System.Int64 i = 0; i < invokeCount; i++) |
376 | 420 | { |
377 | | - alias = workloadDelegate($PassArguments$); |
| 421 | + alias = __WorkloadWrapper($PassArguments$); |
378 | 422 | } |
379 | 423 | BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxingReadonly(alias); |
380 | 424 | } |
|
392 | 436 | } |
393 | 437 | #elif RETURNS_VOID_$ID$ |
394 | 438 |
|
| 439 | + // Prevent inlining the method invoke. |
| 440 | + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining | System.Runtime.CompilerServices.MethodImplOptions.NoOptimization)] |
| 441 | + private void __OverheadWrapper($ArgumentsDefinition$) |
| 442 | + { |
| 443 | + __Overhead($PassArguments$); |
| 444 | + } |
| 445 | + |
| 446 | + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining | System.Runtime.CompilerServices.MethodImplOptions.NoOptimization)] |
| 447 | + private void __WorkloadWrapper($ArgumentsDefinition$) |
| 448 | + { |
| 449 | + $WorkloadMethodCall$; |
| 450 | + } |
| 451 | + |
395 | 452 | #if NETCOREAPP3_0_OR_GREATER |
396 | 453 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)] |
397 | 454 | #endif |
|
400 | 457 | $LoadArguments$ |
401 | 458 | for (System.Int64 i = 0; i < invokeCount; i++) |
402 | 459 | { |
403 | | - overheadDelegate($PassArguments$);@Unroll@ |
| 460 | + __OverheadWrapper($PassArguments$);@Unroll@ |
404 | 461 | } |
405 | 462 | } |
406 | 463 |
|
|
412 | 469 | $LoadArguments$ |
413 | 470 | for (System.Int64 i = 0; i < invokeCount; i++) |
414 | 471 | { |
415 | | - overheadDelegate($PassArguments$); |
| 472 | + __OverheadWrapper($PassArguments$); |
416 | 473 | } |
417 | 474 | } |
418 | 475 |
|
|
424 | 481 | $LoadArguments$ |
425 | 482 | for (System.Int64 i = 0; i < invokeCount; i++) |
426 | 483 | { |
427 | | - workloadDelegate($PassArguments$);@Unroll@ |
| 484 | + __WorkloadWrapper($PassArguments$);@Unroll@ |
428 | 485 | } |
429 | 486 | } |
430 | 487 |
|
|
436 | 493 | $LoadArguments$ |
437 | 494 | for (System.Int64 i = 0; i < invokeCount; i++) |
438 | 495 | { |
439 | | - workloadDelegate($PassArguments$); |
| 496 | + __WorkloadWrapper($PassArguments$); |
440 | 497 | } |
441 | 498 | } |
442 | 499 |
|
|
0 commit comments