Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: src/compiler/arm64/code-generator-arm64.cc

Issue 2623633003: [Atomics] Make Atomics.exchange a builtin using TF (Closed)
Patch Set: remove 0 extend for arm Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/compiler/arm64/code-generator-arm64.cc
diff --git a/src/compiler/arm64/code-generator-arm64.cc b/src/compiler/arm64/code-generator-arm64.cc
index e7d5f2e9203a3173a83f8a4cbe86bbfc791f02a3..84615d0c334a23ba6818e2637052a6bbd4ec8067 100644
--- a/src/compiler/arm64/code-generator-arm64.cc
+++ b/src/compiler/arm64/code-generator-arm64.cc
@@ -99,6 +99,8 @@ class Arm64OperandConverter final : public InstructionOperandConverter {
Register OutputRegister32() { return ToRegister(instr_->Output()).W(); }
+ Register TempRegister32() { return ToRegister(instr_->TempAt(0)).W(); }
+
Operand InputOperand2_32(size_t index) {
switch (AddressingModeField::decode(instr_->opcode())) {
case kMode_None:
@@ -527,6 +529,17 @@ Condition FlagsConditionToCondition(FlagsCondition condition) {
__ Dmb(InnerShareable, BarrierAll); \
} while (0)
+#define ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(load_instr, store_instr) \
+ do { \
+ Label exchange; \
+ __ bind(&exchange); \
+ __ Add(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \
+ __ load_instr(i.OutputRegister32(), i.TempRegister(0)); \
+ __ store_instr(i.TempRegister32(), i.InputRegister32(2), \
+ i.TempRegister(0)); \
jbramley 2017/03/08 11:11:07 Acquire/release instructions shouldn't be used to
+ __ cbnz(i.TempRegister32(), &exchange); \
+ } while (0)
+
#define ASSEMBLE_IEEE754_BINOP(name) \
do { \
FrameScope scope(masm(), StackFrame::MANUAL); \
@@ -1631,6 +1644,23 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
MemOperand(i.InputRegister(0), i.InputRegister(1)));
__ Dmb(InnerShareable, BarrierAll);
break;
+ case kAtomicExchangeInt8:
+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxrb, stlxrb);
+ __ Sxtb(i.OutputRegister(0), i.OutputRegister(0));
+ break;
+ case kAtomicExchangeUint8:
+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxrb, stlxrb);
+ break;
+ case kAtomicExchangeInt16:
+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxrh, stlxrh);
+ __ Sxth(i.OutputRegister(0), i.OutputRegister(0));
+ break;
+ case kAtomicExchangeUint16:
+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxrh, stlxrh);
+ break;
+ case kAtomicExchangeWord32:
+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxr, stlxr);
+ break;
}
return kSuccess;
} // NOLINT(readability/fn_size)

Powered by Google App Engine
This is Rietveld 408576698