Commit 6549dffa authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Remove limit on cmpxchg loop

If there are many workers and we are very unlucky, the cmpxchg loop can
in fact fail for more than 5 times. This CL removes this unneeded
limitation to avoid spurious failures.

R=mstarzinger@chromium.org

Bug: chromium:824443
Change-Id: I0a6adde1330c8a8389a42b36bf44e516fae8c574
Reviewed-on: https://chromium-review.googlesource.com/1213170Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55749}
parent b19637eb
......@@ -134,17 +134,14 @@ bool WasmMemoryTracker::ReserveAddressSpace(size_t num_bytes) {
constexpr size_t kAddressSpaceLimit = 0x80000000; // 2 GiB
#endif
int retries = 5; // cmpxchng can fail, retry some number of times.
do {
size_t old_count = reserved_address_space_;
if ((kAddressSpaceLimit - old_count) < num_bytes) return false;
while (true) {
size_t old_count = reserved_address_space_.load();
if (kAddressSpaceLimit - old_count < num_bytes) return false;
if (reserved_address_space_.compare_exchange_weak(old_count,
old_count + num_bytes)) {
return true;
}
} while (retries-- > 0);
return false;
}
}
void WasmMemoryTracker::ReleaseReservation(size_t num_bytes) {
......
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