diff options
author | Koundinya Veluri <kouvel@users.noreply.github.com> | 2018-02-02 22:52:36 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-02 22:52:36 -0800 |
commit | 59e3686b148c2d2ed28cb8642eed2862aaa2daac (patch) | |
tree | 221ece87f8ca0e04a45f28b673aab8bbc3cbb1ad /src/vm/synch.h | |
parent | 89f1279cbb118d999280352b3aa68f5169789a56 (diff) | |
download | coreclr-59e3686b148c2d2ed28cb8642eed2862aaa2daac.tar.gz coreclr-59e3686b148c2d2ed28cb8642eed2862aaa2daac.tar.bz2 coreclr-59e3686b148c2d2ed28cb8642eed2862aaa2daac.zip |
Prevent compiler optimization that could cause local var values to change in multithreaded environments, in some places (#16089) (#16093)
Diffstat (limited to 'src/vm/synch.h')
-rw-r--r-- | src/vm/synch.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/vm/synch.h b/src/vm/synch.h index 30e6c30672..1da2107b8d 100644 --- a/src/vm/synch.h +++ b/src/vm/synch.h @@ -219,6 +219,12 @@ private: return *this; } + Counts VolatileLoadWithoutBarrier() const + { + LIMITED_METHOD_CONTRACT; + return ::VolatileLoadWithoutBarrier(&data); + } + Counts CompareExchange(Counts toCounts, Counts fromCounts) { LIMITED_METHOD_CONTRACT; @@ -264,7 +270,11 @@ public: private: BYTE __padding1[MAX_CACHE_LINE_SIZE]; // padding to ensure that m_counts gets its own cache line + + // Take care to use 'm_counts.VolatileLoadWithoutBarrier()` when loading this value into a local variable that will be + // reused. See AwareLock::m_lockState for details. Counts m_counts; + BYTE __padding2[MAX_CACHE_LINE_SIZE]; // padding to ensure that m_counts gets its own cache line #if defined(DEBUG) |