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

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

Issue 2799863002: [Atomics] use TFJ builtins for atomic add, sub, and, or, and xor (Closed)
Patch Set: [Atomics] use TFJ builtins for atomic add, sub, and, or, and xor Created 3 years, 8 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/x64/code-generator-x64.cc
diff --git a/src/compiler/x64/code-generator-x64.cc b/src/compiler/x64/code-generator-x64.cc
index f1f3855bfd9a9484d0006ba25963452dcbfd73ae..3215ec24f725717e79f55e9ca6128edfaf871ca2 100644
--- a/src/compiler/x64/code-generator-x64.cc
+++ b/src/compiler/x64/code-generator-x64.cc
@@ -710,6 +710,18 @@ void EmitOOLTrapIfNeeded(Zone* zone, CodeGenerator* codegen,
1); \
} while (false)
+#define ASSEMBLE_ATOMIC_BINOP(bin_inst, mov_inst, cmpxchg_inst) \
+ do { \
+ Label binop; \
+ __ bind(&binop); \
+ __ mov_inst(rax, i.MemoryOperand(1)); \
+ __ movl(i.TempRegister(0), rax); \
+ __ bin_inst(i.TempRegister(0), i.InputRegister(0)); \
+ __ lock(); \
+ __ cmpxchg_inst(i.MemoryOperand(1), i.TempRegister(0)); \
+ __ j(not_equal, &binop); \
+ } while (false)
+
void CodeGenerator::AssembleDeconstructFrame() {
unwinding_info_writer_.MarkFrameDeconstructed(__ pc_offset());
__ movq(rsp, rbp);
@@ -2330,6 +2342,32 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ cmpxchgl(i.MemoryOperand(2), i.InputRegister(1));
break;
}
+#define ATOMIC_BINOP_CASE(op, inst) \
+ case kAtomic##op##Int8: \
+ ASSEMBLE_ATOMIC_BINOP(inst, movb, cmpxchgb); \
+ __ movsxbl(rax, rax); \
+ break; \
+ case kAtomic##op##Uint8: \
+ ASSEMBLE_ATOMIC_BINOP(inst, movb, cmpxchgb); \
+ __ movzxbl(rax, rax); \
+ break; \
+ case kAtomic##op##Int16: \
+ ASSEMBLE_ATOMIC_BINOP(inst, movw, cmpxchgw); \
+ __ movsxwl(rax, rax); \
+ break; \
+ case kAtomic##op##Uint16: \
+ ASSEMBLE_ATOMIC_BINOP(inst, movw, cmpxchgw); \
+ __ movzxwl(rax, rax); \
+ break; \
+ case kAtomic##op##Word32: \
+ ASSEMBLE_ATOMIC_BINOP(inst, movl, cmpxchgl); \
+ break;
+ ATOMIC_BINOP_CASE(Add, addl)
+ ATOMIC_BINOP_CASE(Sub, subl)
+ ATOMIC_BINOP_CASE(And, andl)
+ ATOMIC_BINOP_CASE(Or, orl)
+ ATOMIC_BINOP_CASE(Xor, xorl)
+#undef ATOMIC_BINOP_CASE
case kAtomicLoadInt8:
case kAtomicLoadUint8:
case kAtomicLoadInt16:

Powered by Google App Engine
This is Rietveld 408576698