Commit f5c0361a authored by Aseem Garg's avatar Aseem Garg Committed by Commit Bot

[wasm] fix alignment issue for WasmI64AtomicWait

WasmI64AtomicWait checked alignment at 32 bit instead of 64 bit.

Bug=v8:8075

Change-Id: Ibd668ad8440e928d14a1fcae1577c4aae345151b
Reviewed-on: https://chromium-review.googlesource.com/c/1475918Reviewed-by: 's avatarBen Smith <binji@chromium.org>
Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59713}
parent 3ddcc0bf
......@@ -4295,7 +4295,7 @@ Node* WasmGraphBuilder::AtomicOp(wasm::WasmOpcode opcode, Node* const* inputs,
case wasm::kExprI64AtomicWait: {
Node* index = CheckBoundsAndAlignment(
wasm::ValueTypes::MemSize(MachineType::Uint32()), inputs[0], offset,
wasm::ValueTypes::MemSize(MachineType::Uint64()), inputs[0], offset,
position);
// Now that we've bounds-checked, compute the effective address.
Node* address = graph()->NewNode(mcgraph()->machine()->Int32Add(),
......
......@@ -113,6 +113,42 @@ function WasmI64AtomicWait(memory, offset, index, val_low,
});
})();
(function TestInvalidAlignment() {
let memory = new WebAssembly.Memory({initial: 1, maximum: 1, shared: true});
// Wait and wake must be 4 byte aligned.
[1, 2, 3].forEach(function(invalid) {
assertThrows(function() {
WasmAtomicWake(memory, invalid, 0, -1)
}, Error);
assertThrows(function() {
WasmAtomicWake(memory, 0, invalid, -1)
}, Error);
assertThrows(function() {
WasmI32AtomicWait(memory, invalid, 0, 0, -1)
}, Error);
assertThrows(function() {
WasmI32AtomicWait(memory, 0, invalid, 0, -1)
}, Error);
assertThrows(function() {
WasmI64AtomicWait(memory, invalid, 0, 0, 0, -1)
}, Error);
assertThrows(function() {
WasmI64AtomicWait(memory, 0, invalid, 0, 0, -1)
}, Error);
});
//WasmI64AtomicWait must be 8 byte aligned.
[4, 5, 6, 7].forEach(function(invalid) {
assertThrows(function() {
WasmI64AtomicWait(memory, 0, invalid, 0, 0, -1)
}, Error);
assertThrows(function() {
WasmI64AtomicWait(memory, invalid, 0, 0, 0, -1)
}, Error);
});
})();
(function TestI32WaitTimeout() {
let memory = new WebAssembly.Memory({initial: 1, maximum: 1, shared: true});
var waitMs = 100;
......
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