Skip to content

Commit

Permalink
[mips][wasm] Implement "atomic.fence" operator
Browse files Browse the repository at this point in the history
port 4ca8b4d 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: WebAssembly/threads#141
    See discussion: WebAssembly/threads#140

Change-Id: Ia60d58a6bf58e8236591d515d30184418cee47c5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1710337
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Yu Yin <xwafish@gmail.com>
Cr-Commit-Position: refs/heads/master@{#62843}
  • Loading branch information
xwafish authored and Commit Bot committed Jul 22, 2019
1 parent dbf7ea9 commit 948ba17
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/compiler/backend/mips/code-generator-mips.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ Usdc1(ft, i.MemoryOperand(), kScratchReg);
break;
}
case kMipsSync: {
__ sync();
break;
}
case kMipsPush:
if (instr->InputAt(0)->IsFPRegister()) {
LocationOperand* op = LocationOperand::cast(instr->InputAt(0));
Expand Down
1 change: 1 addition & 0 deletions src/compiler/backend/mips/instruction-codes-mips.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ namespace compiler {
V(MipsStackClaim) \
V(MipsSeb) \
V(MipsSeh) \
V(MipsSync) \
V(MipsS128Zero) \
V(MipsI32x4Splat) \
V(MipsI32x4ExtractLane) \
Expand Down
1 change: 1 addition & 0 deletions src/compiler/backend/mips/instruction-scheduler-mips.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kMipsUsh:
case kMipsUsw:
case kMipsUswc1:
case kMipsSync:
case kMipsWord32AtomicPairStore:
case kMipsWord32AtomicPairAdd:
case kMipsWord32AtomicPairSub:
Expand Down
5 changes: 5 additions & 0 deletions src/compiler/backend/mips/instruction-selector-mips.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,11 @@ void InstructionSelector::VisitFloat64SilenceNaN(Node* node) {
arraysize(temps), temps);
}

void InstructionSelector::VisitMemoryBarrier(Node* node) {
MipsOperandGenerator g(this);
Emit(kMipsSync, g.NoOutput());
}

void InstructionSelector::VisitWord32AtomicLoad(Node* node) {
LoadRepresentation load_rep = LoadRepresentationOf(node->op());
MipsOperandGenerator g(this);
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/backend/mips64/code-generator-mips64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1795,6 +1795,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ Usdc1(ft, i.MemoryOperand(), kScratchReg);
break;
}
case kMips64Sync: {
__ sync();
break;
}
case kMips64Push:
if (instr->InputAt(0)->IsFPRegister()) {
__ Sdc1(i.InputDoubleRegister(0), MemOperand(sp, -kDoubleSize));
Expand Down
1 change: 1 addition & 0 deletions src/compiler/backend/mips64/instruction-codes-mips64.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ namespace compiler {
V(Mips64StackClaim) \
V(Mips64Seb) \
V(Mips64Seh) \
V(Mips64Sync) \
V(Mips64AssertEqual) \
V(Mips64S128Zero) \
V(Mips64I32x4Splat) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kMips64Ush:
case kMips64Usw:
case kMips64Uswc1:
case kMips64Sync:
case kMips64Word64AtomicStoreWord8:
case kMips64Word64AtomicStoreWord16:
case kMips64Word64AtomicStoreWord32:
Expand Down
5 changes: 5 additions & 0 deletions src/compiler/backend/mips64/instruction-selector-mips64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2408,6 +2408,11 @@ void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) {
g.UseRegister(left), g.UseRegister(right));
}

void InstructionSelector::VisitMemoryBarrier(Node* node) {
Mips64OperandGenerator g(this);
Emit(kMips64Sync, g.NoOutput());
}

void InstructionSelector::VisitWord32AtomicLoad(Node* node) {
LoadRepresentation load_rep = LoadRepresentationOf(node->op());
ArchOpcode opcode = kArchNop;
Expand Down

0 comments on commit 948ba17

Please sign in to comment.