Commit c75f19bb authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm][cleanup] Use simpler atomic constructs

Replace two unnecessary compare-exchange operations by simpler fetch_add
or exchange. This makes it easier to read and potentially faster.

R=thibaudm@chromium.org

Change-Id: Id9347ce837863e62887619f905a646bf48c07347
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2377687Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69581}
parent 9e062696
......@@ -3039,11 +3039,7 @@ void CompilationStateImpl::ScheduleCompileJobForNewUnits(int new_units) {
// In that case, we need to notify the compile job about the increased
// concurrency.
DCHECK_LT(0, new_units);
int old_units = current_compile_concurrency_->load();
while (!current_compile_concurrency_->compare_exchange_weak(
old_units, old_units + new_units)) {
// Retry with updated {old_units}.
}
int old_units = current_compile_concurrency_->fetch_add(new_units);
bool concurrency_increased = old_units < max_compile_concurrency_;
base::MutexGuard guard(&mutex_);
......@@ -3078,9 +3074,7 @@ size_t CompilationStateImpl::NumOutstandingCompilations() const {
}
void CompilationStateImpl::SetError() {
bool expected = false;
if (!compile_failed_.compare_exchange_strong(expected, true,
std::memory_order_relaxed)) {
if (compile_failed_.exchange(true, std::memory_order_relaxed)) {
return; // Already failed before.
}
......
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