Commit 4b90359c authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[cpu-profiler] Use compare_exchange_strong in DoSample

This changes the compare/exchange operation to the 'strong' one
which avoids potential spurious failures. These failures would be
hidden by the loop in AtomicGuard - except that we only ever call
compare_exchange_weak once when is_blocking is false. See the linked
bug for more info.

Bug: v8:8649
Change-Id: I94ebe04e86f4676d2b7404d833157f61d5df8a59
Reviewed-on: https://chromium-review.googlesource.com/c/1418190Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarAlexei Filippov <alph@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58909}
parent babdc422
......@@ -184,7 +184,9 @@ class AtomicGuard {
: atomic_(atomic), is_success_(false) {
do {
bool expected = false;
is_success_ = atomic->compare_exchange_weak(expected, true);
// We have to use the strong version here for the case where is_blocking
// is false, and we will only attempt the exchange once.
is_success_ = atomic->compare_exchange_strong(expected, true);
} while (is_blocking && !is_success_);
}
......
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