Skip to content

Commit

Permalink
deps: V8: cherry-pick ed3eedae33d0
Browse files Browse the repository at this point in the history
Original commit message:

    Merged: [ia32][wasm-simd] Fix aligned moves in codegen

    For SIMD instructions that use aligned moves (like movaps or movapd), we
    don't have correct memory alignment for SIMD moves yet. Switch to to
    movupd.

    [email protected],[email protected]
    Bug: v8:9198
    Bug: v8:10831
    Bug: chromium:1134039
    (cherry picked from commit ab23ff3c0eed141361365241d13e3211efd608cf)

    Change-Id: Icc038b4a32364b8bc66b723403ccc11f954b080d
    No-Try: true
    No-Presubmit: true
    No-Tree-Checks: true
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2469600
    Commit-Queue: Zhi An Ng <[email protected]>
    Reviewed-by: Zhi An Ng <[email protected]>
    Cr-Commit-Position: refs/branch-heads/8.6@{#30}
    Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1}
    Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472}

Refs: v8/v8@ed3eeda

PR-URL: #38275
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Shelley Vohr <[email protected]>
  • Loading branch information
targos committed Apr 30, 2021
1 parent 86c7c0a commit 0e6976f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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.35',
'v8_embedder_string': '-node.36',

##### V8 defaults for Node.js #####

Expand Down
4 changes: 4 additions & 0 deletions deps/v8/src/codegen/ia32/assembler-ia32.h
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,9 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
void movapd(XMMRegister dst, Operand src) {
sse2_instr(dst, src, 0x66, 0x0F, 0x28);
}
void movupd(XMMRegister dst, Operand src) {
sse2_instr(dst, src, 0x66, 0x0F, 0x10);
}

void movmskpd(Register dst, XMMRegister src);
void movmskps(Register dst, XMMRegister src);
Expand Down Expand Up @@ -1331,6 +1334,7 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
void vmovapd(XMMRegister dst, Operand src) { vpd(0x28, dst, xmm0, src); }
void vmovups(XMMRegister dst, XMMRegister src) { vmovups(dst, Operand(src)); }
void vmovups(XMMRegister dst, Operand src) { vps(0x10, dst, xmm0, src); }
void vmovupd(XMMRegister dst, Operand src) { vpd(0x10, dst, xmm0, src); }
void vshufps(XMMRegister dst, XMMRegister src1, XMMRegister src2, byte imm8) {
vshufps(dst, src1, Operand(src2), imm8);
}
Expand Down
1 change: 1 addition & 0 deletions deps/v8/src/codegen/ia32/macro-assembler-ia32.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
AVX_OP2_WITH_TYPE(Movaps, movaps, XMMRegister, XMMRegister)
AVX_OP2_WITH_TYPE(Movapd, movapd, XMMRegister, XMMRegister)
AVX_OP2_WITH_TYPE(Movapd, movapd, XMMRegister, const Operand&)
AVX_OP2_WITH_TYPE(Movupd, movupd, XMMRegister, const Operand&)
AVX_OP2_WITH_TYPE(Pmovmskb, pmovmskb, Register, XMMRegister)
AVX_OP2_WITH_TYPE(Movmskps, movmskps, Register, XMMRegister)

Expand Down
6 changes: 3 additions & 3 deletions deps/v8/src/compiler/backend/ia32/code-generator-ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1966,7 +1966,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
tmp = i.TempSimd128Register(0);
// The minpd instruction doesn't propagate NaNs and +0's in its first
// operand. Perform minpd in both orders, merge the resuls, and adjust.
__ Movapd(tmp, src1);
__ Movupd(tmp, src1);
__ Minpd(tmp, tmp, src);
__ Minpd(dst, src, src1);
// propagate -0's and NaNs, which may be non-canonical.
Expand All @@ -1985,7 +1985,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
tmp = i.TempSimd128Register(0);
// The maxpd instruction doesn't propagate NaNs and +0's in its first
// operand. Perform maxpd in both orders, merge the resuls, and adjust.
__ Movapd(tmp, src1);
__ Movupd(tmp, src1);
__ Maxpd(tmp, tmp, src);
__ Maxpd(dst, src, src1);
// Find discrepancies.
Expand Down Expand Up @@ -2375,7 +2375,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
XMMRegister dst = i.OutputSimd128Register();
Operand src1 = i.InputOperand(1);
// See comment above for correction of maxps.
__ movaps(kScratchDoubleReg, src1);
__ vmovups(kScratchDoubleReg, src1);
__ vmaxps(kScratchDoubleReg, kScratchDoubleReg, dst);
__ vmaxps(dst, dst, src1);
__ vxorps(dst, dst, kScratchDoubleReg);
Expand Down
12 changes: 11 additions & 1 deletion deps/v8/src/diagnostics/ia32/disasm-ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,10 @@ int DisassemblerIA32::AVXInstruction(byte* data) {
int mod, regop, rm, vvvv = vex_vreg();
get_modrm(*current, &mod, &regop, &rm);
switch (opcode) {
case 0x10:
AppendToBuffer("vmovupd %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
break;
case 0x28:
AppendToBuffer("vmovapd %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
Expand Down Expand Up @@ -2090,7 +2094,13 @@ int DisassemblerIA32::InstructionDecode(v8::internal::Vector<char> out_buffer,
data += 2;
} else if (*data == 0x0F) {
data++;
if (*data == 0x28) {
if (*data == 0x10) {
data++;
int mod, regop, rm;
get_modrm(*data, &mod, &regop, &rm);
AppendToBuffer("movupd %s,", NameOfXMMRegister(regop));
data += PrintRightXMMOperand(data);
} else if (*data == 0x28) {
data++;
int mod, regop, rm;
get_modrm(*data, &mod, &regop, &rm);
Expand Down
2 changes: 2 additions & 0 deletions deps/v8/test/cctest/test-disasm-ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ TEST(DisasmIa320) {

__ movapd(xmm0, xmm1);
__ movapd(xmm0, Operand(edx, 4));
__ movupd(xmm0, Operand(edx, 4));

__ movd(xmm0, edi);
__ movd(xmm0, Operand(ebx, ecx, times_4, 10000));
Expand Down Expand Up @@ -689,6 +690,7 @@ TEST(DisasmIa320) {
__ vmovaps(xmm0, xmm1);
__ vmovapd(xmm0, xmm1);
__ vmovapd(xmm0, Operand(ebx, ecx, times_4, 10000));
__ vmovupd(xmm0, Operand(ebx, ecx, times_4, 10000));
__ vshufps(xmm0, xmm1, xmm2, 3);
__ vshufps(xmm0, xmm1, Operand(edx, 4), 3);
__ vhaddps(xmm0, xmm1, xmm2);
Expand Down

0 comments on commit 0e6976f

Please sign in to comment.