summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorglider@chromium.org <glider@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-24 22:58:28 +0000
committerglider@chromium.org <glider@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-24 22:58:28 +0000
commit9c9bd97f35920752e99f471becb8e0cda7e5bd36 (patch)
treefabb3b2db69bb26403bb65258d022baa46a89a03
parentea2bf519213234c137b62a125a94561df626226e (diff)
downloadchromium_src-9c9bd97f35920752e99f471becb8e0cda7e5bd36.zip
chromium_src-9c9bd97f35920752e99f471becb8e0cda7e5bd36.tar.gz
chromium_src-9c9bd97f35920752e99f471becb8e0cda7e5bd36.tar.bz2
Add two MemoryBarrier calls and transform the Acquire_Store() calls to Release_Store() ones so that ThreadSanitizer doesn't report a false positive.
Changing Acquire_Store() to a pair of Release_Store(); MemoryBarrier() is more restrictive on the memory access ordering, but does not introduce synchronization errors. On the other hand, using Release_Store() allows ThreadSanitizer to observe the happens-before relation, which it can't understand otherwise. BUG=171660 Review URL: https://chromiumcodereview.appspot.com/11896063 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178683 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--gpu/command_buffer/common/command_buffer_shared.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/gpu/command_buffer/common/command_buffer_shared.h b/gpu/command_buffer/common/command_buffer_shared.h
index 017a644..fafe767 100644
--- a/gpu/command_buffer/common/command_buffer_shared.h
+++ b/gpu/command_buffer/common/command_buffer_shared.h
@@ -30,16 +30,17 @@ public:
base::subtle::NoBarrier_Store(&reading_, 0);
base::subtle::NoBarrier_Store(&latest_, 0);
base::subtle::NoBarrier_Store(&slots_[0], 0);
- base::subtle::Acquire_Store(&slots_[1], 0);
+ base::subtle::Release_Store(&slots_[1], 0);
+ base::subtle::MemoryBarrier();
}
void Write(const T& state) {
int towrite = !base::subtle::Acquire_Load(&reading_);
int index = !base::subtle::Acquire_Load(&slots_[towrite]);
states_[towrite][index] = state;
+ base::subtle::Release_Store(&slots_[towrite], index);
+ base::subtle::Release_Store(&latest_, towrite);
base::subtle::MemoryBarrier();
- base::subtle::Acquire_Store(&slots_[towrite], index);
- base::subtle::Acquire_Store(&latest_, towrite);
}
// Attempt to update the state, updating only if the generation counter is
@@ -47,7 +48,8 @@ public:
void Read(T* state) {
base::subtle::MemoryBarrier();
int toread = !!base::subtle::Acquire_Load(&latest_);
- base::subtle::Acquire_Store(&reading_, toread);
+ base::subtle::Release_Store(&reading_, toread);
+ base::subtle::MemoryBarrier();
int index = !!base::subtle::Acquire_Load(&slots_[toread]);
if (states_[toread][index].generation - state->generation < 0x80000000U)
*state = states_[toread][index];