diff --git a/common.gypi b/common.gypi index 621b8627944..470cfd6adbc 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.54', + 'v8_embedder_string': '-node.55', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/wasm/baseline/ia32/liftoff-assembler-ia32.h b/deps/v8/src/wasm/baseline/ia32/liftoff-assembler-ia32.h index b9466195236..830aa7c4b1d 100644 --- a/deps/v8/src/wasm/baseline/ia32/liftoff-assembler-ia32.h +++ b/deps/v8/src/wasm/baseline/ia32/liftoff-assembler-ia32.h @@ -545,6 +545,16 @@ void LiftoffAssembler::AtomicCompareExchange( Register expected_reg = is_64_bit_op ? expected.low_gp() : expected.gp(); Register result_reg = expected_reg; + // The cmpxchg instruction uses eax to store the old value of the + // compare-exchange primitive. Therefore we have to spill the register and + // move any use to another register. + ClearRegister(eax, {&dst_addr, &value_reg}, + LiftoffRegList::ForRegs(dst_addr, value_reg, expected_reg)); + if (expected_reg != eax) { + mov(eax, expected_reg); + expected_reg = eax; + } + bool is_byte_store = type.size() == 1; LiftoffRegList pinned = LiftoffRegList::ForRegs(dst_addr, value_reg, expected_reg); @@ -558,13 +568,6 @@ void LiftoffAssembler::AtomicCompareExchange( pinned.clear(LiftoffRegister(value_reg)); } - // The cmpxchg instruction uses eax to store the old value of the - // compare-exchange primitive. Therefore we have to spill the register and - // move any use to another register. - ClearRegister(eax, {&dst_addr, &value_reg}, pinned); - if (expected_reg != eax) { - mov(eax, expected_reg); - } Operand dst_op = Operand(dst_addr, offset_imm); diff --git a/deps/v8/test/mjsunit/regress/wasm/regress-1140549.js b/deps/v8/test/mjsunit/regress/wasm/regress-1140549.js new file mode 100644 index 00000000000..65191e19623 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regress-1140549.js @@ -0,0 +1,25 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --wasm-staging + +load('test/mjsunit/wasm/wasm-module-builder.js'); + +const builder = new WasmModuleBuilder(); +builder.addMemory(16, 32, false, true); +builder.addType(makeSig([], [])); +builder.addFunction(undefined, 0 /* sig */) + .addBodyWithEnd([ +// signature: v_v +// body: +kExprI32Const, 0x00, +kExprI32Const, 0x00, +kExprI32Const, 0x00, +kAtomicPrefix, kExprI32AtomicCompareExchange8U, 0x00, 0xc3, 0x01, +kExprDrop, +kExprEnd, // end @193 +]); +builder.addExport('main', 0); +const instance = builder.instantiate(); +print(instance.exports.main(1, 2, 3));