[wasm] Fix flake in cmpxchg stress test

It seems that the mix of atomic and non-atomic updates to the same
memory location is not working correctly. One fix is changing all memory
updates to be atomic. Another fix is removing the non-atomic access that
happens while the workers are already running (using atomic accesses).
This CL implements the latter.

R=ahaas@chromium.org

Bug: v8:10647, v8:10650
Change-Id: I84b4f3f442b6be3c4ea6e51962a523f443f5e43b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2273133
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68603}
This commit is contained in:
Clemens Backes 2020-06-29 18:13:14 +02:00 committed by Commit Bot
parent 2fc49978ea
commit f9d3d78b8d
3 changed files with 12 additions and 25 deletions

View File

@ -842,9 +842,6 @@
# Tier down/up Wasm NativeModule in debugging is non-deterministic with
# multiple isolates (https://crbug.com/v8/10099).
'wasm/tier-down-to-liftoff': [SKIP],
# https://crbug.com/v8/10647
'wasm/compare-exchange64-stress': [SKIP],
}], # 'isolates'
##############################################################################

View File

@ -136,8 +136,7 @@ function makeWorkerCodeForOpcode(compareExchangeOpcode, size, functionName,
function generateSequence(typedarray, start, count) {
let end = count + start;
for (let i = start; i < end; i++) {
// Avoid the value 255, which is used as initial value in memory.
typedarray[i] = Math.floor(Math.random() * 255);
typedarray[i] = Math.floor(Math.random() * 256);
}
}
@ -192,20 +191,16 @@ function testOpcode(opcode, opcodeSize) {
generateSequence(
memoryView, kSequenceStartAddress, kSequenceLength * numBytes);
// Initialize the memory to a value which does not appear in the sequence.
memoryView.fill(255, kMemoryAddress, numBytes);
// Write the first element of the sequence to memory, such that the workers
// can start running as soon as they are spawned.
memoryView.copyWithin(
kMemoryAddress, kSequenceStartAddress,
kSequenceStartAddress + numBytes);
let module = new WebAssembly.Module(builder.toBuffer());
let workers =
spawnWorker(module, memory, kMemoryAddress, kSequenceStartAddress);
// Fire off the workers by writing the first element of the sequence to
// memory. The byte order does not matter here, since all bytes need to be
// updated before the first worker can do an update.
memoryView.copyWithin(
kMemoryAddress, kSequenceStartAddress,
kSequenceStartAddress + numBytes);
waitForWorkers(workers);
print("DONE");

View File

@ -141,8 +141,7 @@ function makeWorkerCodeForOpcode(compareExchangeOpcode, size, functionName,
function generateSequence(typedarray, start, count) {
let end = count + start;
for (let i = start; i < end; i++) {
// Avoid the value 255, which is used as initial value in memory.
typedarray[i] = Math.floor(Math.random() * 255);
typedarray[i] = Math.floor(Math.random() * 256);
}
}
@ -197,20 +196,16 @@ function testOpcode(opcode, opcodeSize) {
generateSequence(
memoryView, kSequenceStartAddress, kSequenceLength * numBytes);
// Initialize the memory to a value which does not appear in the sequence.
memoryView.fill(255, kMemoryAddress, numBytes);
// Write the first element of the sequence to memory, such that the workers
// can start running as soon as they are spawned.
memoryView.copyWithin(
kMemoryAddress, kSequenceStartAddress,
kSequenceStartAddress + numBytes);
let module = new WebAssembly.Module(builder.toBuffer());
let workers =
spawnWorker(module, memory, kMemoryAddress, kSequenceStartAddress);
// Fire off the workers by writing the first element of the sequence to
// memory. The byte order does not matter here, since all bytes need to be
// updated before the first worker can do an update.
memoryView.copyWithin(
kMemoryAddress, kSequenceStartAddress,
kSequenceStartAddress + numBytes);
waitForWorkers(workers);
print("DONE");