diff options
author | Koundinya Veluri <kouvel@users.noreply.github.com> | 2018-01-29 19:08:02 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-29 19:08:02 -0800 |
commit | 2f14b350960af0354608c041d7df501c44dc5640 (patch) | |
tree | e0f10b004301c5039ea7480ab4c069b6b7f3f159 /src/vm/synch.h | |
parent | 6555bd3a1f6e6de0604e3065b4040c3a6ac1e44e (diff) | |
download | coreclr-2f14b350960af0354608c041d7df501c44dc5640.tar.gz coreclr-2f14b350960af0354608c041d7df501c44dc5640.tar.bz2 coreclr-2f14b350960af0354608c041d7df501c44dc5640.zip |
Prevent compiler optimization that could cause local var values to change in multithreaded environments, in some places (#16089)
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) |