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

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

Issue 2649703002: [Atomics] Make Atomics.compareExchange a builtin using TF (Closed)
Patch Set: rebase and move cmpxchg to builtins-sharedarraybuffer-gen.cc Created 3 years, 9 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
« no previous file with comments | « src/compiler/arm/instruction-selector-arm.cc ('k') | src/compiler/arm64/instruction-selector-arm64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4b7c85de56b7af2cff2fe45f63f54dabdc2dc6f7..f0e5d621e304d7d590cd0525c2e3e47a2b21f77f 100644
--- a/src/compiler/arm64/code-generator-arm64.cc
+++ b/src/compiler/arm64/code-generator-arm64.cc
@@ -101,7 +101,9 @@ class Arm64OperandConverter final : public InstructionOperandConverter {
Register OutputRegister32() { return ToRegister(instr_->Output()).W(); }
- Register TempRegister32() { return ToRegister(instr_->TempAt(0)).W(); }
+ Register TempRegister32(size_t index) {
+ return ToRegister(instr_->TempAt(index)).W();
+ }
Operand InputOperand2_32(size_t index) {
switch (AddressingModeField::decode(instr_->opcode())) {
@@ -537,9 +539,24 @@ Condition FlagsConditionToCondition(FlagsCondition condition) {
__ 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), \
+ __ store_instr(i.TempRegister32(0), i.InputRegister32(2), \
i.TempRegister(0)); \
- __ cbnz(i.TempRegister32(), &exchange); \
+ __ cbnz(i.TempRegister32(0), &exchange); \
+ } while (0)
+
+#define ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(load_instr, store_instr) \
aseemgarg 2017/03/16 22:26:57 Landing this for now with ldaxr and stlxr use. Wil
+ do { \
+ Label compareExchange; \
+ Label exit; \
+ __ bind(&compareExchange); \
+ __ Add(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \
+ __ load_instr(i.OutputRegister32(), i.TempRegister(0)); \
+ __ cmp(i.TempRegister32(1), i.OutputRegister32()); \
+ __ B(ne, &exit); \
+ __ store_instr(i.TempRegister32(0), i.InputRegister32(3), \
+ i.TempRegister(0)); \
+ __ cbnz(i.TempRegister32(0), &compareExchange); \
+ __ bind(&exit); \
} while (0)
#define ASSEMBLE_IEEE754_BINOP(name) \
@@ -1663,6 +1680,28 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kAtomicExchangeWord32:
ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxr, stlxr);
break;
+ case kAtomicCompareExchangeInt8:
+ __ Uxtb(i.TempRegister(1), i.InputRegister(2));
+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldaxrb, stlxrb);
+ __ Sxtb(i.OutputRegister(0), i.OutputRegister(0));
+ break;
+ case kAtomicCompareExchangeUint8:
+ __ Uxtb(i.TempRegister(1), i.InputRegister(2));
+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldaxrb, stlxrb);
+ break;
+ case kAtomicCompareExchangeInt16:
+ __ Uxth(i.TempRegister(1), i.InputRegister(2));
+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldaxrh, stlxrh);
+ __ Sxth(i.OutputRegister(0), i.OutputRegister(0));
+ break;
+ case kAtomicCompareExchangeUint16:
+ __ Uxth(i.TempRegister(1), i.InputRegister(2));
+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldaxrh, stlxrh);
+ break;
+ case kAtomicCompareExchangeWord32:
+ __ mov(i.TempRegister(1), i.InputRegister(2));
+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldaxr, stlxr);
+ break;
}
return kSuccess;
} // NOLINT(readability/fn_size)
« no previous file with comments | « src/compiler/arm/instruction-selector-arm.cc ('k') | src/compiler/arm64/instruction-selector-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698