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

Side by Side Diff: src/compiler/arm/code-generator-arm.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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/code-generator.h" 5 #include "src/compiler/code-generator.h"
6 6
7 #include "src/arm/macro-assembler-arm.h" 7 #include "src/arm/macro-assembler-arm.h"
8 #include "src/assembler-inl.h" 8 #include "src/assembler-inl.h"
9 #include "src/compilation-info.h" 9 #include "src/compilation-info.h"
10 #include "src/compiler/code-generator-impl.h" 10 #include "src/compiler/code-generator-impl.h"
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 __ load_instr(i.OutputRegister(0), i.TempRegister(0)); \ 445 __ load_instr(i.OutputRegister(0), i.TempRegister(0)); \
446 __ teq(i.TempRegister(1), Operand(i.OutputRegister(0))); \ 446 __ teq(i.TempRegister(1), Operand(i.OutputRegister(0))); \
447 __ b(ne, &exit); \ 447 __ b(ne, &exit); \
448 __ store_instr(i.TempRegister(0), i.InputRegister(3), i.TempRegister(0)); \ 448 __ store_instr(i.TempRegister(0), i.InputRegister(3), i.TempRegister(0)); \
449 __ teq(i.TempRegister(0), Operand(0)); \ 449 __ teq(i.TempRegister(0), Operand(0)); \
450 __ b(ne, &compareExchange); \ 450 __ b(ne, &compareExchange); \
451 __ bind(&exit); \ 451 __ bind(&exit); \
452 __ dmb(ISH); \ 452 __ dmb(ISH); \
453 } while (0) 453 } while (0)
454 454
455 #define ASSEMBLE_ATOMIC_BINOP(load_instr, store_instr, bin_instr) \
456 do { \
457 Label binop; \
458 __ add(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \
459 __ dmb(ISH); \
460 __ bind(&binop); \
461 __ load_instr(i.OutputRegister(0), i.TempRegister(0)); \
462 __ bin_instr(i.TempRegister(1), i.OutputRegister(0), \
463 Operand(i.InputRegister(2))); \
464 __ store_instr(i.TempRegister(1), i.TempRegister(1), i.TempRegister(0)); \
465 __ teq(i.TempRegister(1), Operand(0)); \
466 __ b(ne, &binop); \
467 __ dmb(ISH); \
468 } while (0)
469
455 #define ASSEMBLE_IEEE754_BINOP(name) \ 470 #define ASSEMBLE_IEEE754_BINOP(name) \
456 do { \ 471 do { \
457 /* TODO(bmeurer): We should really get rid of this special instruction, */ \ 472 /* TODO(bmeurer): We should really get rid of this special instruction, */ \
458 /* and generate a CallAddress instruction instead. */ \ 473 /* and generate a CallAddress instruction instead. */ \
459 FrameScope scope(masm(), StackFrame::MANUAL); \ 474 FrameScope scope(masm(), StackFrame::MANUAL); \
460 __ PrepareCallCFunction(0, 2, kScratchReg); \ 475 __ PrepareCallCFunction(0, 2, kScratchReg); \
461 __ MovToFloatParameters(i.InputDoubleRegister(0), \ 476 __ MovToFloatParameters(i.InputDoubleRegister(0), \
462 i.InputDoubleRegister(1)); \ 477 i.InputDoubleRegister(1)); \
463 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ 478 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \
464 0, 2); \ 479 0, 2); \
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after
2182 __ sxth(i.OutputRegister(0), i.OutputRegister(0)); 2197 __ sxth(i.OutputRegister(0), i.OutputRegister(0));
2183 break; 2198 break;
2184 case kAtomicCompareExchangeUint16: 2199 case kAtomicCompareExchangeUint16:
2185 __ uxth(i.TempRegister(1), i.InputRegister(2)); 2200 __ uxth(i.TempRegister(1), i.InputRegister(2));
2186 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrexh, strexh); 2201 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrexh, strexh);
2187 break; 2202 break;
2188 case kAtomicCompareExchangeWord32: 2203 case kAtomicCompareExchangeWord32:
2189 __ mov(i.TempRegister(1), i.InputRegister(2)); 2204 __ mov(i.TempRegister(1), i.InputRegister(2));
2190 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrex, strex); 2205 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrex, strex);
2191 break; 2206 break;
2207 #define ATOMIC_BINOP_CASE(op, inst) \
2208 case kAtomic##op##Int8: \
2209 ASSEMBLE_ATOMIC_BINOP(ldrexb, strexb, inst); \
2210 __ sxtb(i.OutputRegister(0), i.OutputRegister(0)); \
2211 break; \
2212 case kAtomic##op##Uint8: \
2213 ASSEMBLE_ATOMIC_BINOP(ldrexb, strexb, inst); \
2214 break; \
2215 case kAtomic##op##Int16: \
2216 ASSEMBLE_ATOMIC_BINOP(ldrexh, strexh, inst); \
2217 __ sxth(i.OutputRegister(0), i.OutputRegister(0)); \
2218 break; \
2219 case kAtomic##op##Uint16: \
2220 ASSEMBLE_ATOMIC_BINOP(ldrexh, strexh, inst); \
2221 break; \
2222 case kAtomic##op##Word32: \
2223 ASSEMBLE_ATOMIC_BINOP(ldrex, strex, inst); \
2224 break;
2225 ATOMIC_BINOP_CASE(Add, add)
2226 ATOMIC_BINOP_CASE(Sub, sub)
2227 ATOMIC_BINOP_CASE(And, and_)
2228 ATOMIC_BINOP_CASE(Or, orr)
2229 ATOMIC_BINOP_CASE(Xor, eor)
2230 #undef ATOMIC_BINOP_CASE
2192 } 2231 }
2193 return kSuccess; 2232 return kSuccess;
2194 } // NOLINT(readability/fn_size) 2233 } // NOLINT(readability/fn_size)
2195 2234
2196 2235
2197 // Assembles branches after an instruction. 2236 // Assembles branches after an instruction.
2198 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { 2237 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) {
2199 ArmOperandConverter i(this, instr); 2238 ArmOperandConverter i(this, instr);
2200 Label* tlabel = branch->true_label; 2239 Label* tlabel = branch->true_label;
2201 Label* flabel = branch->false_label; 2240 Label* flabel = branch->false_label;
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
2831 padding_size -= v8::internal::Assembler::kInstrSize; 2870 padding_size -= v8::internal::Assembler::kInstrSize;
2832 } 2871 }
2833 } 2872 }
2834 } 2873 }
2835 2874
2836 #undef __ 2875 #undef __
2837 2876
2838 } // namespace compiler 2877 } // namespace compiler
2839 } // namespace internal 2878 } // namespace internal
2840 } // namespace v8 2879 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698