Commit 948ba172 authored by Yu Yin's avatar Yu Yin Committed by Commit Bot

[mips][wasm] Implement "atomic.fence" operator

port 4ca8b4dd https://crrev.com/c/1701856

Original Commit Message:
    This adds decoding and compilation of the "atomic.fence" operator, which
    is intended to preserve the synchronization guarantees of higher-level
    languages.

    Unlike other atomic operators, it does not target a particular linear
    memory. It may occur in modules which declare no memory, or a non-shared
    memory, without causing a validation error.

    See proposal: https://github.com/WebAssembly/threads/pull/141
    See discussion: https://github.com/WebAssembly/threads/issues/140

Change-Id: Ia60d58a6bf58e8236591d515d30184418cee47c5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1710337Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Yu Yin <xwafish@gmail.com>
Cr-Commit-Position: refs/heads/master@{#62843}
parent dbf7ea90
...@@ -1620,6 +1620,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1620,6 +1620,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ Usdc1(ft, i.MemoryOperand(), kScratchReg); __ Usdc1(ft, i.MemoryOperand(), kScratchReg);
break; break;
} }
case kMipsSync: {
__ sync();
break;
}
case kMipsPush: case kMipsPush:
if (instr->InputAt(0)->IsFPRegister()) { if (instr->InputAt(0)->IsFPRegister()) {
LocationOperand* op = LocationOperand::cast(instr->InputAt(0)); LocationOperand* op = LocationOperand::cast(instr->InputAt(0));
......
...@@ -134,6 +134,7 @@ namespace compiler { ...@@ -134,6 +134,7 @@ namespace compiler {
V(MipsStackClaim) \ V(MipsStackClaim) \
V(MipsSeb) \ V(MipsSeb) \
V(MipsSeh) \ V(MipsSeh) \
V(MipsSync) \
V(MipsS128Zero) \ V(MipsS128Zero) \
V(MipsI32x4Splat) \ V(MipsI32x4Splat) \
V(MipsI32x4ExtractLane) \ V(MipsI32x4ExtractLane) \
......
...@@ -284,6 +284,7 @@ int InstructionScheduler::GetTargetInstructionFlags( ...@@ -284,6 +284,7 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kMipsUsh: case kMipsUsh:
case kMipsUsw: case kMipsUsw:
case kMipsUswc1: case kMipsUswc1:
case kMipsSync:
case kMipsWord32AtomicPairStore: case kMipsWord32AtomicPairStore:
case kMipsWord32AtomicPairAdd: case kMipsWord32AtomicPairAdd:
case kMipsWord32AtomicPairSub: case kMipsWord32AtomicPairSub:
......
...@@ -1775,6 +1775,11 @@ void InstructionSelector::VisitFloat64SilenceNaN(Node* node) { ...@@ -1775,6 +1775,11 @@ void InstructionSelector::VisitFloat64SilenceNaN(Node* node) {
arraysize(temps), temps); arraysize(temps), temps);
} }
void InstructionSelector::VisitMemoryBarrier(Node* node) {
MipsOperandGenerator g(this);
Emit(kMipsSync, g.NoOutput());
}
void InstructionSelector::VisitWord32AtomicLoad(Node* node) { void InstructionSelector::VisitWord32AtomicLoad(Node* node) {
LoadRepresentation load_rep = LoadRepresentationOf(node->op()); LoadRepresentation load_rep = LoadRepresentationOf(node->op());
MipsOperandGenerator g(this); MipsOperandGenerator g(this);
......
...@@ -1795,6 +1795,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1795,6 +1795,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ Usdc1(ft, i.MemoryOperand(), kScratchReg); __ Usdc1(ft, i.MemoryOperand(), kScratchReg);
break; break;
} }
case kMips64Sync: {
__ sync();
break;
}
case kMips64Push: case kMips64Push:
if (instr->InputAt(0)->IsFPRegister()) { if (instr->InputAt(0)->IsFPRegister()) {
__ Sdc1(i.InputDoubleRegister(0), MemOperand(sp, -kDoubleSize)); __ Sdc1(i.InputDoubleRegister(0), MemOperand(sp, -kDoubleSize));
......
...@@ -163,6 +163,7 @@ namespace compiler { ...@@ -163,6 +163,7 @@ namespace compiler {
V(Mips64StackClaim) \ V(Mips64StackClaim) \
V(Mips64Seb) \ V(Mips64Seb) \
V(Mips64Seh) \ V(Mips64Seh) \
V(Mips64Sync) \
V(Mips64AssertEqual) \ V(Mips64AssertEqual) \
V(Mips64S128Zero) \ V(Mips64S128Zero) \
V(Mips64I32x4Splat) \ V(Mips64I32x4Splat) \
......
...@@ -318,6 +318,7 @@ int InstructionScheduler::GetTargetInstructionFlags( ...@@ -318,6 +318,7 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kMips64Ush: case kMips64Ush:
case kMips64Usw: case kMips64Usw:
case kMips64Uswc1: case kMips64Uswc1:
case kMips64Sync:
case kMips64Word64AtomicStoreWord8: case kMips64Word64AtomicStoreWord8:
case kMips64Word64AtomicStoreWord16: case kMips64Word64AtomicStoreWord16:
case kMips64Word64AtomicStoreWord32: case kMips64Word64AtomicStoreWord32:
......
...@@ -2408,6 +2408,11 @@ void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) { ...@@ -2408,6 +2408,11 @@ void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) {
g.UseRegister(left), g.UseRegister(right)); g.UseRegister(left), g.UseRegister(right));
} }
void InstructionSelector::VisitMemoryBarrier(Node* node) {
Mips64OperandGenerator g(this);
Emit(kMips64Sync, g.NoOutput());
}
void InstructionSelector::VisitWord32AtomicLoad(Node* node) { void InstructionSelector::VisitWord32AtomicLoad(Node* node) {
LoadRepresentation load_rep = LoadRepresentationOf(node->op()); LoadRepresentation load_rep = LoadRepresentationOf(node->op());
ArchOpcode opcode = kArchNop; ArchOpcode opcode = kArchNop;
......
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