Harden test against JIT optimizations
authorJoseph Tremoulet <jotrem@microsoft.com>
Tue, 13 Sep 2016 17:01:15 +0000 (13:01 -0400)
committerJoseph Tremoulet <jotrem@microsoft.com>
Thu, 15 Sep 2016 15:40:52 +0000 (11:40 -0400)
commitf6b070c69585761996778fa5228b07d0be26be57
tree3625b6323258a504b6aa31fb9a140e364e597944
parenta4bdd3b33762d07be30f207eb66be934ccd2ffb4
Harden test against JIT optimizations

Declare static field `finalizerCompletedOnce` volatile -- this test has a
side-effect-free busy-loop which checks that static variable for a change it
expects a finalizer to make to it; this static field must be volatile to
ensure the jit doesn't hoist the load from the loop.

Call GC.KeepAlive on the objects constructed in the various allocation
loops in this test, to make sure that the entire allocation isn't
optimized away.
tests/src/GC/Scenarios/FinalizeTimeout/FinalizeTimeout.cs