Improve tailcallstress testing (#41059)
authorEugene Rozenfeld <erozen@microsoft.com>
Mon, 24 Aug 2020 22:06:06 +0000 (15:06 -0700)
committerGitHub <noreply@github.com>
Mon, 24 Aug 2020 22:06:06 +0000 (15:06 -0700)
commitea1d20c71e7c4402a63be4c275296fc39ab75ebd
treec292f45ce782552c0a57177a8196ca92a92fa11d
parentc6b4af37986ed165cd545a1f5869a10038b46c43
Improve tailcallstress testing (#41059)

1. Dispatch all tail calls under TailCallStress via helpers. That
increases our coverage since valid non-tail-prefixed calls are
dispatched as fast calls in normal non-stress mode.

2. Don't attempt to tail call from methods that have a localloc
unless there is an explicit tail prefix. Note that we already disallowed
fast tail calls from such methods so this change only affects
tailcallstress mode.

3. Fix a bug in TestInvokeDOPAndCancel. As the test was written
this assert was firing under tailcallstress:
https://github.com/dotnet/runtime/blob/480c49b2419ab4a0b34bfd86754abc2f17079c77/src/libraries/System.Threading.Tasks.Parallel/tests/ParallelForTests.cs#L1074
When this call to `cts.Cancel`:
https://github.com/dotnet/runtime/blob/480c49b2419ab4a0b34bfd86754abc2f17079c77/src/libraries/System.Threading.Tasks.Parallel/tests/ParallelForTests.cs#L1065
is dispatched via helpers, it takes much longer than when it's
dispatched via a fast tail call (we have to jit a couple of IL stubs).
Because of that, it's possible that all other actions complete on the
other thread before cancellation is completed.
src/coreclr/src/jit/morph.cpp
src/libraries/System.Threading.Tasks.Parallel/tests/ParallelForTests.cs
src/libraries/System.Threading.Thread/tests/ThreadTests.cs