Commit 695cc8fe authored by Ben Smith's avatar Ben Smith Committed by Commit Bot

Remove volatile from TypedArray set/get

It causes a significant regression in TypedArray benchmarks. Thinking it
through, it is actually not necessary for the JavaScript memory model
either. I originally added it to ensure that reads/writes are not elided
or duplicated, but there is no guarantee of this behavior for non-atomic
writes in the model.

BUG=chromium:763814
R=clemensh@chromium.org

Change-Id: Ib03d2e2e77a846d4b9e84eebc7f8fbf861f8fd7c
Reviewed-on: https://chromium-review.googlesource.com/661192Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Ben Smith <binji@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47957}
parent 0c246c33
......@@ -3005,11 +3005,10 @@ typename Traits::ElementType FixedTypedArray<Traits>::get_scalar(int index) {
// ThreadSanitizer will catch these racy accesses and warn about them, so we
// disable TSAN for these reads and writes using annotations.
//
// The access is marked as volatile so the reads/writes will not be elided or
// duplicated. We don't use relaxed atomics here, as it is not a requirement
// of the JavaScript memory model to have tear-free reads of overlapping
// accesses, and using relaxed atomics may introduce overhead.
auto* ptr = reinterpret_cast<volatile ElementType*>(DataPtr());
// We don't use relaxed atomics here, as it is not a requirement of the
// JavaScript memory model to have tear-free reads of overlapping accesses,
// and using relaxed atomics may introduce overhead.
auto* ptr = reinterpret_cast<ElementType*>(DataPtr());
TSAN_ANNOTATE_IGNORE_READS_BEGIN;
auto result = ptr[index];
TSAN_ANNOTATE_IGNORE_READS_END;
......@@ -3021,7 +3020,7 @@ template <class Traits>
void FixedTypedArray<Traits>::set(int index, ElementType value) {
CHECK((index >= 0) && (index < this->length()));
// See the comment in FixedTypedArray<Traits>::get_scalar.
auto* ptr = reinterpret_cast<volatile ElementType*>(DataPtr());
auto* ptr = reinterpret_cast<ElementType*>(DataPtr());
TSAN_ANNOTATE_IGNORE_WRITES_BEGIN;
ptr[index] = value;
TSAN_ANNOTATE_IGNORE_WRITES_END;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment